Mercurial > hg > openttd
changeset 8809:6f39a645401a draft
(svn r12550) -Change: the signal GUI is now persistent - has the same data when it is reopened
author | smatz <smatz@openttd.org> |
---|---|
date | Thu, 03 Apr 2008 21:54:31 +0000 |
parents | 2d40645f197f |
children | f0164fff3eea |
files | src/date.cpp src/misc_gui.cpp src/openttd.cpp src/rail_gui.cpp src/rail_gui.h src/settings.cpp |
diffstat | 6 files changed, 46 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/src/date.cpp +++ b/src/date.cpp @@ -15,6 +15,7 @@ #include "date_func.h" #include "vehicle_base.h" #include "debug.h" +#include "rail_gui.h" #ifdef DEBUG_DUMP_COMMANDS #include "saveload.h" #endif @@ -282,6 +283,8 @@ ShipsYearlyLoop(); if (_network_server) NetworkServerYearlyLoop(); + if (_cur_year == _patches.semaphore_build_before) ResetSignalVariant(); + /* check if we reached end of the game */ if (_cur_year == _patches.ending_year) { ShowEndGameChart();
--- a/src/misc_gui.cpp +++ b/src/misc_gui.cpp @@ -41,6 +41,7 @@ #include "player_gui.h" #include "settings_type.h" #include "newgrf_cargo.h" +#include "rail_gui.h" #include "table/sprites.h" #include "table/strings.h" @@ -1833,6 +1834,7 @@ SetDate(ConvertYMDToDate(_cur_year + p2, ymd.month, ymd.day)); EnginesMonthlyLoop(); SetWindowDirty(FindWindowById(WC_STATUS_BAR, 0)); + ResetSignalVariant(); return _cur_year; }
--- a/src/openttd.cpp +++ b/src/openttd.cpp @@ -93,7 +93,7 @@ extern void SetDifficultyLevel(int mode, GameOptions *gm_opt); extern Player* DoStartupNewPlayer(bool is_ai); extern void ShowOSErrorBox(const char *buf); -extern void SetDefaultRailGui(); +extern void InitializeRailGUI(); /* TODO: usrerror() for errors which are not of an internal nature but * caused by the user, i.e. missing files or fatal configuration errors. @@ -702,7 +702,7 @@ DoCommandP(0, (_patches.autorenew << 15 ) | (_patches.autorenew_months << 16) | 4, _patches.autorenew_money, NULL, CMD_SET_AUTOREPLACE); SettingsDisableElrail(_patches.disable_elrails); - SetDefaultRailGui(); + InitializeRailGUI(); #ifdef ENABLE_NETWORK /* We are the server, we start a new player (not dedicated), @@ -1997,7 +1997,7 @@ if (CheckSavegameVersion(38)) _patches.disable_elrails = false; /* do the same as when elrails were enabled/disabled manually just now */ SettingsDisableElrail(_patches.disable_elrails); - SetDefaultRailGui(); + InitializeRailGUI(); /* From version 53, the map array was changed for house tiles to allow * space for newhouses grf features. A new byte, m7, was also added. */
--- a/src/rail_gui.cpp +++ b/src/rail_gui.cpp @@ -45,9 +45,9 @@ static DiagDirection _build_depot_direction; static byte _waypoint_count = 1; static byte _cur_waypoint_type; -static bool _convert_signal_button = false; ///< convert signal button in the signal GUI pressed -static SignalVariant _cur_signal_variant = SIG_ELECTRIC; ///< set the signal variant (for signal GUI) -static SignalType _cur_signal_type = SIGTYPE_NORMAL; ///< set the signal type (for signal GUI) +static bool _convert_signal_button; ///< convert signal button in the signal GUI pressed +static SignalVariant _cur_signal_variant; ///< set the signal variant (for signal GUI) +static SignalType _cur_signal_type; ///< set the signal type (for signal GUI) static struct { byte orientation; @@ -1385,14 +1385,9 @@ /** * Open the signal selection window - * @pre reset all signal GUI relevant variables */ static void ShowSignalBuilder() { - _convert_signal_button = false; - _cur_signal_variant = _cur_year < _patches.semaphore_build_before ? SIG_SEMAPHORE : SIG_ELECTRIC; - _cur_signal_type = SIGTYPE_NORMAL; - AllocateWindowDesc(&_signal_builder_desc); } @@ -1601,7 +1596,7 @@ MarkWholeScreenDirty(); } -void SetDefaultRailGui() +static void SetDefaultRailGui() { if (_local_player == PLAYER_SPECTATOR || !IsValidPlayer(_local_player)) return; @@ -1650,5 +1645,36 @@ } } +/** + * Updates the current signal variant used in the signal GUI + * to the one adequate to current year. + * @param 0 needed to be called when a patch setting changes + * @return success, needed for patch settings + */ +int32 ResetSignalVariant(int32 = 0) +{ + SignalVariant new_variant = (_cur_year < _patches.semaphore_build_before ? SIG_SEMAPHORE : SIG_ELECTRIC); + if (new_variant != _cur_signal_variant) { + Window *w = FindWindowById(WC_BUILD_SIGNAL, 0); + if (w != NULL) { + SetWindowDirty(w); + w->RaiseWidget((_cur_signal_variant == SIG_ELECTRIC ? BSW_ELECTRIC_NORM : BSW_SEMAPHORE_NORM) + _cur_signal_type); + } + _cur_signal_variant = new_variant; + } + return 0; +} + +/** Resets the rail GUI - sets default railtype to build + * and resets the signal GUI + */ +void InitializeRailGUI() +{ + SetDefaultRailGui(); + + _convert_signal_button = false; + _cur_signal_type = SIGTYPE_NORMAL; + ResetSignalVariant(); +}
--- a/src/rail_gui.h +++ b/src/rail_gui.h @@ -9,5 +9,6 @@ void ShowBuildRailToolbar(RailType railtype, int button); void ReinitGuiAfterToggleElrail(bool disable); +int32 ResetSignalVariant(int32 = 0); #endif /* RAIL_GUI_H */
--- a/src/settings.cpp +++ b/src/settings.cpp @@ -51,6 +51,7 @@ #include "transparency.h" #include "textbuf_gui.h" #include "string_func.h" +#include "rail_gui.h" #include "gui.h" #include "town.h" #include "video/video_driver.hpp" @@ -1404,7 +1405,7 @@ SDT_BOOL(Patches, always_small_airport, 0,NN, false, STR_CONFIG_PATCHES_SMALL_AIRPORTS, NULL), SDT_BOOL(Patches, enable_signal_gui, S, 0, false, STR_CONFIG_PATCHES_ENABLE_SIGNAL_GUI, NULL), SDT_VAR(Patches, drag_signals_density,SLE_UINT8,S, 0, 4, 1, 20, 0, STR_CONFIG_PATCHES_DRAG_SIGNALS_DENSITY,NULL), - SDT_VAR(Patches, semaphore_build_before,SLE_INT32, S, NC, 1975, MIN_YEAR, MAX_YEAR, 1, STR_CONFIG_PATCHES_SEMAPHORE_BUILD_BEFORE_DATE, NULL), + SDT_VAR(Patches, semaphore_build_before,SLE_INT32, S, NC, 1975, MIN_YEAR, MAX_YEAR, 1, STR_CONFIG_PATCHES_SEMAPHORE_BUILD_BEFORE_DATE, ResetSignalVariant), SDT_CONDVAR(Patches, town_layout, SLE_UINT8, 59, SL_MAX_VERSION, 0, MS, TL_ORIGINAL, TL_NO_ROADS, NUM_TLS - 1, 1, STR_CONFIG_PATCHES_TOWN_LAYOUT, CheckTownLayout), /***************************************************************************/