diff options
author | peter1138 <peter1138@openttd.org> | 2009-02-07 01:01:02 +0000 |
---|---|---|
committer | peter1138 <peter1138@openttd.org> | 2009-02-07 01:01:02 +0000 |
commit | 967491a22d6828686f17c9ea6215d3a48cee7dc8 (patch) | |
tree | 96e2527960abf9f0224b1ad21987e0e62bb6985c /src/settings_gui.cpp | |
parent | ae2fda6c0214d4952a1fadcb891a8daa819e65ba (diff) | |
download | openttd-967491a22d6828686f17c9ea6215d3a48cee7dc8.tar.xz |
(svn r15389) -Feature: Add ability to select which base graphics set is used from the Game Options window. The change takes effect when the window is closed. This option can only be used from the intro menu, as reloading graphics during a game may cause issues.
Diffstat (limited to 'src/settings_gui.cpp')
-rw-r--r-- | src/settings_gui.cpp | 42 |
1 files changed, 40 insertions, 2 deletions
diff --git a/src/settings_gui.cpp b/src/settings_gui.cpp index f341af58a..6646fb906 100644 --- a/src/settings_gui.cpp +++ b/src/settings_gui.cpp @@ -25,6 +25,7 @@ #include "widgets/dropdown_func.h" #include "station_func.h" #include "highscore.h" +#include "gfxinit.h" #include <map> #include "table/sprites.h" @@ -112,6 +113,7 @@ enum GameOptionsWidgets { GAMEOPT_RESOLUTION_BTN = 19, GAMEOPT_FULLSCREEN, GAMEOPT_SCREENSHOT_BTN = 22, + GAMEOPT_BASE_GRF_BTN = 24, }; /** @@ -140,18 +142,34 @@ static void ShowTownnameDropdown(Window *w, int sel) static void ShowCustCurrency(); +static void ShowGraphicsSetMenu(Window *w) +{ + int n = GetNumGraphicsSets(); + int current = GetIndexOfCurrentGraphicsSet(); + + DropDownList *list = new DropDownList(); + for (int i = 0; i < n; i++) { + list->push_back(new DropDownListCharStringItem(GetGraphicsSetName(i), i, (_game_mode == GM_MENU) ? false : (current != i))); + } + + ShowDropDownList(w, list, current, GAMEOPT_BASE_GRF_BTN); +} + struct GameOptionsWindow : Window { GameSettings *opt; + bool reload; GameOptionsWindow(const WindowDesc *desc) : Window(desc) { this->opt = (_game_mode == GM_MENU) ? &_settings_newgame : &_settings_game; + this->reload = false; this->FindWindowPlacementAndResize(desc); } ~GameOptionsWindow() { DeleteWindowById(WC_CUSTOM_CURRENCY, 0); + if (this->reload) _switch_mode = SM_MENU; } virtual void OnPaint() @@ -171,6 +189,7 @@ struct GameOptionsWindow : Window { SetDParam(7, i == _num_resolutions ? STR_RES_OTHER : SPECSTR_RESOLUTION_START + i); SetDParam(8, SPECSTR_SCREENSHOT_START + _cur_screenshot_format); this->SetWidgetLoweredState(GAMEOPT_FULLSCREEN, _fullscreen); + SetDParamStr(9, GetGraphicsSetName(GetIndexOfCurrentGraphicsSet())); this->DrawWidgets(); DrawString(20, 175, STR_OPTIONS_FULLSCREEN, TC_FROMSTRING); // fullscreen @@ -246,6 +265,10 @@ struct GameOptionsWindow : Window { case GAMEOPT_SCREENSHOT_BTN: // Setup screenshot format dropdown ShowDropDownMenu(this, BuildDynamicDropdown(SPECSTR_SCREENSHOT_START, _num_screenshot_formats), _cur_screenshot_format, GAMEOPT_SCREENSHOT_BTN, 0, 0); break; + + case GAMEOPT_BASE_GRF_BTN: + ShowGraphicsSetMenu(this); + break; } } @@ -312,6 +335,18 @@ struct GameOptionsWindow : Window { SetScreenshotFormat(index); this->SetDirty(); break; + + case GAMEOPT_BASE_GRF_BTN: + if (_game_mode == GM_MENU) { + const char *name = GetGraphicsSetName(index); + + free(_ini_graphics_set); + _ini_graphics_set = strdup(name); + + SetGraphicsSet(name); + this->reload = true; + } + break; } } }; @@ -319,7 +354,7 @@ struct GameOptionsWindow : Window { static const Widget _game_options_widgets[] = { { WWT_CLOSEBOX, RESIZE_NONE, COLOUR_GREY, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, { WWT_CAPTION, RESIZE_NONE, COLOUR_GREY, 11, 369, 0, 13, STR_00B1_GAME_OPTIONS, STR_018C_WINDOW_TITLE_DRAG_THIS}, -{ WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 0, 369, 14, 238, 0x0, STR_NULL}, +{ WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 0, 369, 14, 280, 0x0, STR_NULL}, { WWT_FRAME, RESIZE_NONE, COLOUR_GREY, 10, 179, 20, 55, STR_02E0_CURRENCY_UNITS, STR_NULL}, { WWT_DROPDOWNIN, RESIZE_NONE, COLOUR_GREY, 20, 169, 34, 45, STR_02E1, STR_02E2_CURRENCY_UNITS_SELECTION}, { WWT_FRAME, RESIZE_NONE, COLOUR_GREY, 190, 359, 20, 55, STR_MEASURING_UNITS, STR_NULL}, @@ -345,11 +380,14 @@ static const Widget _game_options_widgets[] = { { WWT_FRAME, RESIZE_NONE, COLOUR_GREY, 190, 359, 146, 190, STR_OPTIONS_SCREENSHOT_FORMAT, STR_NULL}, { WWT_DROPDOWNIN, RESIZE_NONE, COLOUR_GREY, 200, 349, 160, 171, STR_OPTIONS_SCREENSHOT_FORMAT_CBO, STR_OPTIONS_SCREENSHOT_FORMAT_TIP}, +{ WWT_FRAME, RESIZE_NONE, COLOUR_GREY, 10, 179, 235, 270, STR_OPTIONS_BASE_GRF, STR_NULL}, +{ WWT_DROPDOWNIN, RESIZE_NONE, COLOUR_GREY, 20, 169, 249, 260, STR_OPTIONS_BASE_GRF_CBO, STR_OPTIONS_BASE_GRF_TIP}, + { WIDGETS_END}, }; static const WindowDesc _game_options_desc = { - WDP_CENTER, WDP_CENTER, 370, 239, 370, 239, + WDP_CENTER, WDP_CENTER, 370, 281, 370, 281, WC_GAME_OPTIONS, WC_NONE, WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS, _game_options_widgets, |