changeset 14918:ec91e5febc5d draft

(svn r19515) -Add: Client setting 'gui.newgrf_developer_tools' to enable otherwise hidden features. -Add: Console command 'reload_newgrfs'; only available when newgrf developer tools are enabled.
author frosch <frosch@openttd.org>
date Wed, 24 Mar 2010 20:47:03 +0000
parents eea6004124b6
children 25ceff3979f1
files src/console_cmds.cpp src/settings_type.h src/table/settings.h
diffstat 3 files changed, 33 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/console_cmds.cpp
+++ b/src/console_cmds.cpp
@@ -34,6 +34,7 @@
 #include "gamelog.h"
 #include "ai/ai.hpp"
 #include "ai/ai_config.hpp"
+#include "newgrf.h"
 #include "console_func.h"
 
 #ifdef ENABLE_NETWORK
@@ -110,6 +111,22 @@
 #	define ConHookNoNetwork NULL
 #endif /* ENABLE_NETWORK */
 
+DEF_CONSOLE_HOOK(ConHookNewGRFDeveloperTool)
+{
+	if (_settings_client.gui.newgrf_developer_tools) {
+		if (_game_mode == GM_MENU) {
+			if (echo) IConsoleError("This command is only available in game and editor.");
+			return CHR_DISALLOW;
+		}
+#ifdef ENABLE_NETWORK
+		return ConHookNoNetwork(echo);
+#else
+		return CHR_ALLOW;
+#endif
+	}
+	return CHR_HIDE;
+}
+
 static void IConsoleHelp(const char *str)
 {
 	IConsolePrintF(CC_WARNING, "- %s", str);
@@ -1686,6 +1703,17 @@
 	return true;
 }
 
+DEF_CONSOLE_CMD(ConNewGRFReload)
+{
+	if (argc == 0) {
+		IConsoleHelp("Reloads all active NewGRFs from disk. Equivalent to reapplying NewGRFs via the settings, but without asking for confirmation. This might crash OpenTTD!");
+		return true;
+	}
+
+	ReloadNewGRFData();
+	return true;
+}
+
 #ifdef _DEBUG
 /******************
  *  debug commands
@@ -1826,4 +1854,7 @@
 #ifdef _DEBUG
 	IConsoleDebugLibRegister();
 #endif
+
+	/* NewGRF development stuff */
+	IConsoleCmdRegister("reload_newgrfs",  ConNewGRFReload, ConHookNewGRFDeveloperTool);
 }
--- a/src/settings_type.h
+++ b/src/settings_type.h
@@ -108,6 +108,7 @@
 
 	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
 };
 
 /** Settings related to currency/unit systems. */
--- a/src/table/settings.h
+++ b/src/table/settings.h
@@ -605,6 +605,7 @@
 	 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,                                       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),
 #ifdef ENABLE_NETWORK