tron@2186: /* $Id$ */ tron@2186: belugas@6916: /** @file settings_gui.cpp */ belugas@6916: truelight@0: #include "stdafx.h" Darkvater@1891: #include "openttd.h" tron@2291: #include "currency.h" truelight@0: #include "gui.h" rubidium@8603: #include "window_gui.h" rubidium@8603: #include "textbuf_gui.h" rubidium@8612: #include "command_func.h" rubidium@9282: #include "engine_func.h" tron@430: #include "screenshot.h" dominik@478: #include "newgrf.h" rubidium@5720: #include "network/network.h" truelight@835: #include "town.h" tron@2159: #include "variables.h" rubidium@8704: #include "settings_internal.h" glx@7452: #include "newgrf_townname.h" rubidium@8610: #include "strings_func.h" rubidium@8627: #include "functions.h" rubidium@8627: #include "window_func.h" rubidium@8640: #include "vehicle_base.h" rubidium@8709: #include "core/alloc_func.hpp" rubidium@8710: #include "string_func.h" rubidium@8720: #include "gfx_func.h" glx@9001: #include "waypoint.h" glx@8817: #include "widgets/dropdown_type.h" peter1138@8780: #include "widgets/dropdown_func.h" rubidium@9281: #include "station_func.h" truelight@0: rubidium@8760: #include "table/sprites.h" rubidium@8760: #include "table/strings.h" rubidium@8760: peter1138@3342: static const StringID _units_dropdown[] = { peter1138@3342: STR_UNITS_IMPERIAL, peter1138@3342: STR_UNITS_METRIC, peter1138@3342: STR_UNITS_SI, truelight@0: INVALID_STRING_ID truelight@0: }; truelight@0: truelight@0: static const StringID _driveside_dropdown[] = { truelight@0: STR_02E9_DRIVE_ON_LEFT, truelight@0: STR_02EA_DRIVE_ON_RIGHT, truelight@0: INVALID_STRING_ID truelight@0: }; truelight@0: truelight@0: static const StringID _autosave_dropdown[] = { truelight@0: STR_02F7_OFF, truelight@0: STR_AUTOSAVE_1_MONTH, truelight@0: STR_02F8_EVERY_3_MONTHS, truelight@0: STR_02F9_EVERY_6_MONTHS, truelight@0: STR_02FA_EVERY_12_MONTHS, truelight@0: INVALID_STRING_ID, truelight@0: }; truelight@0: truelight@0: static const StringID _designnames_dropdown[] = { truelight@0: STR_02BE_DEFAULT, truelight@0: STR_02BF_CUSTOM, truelight@0: INVALID_STRING_ID truelight@0: }; truelight@0: truelight@0: static StringID *BuildDynamicDropdown(StringID base, int num) truelight@0: { truelight@0: static StringID buf[32 + 1]; truelight@0: StringID *p = buf; truelight@0: while (--num>=0) *p++ = base++; truelight@0: *p = INVALID_STRING_ID; truelight@0: return buf; truelight@0: } truelight@0: glx@7452: int _nb_orig_names = SPECSTR_TOWNNAME_LAST - SPECSTR_TOWNNAME_START + 1; glx@7452: static StringID *_grf_names = NULL; glx@7452: static int _nb_grf_names = 0; glx@7293: glx@8819: void InitGRFTownGeneratorNames() glx@7293: { glx@7452: free(_grf_names); glx@7452: _grf_names = GetGRFTownNameList(); glx@7452: _nb_grf_names = 0; glx@7452: for (StringID *s = _grf_names; *s != INVALID_STRING_ID; s++) _nb_grf_names++; glx@7452: } glx@7452: glx@7452: static inline StringID TownName(int town_name) glx@7452: { glx@7452: if (town_name < _nb_orig_names) return STR_TOWNNAME_ORIGINAL_ENGLISH + town_name; glx@7452: town_name -= _nb_orig_names; glx@7452: if (town_name < _nb_grf_names) return _grf_names[town_name]; glx@7452: return STR_UNDEFINED; glx@7293: } glx@7293: rubidium@6573: static int GetCurRes() truelight@0: { truelight@0: int i; tron@2639: tron@2639: for (i = 0; i != _num_resolutions; i++) { darkvater@306: if (_resolutions[i][0] == _screen.width && tron@2639: _resolutions[i][1] == _screen.height) { truelight@0: break; tron@2639: } tron@2639: } truelight@0: return i; truelight@0: } truelight@0: rubidium@6573: static inline bool RoadVehiclesAreBuilt() darkvater@871: { tron@2639: const Vehicle* v; tron@2639: tron@915: FOR_ALL_VEHICLES(v) { rubidium@6585: if (v->type == VEH_ROAD) return true; darkvater@871: } darkvater@871: return false; darkvater@871: } darkvater@871: tron@2817: belugas@8684: enum GameOptionsWidgets { peter1138@8832: GAMEOPT_CURRENCY_BTN = 4, peter1138@8832: GAMEOPT_DISTANCE_BTN = 6, peter1138@8832: GAMEOPT_ROADSIDE_BTN = 8, peter1138@8832: GAMEOPT_TOWNNAME_BTN = 10, peter1138@8832: GAMEOPT_AUTOSAVE_BTN = 12, peter1138@8832: GAMEOPT_VEHICLENAME_BTN = 14, belugas@8684: GAMEOPT_VEHICLENAME_SAVE, peter1138@8832: GAMEOPT_LANG_BTN = 17, peter1138@8832: GAMEOPT_RESOLUTION_BTN = 19, belugas@8684: GAMEOPT_FULLSCREEN, peter1138@8832: GAMEOPT_SCREENSHOT_BTN = 22, belugas@8684: }; belugas@8684: glx@8817: /** glx@8819: * Update/redraw the townnames dropdown glx@8819: * @param w the window the dropdown belongs to glx@8819: * @param sel the currently selected townname generator glx@8819: */ glx@8819: static void ShowTownnameDropdown(Window *w, int sel) glx@8819: { glx@8819: typedef std::map TownList; glx@8819: TownList townnames; glx@8819: glx@8819: /* Add and sort original townnames generators */ glx@8819: for (int i = 0; i < _nb_orig_names; i++) townnames[STR_TOWNNAME_ORIGINAL_ENGLISH + i] = i; glx@8819: glx@8819: /* Add and sort newgrf townnames generators */ glx@8819: for (int i = 0; i < _nb_grf_names; i++) townnames[_grf_names[i]] = _nb_orig_names + i; glx@8819: glx@8819: DropDownList *list = new DropDownList(); glx@8819: for (TownList::iterator it = townnames.begin(); it != townnames.end(); it++) { glx@8819: list->push_back(new DropDownListStringItem((*it).first, (*it).second, !(_game_mode == GM_MENU || (*it).second == sel))); glx@8819: } glx@8819: glx@8819: ShowDropDownList(w, list, sel, GAMEOPT_TOWNNAME_BTN); glx@8819: } glx@8819: glx@8819: /** glx@8817: * Update/redraw the languages dropdown glx@8817: * @param w the window the dropdown belongs to glx@8817: */ glx@8817: static void ShowLangDropdown(Window *w) glx@8817: { glx@8817: typedef std::map LangList; glx@8817: glx@8817: /* Sort language names */ glx@8817: LangList langs; glx@8817: for (int i = 0; i < _dynlang.num; i++) langs[SPECSTR_LANGUAGE_START + i] = i; glx@8817: glx@8817: DropDownList *list = new DropDownList(); glx@8817: for (LangList::iterator it = langs.begin(); it != langs.end(); it++) { glx@8817: list->push_back(new DropDownListStringItem((*it).first, (*it).second, false)); glx@8817: } glx@8817: glx@8817: ShowDropDownList(w, list, _dynlang.curr, GAMEOPT_LANG_BTN); glx@8817: } glx@8817: rubidium@6573: static void ShowCustCurrency(); tron@2817: truelight@0: static void GameOptionsWndProc(Window *w, WindowEvent *e) truelight@0: { Darkvater@1500: switch (e->event) { belugas@8686: case WE_PAINT: { belugas@8686: int i; belugas@8686: StringID str = STR_02BE_DEFAULT; darkvater@298: peter1138@8815: w->SetWidgetDisabledState(GAMEOPT_VEHICLENAME_SAVE, !(_vehicle_design_names & 1)); peter1138@8815: if (!w->IsWidgetDisabled(GAMEOPT_VEHICLENAME_SAVE)) str = STR_02BF_CUSTOM; belugas@8686: SetDParam(0, str); belugas@8686: SetDParam(1, _currency_specs[_opt_ptr->currency].name); belugas@8686: SetDParam(2, STR_UNITS_IMPERIAL + _opt_ptr->units); belugas@8686: SetDParam(3, STR_02E9_DRIVE_ON_LEFT + _opt_ptr->road_side); belugas@8686: SetDParam(4, TownName(_opt_ptr->town_name)); belugas@8686: SetDParam(5, _autosave_dropdown[_opt_ptr->autosave]); belugas@8686: SetDParam(6, SPECSTR_LANGUAGE_START + _dynlang.curr); belugas@8686: i = GetCurRes(); belugas@8686: SetDParam(7, i == _num_resolutions ? STR_RES_OTHER : SPECSTR_RESOLUTION_START + i); belugas@8686: SetDParam(8, SPECSTR_SCREENSHOT_START + _cur_screenshot_format); belugas@8686: w->SetWidgetLoweredState(GAMEOPT_FULLSCREEN, _fullscreen); belugas@8684: belugas@8686: DrawWindowWidgets(w); belugas@8686: DrawString(20, 175, STR_OPTIONS_FULLSCREEN, TC_FROMSTRING); // fullscreen belugas@8684: } break; belugas@8684: belugas@8686: case WE_CLICK: belugas@8686: switch (e->we.click.widget) { peter1138@8832: case GAMEOPT_CURRENCY_BTN: /* Setup currencies dropdown */ belugas@8687: ShowDropDownMenu(w, BuildCurrencyDropdown(), _opt_ptr->currency, GAMEOPT_CURRENCY_BTN, _game_mode == GM_MENU ? 0 : ~GetMaskOfAllowedCurrencies(), 0); glx@7293: break; belugas@8684: peter1138@8832: case GAMEOPT_DISTANCE_BTN: /* Setup distance unit dropdown */ belugas@8686: ShowDropDownMenu(w, _units_dropdown, _opt_ptr->units, GAMEOPT_DISTANCE_BTN, 0, 0); belugas@8686: break; belugas@8684: peter1138@8832: case GAMEOPT_ROADSIDE_BTN: { /* Setup road-side dropdown */ belugas@8686: int i = 0; truelight@0: belugas@8686: /* You can only change the drive side if you are in the menu or ingame with belugas@8686: * no vehicles present. In a networking game only the server can change it */ belugas@8686: if ((_game_mode != GM_MENU && RoadVehiclesAreBuilt()) || (_networking && !_network_server)) belugas@8686: i = (-1) ^ (1 << _opt_ptr->road_side); // disable the other value belugas@8686: belugas@8686: ShowDropDownMenu(w, _driveside_dropdown, _opt_ptr->road_side, GAMEOPT_ROADSIDE_BTN, i, 0); belugas@8686: } break; belugas@8686: peter1138@8832: case GAMEOPT_TOWNNAME_BTN: /* Setup townname dropdown */ glx@8819: ShowTownnameDropdown(w, _opt_ptr->town_name); glx@8819: break; belugas@8686: peter1138@8832: case GAMEOPT_AUTOSAVE_BTN: /* Setup autosave dropdown */ belugas@8686: ShowDropDownMenu(w, _autosave_dropdown, _opt_ptr->autosave, GAMEOPT_AUTOSAVE_BTN, 0, 0); belugas@8686: break; belugas@8686: peter1138@8832: case GAMEOPT_VEHICLENAME_BTN: /* Setup customized vehicle-names dropdown */ belugas@8686: ShowDropDownMenu(w, _designnames_dropdown, (_vehicle_design_names & 1) ? 1 : 0, GAMEOPT_VEHICLENAME_BTN, (_vehicle_design_names & 2) ? 0 : 2, 0); belugas@8686: break; belugas@8686: belugas@8686: case GAMEOPT_VEHICLENAME_SAVE: /* Save customized vehicle-names to disk */ belugas@8686: break; // not implemented belugas@8686: peter1138@8832: case GAMEOPT_LANG_BTN: /* Setup interface language dropdown */ glx@8817: ShowLangDropdown(w); belugas@8686: break; belugas@8686: peter1138@8832: case GAMEOPT_RESOLUTION_BTN: /* Setup resolution dropdown */ belugas@8686: ShowDropDownMenu(w, BuildDynamicDropdown(SPECSTR_RESOLUTION_START, _num_resolutions), GetCurRes(), GAMEOPT_RESOLUTION_BTN, 0, 0); belugas@8686: break; belugas@8686: belugas@8686: case GAMEOPT_FULLSCREEN: /* Click fullscreen on/off */ belugas@8686: /* try to toggle full-screen on/off */ belugas@8686: if (!ToggleFullScreen(!_fullscreen)) { belugas@8686: ShowErrorMessage(INVALID_STRING_ID, STR_FULLSCREEN_FAILED, 0, 0); belugas@8686: } belugas@8686: w->SetWidgetLoweredState(GAMEOPT_FULLSCREEN, _fullscreen); belugas@8686: SetWindowDirty(w); belugas@8686: break; belugas@8686: peter1138@8832: case GAMEOPT_SCREENSHOT_BTN: /* Setup screenshot format dropdown */ belugas@8686: ShowDropDownMenu(w, BuildDynamicDropdown(SPECSTR_SCREENSHOT_START, _num_screenshot_formats), _cur_screenshot_format, GAMEOPT_SCREENSHOT_BTN, 0, 0); belugas@8686: break; truelight@0: } truelight@0: break; belugas@8684: belugas@8686: case WE_DROPDOWN_SELECT: belugas@8686: switch (e->we.dropdown.button) { belugas@8686: case GAMEOPT_VEHICLENAME_BTN: /* Vehicle design names */ belugas@8686: if (e->we.dropdown.index == 0) { belugas@8686: DeleteCustomEngineNames(); belugas@8686: MarkWholeScreenDirty(); belugas@8686: } else if (!(_vehicle_design_names & 1)) { belugas@8686: LoadCustomEngineNames(); belugas@8686: MarkWholeScreenDirty(); belugas@8686: } belugas@8686: break; belugas@8684: belugas@8686: case GAMEOPT_CURRENCY_BTN: /* Currency */ belugas@8686: if (e->we.dropdown.index == CUSTOM_CURRENCY_ID) ShowCustCurrency(); belugas@8686: _opt_ptr->currency = e->we.dropdown.index; belugas@8686: MarkWholeScreenDirty(); belugas@8686: break; belugas@8684: belugas@8686: case GAMEOPT_DISTANCE_BTN: /* Measuring units */ belugas@8686: _opt_ptr->units = e->we.dropdown.index; belugas@8686: MarkWholeScreenDirty(); belugas@8686: break; belugas@8686: belugas@8686: case GAMEOPT_ROADSIDE_BTN: /* Road side */ belugas@8686: if (_opt_ptr->road_side != e->we.dropdown.index) { // only change if setting changed belugas@8686: DoCommandP(0, e->we.dropdown.index, 0, NULL, CMD_SET_ROAD_DRIVE_SIDE | CMD_MSG(STR_00B4_CAN_T_DO_THIS)); belugas@8686: MarkWholeScreenDirty(); belugas@8686: } belugas@8686: break; belugas@8686: belugas@8686: case GAMEOPT_TOWNNAME_BTN: /* Town names */ belugas@8686: if (_game_mode == GM_MENU) { glx@8819: _opt_ptr->town_name = e->we.dropdown.index; belugas@8686: InvalidateWindow(WC_GAME_OPTIONS, 0); belugas@8686: } belugas@8686: break; belugas@8686: belugas@8686: case GAMEOPT_AUTOSAVE_BTN: /* Autosave options */ belugas@8686: _opt.autosave = _opt_newgame.autosave = e->we.dropdown.index; belugas@8686: SetWindowDirty(w); belugas@8686: break; belugas@8686: belugas@8686: case GAMEOPT_LANG_BTN: /* Change interface language */ belugas@8686: ReadLanguagePack(e->we.dropdown.index); belugas@8686: CheckForMissingGlyphsInLoadedLanguagePack(); belugas@8686: UpdateAllStationVirtCoord(); glx@9001: UpdateAllWaypointSigns(); belugas@8686: MarkWholeScreenDirty(); belugas@8686: break; belugas@8686: belugas@8686: case GAMEOPT_RESOLUTION_BTN: /* Change resolution */ belugas@8686: if (e->we.dropdown.index < _num_resolutions && ChangeResInGame(_resolutions[e->we.dropdown.index][0],_resolutions[e->we.dropdown.index][1])) belugas@8686: SetWindowDirty(w); belugas@8686: break; belugas@8686: belugas@8686: case GAMEOPT_SCREENSHOT_BTN: /* Change screenshot format */ belugas@8686: SetScreenshotFormat(e->we.dropdown.index); belugas@8686: SetWindowDirty(w); belugas@8686: break; dominik@1113: } truelight@0: break; belugas@8684: belugas@8686: case WE_DESTROY: belugas@8686: DeleteWindowById(WC_CUSTOM_CURRENCY, 0); truelight@0: break; truelight@0: } dominik@759: truelight@0: } truelight@0: Darkvater@1794: /** Change the side of the road vehicles drive on (server only). tron@3491: * @param tile unused belugas@6979: * @param flags operation to perform Darkvater@1794: * @param p1 the side of the road; 0 = left side and 1 = right side Darkvater@1794: * @param p2 unused Darkvater@1794: */ rubidium@7439: CommandCost CmdSetRoadDriveSide(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) truelight@0: { Darkvater@1803: /* Check boundaries and you can only change this if NO vehicles have been built yet, Darkvater@1803: * except in the intro-menu where of course it's always possible to do so. */ Darkvater@1803: if (p1 > 1 || (_game_mode != GM_MENU && RoadVehiclesAreBuilt())) return CMD_ERROR; Darkvater@1794: truelight@0: if (flags & DC_EXEC) { Darkvater@1500: _opt_ptr->road_side = p1; truelight@0: InvalidateWindow(WC_GAME_OPTIONS,0); truelight@0: } rubidium@7446: return CommandCost(); truelight@0: } truelight@0: truelight@0: static const Widget _game_options_widgets[] = { rubidium@4344: { WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, rubidium@4344: { WWT_CAPTION, RESIZE_NONE, 14, 11, 369, 0, 13, STR_00B1_GAME_OPTIONS, STR_018C_WINDOW_TITLE_DRAG_THIS}, rubidium@4344: { WWT_PANEL, RESIZE_NONE, 14, 0, 369, 14, 238, 0x0, STR_NULL}, rubidium@4344: { WWT_FRAME, RESIZE_NONE, 14, 10, 179, 20, 55, STR_02E0_CURRENCY_UNITS, STR_NULL}, peter1138@8832: { WWT_DROPDOWNIN, RESIZE_NONE, 14, 20, 169, 34, 45, STR_02E1, STR_02E2_CURRENCY_UNITS_SELECTION}, rubidium@4344: { WWT_FRAME, RESIZE_NONE, 14, 190, 359, 20, 55, STR_MEASURING_UNITS, STR_NULL}, peter1138@8832: { WWT_DROPDOWNIN, RESIZE_NONE, 14, 200, 349, 34, 45, STR_02E4, STR_MEASURING_UNITS_SELECTION}, rubidium@4344: { WWT_FRAME, RESIZE_NONE, 14, 10, 179, 62, 97, STR_02E6_ROAD_VEHICLES, STR_NULL}, peter1138@8832: { WWT_DROPDOWNIN, RESIZE_NONE, 14, 20, 169, 76, 87, STR_02E7, STR_02E8_SELECT_SIDE_OF_ROAD_FOR}, rubidium@4344: { WWT_FRAME, RESIZE_NONE, 14, 190, 359, 62, 97, STR_02EB_TOWN_NAMES, STR_NULL}, peter1138@8832: { WWT_DROPDOWNIN, RESIZE_NONE, 14, 200, 349, 76, 87, STR_02EC, STR_02ED_SELECT_STYLE_OF_TOWN_NAMES}, rubidium@4344: { WWT_FRAME, RESIZE_NONE, 14, 10, 179, 104, 139, STR_02F4_AUTOSAVE, STR_NULL}, peter1138@8832: { WWT_DROPDOWNIN, RESIZE_NONE, 14, 20, 169, 118, 129, STR_02F5, STR_02F6_SELECT_INTERVAL_BETWEEN}, truelight@0: rubidium@4344: { WWT_FRAME, RESIZE_NONE, 14, 10, 359, 194, 228, STR_02BC_VEHICLE_DESIGN_NAMES, STR_NULL}, peter1138@8832: { WWT_DROPDOWNIN, RESIZE_NONE, 14, 20, 119, 207, 218, STR_02BD, STR_02C1_VEHICLE_DESIGN_NAMES_SELECTION}, rubidium@4344: { WWT_TEXTBTN, RESIZE_NONE, 14, 130, 349, 207, 218, STR_02C0_SAVE_CUSTOM_NAMES, STR_02C2_SAVE_CUSTOMIZED_VEHICLE}, truelight@0: rubidium@4344: { WWT_FRAME, RESIZE_NONE, 14, 190, 359, 104, 139, STR_OPTIONS_LANG, STR_NULL}, peter1138@8832: { WWT_DROPDOWNIN, RESIZE_NONE, 14, 200, 349, 118, 129, STR_OPTIONS_LANG_CBO, STR_OPTIONS_LANG_TIP}, darkvater@298: rubidium@4344: { WWT_FRAME, RESIZE_NONE, 14, 10, 179, 146, 190, STR_OPTIONS_RES, STR_NULL}, peter1138@8832: { WWT_DROPDOWNIN, RESIZE_NONE, 14, 20, 169, 160, 171, STR_OPTIONS_RES_CBO, STR_OPTIONS_RES_TIP}, rubidium@4344: { WWT_TEXTBTN, RESIZE_NONE, 14, 149, 169, 176, 184, STR_EMPTY, STR_OPTIONS_FULLSCREEN_TIP}, truelight@0: rubidium@4344: { WWT_FRAME, RESIZE_NONE, 14, 190, 359, 146, 190, STR_OPTIONS_SCREENSHOT_FORMAT, STR_NULL}, peter1138@8832: { WWT_DROPDOWNIN, RESIZE_NONE, 14, 200, 349, 160, 171, STR_OPTIONS_SCREENSHOT_FORMAT_CBO, STR_OPTIONS_SCREENSHOT_FORMAT_TIP}, truelight@0: darkvater@176: { WIDGETS_END}, truelight@0: }; truelight@0: truelight@0: static const WindowDesc _game_options_desc = { rubidium@7837: WDP_CENTER, WDP_CENTER, 370, 239, 370, 239, rubidium@6144: WC_GAME_OPTIONS, WC_NONE, ludde@2064: WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS, truelight@0: _game_options_widgets, truelight@0: GameOptionsWndProc truelight@0: }; truelight@0: truelight@0: rubidium@6573: void ShowGameOptions() truelight@0: { truelight@0: DeleteWindowById(WC_GAME_OPTIONS, 0); truelight@0: AllocateWindowDesc(&_game_options_desc); truelight@0: } truelight@0: rubidium@6574: struct GameSettingData { truelight@0: int16 min; truelight@0: int16 max; truelight@0: int16 step; truelight@0: StringID str; rubidium@6574: }; truelight@0: truelight@0: static const GameSettingData _game_setting_info[] = { Darkvater@1500: { 0, 7, 1, STR_NULL}, Darkvater@1500: { 0, 3, 1, STR_6830_IMMEDIATE}, belugas@7056: { 0, 3, 1, STR_NUM_VERY_LOW}, maedhros@8920: { 0, 4, 1, STR_NONE}, Darkvater@1500: {100, 500, 50, STR_NULL}, Darkvater@1500: { 2, 4, 1, STR_NULL}, Darkvater@1500: { 0, 2, 1, STR_6820_LOW}, Darkvater@1500: { 0, 4, 1, STR_681B_VERY_SLOW}, Darkvater@1500: { 0, 2, 1, STR_6820_LOW}, Darkvater@1500: { 0, 2, 1, STR_6823_NONE}, Darkvater@1500: { 0, 3, 1, STR_6826_X1_5}, Darkvater@1500: { 0, 2, 1, STR_6820_LOW}, Darkvater@1500: { 0, 3, 1, STR_682A_VERY_FLAT}, Darkvater@1500: { 0, 3, 1, STR_VERY_LOW}, Darkvater@1500: { 0, 1, 1, STR_682E_STEADY}, Darkvater@1500: { 0, 1, 1, STR_6834_AT_END_OF_LINE_AND_AT_STATIONS}, Darkvater@1500: { 0, 1, 1, STR_6836_OFF}, maedhros@8920: { 0, 2, 1, STR_PERMISSIVE}, truelight@0: }; truelight@0: celestar@1385: /* rubidium@4549: * A: competitors rubidium@4549: * B: start time in months / 3 belugas@7056: * C: town count (2 = high, 0 = very low) belugas@7056: * D: industry count (4 = high, 0 = none) rubidium@4549: * E: inital loan / 1000 (in GBP) rubidium@4549: * F: interest rate rubidium@4549: * G: running costs (0 = low, 2 = high) rubidium@4549: * H: construction speed of competitors (0 = very slow, 4 = very fast) rubidium@4549: * I: intelligence (0-2) rubidium@4549: * J: breakdowns (0 = off, 2 = normal) rubidium@4549: * K: subsidy multiplier (0 = 1.5, 3 = 4.0) rubidium@4549: * L: construction cost (0-2) rubidium@4549: * M: terrain type (0 = very flat, 3 = mountainous) rubidium@4549: * N: amount of water (0 = very low, 3 = high) rubidium@4549: * O: economy (0 = steady, 1 = fluctuating) rubidium@4549: * P: Train reversing (0 = end of line + stations, 1 = end of line) rubidium@4549: * Q: disasters rubidium@4549: * R: area restructuring (0 = permissive, 2 = hostile) rubidium@4549: */ rubidium@8238: static const GDType _default_game_diff[3][GAME_DIFFICULTY_NUM] = { /* celestar@1385: A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R*/ belugas@7056: {2, 2, 1, 4, 300, 2, 0, 2, 0, 1, 2, 0, 1, 0, 0, 0, 0, 0}, ///< easy belugas@7056: {4, 1, 1, 3, 150, 3, 1, 3, 1, 2, 1, 1, 2, 1, 1, 1, 1, 1}, ///< medium belugas@7056: {7, 0, 0, 2, 100, 4, 1, 3, 2, 2, 0, 2, 3, 2, 1, 1, 1, 2}, ///< hard truelight@0: }; truelight@0: truelight@0: void SetDifficultyLevel(int mode, GameOptions *gm_opt) truelight@0: { truelight@0: int i; truelight@0: assert(mode <= 3); truelight@0: truelight@0: gm_opt->diff_level = mode; truelight@0: if (mode != 3) { // not custom Darkvater@1500: for (i = 0; i != GAME_DIFFICULTY_NUM; i++) rubidium@8238: ((GDType*)&gm_opt->diff)[i] = _default_game_diff[mode][i]; truelight@0: } truelight@0: } truelight@0: rubidium@6704: /** rubidium@6704: * Checks the difficulty levels read from the configuration and rubidium@6704: * forces them to be correct when invalid. rubidium@6704: */ rubidium@6704: void CheckDifficultyLevels() rubidium@6704: { rubidium@6704: if (_opt_newgame.diff_level != 3) { rubidium@6704: SetDifficultyLevel(_opt_newgame.diff_level, &_opt_newgame); rubidium@6704: } else { rubidium@6704: for (uint i = 0; i < GAME_DIFFICULTY_NUM; i++) { rubidium@8238: GDType *diff = ((GDType*)&_opt_newgame.diff) + i; skidd13@8418: *diff = Clamp(*diff, _game_setting_info[i].min, _game_setting_info[i].max); rubidium@6704: *diff -= *diff % _game_setting_info[i].step; rubidium@6704: } rubidium@6704: } rubidium@6704: } rubidium@6704: rubidium@6573: extern void StartupEconomy(); darkvater@46: darkvater@983: enum { darkvater@983: GAMEDIFF_WND_TOP_OFFSET = 45, darkvater@983: GAMEDIFF_WND_ROWSIZE = 9 darkvater@983: }; darkvater@983: belugas@6916: /* Temporary holding place of values in the difficulty window until 'Save' is clicked */ Darkvater@1500: static GameOptions _opt_mod_temp; Darkvater@1500: // 0x383E = (1 << 13) | (1 << 12) | (1 << 11) | (1 << 5) | (1 << 4) | (1 << 3) | (1 << 2) | (1 << 1) Darkvater@1500: #define DIFF_INGAME_DISABLED_BUTTONS 0x383E Darkvater@1500: skidd13@8904: #define NO_SETTINGS_BUTTON 0xFF skidd13@8904: skidd13@8904: /** Carriage for the game settings window data */ skidd13@8904: struct difficulty_d { skidd13@8904: bool clicked_increase; skidd13@8904: uint8 clicked_button; skidd13@8904: uint8 timeout; skidd13@8904: }; skidd13@8904: assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(difficulty_d)); skidd13@8904: skidd13@8632: /* Names of the game difficulty settings window */ skidd13@8632: enum GameDifficultyWidgets { skidd13@8632: GDW_CLOSEBOX = 0, skidd13@8632: GDW_CAPTION, skidd13@8632: GDW_UPPER_BG, skidd13@8632: GDW_LVL_EASY, skidd13@8632: GDW_LVL_MEDIUM, skidd13@8632: GDW_LVL_HARD, skidd13@8632: GDW_LVL_CUSTOM, skidd13@8632: GDW_HIGHSCORE, skidd13@8632: GDW_SETTING_BG, skidd13@8632: GDW_LOWER_BG, skidd13@8632: GDW_ACCEPT, skidd13@8632: GDW_CANCEL, skidd13@8632: }; skidd13@8632: truelight@0: static void GameDifficultyWndProc(Window *w, WindowEvent *e) truelight@0: { skidd13@8904: difficulty_d *diffic_d = &WP(w, difficulty_d); Darkvater@1500: switch (e->event) { belugas@8686: case WE_CREATE: skidd13@8904: diffic_d->clicked_increase = false; skidd13@8904: diffic_d->clicked_button = NO_SETTINGS_BUTTON; skidd13@8904: diffic_d->timeout = 0; belugas@8686: /* Hide the closebox to make sure that the user aborts or confirms his changes */ belugas@8686: w->HideWidget(GDW_CLOSEBOX); belugas@8686: w->widget[GDW_CAPTION].left = 0; belugas@8686: /* Setup disabled buttons when creating window belugas@8686: * disable all other difficulty buttons during gameplay except for 'custom' */ belugas@8686: w->SetWidgetsDisabledState(_game_mode == GM_NORMAL, belugas@8686: GDW_LVL_EASY, belugas@8686: GDW_LVL_MEDIUM, belugas@8686: GDW_LVL_HARD, belugas@8686: GDW_LVL_CUSTOM, belugas@8686: WIDGET_LIST_END); belugas@8686: w->SetWidgetDisabledState(GDW_HIGHSCORE, _game_mode == GM_EDITOR || _networking); // highscore chart in multiplayer belugas@8686: w->SetWidgetDisabledState(GDW_ACCEPT, _networking && !_network_server); // Save-button in multiplayer (and if client) belugas@8686: w->LowerWidget(GDW_LVL_EASY + _opt_mod_temp.diff_level); belugas@8686: break; truelight@0: belugas@8686: case WE_PAINT: { belugas@8686: DrawWindowWidgets(w); truelight@0: belugas@8686: /* XXX - Disabled buttons in normal gameplay or during muliplayer as non server. belugas@8686: * Bitshifted for each button to see if that bit is set. If it is set, the belugas@8686: * button is disabled */ belugas@8686: uint32 disabled = 0; belugas@8686: if (_networking && !_network_server) { belugas@8686: disabled = MAX_UVALUE(uint32); // Disable all belugas@8686: } else if (_game_mode == GM_NORMAL) { belugas@8686: disabled = DIFF_INGAME_DISABLED_BUTTONS; truelight@0: } truelight@0: belugas@8686: int value; belugas@8686: int y = GAMEDIFF_WND_TOP_OFFSET; belugas@8686: for (uint i = 0; i != GAME_DIFFICULTY_NUM; i++) { belugas@8686: const GameSettingData *gsd = &_game_setting_info[i]; belugas@8686: value = ((GDType*)&_opt_mod_temp.diff)[i]; belugas@8686: belugas@8686: DrawArrowButtons(5, y, 3, glx@9008: (diffic_d->clicked_button == i) ? 1 + !!diffic_d->clicked_increase : 0, belugas@8686: !(HasBit(disabled, i) || gsd->min == value), belugas@8686: !(HasBit(disabled, i) || gsd->max == value)); belugas@8686: belugas@8686: value += _game_setting_info[i].str; belugas@8686: if (i == 4) value *= 1000; // XXX - handle currency option belugas@8686: SetDParam(0, value); belugas@8686: DrawString(30, y, STR_6805_MAXIMUM_NO_COMPETITORS + i, TC_FROMSTRING); belugas@8686: belugas@8686: y += GAMEDIFF_WND_ROWSIZE + 2; // space items apart a bit belugas@8686: } rubidium@6988: } break; belugas@8684: belugas@8686: case WE_CLICK: belugas@8686: switch (e->we.click.widget) { belugas@8686: case GDW_SETTING_BG: { /* Difficulty settings widget, decode click */ belugas@8686: /* Don't allow clients to make any changes */ belugas@8686: if (_networking && !_network_server) return; belugas@8684: belugas@8686: const int x = e->we.click.pt.x - 5; belugas@8686: if (!IsInsideMM(x, 0, 21)) // Button area belugas@8686: return; belugas@8686: belugas@8686: const int y = e->we.click.pt.y - GAMEDIFF_WND_TOP_OFFSET; belugas@8686: if (y < 0) return; belugas@8686: belugas@8686: /* Get button from Y coord. */ skidd13@8904: const uint8 btn = y / (GAMEDIFF_WND_ROWSIZE + 2); belugas@8686: if (btn >= GAME_DIFFICULTY_NUM || y % (GAMEDIFF_WND_ROWSIZE + 2) >= 9) belugas@8686: return; belugas@8686: belugas@8686: /* Clicked disabled button? */ belugas@8686: if (_game_mode == GM_NORMAL && HasBit(DIFF_INGAME_DISABLED_BUTTONS, btn)) belugas@8686: return; belugas@8686: skidd13@8904: diffic_d->timeout = 5; belugas@8686: belugas@8686: int16 val = ((GDType*)&_opt_mod_temp.diff)[btn]; belugas@8686: belugas@8686: const GameSettingData *info = &_game_setting_info[btn]; // get information about the difficulty setting belugas@8686: if (x >= 10) { belugas@8686: /* Increase button clicked */ belugas@8686: val = min(val + info->step, info->max); skidd13@8904: diffic_d->clicked_increase = true; belugas@8686: } else { belugas@8686: /* Decrease button clicked */ belugas@8686: val -= info->step; belugas@8686: val = max(val, info->min); skidd13@8904: diffic_d->clicked_increase = false; belugas@8686: } skidd13@8904: diffic_d->clicked_button = btn; belugas@8686: belugas@8686: /* save value in temporary variable */ belugas@8686: ((GDType*)&_opt_mod_temp.diff)[btn] = val; belugas@8686: w->RaiseWidget(GDW_LVL_EASY + _opt_mod_temp.diff_level); belugas@8686: SetDifficultyLevel(3, &_opt_mod_temp); // set difficulty level to custom belugas@8686: w->LowerWidget(GDW_LVL_CUSTOM); belugas@8686: SetWindowDirty(w); belugas@8686: } break; belugas@8686: belugas@8686: case GDW_LVL_EASY: belugas@8686: case GDW_LVL_MEDIUM: belugas@8686: case GDW_LVL_HARD: belugas@8686: case GDW_LVL_CUSTOM: belugas@8686: /* temporarily change difficulty level */ belugas@8686: w->RaiseWidget(GDW_LVL_EASY + _opt_mod_temp.diff_level); belugas@8686: SetDifficultyLevel(e->we.click.widget - GDW_LVL_EASY, &_opt_mod_temp); belugas@8686: w->LowerWidget(GDW_LVL_EASY + _opt_mod_temp.diff_level); belugas@8686: SetWindowDirty(w); belugas@8686: break; belugas@8686: belugas@8686: case GDW_HIGHSCORE: // Highscore Table belugas@8686: ShowHighscoreTable(_opt_mod_temp.diff_level, -1); belugas@8686: break; belugas@8686: belugas@8686: case GDW_ACCEPT: { // Save button - save changes belugas@8686: GDType btn, val; belugas@8686: for (btn = 0; btn != GAME_DIFFICULTY_NUM; btn++) { belugas@8686: val = ((GDType*)&_opt_mod_temp.diff)[btn]; belugas@8686: /* if setting has changed, change it */ belugas@8686: if (val != ((GDType*)&_opt_ptr->diff)[btn]) belugas@8686: DoCommandP(0, btn, val, NULL, CMD_CHANGE_DIFFICULTY_LEVEL); belugas@8686: } belugas@8686: DoCommandP(0, UINT_MAX, _opt_mod_temp.diff_level, NULL, CMD_CHANGE_DIFFICULTY_LEVEL); belugas@8686: DeleteWindow(w); belugas@8686: /* If we are in the editor, we should reload the economy. belugas@8686: * This way when you load a game, the max loan and interest rate belugas@8686: * are loaded correctly. */ belugas@8686: if (_game_mode == GM_EDITOR) StartupEconomy(); belugas@8686: break; belugas@8686: } belugas@8686: belugas@8686: case GDW_CANCEL: // Cancel button - close window, abandon changes belugas@8686: DeleteWindow(w); belugas@8686: break; belugas@8686: } break; belugas@8686: belugas@8686: case WE_MOUSELOOP: /* Handle the visual 'clicking' of the buttons */ skidd13@8904: if (diffic_d->timeout != 0) { skidd13@8904: diffic_d->timeout--; skidd13@8904: if (diffic_d->timeout == 0) diffic_d->clicked_button = NO_SETTINGS_BUTTON; belugas@8686: SetWindowDirty(w); truelight@0: } truelight@0: break; truelight@0: } truelight@0: } Darkvater@1500: #undef DIFF_INGAME_DISABLED_BUTTONS Darkvater@1500: skidd13@8632: /* Widget definition for the game difficulty settings window */ truelight@0: static const Widget _game_difficulty_widgets[] = { skidd13@8632: { WWT_CLOSEBOX, RESIZE_NONE, 10, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, // GDW_CLOSEBOX skidd13@8632: { WWT_CAPTION, RESIZE_NONE, 10, 11, 369, 0, 13, STR_6800_DIFFICULTY_LEVEL, STR_018C_WINDOW_TITLE_DRAG_THIS}, // GDW_CAPTION skidd13@8632: { WWT_PANEL, RESIZE_NONE, 10, 0, 369, 14, 41, 0x0, STR_NULL}, // GDW_UPPER_BG skidd13@8632: { WWT_PUSHTXTBTN, RESIZE_NONE, 3, 10, 96, 16, 27, STR_6801_EASY, STR_NULL}, // GDW_LVL_EASY skidd13@8632: { WWT_PUSHTXTBTN, RESIZE_NONE, 3, 97, 183, 16, 27, STR_6802_MEDIUM, STR_NULL}, // GDW_LVL_MEDIUM skidd13@8632: { WWT_PUSHTXTBTN, RESIZE_NONE, 3, 184, 270, 16, 27, STR_6803_HARD, STR_NULL}, // GDW_LVL_HARD skidd13@8632: { WWT_PUSHTXTBTN, RESIZE_NONE, 3, 271, 357, 16, 27, STR_6804_CUSTOM, STR_NULL}, // GDW_LVL_CUSTOM skidd13@8632: { WWT_TEXTBTN, RESIZE_NONE, 6, 10, 357, 28, 39, STR_6838_SHOW_HI_SCORE_CHART, STR_NULL}, // GDW_HIGHSCORE skidd13@8632: { WWT_PANEL, RESIZE_NONE, 10, 0, 369, 42, 262, 0x0, STR_NULL}, // GDW_SETTING_BG skidd13@8632: { WWT_PANEL, RESIZE_NONE, 10, 0, 369, 263, 278, 0x0, STR_NULL}, // GDW_LOWER_BG skidd13@8632: { WWT_PUSHTXTBTN, RESIZE_NONE, 3, 105, 185, 265, 276, STR_OPTIONS_SAVE_CHANGES, STR_NULL}, // GDW_ACCEPT skidd13@8632: { WWT_PUSHTXTBTN, RESIZE_NONE, 3, 186, 266, 265, 276, STR_012E_CANCEL, STR_NULL}, // GDW_CANCEL darkvater@176: { WIDGETS_END}, truelight@0: }; truelight@0: skidd13@8632: /* Window definition for the game difficulty settings window */ truelight@0: static const WindowDesc _game_difficulty_desc = { rubidium@7837: WDP_CENTER, WDP_CENTER, 370, 279, 370, 279, rubidium@6144: WC_GAME_OPTIONS, WC_NONE, truelight@0: WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET, truelight@0: _game_difficulty_widgets, truelight@0: GameDifficultyWndProc truelight@0: }; truelight@0: rubidium@6573: void ShowGameDifficulty() truelight@0: { truelight@0: DeleteWindowById(WC_GAME_OPTIONS, 0); Darkvater@1500: /* Copy current settings (ingame or in intro) to temporary holding place Darkvater@1500: * change that when setting stuff, copy back on clicking 'OK' */ tron@5024: _opt_mod_temp = *_opt_ptr; truelight@0: AllocateWindowDesc(&_game_difficulty_desc); truelight@193: } truelight@0: Darkvater@3247: static const char *_patches_ui[] = { Darkvater@3247: "vehicle_speed", Darkvater@3247: "status_long_date", Darkvater@3247: "show_finances", Darkvater@3247: "autoscroll", Darkvater@3247: "reverse_scroll", peter1138@7226: "smooth_scroll", Darkvater@3247: "errmsg_duration", Darkvater@3247: "toolbar_pos", Darkvater@4834: "measure_tooltip", Darkvater@3247: "window_snap_radius", Darkvater@3247: "population_in_label", Darkvater@3247: "link_terraform_toolbar", peter1138@4616: "liveries", Darkvater@5107: "prefer_teamchat", bjarni@6615: /* While the horizontal scrollwheel scrolling is written as general code, only bjarni@6615: * the cocoa (OSX) driver generates input for it. bjarni@6622: * Since it's also able to completely disable the scrollwheel will we display it on all platforms anyway */ bjarni@6615: "scrollwheel_scrolling", bjarni@6615: "scrollwheel_multiplier", bjarni@7981: #ifdef __APPLE__ bjarni@7981: /* We might need to emulate a right mouse button on mac */ bjarni@7981: "right_mouse_btn_emulation", bjarni@7981: #endif maedhros@7039: "pause_on_newgame", rubidium@7139: "advanced_vehicle_list", truelight@7494: "loading_indicators", maedhros@7476: "timetable_in_ticks", rubidium@7560: "default_rail_type", rubidium@7582: "always_build_infrastructure", truelight@21: }; truelight@21: Darkvater@3247: static const char *_patches_construction[] = { Darkvater@3247: "build_on_slopes", rubidium@8078: "autoslope", Darkvater@3247: "extra_dynamite", Darkvater@3247: "longbridges", Darkvater@3247: "signal_side", Darkvater@3247: "always_small_airport", rubidium@8487: "enable_signal_gui", Darkvater@3247: "drag_signals_density", truelight@4300: "oil_refinery_limit", maedhros@5939: "semaphore_build_before", Darkvater@3247: }; Darkvater@3247: Darkvater@3247: static const char *_patches_stations[] = { Darkvater@3247: "join_stations", Darkvater@3247: "full_load_any", Darkvater@3247: "improved_load", Darkvater@3247: "selectgoods", Darkvater@3247: "new_nonstop", Darkvater@3247: "nonuniform_stations", Darkvater@3247: "station_spread", Darkvater@3247: "serviceathelipad", Darkvater@3247: "modified_catchment", peter1138@5211: "gradual_loading", rubidium@6338: "road_stop_on_town_road", maedhros@7170: "adjacent_stations", Darkvater@3247: }; Darkvater@3247: Darkvater@3247: static const char *_patches_economy[] = { Darkvater@3247: "inflation", rubidium@7673: "raw_industry_construction", Darkvater@3247: "multiple_industry_per_town", Darkvater@3247: "same_industry_close", Darkvater@3247: "bribe", rubidium@8153: "exclusive_rights", rubidium@8153: "give_money", rubidium@4285: "colored_news_year", rubidium@4285: "ending_year", Darkvater@3247: "smooth_economy", Darkvater@3247: "allow_shares", rubidium@8137: "town_layout", rubidium@8137: "mod_road_rebuild", maedhros@6950: "town_growth_rate", maedhros@6950: "larger_towns", maedhros@6982: "initial_city_size", Darkvater@3247: }; Darkvater@3247: Darkvater@3247: static const char *_patches_ai[] = { Darkvater@3247: "ainew_active", Darkvater@3247: "ai_in_multiplayer", Darkvater@3247: "ai_disable_veh_train", Darkvater@3247: "ai_disable_veh_roadveh", Darkvater@3247: "ai_disable_veh_aircraft", Darkvater@3247: "ai_disable_veh_ship", Darkvater@3247: }; Darkvater@3247: Darkvater@3247: static const char *_patches_vehicles[] = { Darkvater@3247: "realistic_acceleration", Darkvater@3247: "forbid_90_deg", Darkvater@3247: "mammoth_trains", Darkvater@3247: "gotodepot", Darkvater@3247: "roadveh_queue", smatz@9047: "pathfinder_for_trains", smatz@9047: "pathfinder_for_roadvehs", smatz@9047: "pathfinder_for_ships", Darkvater@3247: "train_income_warn", Darkvater@3247: "order_review_system", Darkvater@3247: "never_expire_vehicles", KUDr@4870: "lost_train_warn", Darkvater@3247: "autorenew", Darkvater@3247: "autorenew_months", Darkvater@3247: "autorenew_money", Darkvater@3247: "max_trains", Darkvater@3247: "max_roadveh", Darkvater@3247: "max_aircraft", Darkvater@3247: "max_ships", Darkvater@3247: "servint_ispercent", Darkvater@3247: "servint_trains", Darkvater@3247: "servint_roadveh", Darkvater@3247: "servint_ships", Darkvater@3247: "servint_aircraft", Darkvater@3247: "no_servicing_if_no_breakdowns", Darkvater@3247: "wagon_speed_limits", KUDr@5116: "disable_elrails", peter1138@5163: "freight_trains", peter1138@9144: "plane_speed", maedhros@7476: "timetabling", Darkvater@3247: }; Darkvater@3247: rubidium@6574: struct PatchEntry { Darkvater@3247: const SettingDesc *setting; Darkvater@3247: uint index; rubidium@6574: }; Darkvater@3247: rubidium@6574: struct PatchPage { Darkvater@3247: const char **names; Darkvater@3247: PatchEntry *entries; Darkvater@3118: byte num; rubidium@6574: }; truelight@0: Darkvater@3247: /* PatchPage holds the categories, the number of elements in each category Darkvater@3247: * and (in NULL) a dynamic array of settings based on the string-representations Darkvater@3247: * of the settings. This way there is no worry about indeces, and such */ Darkvater@3247: static PatchPage _patches_page[] = { Darkvater@3247: {_patches_ui, NULL, lengthof(_patches_ui)}, Darkvater@3247: {_patches_construction, NULL, lengthof(_patches_construction)}, Darkvater@3247: {_patches_vehicles, NULL, lengthof(_patches_vehicles)}, Darkvater@3247: {_patches_stations, NULL, lengthof(_patches_stations)}, Darkvater@3247: {_patches_economy, NULL, lengthof(_patches_economy)}, Darkvater@3247: {_patches_ai, NULL, lengthof(_patches_ai)}, truelight@0: }; truelight@0: belugas@8684: enum PatchesSelectionWidgets { belugas@8684: PATCHSEL_OPTIONSPANEL = 3, belugas@8684: PATCHSEL_INTERFACE, belugas@8684: PATCHSEL_CONSTRUCTION, belugas@8684: PATCHSEL_VEHICLES, belugas@8684: PATCHSEL_STATIONS, belugas@8684: PATCHSEL_ECONOMY, belugas@8684: PATCHSEL_COMPETITORS belugas@8684: }; belugas@8684: Darkvater@3118: /** The main patches window. Shows a number of categories on top and Darkvater@3118: * a selection of patches in that category. Darkvater@3118: * Uses WP(w, def_d) macro - data_1, data_2, data_3 */ truelight@0: static void PatchesSelectionWndProc(Window *w, WindowEvent *e) truelight@0: { Darkvater@3118: static Patches *patches_ptr; peter1138@9089: static int patches_max = 0; Darkvater@3118: Darkvater@1741: switch (e->event) { belugas@8686: case WE_CREATE: { belugas@8686: static bool first_time = true; truelight@0: belugas@8686: patches_ptr = (_game_mode == GM_MENU) ? &_patches_newgame : &_patches; Darkvater@3118: belugas@8686: /* Build up the dynamic settings-array only once per OpenTTD session */ belugas@8686: if (first_time) { belugas@8686: PatchPage *page; belugas@8686: for (page = &_patches_page[0]; page != endof(_patches_page); page++) { belugas@8686: uint i; Darkvater@3118: peter1138@9089: if (patches_max < page->num) patches_max = page->num; peter1138@9089: belugas@8686: page->entries = MallocT(page->num); belugas@8686: for (i = 0; i != page->num; i++) { belugas@8686: uint index; belugas@8686: const SettingDesc *sd = GetPatchFromName(page->names[i], &index); belugas@8686: assert(sd != NULL); truelight@0: belugas@8686: page->entries[i].setting = sd; belugas@8686: page->entries[i].index = index; truelight@0: } truelight@0: } belugas@8686: first_time = false; belugas@8686: } peter1138@9089: peter1138@9089: /* Resize the window to fit the largest patch tab */ peter1138@9089: ResizeWindowForWidget(w, PATCHSEL_OPTIONSPANEL, 0, patches_max * 11); peter1138@9089: peter1138@9090: /* Recentre the window for the new size */ peter1138@9090: w->top = w->top - (patches_max * 11) / 2; peter1138@9090: belugas@8686: w->LowerWidget(4); belugas@8686: } break; Darkvater@3118: belugas@8686: case WE_PAINT: { belugas@8686: int x, y; belugas@8686: const PatchPage *page = &_patches_page[WP(w, def_d).data_1]; belugas@8686: uint i; belugas@8686: belugas@8686: /* Set up selected category */ belugas@8686: DrawWindowWidgets(w); belugas@8686: belugas@8686: x = 5; belugas@8686: y = 47; belugas@8686: for (i = 0; i != page->num; i++) { belugas@8686: const SettingDesc *sd = page->entries[i].setting; belugas@8686: const SettingDescBase *sdb = &sd->desc; belugas@8686: const void *var = GetVariableAddress(patches_ptr, &sd->save); belugas@8686: bool editable = true; belugas@8686: bool disabled = false; belugas@8686: belugas@8686: // We do not allow changes of some items when we are a client in a networkgame belugas@8686: if (!(sd->save.conv & SLF_NETWORK_NO) && _networking && !_network_server) editable = false; belugas@8686: if ((sdb->flags & SGF_NETWORK_ONLY) && !_networking) editable = false; belugas@8686: if ((sdb->flags & SGF_NO_NETWORK) && _networking) editable = false; belugas@8686: belugas@8686: if (sdb->cmd == SDT_BOOLX) { belugas@8686: static const int _bool_ctabs[2][2] = {{9, 4}, {7, 6}}; belugas@8686: /* Draw checkbox for boolean-value either on/off */ belugas@8686: bool on = (*(bool*)var); belugas@8686: belugas@8686: DrawFrameRect(x, y, x + 19, y + 8, _bool_ctabs[!!on][!!editable], on ? FR_LOWERED : FR_NONE); belugas@8686: SetDParam(0, on ? STR_CONFIG_PATCHES_ON : STR_CONFIG_PATCHES_OFF); belugas@8686: } else { belugas@8686: int32 value; belugas@8686: belugas@8686: value = (int32)ReadValue(var, sd->save.conv); belugas@8686: belugas@8686: /* Draw [<][>] boxes for settings of an integer-type */ belugas@8686: DrawArrowButtons(x, y, 3, WP(w, def_d).data_2 - (i * 2), (editable && value != sdb->min), (editable && value != sdb->max)); belugas@8686: belugas@8686: disabled = (value == 0) && (sdb->flags & SGF_0ISDISABLED); belugas@8686: if (disabled) { belugas@8686: SetDParam(0, STR_CONFIG_PATCHES_DISABLED); belugas@8686: } else { belugas@8686: if (sdb->flags & SGF_CURRENCY) { belugas@8686: SetDParam(0, STR_CONFIG_PATCHES_CURRENCY); belugas@8686: } else if (sdb->flags & SGF_MULTISTRING) { belugas@8686: SetDParam(0, sdb->str + value + 1); belugas@8686: } else { belugas@8686: SetDParam(0, (sdb->flags & SGF_NOCOMMA) ? STR_CONFIG_PATCHES_INT32 : STR_7024); belugas@8686: } belugas@8686: SetDParam(1, value); belugas@8686: } truelight@0: } belugas@8686: DrawString(30, y, (sdb->str) + disabled, TC_FROMSTRING); belugas@8686: y += 11; truelight@0: } belugas@8684: } break; truelight@193: belugas@8686: case WE_CLICK: belugas@8686: switch (e->we.click.widget) { belugas@8686: case PATCHSEL_OPTIONSPANEL: { belugas@8686: const PatchPage *page = &_patches_page[WP(w, def_d).data_1]; belugas@8686: const SettingDesc *sd; belugas@8686: void *var; belugas@8686: int32 value; belugas@8686: int x, y; belugas@8686: byte btn; belugas@8686: belugas@8686: y = e->we.click.pt.y - 46 - 1; belugas@8686: if (y < 0) return; belugas@8686: belugas@8686: x = e->we.click.pt.x - 5; belugas@8686: if (x < 0) return; belugas@8686: belugas@8686: btn = y / 11; belugas@8686: if (y % 11 > 9) return; belugas@8686: if (btn >= page->num) return; belugas@8686: belugas@8686: sd = page->entries[btn].setting; belugas@8686: belugas@8686: /* return if action is only active in network, or only settable by server */ belugas@8686: if (!(sd->save.conv & SLF_NETWORK_NO) && _networking && !_network_server) return; belugas@8686: if ((sd->desc.flags & SGF_NETWORK_ONLY) && !_networking) return; belugas@8686: if ((sd->desc.flags & SGF_NO_NETWORK) && _networking) return; belugas@8686: belugas@8686: var = GetVariableAddress(patches_ptr, &sd->save); belugas@8686: value = (int32)ReadValue(var, sd->save.conv); belugas@8686: belugas@8686: /* clicked on the icon on the left side. Either scroller or bool on/off */ belugas@8686: if (x < 21) { belugas@8686: const SettingDescBase *sdb = &sd->desc; belugas@8686: int32 oldvalue = value; belugas@8686: belugas@8686: switch (sdb->cmd) { belugas@8686: case SDT_BOOLX: value ^= 1; break; belugas@8686: case SDT_NUMX: { belugas@8686: /* Add a dynamic step-size to the scroller. In a maximum of belugas@8686: * 50-steps you should be able to get from min to max, belugas@8686: * unless specified otherwise in the 'interval' variable belugas@8686: * of the current patch. */ belugas@8686: uint32 step = (sdb->interval == 0) ? ((sdb->max - sdb->min) / 50) : sdb->interval; belugas@8686: if (step == 0) step = 1; belugas@8686: belugas@8686: // don't allow too fast scrolling belugas@8686: if ((w->flags4 & WF_TIMEOUT_MASK) > 2 << WF_TIMEOUT_SHL) { belugas@8686: _left_button_clicked = false; belugas@8686: return; belugas@8686: } belugas@8686: belugas@8686: /* Increase or decrease the value and clamp it to extremes */ belugas@8686: if (x >= 10) { belugas@8686: value += step; belugas@8686: if (value > sdb->max) value = sdb->max; belugas@8686: } else { belugas@8686: value -= step; belugas@8686: if (value < sdb->min) value = (sdb->flags & SGF_0ISDISABLED) ? 0 : sdb->min; belugas@8686: } belugas@8686: belugas@8686: /* Set up scroller timeout for numeric values */ belugas@8686: if (value != oldvalue && !(sd->desc.flags & SGF_MULTISTRING)) { belugas@8686: WP(w, def_d).data_2 = btn * 2 + 1 + ((x >= 10) ? 1 : 0); belugas@8686: w->flags4 |= 5 << WF_TIMEOUT_SHL; belugas@8686: _left_button_clicked = false; belugas@8686: } belugas@8686: } break; belugas@8686: default: NOT_REACHED(); belugas@8686: } belugas@8686: belugas@8686: if (value != oldvalue) { belugas@8686: SetPatchValue(page->entries[btn].index, patches_ptr, value); belugas@8686: SetWindowDirty(w); belugas@8686: } belugas@8686: } else { belugas@8686: /* only open editbox for types that its sensible for */ belugas@8686: if (sd->desc.cmd != SDT_BOOLX && !(sd->desc.flags & SGF_MULTISTRING)) { belugas@8686: /* Show the correct currency-translated value */ belugas@8686: if (sd->desc.flags & SGF_CURRENCY) value *= _currency->rate; belugas@8686: belugas@8686: WP(w, def_d).data_3 = btn; belugas@8686: SetDParam(0, value); belugas@8686: ShowQueryString(STR_CONFIG_PATCHES_INT32, STR_CONFIG_PATCHES_QUERY_CAPT, 10, 100, w, CS_NUMERAL); belugas@8686: } belugas@8686: } belugas@8686: } break; belugas@8686: belugas@8686: case PATCHSEL_INTERFACE: case PATCHSEL_CONSTRUCTION: case PATCHSEL_VEHICLES: belugas@8686: case PATCHSEL_STATIONS: case PATCHSEL_ECONOMY: case PATCHSEL_COMPETITORS: belugas@8686: w->RaiseWidget(WP(w, def_d).data_1 + PATCHSEL_INTERFACE); belugas@8686: WP(w, def_d).data_1 = e->we.click.widget - PATCHSEL_INTERFACE; belugas@8686: w->LowerWidget(WP(w, def_d).data_1 + PATCHSEL_INTERFACE); belugas@8686: DeleteWindowById(WC_QUERY_STRING, 0); belugas@8686: SetWindowDirty(w); belugas@8686: break; belugas@8686: } belugas@8686: break; belugas@8686: belugas@8686: case WE_TIMEOUT: belugas@8686: WP(w, def_d).data_2 = 0; truelight@0: SetWindowDirty(w); truelight@0: break; truelight@0: belugas@8686: case WE_ON_EDIT_TEXT: belugas@8686: if (e->we.edittext.str != NULL) { belugas@8686: const PatchEntry *pe = &_patches_page[WP(w, def_d).data_1].entries[WP(w,def_d).data_3]; belugas@8686: const SettingDesc *sd = pe->setting; belugas@8686: int32 value = atoi(e->we.edittext.str); Darkvater@3118: belugas@8686: /* Save the correct currency-translated value */ belugas@8686: if (sd->desc.flags & SGF_CURRENCY) value /= _currency->rate; truelight@0: belugas@8686: SetPatchValue(pe->index, patches_ptr, value); belugas@8686: SetWindowDirty(w); belugas@8686: } belugas@8686: break; belugas@8686: belugas@8686: case WE_DESTROY: belugas@8686: DeleteWindowById(WC_QUERY_STRING, 0); belugas@8686: break; truelight@0: } truelight@0: } truelight@0: truelight@0: static const Widget _patches_selection_widgets[] = { rubidium@4344: { WWT_CLOSEBOX, RESIZE_NONE, 10, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, rubidium@4344: { WWT_CAPTION, RESIZE_NONE, 10, 11, 369, 0, 13, STR_CONFIG_PATCHES_CAPTION, STR_018C_WINDOW_TITLE_DRAG_THIS}, rubidium@4344: { WWT_PANEL, RESIZE_NONE, 10, 0, 369, 14, 41, 0x0, STR_NULL}, peter1138@9089: { WWT_PANEL, RESIZE_NONE, 10, 0, 369, 42, 50, 0x0, STR_NULL}, truelight@0: rubidium@4344: { WWT_TEXTBTN, RESIZE_NONE, 3, 10, 96, 16, 27, STR_CONFIG_PATCHES_GUI, STR_NULL}, rubidium@4344: { WWT_TEXTBTN, RESIZE_NONE, 3, 97, 183, 16, 27, STR_CONFIG_PATCHES_CONSTRUCTION, STR_NULL}, rubidium@4344: { WWT_TEXTBTN, RESIZE_NONE, 3, 184, 270, 16, 27, STR_CONFIG_PATCHES_VEHICLES, STR_NULL}, rubidium@4344: { WWT_TEXTBTN, RESIZE_NONE, 3, 271, 357, 16, 27, STR_CONFIG_PATCHES_STATIONS, STR_NULL}, rubidium@4344: { WWT_TEXTBTN, RESIZE_NONE, 3, 10, 96, 28, 39, STR_CONFIG_PATCHES_ECONOMY, STR_NULL}, rubidium@4344: { WWT_TEXTBTN, RESIZE_NONE, 3, 97, 183, 28, 39, STR_CONFIG_PATCHES_AI, STR_NULL}, darkvater@176: { WIDGETS_END}, truelight@0: }; truelight@0: truelight@0: static const WindowDesc _patches_selection_desc = { peter1138@9089: WDP_CENTER, WDP_CENTER, 370, 51, 370, 51, rubidium@6144: WC_GAME_OPTIONS, WC_NONE, truelight@0: WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET, truelight@0: _patches_selection_widgets, truelight@0: PatchesSelectionWndProc, truelight@0: }; truelight@0: rubidium@6573: void ShowPatchesSelection() truelight@0: { truelight@0: DeleteWindowById(WC_GAME_OPTIONS, 0); truelight@0: AllocateWindowDesc(&_patches_selection_desc); truelight@0: } dominik@478: dominik@478: miham@4211: /** miham@4211: * Draw [<][>] boxes. miham@4211: * @param x the x position to draw miham@4211: * @param y the y position to draw miham@4211: * @param ctab the color of the buttons miham@4211: * @param state 0 = none clicked, 1 = first clicked, 2 = second clicked miham@4211: * @param clickable_left is the left button clickable? miham@4211: * @param clickable_right is the right button clickable? miham@4211: */ miham@4211: void DrawArrowButtons(int x, int y, int ctab, byte state, bool clickable_left, bool clickable_right) dominik@759: { peter1138@5919: int color = (1 << PALETTE_MODIFIER_GREYOUT) | _colour_gradient[COLOUR_YELLOW][2]; Darkvater@3107: rubidium@5838: DrawFrameRect(x, y + 1, x + 9, y + 9, ctab, (state == 1) ? FR_LOWERED : FR_NONE); rubidium@5838: DrawFrameRect(x + 10, y + 1, x + 19, y + 9, ctab, (state == 2) ? FR_LOWERED : FR_NONE); belugas@8320: DrawStringCentered(x + 5, y + 1, STR_6819, TC_FROMSTRING); // [<] belugas@8320: DrawStringCentered(x + 15, y + 1, STR_681A, TC_FROMSTRING); // [>] miham@4211: miham@4211: /* Grey out the buttons that aren't clickable */ miham@4211: if (!clickable_left) miham@4211: GfxFillRect(x + 1, y + 1, x + 1 + 8, y + 8, color); miham@4211: if (!clickable_right) miham@4211: GfxFillRect(x + 11, y + 1, x + 11 + 8, y + 8, color); dominik@759: } dominik@759: belugas@8684: /** These are not, strickly speaking, widget enums, belugas@8684: * since they have been changed as line coordinates. belugas@8684: * So, rather, they are more like order of appearance */ belugas@8684: enum CustomCurrenciesWidgets { belugas@8684: CUSTCURR_EXCHANGERATE = 0, belugas@8684: CUSTCURR_SEPARATOR, belugas@8684: CUSTCURR_PREFIX, belugas@8684: CUSTCURR_SUFFIX, belugas@8684: CUSTCURR_TO_EURO, belugas@8684: }; belugas@8684: tron@2307: static char _str_separator[2]; dominik@759: dominik@759: static void CustCurrencyWndProc(Window *w, WindowEvent *e) dominik@759: { dominik@759: switch (e->event) { tron@4488: case WE_PAINT: { tron@4488: int x; tron@4488: int y = 20; rubidium@8578: int clk = WP(w, def_d).data_1; tron@4488: DrawWindowWidgets(w); dominik@759: belugas@8684: /* exchange rate */ tron@4488: DrawArrowButtons(10, y, 3, GB(clk, 0, 2), true, true); tron@4488: SetDParam(0, 1); tron@4488: SetDParam(1, 1); belugas@8320: DrawString(35, y + 1, STR_CURRENCY_EXCHANGE_RATE, TC_FROMSTRING); tron@4488: y += 12; dominik@759: belugas@8684: /* separator */ rubidium@5838: DrawFrameRect(10, y + 1, 29, y + 9, 0, GB(clk, 2, 2) ? FR_LOWERED : FR_NONE); belugas@8320: x = DrawString(35, y + 1, STR_CURRENCY_SEPARATOR, TC_FROMSTRING); belugas@8320: DoDrawString(_str_separator, x + 4, y + 1, TC_ORANGE); tron@4488: y += 12; tron@4488: belugas@8684: /* prefix */ rubidium@5838: DrawFrameRect(10, y + 1, 29, y + 9, 0, GB(clk, 4, 2) ? FR_LOWERED : FR_NONE); belugas@8320: x = DrawString(35, y + 1, STR_CURRENCY_PREFIX, TC_FROMSTRING); belugas@8320: DoDrawString(_custom_currency.prefix, x + 4, y + 1, TC_ORANGE); tron@4488: y += 12; tron@4488: belugas@8684: /* suffix */ rubidium@5838: DrawFrameRect(10, y + 1, 29, y + 9, 0, GB(clk, 6, 2) ? FR_LOWERED : FR_NONE); belugas@8320: x = DrawString(35, y + 1, STR_CURRENCY_SUFFIX, TC_FROMSTRING); belugas@8320: DoDrawString(_custom_currency.suffix, x + 4, y + 1, TC_ORANGE); tron@4488: y += 12; tron@4488: belugas@8684: /* switch to euro */ tron@4488: DrawArrowButtons(10, y, 3, GB(clk, 8, 2), true, true); tron@4488: SetDParam(0, _custom_currency.to_euro); belugas@8320: DrawString(35, y + 1, (_custom_currency.to_euro != CF_NOEURO) ? STR_CURRENCY_SWITCH_TO_EURO : STR_CURRENCY_SWITCH_TO_EURO_NEVER, TC_FROMSTRING); tron@4488: y += 12; tron@4488: belugas@8684: /* Preview */ tron@4488: y += 12; tron@4488: SetDParam(0, 10000); belugas@8320: DrawString(35, y + 1, STR_CURRENCY_PREVIEW, TC_FROMSTRING); belugas@8684: } break; truelight@812: tron@4488: case WE_CLICK: { belugas@4634: int line = (e->we.click.pt.y - 20) / 12; tron@4488: int len = 0; belugas@4634: int x = e->we.click.pt.x; tron@4488: StringID str = 0; tron@4488: CharSetFilter afilter = CS_ALPHANUMERAL; truelight@812: tron@4488: switch (line) { belugas@8684: case CUSTCURR_EXCHANGERATE: skidd13@8450: if (IsInsideMM(x, 10, 30)) { // clicked buttons tron@4488: if (x < 20) { tron@4488: if (_custom_currency.rate > 1) _custom_currency.rate--; rubidium@8578: WP(w, def_d).data_1 = 1 << (line * 2 + 0); tron@4488: } else { tron@4488: if (_custom_currency.rate < 5000) _custom_currency.rate++; rubidium@8578: WP(w, def_d).data_1 = 1 << (line * 2 + 1); tron@4488: } tron@4488: } else { // enter text tron@4488: SetDParam(0, _custom_currency.rate); tron@4488: str = STR_CONFIG_PATCHES_INT32; tron@4488: len = 4; tron@4488: afilter = CS_NUMERAL; tron@4488: } tron@2639: break; tron@2639: belugas@8684: case CUSTCURR_SEPARATOR: skidd13@8450: if (IsInsideMM(x, 10, 30)) { // clicked button rubidium@8578: WP(w, def_d).data_1 = 1 << (line * 2 + 1); tron@4488: } tron@4488: str = BindCString(_str_separator); tron@4488: len = 1; tron@2639: break; tron@2639: belugas@8684: case CUSTCURR_PREFIX: skidd13@8450: if (IsInsideMM(x, 10, 30)) { // clicked button rubidium@8578: WP(w, def_d).data_1 = 1 << (line * 2 + 1); tron@4488: } tron@4488: str = BindCString(_custom_currency.prefix); tron@4488: len = 12; tron@4488: break; tron@4488: belugas@8684: case CUSTCURR_SUFFIX: skidd13@8450: if (IsInsideMM(x, 10, 30)) { // clicked button rubidium@8578: WP(w, def_d).data_1 = 1 << (line * 2 + 1); tron@4488: } tron@4488: str = BindCString(_custom_currency.suffix); tron@4488: len = 12; tron@4488: break; tron@4488: belugas@8684: case CUSTCURR_TO_EURO: skidd13@8450: if (IsInsideMM(x, 10, 30)) { // clicked buttons tron@4488: if (x < 20) { tron@4488: _custom_currency.to_euro = (_custom_currency.to_euro <= 2000) ? tron@4488: CF_NOEURO : _custom_currency.to_euro - 1; rubidium@8578: WP(w, def_d).data_1 = 1 << (line * 2 + 0); tron@4488: } else { tron@4488: _custom_currency.to_euro = skidd13@8418: Clamp(_custom_currency.to_euro + 1, 2000, MAX_YEAR); rubidium@8578: WP(w, def_d).data_1 = 1 << (line * 2 + 1); tron@4488: } tron@4488: } else { // enter text tron@4488: SetDParam(0, _custom_currency.to_euro); tron@4488: str = STR_CONFIG_PATCHES_INT32; tron@4488: len = 4; tron@4488: afilter = CS_NUMERAL; tron@4488: } tron@2639: break; dominik@759: } dominik@759: tron@4488: if (len != 0) { Darkvater@5682: WP(w, def_d).data_2 = line; Darkvater@5682: ShowQueryString(str, STR_CURRENCY_CHANGE_PARAMETER, len + 1, 250, w, afilter); tron@4488: } dominik@759: tron@4488: w->flags4 |= 5 << WF_TIMEOUT_SHL; tron@4488: SetWindowDirty(w); belugas@8684: } break; tron@4488: tron@4488: case WE_ON_EDIT_TEXT: { belugas@8684: const char *b = e->we.edittext.str; tron@4488: belugas@8684: switch (WP(w, def_d).data_2) { belugas@8684: case CUSTCURR_EXCHANGERATE: belugas@8684: _custom_currency.rate = Clamp(atoi(b), 1, 5000); belugas@8684: break; tron@4488: belugas@8684: case CUSTCURR_SEPARATOR: /* Thousands seperator */ belugas@8684: _custom_currency.separator = (b[0] == '\0') ? ' ' : b[0]; belugas@8684: ttd_strlcpy(_str_separator, b, lengthof(_str_separator)); belugas@8684: break; tron@4488: belugas@8684: case CUSTCURR_PREFIX: belugas@8684: ttd_strlcpy(_custom_currency.prefix, b, lengthof(_custom_currency.prefix)); belugas@8684: break; belugas@8684: belugas@8684: case CUSTCURR_SUFFIX: belugas@8684: ttd_strlcpy(_custom_currency.suffix, b, lengthof(_custom_currency.suffix)); belugas@8684: break; belugas@8684: belugas@8684: case CUSTCURR_TO_EURO: { /* Year to switch to euro */ belugas@8684: int val = atoi(b); belugas@8684: belugas@8684: _custom_currency.to_euro = (val < 2000 ? CF_NOEURO : min(val, MAX_YEAR)); belugas@8684: break; tron@4488: } belugas@8684: } tron@4488: MarkWholeScreenDirty(); belugas@8684: } break; tron@4488: tron@4488: case WE_TIMEOUT: rubidium@8578: WP(w, def_d).data_1 = 0; tron@4488: SetWindowDirty(w); tron@4488: break; tron@4488: tron@4488: case WE_DESTROY: tron@4488: DeleteWindowById(WC_QUERY_STRING, 0); tron@4488: MarkWholeScreenDirty(); tron@4488: break; dominik@759: } dominik@759: } dominik@759: dominik@759: static const Widget _cust_currency_widgets[] = { rubidium@4344: { WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, rubidium@4344: { WWT_CAPTION, RESIZE_NONE, 14, 11, 229, 0, 13, STR_CURRENCY_WINDOW, STR_018C_WINDOW_TITLE_DRAG_THIS}, rubidium@4344: { WWT_PANEL, RESIZE_NONE, 14, 0, 229, 14, 119, 0x0, STR_NULL}, dominik@759: { WIDGETS_END}, dominik@759: }; dominik@759: dominik@759: static const WindowDesc _cust_currency_desc = { rubidium@7837: WDP_CENTER, WDP_CENTER, 230, 120, 230, 120, rubidium@6144: WC_CUSTOM_CURRENCY, WC_NONE, dominik@759: WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS, dominik@759: _cust_currency_widgets, dominik@759: CustCurrencyWndProc, dominik@759: }; dominik@759: rubidium@6573: static void ShowCustCurrency() dominik@759: { tron@2306: _str_separator[0] = _custom_currency.separator; Darkvater@1759: _str_separator[1] = '\0'; dominik@759: dominik@759: DeleteWindowById(WC_CUSTOM_CURRENCY, 0); tron@2639: AllocateWindowDesc(&_cust_currency_desc); dominik@759: }