(svn r15840) -Codechange: complete the game option window widget enum and unify the naming.

This commit is contained in:
rubidium 2009-03-25 00:08:47 +00:00
parent a045f4129e
commit 2e7cab3b77

View File

@ -95,17 +95,31 @@ static int GetCurRes()
return i; return i;
} }
/** Widgets of the game options menu */
enum GameOptionsWidgets { enum GameOptionsWidgets {
GAMEOPT_CURRENCY_BTN = 4, GOW_CLOSEBOX = 0, ///< Close the window
GAMEOPT_DISTANCE_BTN = 6, GOW_CAPTION, ///< Caption of the window
GAMEOPT_ROADSIDE_BTN = 8, GOW_BACKGROUND, ///< Background of the window
GAMEOPT_TOWNNAME_BTN = 10, GOW_CURRENCY_FRAME, ///< Frame of the currency dropdown
GAMEOPT_AUTOSAVE_BTN = 12, GOW_CURRENCY_DROPDOWN, ///< Currency dropdown
GAMEOPT_LANG_BTN = 14, GOW_DISTANCE_FRAME, ///< Measuring unit frame
GAMEOPT_RESOLUTION_BTN = 16, GOW_DISTANCE_DROPDOWN, ///< Measuring unit dropdown
GAMEOPT_FULLSCREEN, GOW_ROADSIDE_FRAME, ///< Road side frame
GAMEOPT_SCREENSHOT_BTN = 19, GOW_ROADSIDE_DROPDOWN, ///< Dropdown to select the road side (to set the right side ;))
GAMEOPT_BASE_GRF_BTN = 21, GOW_TOWNNAME_FRAME, ///< Frame for the town name dropdown
GOW_TOWNNAME_DROPDOWN, ///< Town name dropdown
GOW_AUTOSAVE_FRAME, ///< Frame for autosave
GOW_AUTOSAVE_DROPDOWN, ///< Dropdown to say how often to autosave
GOW_LANG_FRAME, ///< Language dropdown frame
GOW_LANG_DROPDOWN, ///< Language dropdown
GOW_RESOLUTION_FRAME, ///< Frame for the dropdown for the resolution
GOW_RESOLUTION_DROPDOWN, ///< Dropdown for the resolution
GOW_FULLSCREEN_LABEL, ///< Text (right) to the fullscreen button
GOW_FULLSCREEN_BUTTON, ///< Toggle fullscreen
GOW_SCREENSHOT_FRAME, ///< Frame for the screenshot type
GOW_SCREENSHOT_DROPDOWN, ///< Select the screenshot type... please use PNG!
GOW_BASE_GRF_FRAME, ///< Base GRF selection frame
GOW_BASE_GRF_DROPDOWN, ///< Use to select a base GRF
}; };
/** /**
@ -129,7 +143,7 @@ static void ShowTownnameDropdown(Window *w, int sel)
list->push_back(new DropDownListStringItem((*it).first, (*it).second, !(_game_mode == GM_MENU || GetNumTowns() == 0 || (*it).second == sel))); list->push_back(new DropDownListStringItem((*it).first, (*it).second, !(_game_mode == GM_MENU || GetNumTowns() == 0 || (*it).second == sel)));
} }
ShowDropDownList(w, list, sel, GAMEOPT_TOWNNAME_BTN); ShowDropDownList(w, list, sel, GOW_TOWNNAME_DROPDOWN);
} }
static void ShowCustCurrency(); static void ShowCustCurrency();
@ -144,7 +158,7 @@ static void ShowGraphicsSetMenu(Window *w)
list->push_back(new DropDownListCharStringItem(GetGraphicsSetName(i), i, (_game_mode == GM_MENU) ? false : (current != i))); list->push_back(new DropDownListCharStringItem(GetGraphicsSetName(i), i, (_game_mode == GM_MENU) ? false : (current != i)));
} }
ShowDropDownList(w, list, current, GAMEOPT_BASE_GRF_BTN); ShowDropDownList(w, list, current, GOW_BASE_GRF_DROPDOWN);
} }
struct GameOptionsWindow : Window { struct GameOptionsWindow : Window {
@ -175,25 +189,24 @@ struct GameOptionsWindow : Window {
int i = GetCurRes(); int i = GetCurRes();
SetDParam(7, i == _num_resolutions ? STR_RES_OTHER : SPECSTR_RESOLUTION_START + i); SetDParam(7, i == _num_resolutions ? STR_RES_OTHER : SPECSTR_RESOLUTION_START + i);
SetDParam(8, SPECSTR_SCREENSHOT_START + _cur_screenshot_format); SetDParam(8, SPECSTR_SCREENSHOT_START + _cur_screenshot_format);
this->SetWidgetLoweredState(GAMEOPT_FULLSCREEN, _fullscreen); this->SetWidgetLoweredState(GOW_FULLSCREEN_BUTTON, _fullscreen);
SetDParamStr(9, GetGraphicsSetName(GetIndexOfCurrentGraphicsSet())); SetDParamStr(9, GetGraphicsSetName(GetIndexOfCurrentGraphicsSet()));
this->DrawWidgets(); this->DrawWidgets();
DrawString(20, this->width / 2, 175, STR_OPTIONS_FULLSCREEN, TC_FROMSTRING); // fullscreen
} }
virtual void OnClick(Point pt, int widget) virtual void OnClick(Point pt, int widget)
{ {
switch (widget) { switch (widget) {
case GAMEOPT_CURRENCY_BTN: // Setup currencies dropdown case GOW_CURRENCY_DROPDOWN: // Setup currencies dropdown
ShowDropDownMenu(this, BuildCurrencyDropdown(), this->opt->locale.currency, GAMEOPT_CURRENCY_BTN, _game_mode == GM_MENU ? 0 : ~GetMaskOfAllowedCurrencies(), 0); ShowDropDownMenu(this, BuildCurrencyDropdown(), this->opt->locale.currency, GOW_CURRENCY_DROPDOWN, _game_mode == GM_MENU ? 0 : ~GetMaskOfAllowedCurrencies(), 0);
break; break;
case GAMEOPT_DISTANCE_BTN: // Setup distance unit dropdown case GOW_DISTANCE_DROPDOWN: // Setup distance unit dropdown
ShowDropDownMenu(this, _units_dropdown, this->opt->locale.units, GAMEOPT_DISTANCE_BTN, 0, 0); ShowDropDownMenu(this, _units_dropdown, this->opt->locale.units, GOW_DISTANCE_DROPDOWN, 0, 0);
break; break;
case GAMEOPT_ROADSIDE_BTN: { // Setup road-side dropdown case GOW_ROADSIDE_DROPDOWN: { // Setup road-side dropdown
int i = 0; int i = 0;
extern bool RoadVehiclesAreBuilt(); extern bool RoadVehiclesAreBuilt();
@ -203,18 +216,18 @@ struct GameOptionsWindow : Window {
i = (-1) ^ (1 << this->opt->vehicle.road_side); // disable the other value i = (-1) ^ (1 << this->opt->vehicle.road_side); // disable the other value
} }
ShowDropDownMenu(this, _driveside_dropdown, this->opt->vehicle.road_side, GAMEOPT_ROADSIDE_BTN, i, 0); ShowDropDownMenu(this, _driveside_dropdown, this->opt->vehicle.road_side, GOW_ROADSIDE_DROPDOWN, i, 0);
} break; } break;
case GAMEOPT_TOWNNAME_BTN: // Setup townname dropdown case GOW_TOWNNAME_DROPDOWN: // Setup townname dropdown
ShowTownnameDropdown(this, this->opt->game_creation.town_name); ShowTownnameDropdown(this, this->opt->game_creation.town_name);
break; break;
case GAMEOPT_AUTOSAVE_BTN: // Setup autosave dropdown case GOW_AUTOSAVE_DROPDOWN: // Setup autosave dropdown
ShowDropDownMenu(this, _autosave_dropdown, _settings_client.gui.autosave, GAMEOPT_AUTOSAVE_BTN, 0, 0); ShowDropDownMenu(this, _autosave_dropdown, _settings_client.gui.autosave, GOW_AUTOSAVE_DROPDOWN, 0, 0);
break; break;
case GAMEOPT_LANG_BTN: { // Setup interface language dropdown case GOW_LANG_DROPDOWN: { // Setup interface language dropdown
typedef std::map<StringID, int, StringIDCompare> LangList; typedef std::map<StringID, int, StringIDCompare> LangList;
/* Sort language names */ /* Sort language names */
@ -226,27 +239,27 @@ struct GameOptionsWindow : Window {
list->push_back(new DropDownListStringItem((*it).first, (*it).second, false)); list->push_back(new DropDownListStringItem((*it).first, (*it).second, false));
} }
ShowDropDownList(this, list, _dynlang.curr, GAMEOPT_LANG_BTN); ShowDropDownList(this, list, _dynlang.curr, GOW_LANG_DROPDOWN);
} break; } break;
case GAMEOPT_RESOLUTION_BTN: // Setup resolution dropdown case GOW_RESOLUTION_DROPDOWN: // Setup resolution dropdown
ShowDropDownMenu(this, BuildDynamicDropdown(SPECSTR_RESOLUTION_START, _num_resolutions), GetCurRes(), GAMEOPT_RESOLUTION_BTN, 0, 0); ShowDropDownMenu(this, BuildDynamicDropdown(SPECSTR_RESOLUTION_START, _num_resolutions), GetCurRes(), GOW_RESOLUTION_DROPDOWN, 0, 0);
break; break;
case GAMEOPT_FULLSCREEN: // Click fullscreen on/off case GOW_FULLSCREEN_BUTTON: // Click fullscreen on/off
/* try to toggle full-screen on/off */ /* try to toggle full-screen on/off */
if (!ToggleFullScreen(!_fullscreen)) { if (!ToggleFullScreen(!_fullscreen)) {
ShowErrorMessage(INVALID_STRING_ID, STR_FULLSCREEN_FAILED, 0, 0); ShowErrorMessage(INVALID_STRING_ID, STR_FULLSCREEN_FAILED, 0, 0);
} }
this->SetWidgetLoweredState(GAMEOPT_FULLSCREEN, _fullscreen); this->SetWidgetLoweredState(GOW_FULLSCREEN_BUTTON, _fullscreen);
this->SetDirty(); this->SetDirty();
break; break;
case GAMEOPT_SCREENSHOT_BTN: // Setup screenshot format dropdown case GOW_SCREENSHOT_DROPDOWN: // Setup screenshot format dropdown
ShowDropDownMenu(this, BuildDynamicDropdown(SPECSTR_SCREENSHOT_START, _num_screenshot_formats), _cur_screenshot_format, GAMEOPT_SCREENSHOT_BTN, 0, 0); ShowDropDownMenu(this, BuildDynamicDropdown(SPECSTR_SCREENSHOT_START, _num_screenshot_formats), _cur_screenshot_format, GOW_SCREENSHOT_DROPDOWN, 0, 0);
break; break;
case GAMEOPT_BASE_GRF_BTN: case GOW_BASE_GRF_DROPDOWN:
ShowGraphicsSetMenu(this); ShowGraphicsSetMenu(this);
break; break;
} }
@ -255,18 +268,18 @@ struct GameOptionsWindow : Window {
virtual void OnDropdownSelect(int widget, int index) virtual void OnDropdownSelect(int widget, int index)
{ {
switch (widget) { switch (widget) {
case GAMEOPT_CURRENCY_BTN: // Currency case GOW_CURRENCY_DROPDOWN: // Currency
if (index == CUSTOM_CURRENCY_ID) ShowCustCurrency(); if (index == CUSTOM_CURRENCY_ID) ShowCustCurrency();
this->opt->locale.currency = index; this->opt->locale.currency = index;
MarkWholeScreenDirty(); MarkWholeScreenDirty();
break; break;
case GAMEOPT_DISTANCE_BTN: // Measuring units case GOW_DISTANCE_DROPDOWN: // Measuring units
this->opt->locale.units = index; this->opt->locale.units = index;
MarkWholeScreenDirty(); MarkWholeScreenDirty();
break; break;
case GAMEOPT_ROADSIDE_BTN: // Road side case GOW_ROADSIDE_DROPDOWN: // Road side
if (this->opt->vehicle.road_side != index) { // only change if setting changed if (this->opt->vehicle.road_side != index) { // only change if setting changed
uint i; uint i;
if (GetSettingFromName("vehicle.road_side", &i) == NULL) NOT_REACHED(); if (GetSettingFromName("vehicle.road_side", &i) == NULL) NOT_REACHED();
@ -275,19 +288,19 @@ struct GameOptionsWindow : Window {
} }
break; break;
case GAMEOPT_TOWNNAME_BTN: // Town names case GOW_TOWNNAME_DROPDOWN: // Town names
if (_game_mode == GM_MENU || GetNumTowns() == 0) { if (_game_mode == GM_MENU || GetNumTowns() == 0) {
this->opt->game_creation.town_name = index; this->opt->game_creation.town_name = index;
InvalidateWindow(WC_GAME_OPTIONS, 0); InvalidateWindow(WC_GAME_OPTIONS, 0);
} }
break; break;
case GAMEOPT_AUTOSAVE_BTN: // Autosave options case GOW_AUTOSAVE_DROPDOWN: // Autosave options
_settings_client.gui.autosave = index; _settings_client.gui.autosave = index;
this->SetDirty(); this->SetDirty();
break; break;
case GAMEOPT_LANG_BTN: // Change interface language case GOW_LANG_DROPDOWN: // Change interface language
ReadLanguagePack(index); ReadLanguagePack(index);
CheckForMissingGlyphsInLoadedLanguagePack(); CheckForMissingGlyphsInLoadedLanguagePack();
UpdateAllStationVirtCoord(); UpdateAllStationVirtCoord();
@ -295,18 +308,18 @@ struct GameOptionsWindow : Window {
MarkWholeScreenDirty(); MarkWholeScreenDirty();
break; break;
case GAMEOPT_RESOLUTION_BTN: // Change resolution case GOW_RESOLUTION_DROPDOWN: // Change resolution
if (index < _num_resolutions && ChangeResInGame(_resolutions[index].width, _resolutions[index].height)) { if (index < _num_resolutions && ChangeResInGame(_resolutions[index].width, _resolutions[index].height)) {
this->SetDirty(); this->SetDirty();
} }
break; break;
case GAMEOPT_SCREENSHOT_BTN: // Change screenshot format case GOW_SCREENSHOT_DROPDOWN: // Change screenshot format
SetScreenshotFormat(index); SetScreenshotFormat(index);
this->SetDirty(); this->SetDirty();
break; break;
case GAMEOPT_BASE_GRF_BTN: case GOW_BASE_GRF_DROPDOWN:
if (_game_mode == GM_MENU) { if (_game_mode == GM_MENU) {
const char *name = GetGraphicsSetName(index); const char *name = GetGraphicsSetName(index);
@ -322,32 +335,33 @@ struct GameOptionsWindow : Window {
}; };
static const Widget _game_options_widgets[] = { static const Widget _game_options_widgets[] = {
{ WWT_CLOSEBOX, RESIZE_NONE, COLOUR_GREY, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, { WWT_CLOSEBOX, RESIZE_NONE, COLOUR_GREY, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, // GOW_CLOSEBOX
{ WWT_CAPTION, RESIZE_NONE, COLOUR_GREY, 11, 369, 0, 13, STR_00B1_GAME_OPTIONS, STR_018C_WINDOW_TITLE_DRAG_THIS}, { WWT_CAPTION, RESIZE_NONE, COLOUR_GREY, 11, 369, 0, 13, STR_00B1_GAME_OPTIONS, STR_018C_WINDOW_TITLE_DRAG_THIS}, // GOW_CAPTION
{ WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 0, 369, 14, 242, 0x0, STR_NULL}, { WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 0, 369, 14, 242, 0x0, STR_NULL}, // GOW_BACKGROUND
{ WWT_FRAME, RESIZE_NONE, COLOUR_GREY, 10, 179, 20, 55, STR_02E0_CURRENCY_UNITS, STR_NULL}, { WWT_FRAME, RESIZE_NONE, COLOUR_GREY, 10, 179, 20, 55, STR_02E0_CURRENCY_UNITS, STR_NULL}, // GOW_CURRENCY_FRAME
{ WWT_DROPDOWN, RESIZE_NONE, COLOUR_GREY, 20, 169, 34, 45, STR_02E1, STR_02E2_CURRENCY_UNITS_SELECTION}, { WWT_DROPDOWN, RESIZE_NONE, COLOUR_GREY, 20, 169, 34, 45, STR_02E1, STR_02E2_CURRENCY_UNITS_SELECTION}, // GOW_CURRENCY_DROPDOWN
{ WWT_FRAME, RESIZE_NONE, COLOUR_GREY, 190, 359, 20, 55, STR_MEASURING_UNITS, STR_NULL}, { WWT_FRAME, RESIZE_NONE, COLOUR_GREY, 190, 359, 20, 55, STR_MEASURING_UNITS, STR_NULL}, // GOW_DISTANCE_FRAME
{ WWT_DROPDOWN, RESIZE_NONE, COLOUR_GREY, 200, 349, 34, 45, STR_02E4, STR_MEASURING_UNITS_SELECTION}, { WWT_DROPDOWN, RESIZE_NONE, COLOUR_GREY, 200, 349, 34, 45, STR_02E4, STR_MEASURING_UNITS_SELECTION}, // GOW_DISTANCE_DROPDOWN
{ WWT_FRAME, RESIZE_NONE, COLOUR_GREY, 10, 179, 62, 97, STR_02E6_ROAD_VEHICLES, STR_NULL}, { WWT_FRAME, RESIZE_NONE, COLOUR_GREY, 10, 179, 62, 97, STR_02E6_ROAD_VEHICLES, STR_NULL}, // GOW_ROADSIDE_FRAME
{ WWT_DROPDOWN, RESIZE_NONE, COLOUR_GREY, 20, 169, 76, 87, STR_02E7, STR_02E8_SELECT_SIDE_OF_ROAD_FOR}, { WWT_DROPDOWN, RESIZE_NONE, COLOUR_GREY, 20, 169, 76, 87, STR_02E7, STR_02E8_SELECT_SIDE_OF_ROAD_FOR}, // GOW_ROADSIDE_DROPDOWN
{ WWT_FRAME, RESIZE_NONE, COLOUR_GREY, 190, 359, 62, 97, STR_02EB_TOWN_NAMES, STR_NULL}, { WWT_FRAME, RESIZE_NONE, COLOUR_GREY, 190, 359, 62, 97, STR_02EB_TOWN_NAMES, STR_NULL}, // GOW_TOWNNAME_FRAME
{ WWT_DROPDOWN, RESIZE_NONE, COLOUR_GREY, 200, 349, 76, 87, STR_02EC, STR_02ED_SELECT_STYLE_OF_TOWN_NAMES}, { WWT_DROPDOWN, RESIZE_NONE, COLOUR_GREY, 200, 349, 76, 87, STR_02EC, STR_02ED_SELECT_STYLE_OF_TOWN_NAMES}, // GOW_TOWNNAME_DROPDOWN
{ WWT_FRAME, RESIZE_NONE, COLOUR_GREY, 10, 179, 104, 139, STR_02F4_AUTOSAVE, STR_NULL}, { WWT_FRAME, RESIZE_NONE, COLOUR_GREY, 10, 179, 104, 139, STR_02F4_AUTOSAVE, STR_NULL}, // GOW_AUTOSAVE_FRAME
{ WWT_DROPDOWN, RESIZE_NONE, COLOUR_GREY, 20, 169, 118, 129, STR_02F5, STR_02F6_SELECT_INTERVAL_BETWEEN}, { WWT_DROPDOWN, RESIZE_NONE, COLOUR_GREY, 20, 169, 118, 129, STR_02F5, STR_02F6_SELECT_INTERVAL_BETWEEN}, // GOW_AUTOSAVE_DROPDOWN
{ WWT_FRAME, RESIZE_NONE, COLOUR_GREY, 190, 359, 104, 139, STR_OPTIONS_LANG, STR_NULL}, { WWT_FRAME, RESIZE_NONE, COLOUR_GREY, 190, 359, 104, 139, STR_OPTIONS_LANG, STR_NULL}, // GOW_LANG_FRAME
{ WWT_DROPDOWN, RESIZE_NONE, COLOUR_GREY, 200, 349, 118, 129, STR_OPTIONS_LANG_CBO, STR_OPTIONS_LANG_TIP}, { WWT_DROPDOWN, RESIZE_NONE, COLOUR_GREY, 200, 349, 118, 129, STR_OPTIONS_LANG_CBO, STR_OPTIONS_LANG_TIP}, // GOW_LANG_DROPDOWN
{ WWT_FRAME, RESIZE_NONE, COLOUR_GREY, 10, 179, 146, 190, STR_OPTIONS_RES, STR_NULL}, { WWT_FRAME, RESIZE_NONE, COLOUR_GREY, 10, 179, 146, 190, STR_OPTIONS_RES, STR_NULL}, // GOW_RESOLUTION_FRAME
{ WWT_DROPDOWN, RESIZE_NONE, COLOUR_GREY, 20, 169, 160, 171, STR_OPTIONS_RES_CBO, STR_OPTIONS_RES_TIP}, { WWT_DROPDOWN, RESIZE_NONE, COLOUR_GREY, 20, 169, 160, 171, STR_OPTIONS_RES_CBO, STR_OPTIONS_RES_TIP}, // GOW_RESOLUTION_DROPDOWN
{ WWT_TEXTBTN, RESIZE_NONE, COLOUR_GREY, 149, 169, 176, 184, STR_EMPTY, STR_OPTIONS_FULLSCREEN_TIP}, { WWT_TEXT, RESIZE_NONE, COLOUR_GREY, 20, 146, 175, 186, STR_OPTIONS_FULLSCREEN, STR_NULL}, // GOW_FULLSCREEN_LABEL
{ WWT_TEXTBTN, RESIZE_NONE, COLOUR_GREY, 149, 169, 176, 184, STR_EMPTY, STR_OPTIONS_FULLSCREEN_TIP}, // GOW_FULLSCREEN_BUTTON
{ WWT_FRAME, RESIZE_NONE, COLOUR_GREY, 190, 359, 146, 190, STR_OPTIONS_SCREENSHOT_FORMAT, STR_NULL}, { WWT_FRAME, RESIZE_NONE, COLOUR_GREY, 190, 359, 146, 190, STR_OPTIONS_SCREENSHOT_FORMAT, STR_NULL}, // GOW_SCREENSHOT_FRAME
{ WWT_DROPDOWN, RESIZE_NONE, COLOUR_GREY, 200, 349, 160, 171, STR_OPTIONS_SCREENSHOT_FORMAT_CBO, STR_OPTIONS_SCREENSHOT_FORMAT_TIP}, { WWT_DROPDOWN, RESIZE_NONE, COLOUR_GREY, 200, 349, 160, 171, STR_OPTIONS_SCREENSHOT_FORMAT_CBO, STR_OPTIONS_SCREENSHOT_FORMAT_TIP}, // GOW_SCREENSHOT_DROPDOWN
{ WWT_FRAME, RESIZE_NONE, COLOUR_GREY, 10, 179, 197, 232, STR_OPTIONS_BASE_GRF, STR_NULL}, { WWT_FRAME, RESIZE_NONE, COLOUR_GREY, 10, 179, 197, 232, STR_OPTIONS_BASE_GRF, STR_NULL}, // GOW_BASE_GRF_FRAME
{ WWT_DROPDOWN, RESIZE_NONE, COLOUR_GREY, 20, 169, 211, 222, STR_OPTIONS_BASE_GRF_CBO, STR_OPTIONS_BASE_GRF_TIP}, { WWT_DROPDOWN, RESIZE_NONE, COLOUR_GREY, 20, 169, 211, 222, STR_OPTIONS_BASE_GRF_CBO, STR_OPTIONS_BASE_GRF_TIP}, // GOW_BASE_GRF_DROPDOWN
{ WIDGETS_END}, { WIDGETS_END},
}; };