summaryrefslogtreecommitdiff
path: root/src/script
diff options
context:
space:
mode:
authortruebrain <truebrain@openttd.org>2011-12-19 20:57:08 +0000
committertruebrain <truebrain@openttd.org>2011-12-19 20:57:08 +0000
commit1616961ea2c1fa84c41d7df9af535fbb190d2c41 (patch)
tree4ff03a081e56d7f81491dfb06d1d2257a87bcb82 /src/script
parent963802e9a7cb67f51cb7e6ffe9d33a02cfe93821 (diff)
downloadopenttd-1616961ea2c1fa84c41d7df9af535fbb190d2c41.tar.xz
(svn r23613) -Add: allow IsDeveloperOnly in info.nut, to indicate if you can select this GS via the GUI (optional, defaults to false)
Diffstat (limited to 'src/script')
-rw-r--r--src/script/api/script_info_docs.hpp13
-rw-r--r--src/script/script_info.hpp4
-rw-r--r--src/script/script_scanner.cpp15
3 files changed, 26 insertions, 6 deletions
diff --git a/src/script/api/script_info_docs.hpp b/src/script/api/script_info_docs.hpp
index 10d2f09f7..dd7673294 100644
--- a/src/script/api/script_info_docs.hpp
+++ b/src/script/api/script_info_docs.hpp
@@ -130,6 +130,19 @@ public:
bool UseAsRandomAI();
/**
+ * Can a non-developer select Script for a new game.
+ *
+ * The idea behind this function is to 'forbid' using your script with a new
+ * game if you for example specificly wrote it for a certain scenario.
+ *
+ * @return True if the Script can be selected from the GUI as non-developer.
+ * @note This function is optional. Default is false.
+ *
+ * @api -ai
+ */
+ bool IsDeveloperOnly();
+
+ /**
* Gets the name of main class of the Script so OpenTTD knows
* what class to instantiate.
*
diff --git a/src/script/script_info.hpp b/src/script/script_info.hpp
index 4e59c7d72..4ed160726 100644
--- a/src/script/script_info.hpp
+++ b/src/script/script_info.hpp
@@ -142,6 +142,10 @@ public:
*/
int GetSettingDefaultValue(const char *name) const;
+ /**
+ * Can this script be selected by developers only?
+ */
+ virtual bool IsDeveloperOnly() const { return false; }
protected:
class Squirrel *engine; ///< Engine used to register for Squirrel.
diff --git a/src/script/script_scanner.cpp b/src/script/script_scanner.cpp
index 0f572a7c0..233bf09cc 100644
--- a/src/script/script_scanner.cpp
+++ b/src/script/script_scanner.cpp
@@ -13,6 +13,7 @@
#include "../debug.h"
#include "../string_func.h"
#include "../fileio_func.h"
+#include "../settings_type.h"
#include <sys/stat.h>
#include "../script/squirrel.hpp"
@@ -144,12 +145,14 @@ void ScriptScanner::RegisterScript(ScriptInfo *info)
this->info_list[strdup(script_name)] = info;
- /* Add the script to the 'unique' script list, where only the highest version
- * of the script is registered. */
- if (this->info_single_list.find(script_original_name) == this->info_single_list.end()) {
- this->info_single_list[strdup(script_original_name)] = info;
- } else if (this->info_single_list[script_original_name]->GetVersion() < info->GetVersion()) {
- this->info_single_list[script_original_name] = info;
+ if (!info->IsDeveloperOnly() || _settings_client.gui.ai_developer_tools) {
+ /* Add the script to the 'unique' script list, where only the highest version
+ * of the script is registered. */
+ if (this->info_single_list.find(script_original_name) == this->info_single_list.end()) {
+ this->info_single_list[strdup(script_original_name)] = info;
+ } else if (this->info_single_list[script_original_name]->GetVersion() < info->GetVersion()) {
+ this->info_single_list[script_original_name] = info;
+ }
}
}