summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/fios_gui.cpp4
-rw-r--r--src/settings.cpp27
-rw-r--r--src/settings_type.h12
-rw-r--r--src/table/settings.h5
-rw-r--r--src/toolbar_gui.cpp2
5 files changed, 32 insertions, 18 deletions
diff --git a/src/fios_gui.cpp b/src/fios_gui.cpp
index 7e7dd2543..b0b8d8657 100644
--- a/src/fios_gui.cpp
+++ b/src/fios_gui.cpp
@@ -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());
}
diff --git a/src/settings.cpp b/src/settings.cpp
index f4a166da5..7354534b4 100644
--- a/src/settings.cpp
+++ b/src/settings.cpp
@@ -702,18 +702,6 @@ static bool RedrawScreen(int32 p1)
}
/**
- * 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.
* @return Always true.
@@ -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);
diff --git a/src/settings_type.h b/src/settings_type.h
index 8e1b1bc9e..a433fd3fa 100644
--- a/src/settings_type.h
+++ b/src/settings_type.h
@@ -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. */
diff --git a/src/table/settings.h b/src/table/settings.h
index ed47cdffa..d27f509ac 100644
--- a/src/table/settings.h
+++ b/src/table/settings.h
@@ -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),
diff --git a/src/toolbar_gui.cpp b/src/toolbar_gui.cpp
index 6047c6c42..b703f6790 100644
--- a/src/toolbar_gui.cpp
+++ b/src/toolbar_gui.cpp
@@ -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;