1
0
Fork 0

(svn r12550) -Change: the signal GUI is now persistent - has the same data when it is reopened

release/0.7
smatz 2008-04-03 21:54:31 +00:00
parent 277df6d622
commit ff7e8fb2dd
6 changed files with 46 additions and 13 deletions

View File

@ -15,6 +15,7 @@
#include "date_func.h" #include "date_func.h"
#include "vehicle_base.h" #include "vehicle_base.h"
#include "debug.h" #include "debug.h"
#include "rail_gui.h"
#ifdef DEBUG_DUMP_COMMANDS #ifdef DEBUG_DUMP_COMMANDS
#include "saveload.h" #include "saveload.h"
#endif #endif
@ -282,6 +283,8 @@ void IncreaseDate()
ShipsYearlyLoop(); ShipsYearlyLoop();
if (_network_server) NetworkServerYearlyLoop(); if (_network_server) NetworkServerYearlyLoop();
if (_cur_year == _patches.semaphore_build_before) ResetSignalVariant();
/* check if we reached end of the game */ /* check if we reached end of the game */
if (_cur_year == _patches.ending_year) { if (_cur_year == _patches.ending_year) {
ShowEndGameChart(); ShowEndGameChart();

View File

@ -41,6 +41,7 @@
#include "player_gui.h" #include "player_gui.h"
#include "settings_type.h" #include "settings_type.h"
#include "newgrf_cargo.h" #include "newgrf_cargo.h"
#include "rail_gui.h"
#include "table/sprites.h" #include "table/sprites.h"
#include "table/strings.h" #include "table/strings.h"
@ -1833,6 +1834,7 @@ static int32 ClickChangeDateCheat(int32 p1, int32 p2)
SetDate(ConvertYMDToDate(_cur_year + p2, ymd.month, ymd.day)); SetDate(ConvertYMDToDate(_cur_year + p2, ymd.month, ymd.day));
EnginesMonthlyLoop(); EnginesMonthlyLoop();
SetWindowDirty(FindWindowById(WC_STATUS_BAR, 0)); SetWindowDirty(FindWindowById(WC_STATUS_BAR, 0));
ResetSignalVariant();
return _cur_year; return _cur_year;
} }

View File

@ -93,7 +93,7 @@ void ResetMusic();
extern void SetDifficultyLevel(int mode, GameOptions *gm_opt); extern void SetDifficultyLevel(int mode, GameOptions *gm_opt);
extern Player* DoStartupNewPlayer(bool is_ai); extern Player* DoStartupNewPlayer(bool is_ai);
extern void ShowOSErrorBox(const char *buf); extern void ShowOSErrorBox(const char *buf);
extern void SetDefaultRailGui(); extern void InitializeRailGUI();
/* TODO: usrerror() for errors which are not of an internal nature but /* TODO: usrerror() for errors which are not of an internal nature but
* caused by the user, i.e. missing files or fatal configuration errors. * caused by the user, i.e. missing files or fatal configuration errors.
@ -702,7 +702,7 @@ static void MakeNewGameDone()
DoCommandP(0, (_patches.autorenew << 15 ) | (_patches.autorenew_months << 16) | 4, _patches.autorenew_money, NULL, CMD_SET_AUTOREPLACE); DoCommandP(0, (_patches.autorenew << 15 ) | (_patches.autorenew_months << 16) | 4, _patches.autorenew_money, NULL, CMD_SET_AUTOREPLACE);
SettingsDisableElrail(_patches.disable_elrails); SettingsDisableElrail(_patches.disable_elrails);
SetDefaultRailGui(); InitializeRailGUI();
#ifdef ENABLE_NETWORK #ifdef ENABLE_NETWORK
/* We are the server, we start a new player (not dedicated), /* We are the server, we start a new player (not dedicated),
@ -1997,7 +1997,7 @@ bool AfterLoadGame()
if (CheckSavegameVersion(38)) _patches.disable_elrails = false; if (CheckSavegameVersion(38)) _patches.disable_elrails = false;
/* do the same as when elrails were enabled/disabled manually just now */ /* do the same as when elrails were enabled/disabled manually just now */
SettingsDisableElrail(_patches.disable_elrails); SettingsDisableElrail(_patches.disable_elrails);
SetDefaultRailGui(); InitializeRailGUI();
/* From version 53, the map array was changed for house tiles to allow /* 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. */ * space for newhouses grf features. A new byte, m7, was also added. */

View File

@ -45,9 +45,9 @@ static bool _remove_button_clicked;
static DiagDirection _build_depot_direction; static DiagDirection _build_depot_direction;
static byte _waypoint_count = 1; static byte _waypoint_count = 1;
static byte _cur_waypoint_type; static byte _cur_waypoint_type;
static bool _convert_signal_button = false; ///< convert signal button in the signal GUI pressed static bool _convert_signal_button; ///< convert signal button in the signal GUI pressed
static SignalVariant _cur_signal_variant = SIG_ELECTRIC; ///< set the signal variant (for signal GUI) static SignalVariant _cur_signal_variant; ///< set the signal variant (for signal GUI)
static SignalType _cur_signal_type = SIGTYPE_NORMAL; ///< set the signal type (for signal GUI) static SignalType _cur_signal_type; ///< set the signal type (for signal GUI)
static struct { static struct {
byte orientation; byte orientation;
@ -1385,14 +1385,9 @@ static const WindowDesc _signal_builder_desc = {
/** /**
* Open the signal selection window * Open the signal selection window
* @pre reset all signal GUI relevant variables
*/ */
static void ShowSignalBuilder() 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); AllocateWindowDesc(&_signal_builder_desc);
} }
@ -1601,7 +1596,7 @@ void ReinitGuiAfterToggleElrail(bool disable)
MarkWholeScreenDirty(); MarkWholeScreenDirty();
} }
void SetDefaultRailGui() static void SetDefaultRailGui()
{ {
if (_local_player == PLAYER_SPECTATOR || !IsValidPlayer(_local_player)) return; if (_local_player == PLAYER_SPECTATOR || !IsValidPlayer(_local_player)) return;
@ -1650,5 +1645,36 @@ void SetDefaultRailGui()
} }
} }
/**
* 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();
}

View File

@ -9,5 +9,6 @@
void ShowBuildRailToolbar(RailType railtype, int button); void ShowBuildRailToolbar(RailType railtype, int button);
void ReinitGuiAfterToggleElrail(bool disable); void ReinitGuiAfterToggleElrail(bool disable);
int32 ResetSignalVariant(int32 = 0);
#endif /* RAIL_GUI_H */ #endif /* RAIL_GUI_H */

View File

@ -51,6 +51,7 @@
#include "transparency.h" #include "transparency.h"
#include "textbuf_gui.h" #include "textbuf_gui.h"
#include "string_func.h" #include "string_func.h"
#include "rail_gui.h"
#include "gui.h" #include "gui.h"
#include "town.h" #include "town.h"
#include "video/video_driver.hpp" #include "video/video_driver.hpp"
@ -1404,7 +1405,7 @@ const SettingDesc _patch_settings[] = {
SDT_BOOL(Patches, always_small_airport, 0,NN, false, STR_CONFIG_PATCHES_SMALL_AIRPORTS, NULL), 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_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, 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), 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),
/***************************************************************************/ /***************************************************************************/