(svn r304) -Fix: [967096] fullscreen. New button 'Fullscreen' in 'Game Options' menu which lets you set fullscreen ingame.
authordarkvater
Tue, 21 Sep 2004 20:56:49 +0000
changeset 298 0123c0489940
parent 297 6c4ab6ff031f
child 299 69b73a1fc503
(svn r304) -Fix: [967096] fullscreen. New button 'Fullscreen' in 'Game Options' menu which lets you set fullscreen ingame.
gfx.c
gfx.h
lang/english.txt
settings_gui.c
win32.c
--- a/gfx.c	Mon Sep 20 19:09:06 2004 +0000
+++ b/gfx.c	Tue Sep 21 20:56:49 2004 +0000
@@ -1928,3 +1928,14 @@
 	_cur_resolution[1] = h;
 	return true;
 }
+
+void ToggleFullScreen(const bool full_screen)
+{
+	_fullscreen = full_screen;
+	/* use preset resolutions, not _screen.height and _screen.width. On windows for example
+	   if Desktop-size is 1280x1024, and gamesize is also 1280x1024, _screen.height will be 
+		 only 1000 because of possible start-bar. For this reason you cannot switch to 
+		 fullscreen mode from this resolution. Use of preset resolution will fix this */
+	if (!_video_driver->change_resolution(_cur_resolution[0], _cur_resolution[1]))
+		_fullscreen ^= true; // switching resolution failed, put back full_screen to original status
+}
--- a/gfx.h	Mon Sep 20 19:09:06 2004 +0000
+++ b/gfx.h	Tue Sep 21 20:56:49 2004 +0000
@@ -78,6 +78,7 @@
 void ScreenSizeChanged();
 void UndrawMouseCursor();
 bool ChangeResInGame(int w, int h);
+void ToggleFullScreen(const bool full_screen);
 
 typedef struct {
 	int xoffs, yoffs;
--- a/lang/english.txt	Mon Sep 20 19:09:06 2004 +0000
+++ b/lang/english.txt	Tue Sep 21 20:56:49 2004 +0000
@@ -887,6 +887,9 @@
 STR_OPTIONS_LANG_CBO					:{BLACK}{SKIP}{SKIP}{SKIP}{SKIP}{SKIP}{SKIP}{STRING}
 STR_OPTIONS_LANG_TIP					:{BLACK}Select the interface language to use
 
+STR_OPTIONS_FULLSCREEN			:{BLACK}Fullscreen
+STR_OPTIONS_FULLSCREEN_TIP	:{BLACK}Check this box to play OpenTTD fullscreen mode
+
 STR_OPTIONS_RES							:{BLACK}Screen resolution
 STR_OPTIONS_RES_CBO						:{BLACK}{SKIP}{SKIP}{SKIP}{SKIP}{SKIP}{SKIP}{SKIP}{STRING}
 STR_OPTIONS_RES_TIP						:{BLACK}Select the screen resolution to use
--- a/settings_gui.c	Mon Sep 20 19:09:06 2004 +0000
+++ b/settings_gui.c	Tue Sep 21 20:56:49 2004 +0000
@@ -77,7 +77,10 @@
 		i = GetCurRes();
 		SET_DPARAM16(7, i == _num_resolutions ? STR_RES_OTHER : SPECSTR_RESOLUTION_START + i);
 		SET_DPARAM16(8, SPECSTR_SCREENSHOT_START + _cur_screenshot_format);
+		(_fullscreen) ? SETBIT(w->click_state, 28) : CLRBIT(w->click_state, 28); // fullscreen button
+
 		DrawWindowWidgets(w);
+		DrawString(20, 175, STR_OPTIONS_FULLSCREEN, 0); // fullscreen
 	}	break;
 
 	case WE_CLICK:
@@ -113,8 +116,12 @@
 			// setup resolution dropdown
 			ShowDropDownMenu(w, BuildDynamicDropdown(SPECSTR_RESOLUTION_START, _num_resolutions), GetCurRes(), e->click.widget, 0);
 			return;
-		case 30:
-			// setup screenshot format dropdown
+		case 28: /* Click fullscreen on/off */
+			(_fullscreen) ? CLRBIT(w->click_state, 28) : SETBIT(w->click_state, 28);
+			ToggleFullScreen(!_fullscreen); // toggle full-screen on/off
+			SetWindowDirty(w);
+			return;
+		case 31: /* Setup screenshot format dropdown */
 			ShowDropDownMenu(w, BuildDynamicDropdown(SPECSTR_SCREENSHOT_START, _num_screenshot_formats), _cur_screenshot_format, e->click.widget, 0);
 			return;
 
@@ -197,7 +204,7 @@
 static const Widget _game_options_widgets[] = {
 {   WWT_CLOSEBOX,    14,     0,    10,     0,    13, STR_00C5,								STR_018B_CLOSE_WINDOW},
 {    WWT_CAPTION,    14,    11,   369,     0,    13, STR_00B1_GAME_OPTIONS,		STR_018C_WINDOW_TITLE_DRAG_THIS},
-{      WWT_PANEL,    14,     0,   369,    14,   233, 0x0,											STR_NULL},
+{      WWT_PANEL,    14,     0,   369,    14,   238, 0x0,											STR_NULL},
 {      WWT_FRAME,    14,    10,   179,    20,    55, STR_02E0_CURRENCY_UNITS,	STR_NULL},
 {          WWT_6,    14,    20,   169,    34,    45, STR_02E1,								STR_02E2_CURRENCY_UNITS_SELECTION},
 {   WWT_CLOSEBOX,    14,   158,   168,    35,    44, STR_0225,								STR_02E2_CURRENCY_UNITS_SELECTION},
@@ -214,27 +221,29 @@
 {          WWT_6,    14,    20,   169,   118,   129, STR_02F5,								STR_02F6_SELECT_INTERVAL_BETWEEN},
 {   WWT_CLOSEBOX,    14,   158,   168,   119,   128, STR_0225,								STR_02F6_SELECT_INTERVAL_BETWEEN},
 
-{      WWT_FRAME,    14,    10,   359,   188,   223, STR_02BC_VEHICLE_DESIGN_NAMES,				STR_NULL},
-{          WWT_6,    14,    20,   119,   202,   213, STR_02BD,								STR_02C1_VEHICLE_DESIGN_NAMES_SELECTION},
-{   WWT_CLOSEBOX,    14,   108,   118,   203,   212, STR_0225,								STR_02C1_VEHICLE_DESIGN_NAMES_SELECTION},
-{   WWT_CLOSEBOX,    14,   130,   349,   202,   213, STR_02C0_SAVE_CUSTOM_NAMES_TO_DISK,	STR_02C2_SAVE_CUSTOMIZED_VEHICLE},
+{      WWT_FRAME,    14,    10,   359,   194,   228, STR_02BC_VEHICLE_DESIGN_NAMES,				STR_NULL},
+{          WWT_6,    14,    20,   119,   207,   218, STR_02BD,								STR_02C1_VEHICLE_DESIGN_NAMES_SELECTION},
+{   WWT_CLOSEBOX,    14,   108,   118,   208,   217, STR_0225,								STR_02C1_VEHICLE_DESIGN_NAMES_SELECTION},
+{   WWT_CLOSEBOX,    14,   130,   349,   207,   218, STR_02C0_SAVE_CUSTOM_NAMES_TO_DISK,	STR_02C2_SAVE_CUSTOMIZED_VEHICLE},
 
 {      WWT_FRAME,    14,   190,   359,   104,   139, STR_OPTIONS_LANG,				STR_NULL},
 {          WWT_6,    14,   200,   349,   118,   129, STR_OPTIONS_LANG_CBO,		STR_OPTIONS_LANG_TIP},
 {   WWT_CLOSEBOX,    14,   338,   348,   119,   128, STR_0225,								STR_OPTIONS_LANG_TIP},
-{      WWT_FRAME,    14,    10,   179,   146,   181, STR_OPTIONS_RES,					STR_NULL},
+
+{      WWT_FRAME,    14,    10,   179,   146,   190, STR_OPTIONS_RES,					STR_NULL},
 {          WWT_6,    14,    20,   169,   160,   171, STR_OPTIONS_RES_CBO,			STR_OPTIONS_RES_TIP},
 {   WWT_CLOSEBOX,    14,   158,   168,   161,   170, STR_0225,								STR_OPTIONS_RES_TIP},
+{    WWT_TEXTBTN,    14,   149,   169,   176,   184, STR_EMPTY,								STR_OPTIONS_FULLSCREEN_TIP},
 
-{      WWT_FRAME,    14,   190,   359,   146,   181, STR_OPTIONS_SCREENSHOT_FORMAT,			STR_NULL},
-{          WWT_6,    14,   200,   349,   160,   171, STR_OPTIONS_SCREENSHOT_FORMAT_CBO,	STR_OPTIONS_SCREENSHOT_FORMAT_TIP},
+{      WWT_FRAME,    14,   190,   359,   146,   190, STR_OPTIONS_SCREENSHOT_FORMAT,				STR_NULL},
+{          WWT_6,    14,   200,   349,   160,   171, STR_OPTIONS_SCREENSHOT_FORMAT_CBO,		STR_OPTIONS_SCREENSHOT_FORMAT_TIP},
 {   WWT_CLOSEBOX,    14,   338,   348,   161,   170, STR_0225,								STR_OPTIONS_SCREENSHOT_FORMAT_TIP},
 
 {   WIDGETS_END},
 };
 
 static const WindowDesc _game_options_desc = {
-	WDP_CENTER, WDP_CENTER, 370, 234,
+	WDP_CENTER, WDP_CENTER, 370, 239,
 	WC_GAME_OPTIONS,0,
 	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_RESTORE_DPARAM | WDF_UNCLICK_BUTTONS,
 	_game_options_widgets,
--- a/win32.c	Mon Sep 20 19:09:06 2004 +0000
+++ b/win32.c	Tue Sep 21 20:56:49 2004 +0000
@@ -498,6 +498,7 @@
 				error("CreateWindow failed");
 		}
 	}
+	GameSizeChanged(); // invalidate all windows, force redraw
 }
 
 static bool AllocateDibSection(int w, int h)
@@ -727,7 +728,7 @@
 	_wnd.width = _wnd.width_org = w;
 	_wnd.height = _wnd.height_org = h;
 
-	MakeWindow(_wnd.fullscreen);
+	MakeWindow(_fullscreen); // _wnd.fullscreen screws up ingame resolution switching
 
 	return true;
 }