(svn r21116) -Add [FS#3012]: Reduce the chances to accidentially break savegames with NewGRFs

pull/155/head
planetmaker 14 years ago
parent 09a1d006ba
commit 98de280343

@ -516,7 +516,7 @@ public:
break;
case SLWW_LOAD_BUTTON:
if (this->selected != NULL && !_load_check_data.HasErrors()) {
if (this->selected != NULL && !_load_check_data.HasErrors() && (_load_check_data.grf_compatibility != GLC_NOT_FOUND || _settings_client.gui.UserIsAllowedToChangeNewGRFs())) {
_switch_mode = (_game_mode == GM_EDITOR) ? SM_LOAD_SCENARIO : SM_LOAD;
const char *name = FiosBrowseTo(this->selected);
@ -665,7 +665,7 @@ public:
/* Selection changes */
if (_saveload_mode == SLD_LOAD_GAME || _saveload_mode == SLD_LOAD_SCENARIO) {
this->SetWidgetDisabledState(SLWW_LOAD_BUTTON,
this->selected == NULL || _load_check_data.HasErrors());
this->selected == NULL || _load_check_data.HasErrors() || !(_load_check_data.grf_compatibility != GLC_NOT_FOUND || _settings_client.gui.UserIsAllowedToChangeNewGRFs()));
this->SetWidgetDisabledState(SLWW_NEWGRF_INFO,
!_load_check_data.HasNewGrfs());
}

@ -701,18 +701,6 @@ static bool RedrawScreen(int32 p1)
return true;
}
/**
* Reinitalise all windows, i.e. construct their windows
* from the begin. For example to show a particular button
* that was previously hidden.
* @param p1 ignored
*/
static bool ReinitWindows(int32 p1)
{
ReInitAllWindows();
return true;
}
/**
* Redraw the smallmap after a colour scheme change.
* @param p1 Callback parameter.
@ -890,6 +878,21 @@ static bool InvalidateVehTimetableWindow(int32 p1)
return true;
}
/**
* Update any possible saveload window and delete any newgrf dialogue as
* its widget parts might change. Reinit all windows as it allows access to the
* newgrf debug button.
* @param p1 unused.
* @return Always true.
*/
static bool InvalidateNewGRFChangeWindows(int32 p1)
{
InvalidateWindowClassesData(WC_SAVELOAD);
DeleteWindowByClass(WC_GAME_OPTIONS);
ReInitAllWindows();
return true;
}
static bool InvalidateCompanyLiveryWindow(int32 p1)
{
InvalidateWindowClassesData(WC_COMPANY_COLOUR);

@ -109,9 +109,19 @@ struct GUISettings {
uint8 developer; ///< print non-fatal warnings in console (>= 1), copy debug output to console (== 2)
bool show_date_in_logs; ///< whether to show dates in console logs
bool newgrf_developer_tools; ///< activate NewGRF developer tools
bool newgrf_developer_tools; ///< activate NewGRF developer tools and allow modifying NewGRFs in an existing game
bool ai_developer_tools; ///< activate AI developer tools
bool scenario_developer; ///< activate scenario developer: allow modifying NewGRFs in an existing game
bool newgrf_show_old_versions; ///< whether to show old versions in the NewGRF list
/**
* Returns true when the user has sufficient privileges to edit newgrfs on a running game
* @return whether the user has sufficient privileges to edit newgrfs in an existing game
*/
bool UserIsAllowedToChangeNewGRFs() const
{
return this->scenario_developer || this->newgrf_developer_tools;
}
};
/** Settings related to currency/unit systems. */

@ -13,7 +13,6 @@
static bool v_PositionMainToolbar(int32 p1);
static bool PopulationInLabelActive(int32 p1);
static bool RedrawScreen(int32 p1);
static bool ReinitWindows(int32 p1);
static bool RedrawSmallmap(int32 p1);
static bool InvalidateDetailsWindow(int32 p1);
static bool InvalidateStationBuildWindow(int32 p1);
@ -40,6 +39,7 @@ static bool ChangeDynamicEngines(int32 p1);
static bool StationCatchmentChanged(int32 p1);
static bool InvalidateVehTimetableWindow(int32 p1);
static bool InvalidateCompanyLiveryWindow(int32 p1);
static bool InvalidateNewGRFChangeWindows(int32 p1);
static bool InvalidateIndustryViewWindow(int32 p1);
#ifdef ENABLE_NETWORK
@ -615,8 +615,9 @@ const SettingDesc _settings[] = {
SDTC_BOOL(gui.show_date_in_logs, S, 0, false, STR_NULL, NULL),
#endif
SDTC_VAR(gui.developer, SLE_UINT8, S, 0, 1, 0, 2, 0, STR_NULL, NULL),
SDTC_BOOL(gui.newgrf_developer_tools, S, 0, false, STR_NULL, ReinitWindows),
SDTC_BOOL(gui.newgrf_developer_tools, S, 0, false, STR_NULL, InvalidateNewGRFChangeWindows),
SDTC_BOOL(gui.ai_developer_tools, S, 0, false, STR_NULL, NULL),
SDTC_BOOL(gui.scenario_developer, S, 0, false, STR_NULL, InvalidateNewGRFChangeWindows),
SDTC_BOOL(gui.newgrf_show_old_versions, S, 0, false, STR_NULL, NULL),
SDTC_VAR(gui.console_backlog_timeout, SLE_UINT16, S, 0, 100, 10, 65500, 0, STR_NULL, NULL),
SDTC_VAR(gui.console_backlog_length, SLE_UINT16, S, 0, 100, 10, 65500, 0, STR_NULL, NULL),

@ -319,7 +319,7 @@ static void MenuClickSettings(int index)
case OME_GAMEOPTIONS: ShowGameOptions(); return;
case OME_DIFFICULTIES: ShowGameDifficulty(); return;
case OME_SETTINGS: ShowGameSettings(); return;
case OME_NEWGRFSETTINGS: ShowNewGRFSettings(!_networking, true, true, &_grfconfig); return;
case OME_NEWGRFSETTINGS: ShowNewGRFSettings(!_networking && _settings_client.gui.UserIsAllowedToChangeNewGRFs(), true, true, &_grfconfig); return;
case OME_TRANSPARENCIES: ShowTransparencyToolbar(); break;
case OME_SHOW_TOWNNAMES: ToggleBit(_display_opt, DO_SHOW_TOWN_NAMES); break;

Loading…
Cancel
Save