src/settings_gui.cpp
branchcpp_gui
changeset 6258 a2f86b8fd99b
parent 6254 abc6ad7c035c
child 6298 c30fe89622df
equal deleted inserted replaced
6257:2ffe947969ca 6258:a2f86b8fd99b
    88 }
    88 }
    89 
    89 
    90 
    90 
    91 static void ShowCustCurrency(void);
    91 static void ShowCustCurrency(void);
    92 
    92 
    93 static void GameOptionsWndProc(Window *w, WindowEvent *e)
    93 static void GameOptionsWndProc(BaseWindow *w, WindowEvent *e)
    94 {
    94 {
    95 	switch (e->event) {
    95 	switch (e->event) {
    96 	case WE_PAINT: {
    96 	case WE_PAINT: {
    97 		int i;
    97 		int i;
    98 		StringID str = STR_02BE_DEFAULT;
    98 		StringID str = STR_02BE_DEFAULT;
   237 		InvalidateWindow(WC_GAME_OPTIONS,0);
   237 		InvalidateWindow(WC_GAME_OPTIONS,0);
   238 	}
   238 	}
   239 	return 0;
   239 	return 0;
   240 }
   240 }
   241 
   241 
   242 static const Widget _game_options_widgets[] = {
   242 static const OldWidget _game_options_widgets[] = {
   243 {   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,                          STR_018B_CLOSE_WINDOW},
   243 {   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,                          STR_018B_CLOSE_WINDOW},
   244 {    WWT_CAPTION,   RESIZE_NONE,    14,    11,   369,     0,    13, STR_00B1_GAME_OPTIONS,             STR_018C_WINDOW_TITLE_DRAG_THIS},
   244 {    WWT_CAPTION,   RESIZE_NONE,    14,    11,   369,     0,    13, STR_00B1_GAME_OPTIONS,             STR_018C_WINDOW_TITLE_DRAG_THIS},
   245 {      WWT_PANEL,   RESIZE_NONE,    14,     0,   369,    14,   238, 0x0,                               STR_NULL},
   245 {      WWT_PANEL,   RESIZE_NONE,    14,     0,   369,    14,   238, 0x0,                               STR_NULL},
   246 {      WWT_FRAME,   RESIZE_NONE,    14,    10,   179,    20,    55, STR_02E0_CURRENCY_UNITS,           STR_NULL},
   246 {      WWT_FRAME,   RESIZE_NONE,    14,    10,   179,    20,    55, STR_02E0_CURRENCY_UNITS,           STR_NULL},
   247 {      WWT_INSET,   RESIZE_NONE,    14,    20,   169,    34,    45, STR_02E1,                          STR_02E2_CURRENCY_UNITS_SELECTION},
   247 {      WWT_INSET,   RESIZE_NONE,    14,    20,   169,    34,    45, STR_02E1,                          STR_02E2_CURRENCY_UNITS_SELECTION},
   290 
   290 
   291 
   291 
   292 void ShowGameOptions(void)
   292 void ShowGameOptions(void)
   293 {
   293 {
   294 	DeleteWindowById(WC_GAME_OPTIONS, 0);
   294 	DeleteWindowById(WC_GAME_OPTIONS, 0);
   295 	AllocateWindowDesc(&_game_options_desc);
   295 	BaseWindow::Allocate(&_game_options_desc);
   296 }
   296 }
   297 
   297 
   298 typedef struct {
   298 typedef struct {
   299 	int16 min;
   299 	int16 min;
   300 	int16 max;
   300 	int16 max;
   379 // Temporary holding place of values in the difficulty window until 'Save' is clicked
   379 // Temporary holding place of values in the difficulty window until 'Save' is clicked
   380 static GameOptions _opt_mod_temp;
   380 static GameOptions _opt_mod_temp;
   381 // 0x383E = (1 << 13) | (1 << 12) | (1 << 11) | (1 << 5) | (1 << 4) | (1 << 3) | (1 << 2) | (1 << 1)
   381 // 0x383E = (1 << 13) | (1 << 12) | (1 << 11) | (1 << 5) | (1 << 4) | (1 << 3) | (1 << 2) | (1 << 1)
   382 #define DIFF_INGAME_DISABLED_BUTTONS 0x383E
   382 #define DIFF_INGAME_DISABLED_BUTTONS 0x383E
   383 
   383 
   384 static void GameDifficultyWndProc(Window *w, WindowEvent *e)
   384 static void GameDifficultyWndProc(BaseWindow *w, WindowEvent *e)
   385 {
   385 {
   386 	switch (e->event) {
   386 	switch (e->event) {
   387 	case WE_CREATE: // Setup disabled buttons when creating window
   387 	case WE_CREATE: // Setup disabled buttons when creating window
   388 		/* disable all other difficulty buttons during gameplay except for 'custom' */
   388 		/* disable all other difficulty buttons during gameplay except for 'custom' */
   389 		w->SetWidgetDisabledState( 3, _game_mode == GM_NORMAL);
   389 		w->SetWidgetDisabledState( 3, _game_mode == GM_NORMAL);
   525 	}
   525 	}
   526 }
   526 }
   527 
   527 
   528 #undef DIFF_INGAME_DISABLED_BUTTONS
   528 #undef DIFF_INGAME_DISABLED_BUTTONS
   529 
   529 
   530 static const Widget _game_difficulty_widgets[] = {
   530 static const OldWidget _game_difficulty_widgets[] = {
   531 {   WWT_CLOSEBOX,   RESIZE_NONE,    10,     0,    10,     0,    13, STR_00C5,                     STR_018B_CLOSE_WINDOW},
   531 {   WWT_CLOSEBOX,   RESIZE_NONE,    10,     0,    10,     0,    13, STR_00C5,                     STR_018B_CLOSE_WINDOW},
   532 {    WWT_CAPTION,   RESIZE_NONE,    10,    11,   369,     0,    13, STR_6800_DIFFICULTY_LEVEL,    STR_018C_WINDOW_TITLE_DRAG_THIS},
   532 {    WWT_CAPTION,   RESIZE_NONE,    10,    11,   369,     0,    13, STR_6800_DIFFICULTY_LEVEL,    STR_018C_WINDOW_TITLE_DRAG_THIS},
   533 {      WWT_PANEL,   RESIZE_NONE,    10,     0,   369,    14,    29, 0x0,                          STR_NULL},
   533 {      WWT_PANEL,   RESIZE_NONE,    10,     0,   369,    14,    29, 0x0,                          STR_NULL},
   534 { WWT_PUSHTXTBTN,   RESIZE_NONE,     3,    10,    96,    16,    27, STR_6801_EASY,                STR_NULL},
   534 { WWT_PUSHTXTBTN,   RESIZE_NONE,     3,    10,    96,    16,    27, STR_6801_EASY,                STR_NULL},
   535 { WWT_PUSHTXTBTN,   RESIZE_NONE,     3,    97,   183,    16,    27, STR_6802_MEDIUM,              STR_NULL},
   535 { WWT_PUSHTXTBTN,   RESIZE_NONE,     3,    97,   183,    16,    27, STR_6802_MEDIUM,              STR_NULL},
   555 {
   555 {
   556 	DeleteWindowById(WC_GAME_OPTIONS, 0);
   556 	DeleteWindowById(WC_GAME_OPTIONS, 0);
   557 	/* Copy current settings (ingame or in intro) to temporary holding place
   557 	/* Copy current settings (ingame or in intro) to temporary holding place
   558 	 * change that when setting stuff, copy back on clicking 'OK' */
   558 	 * change that when setting stuff, copy back on clicking 'OK' */
   559 	_opt_mod_temp = *_opt_ptr;
   559 	_opt_mod_temp = *_opt_ptr;
   560 	AllocateWindowDesc(&_game_difficulty_desc);
   560 	BaseWindow::Allocate(&_game_difficulty_desc);
   561 }
   561 }
   562 
   562 
   563 static const char *_patches_ui[] = {
   563 static const char *_patches_ui[] = {
   564 	"vehicle_speed",
   564 	"vehicle_speed",
   565 	"status_long_date",
   565 	"status_long_date",
   679 };
   679 };
   680 
   680 
   681 /** The main patches window. Shows a number of categories on top and
   681 /** The main patches window. Shows a number of categories on top and
   682  * a selection of patches in that category.
   682  * a selection of patches in that category.
   683  * Uses WP(w, def_d) macro - data_1, data_2, data_3 */
   683  * Uses WP(w, def_d) macro - data_1, data_2, data_3 */
   684 static void PatchesSelectionWndProc(Window *w, WindowEvent *e)
   684 static void PatchesSelectionWndProc(BaseWindow *w, WindowEvent *e)
   685 {
   685 {
   686 	static Patches *patches_ptr;
   686 	static Patches *patches_ptr;
   687 
   687 
   688 	switch (e->event) {
   688 	switch (e->event) {
   689 	case WE_CREATE: {
   689 	case WE_CREATE: {
   889 		DeleteWindowById(WC_QUERY_STRING, 0);
   889 		DeleteWindowById(WC_QUERY_STRING, 0);
   890 		break;
   890 		break;
   891 	}
   891 	}
   892 }
   892 }
   893 
   893 
   894 static const Widget _patches_selection_widgets[] = {
   894 static const OldWidget _patches_selection_widgets[] = {
   895 {   WWT_CLOSEBOX,   RESIZE_NONE,    10,     0,    10,     0,    13, STR_00C5,                        STR_018B_CLOSE_WINDOW},
   895 {   WWT_CLOSEBOX,   RESIZE_NONE,    10,     0,    10,     0,    13, STR_00C5,                        STR_018B_CLOSE_WINDOW},
   896 {    WWT_CAPTION,   RESIZE_NONE,    10,    11,   369,     0,    13, STR_CONFIG_PATCHES_CAPTION,      STR_018C_WINDOW_TITLE_DRAG_THIS},
   896 {    WWT_CAPTION,   RESIZE_NONE,    10,    11,   369,     0,    13, STR_CONFIG_PATCHES_CAPTION,      STR_018C_WINDOW_TITLE_DRAG_THIS},
   897 {      WWT_PANEL,   RESIZE_NONE,    10,     0,   369,    14,    41, 0x0,                             STR_NULL},
   897 {      WWT_PANEL,   RESIZE_NONE,    10,     0,   369,    14,    41, 0x0,                             STR_NULL},
   898 {      WWT_PANEL,   RESIZE_NONE,    10,     0,   369,    42,   370, 0x0,                             STR_NULL},
   898 {      WWT_PANEL,   RESIZE_NONE,    10,     0,   369,    42,   370, 0x0,                             STR_NULL},
   899 
   899 
   915 };
   915 };
   916 
   916 
   917 void ShowPatchesSelection(void)
   917 void ShowPatchesSelection(void)
   918 {
   918 {
   919 	DeleteWindowById(WC_GAME_OPTIONS, 0);
   919 	DeleteWindowById(WC_GAME_OPTIONS, 0);
   920 	AllocateWindowDesc(&_patches_selection_desc);
   920 	BaseWindow::Allocate(&_patches_selection_desc);
   921 }
   921 }
   922 
   922 
   923 
   923 
   924 /**
   924 /**
   925  * Draw [<][>] boxes.
   925  * Draw [<][>] boxes.
   946 		GfxFillRect(x + 11, y + 1, x + 11 + 8, y + 8, color);
   946 		GfxFillRect(x + 11, y + 1, x + 11 + 8, y + 8, color);
   947 }
   947 }
   948 
   948 
   949 static char _str_separator[2];
   949 static char _str_separator[2];
   950 
   950 
   951 static void CustCurrencyWndProc(Window *w, WindowEvent *e)
   951 static void CustCurrencyWndProc(BaseWindow *w, WindowEvent *e)
   952 {
   952 {
   953 	switch (e->event) {
   953 	switch (e->event) {
   954 		case WE_PAINT: {
   954 		case WE_PAINT: {
   955 			int x;
   955 			int x;
   956 			int y = 20;
   956 			int y = 20;
  1117 			MarkWholeScreenDirty();
  1117 			MarkWholeScreenDirty();
  1118 			break;
  1118 			break;
  1119 	}
  1119 	}
  1120 }
  1120 }
  1121 
  1121 
  1122 static const Widget _cust_currency_widgets[] = {
  1122 static const OldWidget _cust_currency_widgets[] = {
  1123 {   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,            STR_018B_CLOSE_WINDOW},
  1123 {   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,            STR_018B_CLOSE_WINDOW},
  1124 {    WWT_CAPTION,   RESIZE_NONE,    14,    11,   229,     0,    13, STR_CURRENCY_WINDOW, STR_018C_WINDOW_TITLE_DRAG_THIS},
  1124 {    WWT_CAPTION,   RESIZE_NONE,    14,    11,   229,     0,    13, STR_CURRENCY_WINDOW, STR_018C_WINDOW_TITLE_DRAG_THIS},
  1125 {      WWT_PANEL,   RESIZE_NONE,    14,     0,   229,    14,   119, 0x0,                 STR_NULL},
  1125 {      WWT_PANEL,   RESIZE_NONE,    14,     0,   229,    14,   119, 0x0,                 STR_NULL},
  1126 {   WIDGETS_END},
  1126 {   WIDGETS_END},
  1127 };
  1127 };
  1138 {
  1138 {
  1139 	_str_separator[0] = _custom_currency.separator;
  1139 	_str_separator[0] = _custom_currency.separator;
  1140 	_str_separator[1] = '\0';
  1140 	_str_separator[1] = '\0';
  1141 
  1141 
  1142 	DeleteWindowById(WC_CUSTOM_CURRENCY, 0);
  1142 	DeleteWindowById(WC_CUSTOM_CURRENCY, 0);
  1143 	AllocateWindowDesc(&_cust_currency_desc);
  1143 	BaseWindow::Allocate(&_cust_currency_desc);
  1144 }
  1144 }