From 1616961ea2c1fa84c41d7df9af535fbb190d2c41 Mon Sep 17 00:00:00 2001 From: truebrain Date: Mon, 19 Dec 2011 20:57:08 +0000 Subject: (svn r23613) -Add: allow IsDeveloperOnly in info.nut, to indicate if you can select this GS via the GUI (optional, defaults to false) --- src/game/game_info.cpp | 8 +++++++- src/game/game_info.hpp | 3 +++ 2 files changed, 10 insertions(+), 1 deletion(-) (limited to 'src/game') diff --git a/src/game/game_info.cpp b/src/game/game_info.cpp index 2d304bc94..ab4f4edc7 100644 --- a/src/game/game_info.cpp +++ b/src/game/game_info.cpp @@ -67,7 +67,12 @@ template <> const char *GetClassName() { return "GSInfo"; } } else { info->min_loadable_version = info->GetVersion(); } - + /* When there is an IsSelectable function, call it. */ + if (info->engine->MethodExists(*info->SQ_instance, "IsDeveloperOnly")) { + if (!info->engine->CallBoolMethod(*info->SQ_instance, "IsDeveloperOnly", &info->is_developer_only, MAX_GET_OPS)) return SQ_ERROR; + } else { + info->is_developer_only = false; + } /* Try to get the API version the AI is written for. */ if (!info->CheckMethod("GetAPIVersion")) return SQ_ERROR; if (!info->engine->CallStringMethodStrdup(*info->SQ_instance, "GetAPIVersion", &info->api_version, MAX_GET_OPS)) return SQ_ERROR; @@ -85,6 +90,7 @@ template <> const char *GetClassName() { return "GSInfo"; } GameInfo::GameInfo() : min_loadable_version(0), + is_developer_only(false), api_version(NULL) { } diff --git a/src/game/game_info.hpp b/src/game/game_info.hpp index 8fe588dd0..3d42d3379 100644 --- a/src/game/game_info.hpp +++ b/src/game/game_info.hpp @@ -41,8 +41,11 @@ public: */ const char *GetAPIVersion() const { return this->api_version; } + /* virtual */ bool IsDeveloperOnly() const { return this->is_developer_only; } + private: int min_loadable_version; ///< The Game can load savegame data if the version is equal or greater than this. + bool is_developer_only; ///< Is the script selectable by non-developers? const char *api_version; ///< API version used by this Game. }; -- cgit v1.2.3-54-g00ecf