From 490726b4ac1040f597bcb9e1ee9cdbdd3e50cdc3 Mon Sep 17 00:00:00 2001 From: zicodxx <> Date: Sun, 19 Oct 2008 12:53:30 +0000 Subject: [PATCH] Setting Fullscreen toggle setting the GameCfg value at each change, not only in change_res(); Do not allow the toggle while playing since ALT-GR+ENTER could be used as game-keys; Reorganized Resolutions menu to automatically calculate aspect ratio for preset resolutions and making custom fields exclusive --- CHANGELOG.txt | 4 ++ arch/ogl/gr.c | 2 +- arch/sdl/gr.c | 1 + main/gamecntl.c | 6 --- main/menu.c | 110 +++++++++++++++++++++++++----------------------- main/movie.c | 4 -- main/titles.c | 4 -- 7 files changed, 63 insertions(+), 68 deletions(-) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index be4d5d8e1..235823619 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -1,5 +1,9 @@ D2X-Rebirth Changelog +20081019 +-------- +arch/sdl/gr.c, arch/ogl/gr.c, main/gamecntl.c, main/menu.c, main/movie.c, main/titles.c: Setting Fullscreen toggle setting the GameCfg value at each change, not only in change_res(); Do not allow the toggle while playing since ALT-GR+ENTER could be used as game-keys; Reorganized Resolutions menu to automatically calculate aspect ratio for preset resolutions and making custom fields exclusive + 20081016 -------- main/credits.h, main/collide.c, main/newmenu.c, main/menu.c, main/playsave.c, main/playsave.h, main/titles.c, main/wall.c, main/render.c, main/newdemo.c, main/newdemo.h, main/config.c, main/gameseq.c, main/gamerend.c, main/endlevel.c, main/scores.c, main/game.c, main/kconfig.c, main/gamecntl.c, main/credits.c, 2d/ibitblt.c, arch/sdl/mouse.c, arch/win32/hmpfile.c, arch/include/joy.h: Giving credits function ability to use custom creditfile (again); Made laser-offset for laser exclusive so Prox mines won't go tru doors; Preventing cycling tru cockpit modes while dead, but allowing to load a state; Implemented D2X' lighting code to D1X (faster, better, sexier - weeee); Try to hop over some errors regarding walls/doors in levels instead of using -1 indexes for arrays; Made the briefing text ptr a bit more failsafe in case the file is corrupt/non-standard; Made scores use the menu screen even in GAME OVER; Fixed bug in neighbour fields of Weapon Keys table; Added the Weapon Keys stuff to TABLE_CREATION; Fixed bug where D2X did not recall applied resolution in the resolutions menu; Simpler check to create DEMO_DIR; Seperated X/Y sensitivity for mouse and joystick; Flush controls when Automap toggles so keypress won't deactivate it again; Made FrameCount in Demos aligned to the Dropframe condition; Added KEy to ttoggle playback text off; Gracefully exit demo code if demo is corrupt; Removed that new percent counter because many old demos seem to have corrupted last frames; Closing endlevel data file if IFF error so the mission still can be freed; Fixed Cruising for keyboard which was not aligned to FPS correctly; Used mouse delta scaling in kconfig.c instead of mouse.c to not screw up when delta is requested in non-ingame situations - it actually belongs to the controls IMHO; Now support up to 8 joysticks; Changed some leftover malloc's to d_malloc and free to d_free diff --git a/arch/ogl/gr.c b/arch/ogl/gr.c index 7f88f1654..2695bcb2d 100644 --- a/arch/ogl/gr.c +++ b/arch/ogl/gr.c @@ -130,7 +130,7 @@ int gr_toggle_fullscreen(void) glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); } - + GameCfg.WindowMode = !ogl_fullscreen; return ogl_fullscreen; } diff --git a/arch/sdl/gr.c b/arch/sdl/gr.c index 05e149fd3..c26c1643f 100644 --- a/arch/sdl/gr.c +++ b/arch/sdl/gr.c @@ -105,6 +105,7 @@ int gr_toggle_fullscreen(void) gr_remap_mono_fonts(); sdl_video_flags^=SDL_FULLSCREEN; SDL_WM_ToggleFullScreen(screen); + GameCfg.WindowMode = (sdl_video_flags & SDL_FULLSCREEN)?0:1; return (sdl_video_flags & SDL_FULLSCREEN)?1:0; } diff --git a/main/gamecntl.c b/main/gamecntl.c index e6d8046e5..4020be16c 100644 --- a/main/gamecntl.c +++ b/main/gamecntl.c @@ -1160,12 +1160,6 @@ int HandleSystemKey(int key) macintosh_quit(); break; #endif - - case KEY_ALTED+KEY_ENTER: - case KEY_ALTED+KEY_PADENTER: - gr_toggle_fullscreen(); - game_flush_inputs(); - break; default: break; diff --git a/main/menu.c b/main/menu.c index 482ab3102..ab930aff8 100644 --- a/main/menu.c +++ b/main/menu.c @@ -451,8 +451,6 @@ try_again: } -extern void GameLoop(int, int ); - void options_menuset(int nitems, newmenu_item * items, int *last_key, int citem ) { if ( citem==4) @@ -465,100 +463,106 @@ void options_menuset(int nitems, newmenu_item * items, int *last_key, int citem } -// added on 9/20/98 by Victor Rachels to attempt to add screen res change ingame -// Changed on 3/24/99 by Owen Evans to make it work =) -void change_res_poll() +int gcd(int a, int b) { + if (!b) + return a; + + return gcd(b, a%b); } +void change_res_poll() {} + void change_res() { - newmenu_item m[14]; - u_int32_t modes[14]; + newmenu_item m[15]; + u_int32_t modes[15]; int i = 0, mc = 0, num_presets = 0; char customres[16], aspect[16]; int fullscreenc; u_int32_t screen_mode = 0, aspect_mode = 0; - int screen_width = 0; - int screen_height = 0; - m[mc].type = NM_TYPE_RADIO; m[mc].text = "320x200"; m[mc].value = (Game_screen_mode == SM(320,200)); m[mc].group = 0; modes[mc] = SM(320,200); mc++; - m[mc].type = NM_TYPE_RADIO; m[mc].text = "640x480"; m[mc].value = (Game_screen_mode == SM(640,480)); m[mc].group = 0; modes[mc] = SM(640,480); mc++; - m[mc].type = NM_TYPE_RADIO; m[mc].text = "800x600"; m[mc].value = (Game_screen_mode == SM(800,600)); m[mc].group = 0; modes[mc] = SM(800,600); mc++; - m[mc].type = NM_TYPE_RADIO; m[mc].text = "1024x768"; m[mc].value = (Game_screen_mode == SM(1024,768)); m[mc].group = 0; modes[mc] = SM(1024,768); mc++; - m[mc].type = NM_TYPE_RADIO; m[mc].text = "1280x800"; m[mc].value = (Game_screen_mode == SM(1280,800)); m[mc].group = 0; modes[mc] = SM(1280,800); mc++; - m[mc].type = NM_TYPE_RADIO; m[mc].text = "1280x1024"; m[mc].value = (Game_screen_mode == SM(1280,1024)); m[mc].group = 0; modes[mc] = SM(1280,1024); mc++; - m[mc].type = NM_TYPE_RADIO; m[mc].text = "1440x990"; m[mc].value = (Game_screen_mode == SM(1440,990)); m[mc].group = 0; modes[mc] = SM(1440,990); mc++; - m[mc].type = NM_TYPE_RADIO; m[mc].text = "1600x1200"; m[mc].value = (Game_screen_mode == SM(1600,1200)); m[mc].group = 0; modes[mc] = SM(1600,1200); mc++; - m[mc].type = NM_TYPE_RADIO; m[mc].text = "1920x1200"; m[mc].value = (Game_screen_mode == SM(1920,1200)); m[mc].group = 0; modes[mc] = SM(1920,1200); mc++; - + // the list of pre-defined resolutions + m[mc].type = NM_TYPE_RADIO; m[mc].text = "320x200 (16x10)"; m[mc].value = (Game_screen_mode == SM(320,200)); m[mc].group = 0; modes[mc] = SM(320,200); mc++; + m[mc].type = NM_TYPE_RADIO; m[mc].text = "640x480 (4x3)"; m[mc].value = (Game_screen_mode == SM(640,480)); m[mc].group = 0; modes[mc] = SM(640,480); mc++; + m[mc].type = NM_TYPE_RADIO; m[mc].text = "800x600 (4x3)"; m[mc].value = (Game_screen_mode == SM(800,600)); m[mc].group = 0; modes[mc] = SM(800,600); mc++; + m[mc].type = NM_TYPE_RADIO; m[mc].text = "1024x768 (4x3)"; m[mc].value = (Game_screen_mode == SM(1024,768)); m[mc].group = 0; modes[mc] = SM(1024,768); mc++; + m[mc].type = NM_TYPE_RADIO; m[mc].text = "1280x800 (16x10)"; m[mc].value = (Game_screen_mode == SM(1280,800)); m[mc].group = 0; modes[mc] = SM(1280,800); mc++; + m[mc].type = NM_TYPE_RADIO; m[mc].text = "1280x1024 (5x4)"; m[mc].value = (Game_screen_mode == SM(1280,1024)); m[mc].group = 0; modes[mc] = SM(1280,1024); mc++; + m[mc].type = NM_TYPE_RADIO; m[mc].text = "1440x960 (3x2)"; m[mc].value = (Game_screen_mode == SM(1440,960)); m[mc].group = 0; modes[mc] = SM(1440,960); mc++; + m[mc].type = NM_TYPE_RADIO; m[mc].text = "1600x1200 (4x3)"; m[mc].value = (Game_screen_mode == SM(1600,1200)); m[mc].group = 0; modes[mc] = SM(1600,1200); mc++; + m[mc].type = NM_TYPE_RADIO; m[mc].text = "1920x1200 (16x10)"; m[mc].value = (Game_screen_mode == SM(1920,1200)); m[mc].group = 0; modes[mc] = SM(1920,1200); mc++; num_presets = mc; - m[mc].value=0; // make sure we count and reach the right selection + + // now see which field is true and break there + m[mc].value=0; for (i = 0; i < mc; i++) if (m[mc].value) break; - - m[mc].type = NM_TYPE_RADIO; m[mc].text = "custom:"; m[mc].value = (i == mc); m[mc].group = 0; modes[mc] = 0; mc++; + + // the field for custom resolution and aspect + m[mc].type = NM_TYPE_RADIO; m[mc].text = "use custom values"; m[mc].value = (i == mc); m[mc].group = 0; modes[mc] = 0; mc++; + m[mc].type = NM_TYPE_TEXT; m[mc].text = "resolution:"; mc++; sprintf(customres, "%ix%i", SM_W(Game_screen_mode), SM_H(Game_screen_mode)); m[mc].type = NM_TYPE_INPUT; m[mc].text = customres; m[mc].text_len = 11; modes[mc] = 0; mc++; - m[mc].type = NM_TYPE_TEXT; m[mc].text = "aspect:"; mc++; sprintf(aspect, "%ix%i", GameCfg.AspectY, GameCfg.AspectX); m[mc].type = NM_TYPE_INPUT; m[mc].text = aspect; m[mc].text_len = 11; modes[mc] = 0; mc++; + // fullscreen toggle fullscreenc = mc; m[mc].type = NM_TYPE_CHECK; m[mc].text = "Fullscreen"; m[mc].value = gr_check_fullscreen(); mc++; - i = newmenu_do1(NULL, "Screen Resolution", mc, m, &change_res_poll, 0 ); + // create the menu + i = newmenu_do1(NULL, "Screen Resolution", mc, m, &change_res_poll, 0); + // menu is done, now do what we need to do + + // now check for fullscreen toggle and apply if necessary if (m[fullscreenc].value != gr_check_fullscreen()) { gr_toggle_fullscreen(); Game_screen_mode = -1; - GameCfg.WindowMode = !m[fullscreenc].value; } + // check which preset field was selected for (i = 0; (m[i].value == 0) && (i < num_presets); i++); - if (modes[i]==0) + if (modes[i]==0) // no preset selected, use custom values and set screen_mode and aspect { if (!strchr(customres, 'x')) return; - screen_mode = SM(atoi(customres), atoi(strchr(customres, 'x')+1)); - } - else - { - screen_mode = modes[i]; - } - if (strchr(aspect, 'x')) - { - aspect_mode = SM(atoi(aspect), atoi(strchr(aspect, 'x')+1)); - if (GameCfg.AspectY != SM_W(aspect_mode) || GameCfg.AspectX != SM_H(aspect_mode)) + if (SM_W(screen_mode) < 320 || SM_H(screen_mode) < 200) // oh oh - the resolution is too small. Revert! { - GameCfg.AspectY = SM_W(aspect_mode); - GameCfg.AspectX = SM_H(aspect_mode); - gr_set_mode(Game_screen_mode); + nm_messagebox( TXT_WARNING, 1, "OK", "Entered resolution is too small.\nReverting ..." ); + return; + } + screen_mode = SM(atoi(customres), atoi(strchr(customres, 'x')+1)); + if (strchr(aspect, 'x')) // we even have a custom aspect set up + { + aspect_mode = SM(atoi(aspect), atoi(strchr(aspect, 'x')+1)); + GameCfg.AspectY = SM_W(aspect_mode)/gcd(SM_W(aspect_mode),SM_H(aspect_mode)); + GameCfg.AspectX = SM_H(aspect_mode)/gcd(SM_W(aspect_mode),SM_H(aspect_mode)); } } - - screen_width = SM_W(screen_mode); - screen_height = SM_H(screen_mode); - - if (Game_screen_mode == screen_mode) - return; - - if (screen_width < 320 || screen_height < 200) { - nm_messagebox( TXT_WARNING, 1, "OK", "Entered resolution is too small.\nReverting ..." ); - return; + else // a preset field is selected - set screen_mode and aspect + { + screen_mode = modes[i]; + GameCfg.AspectY = SM_W(screen_mode)/gcd(SM_W(screen_mode),SM_H(screen_mode)); + GameCfg.AspectX = SM_H(screen_mode)/gcd(SM_W(screen_mode),SM_H(screen_mode)); } - newmenu_close(); - Game_screen_mode = screen_mode; + // clean up and apply everything + newmenu_close(); set_screen_mode(SCREEN_MENU); - game_init_render_buffers(screen_width, screen_height, VR_NONE, 0); + gr_set_mode(Game_screen_mode); + if (Game_screen_mode != screen_mode) + { + Game_screen_mode = screen_mode; + game_init_render_buffers(SM_W(screen_mode), SM_H(screen_mode), VR_NONE, 0); + } } -//End changed section (OE) void input_menuset(int nitems, newmenu_item * items, int *last_key, int citem ) { diff --git a/main/movie.c b/main/movie.c index e6fe028df..f0f0d5bfc 100644 --- a/main/movie.c +++ b/main/movie.c @@ -323,10 +323,6 @@ int RunMovie(char *filename, int hires_flag, int must_have,int dx,int dy) clear_pause_message(); } - if ((key == KEY_ALTED+KEY_ENTER) || - (key == KEY_ALTED+KEY_PADENTER)) - gr_toggle_fullscreen(); - frame_num++; } diff --git a/main/titles.c b/main/titles.c index 5ba2c35a5..2a9a09c20 100644 --- a/main/titles.c +++ b/main/titles.c @@ -1033,10 +1033,6 @@ int show_briefing(int screen_num, char *message) if ((key_check == KEY_SPACEBAR) || (key_check == KEY_ENTER)) delay_count = 0; - if ((key_check == KEY_ALTED+KEY_ENTER) || - (key_check == KEY_ALTED+KEY_PADENTER)) - gr_toggle_fullscreen(); - if (Briefing_text_x > bsp->text_ulx + bsp->text_width) { Briefing_text_x = bsp->text_ulx; Briefing_text_y += bsp->text_uly;