ai_info.hpp
Go to the documentation of this file.00001
00002
00005 #ifndef AI_INFO
00006 #define AI_INFO
00007
00008 #include <list>
00009 #include "../core/smallmap_type.hpp"
00010 #include "api/ai_object.hpp"
00011
00012 enum AIConfigFlags {
00013 AICONFIG_NONE = 0x0,
00014 AICONFIG_RANDOM = 0x1,
00015 AICONFIG_BOOLEAN = 0x2,
00016 };
00017
00018 typedef SmallMap<int, char *> LabelMapping;
00019
00020 struct AIConfigItem {
00021 const char *name;
00022 const char *description;
00023 int min_value;
00024 int max_value;
00025 int custom_value;
00026 int easy_value;
00027 int medium_value;
00028 int hard_value;
00029 int random_deviation;
00030 int step_size;
00031 AIConfigFlags flags;
00032 LabelMapping *labels;
00033 };
00034
00035 extern AIConfigItem _start_date_config;
00036
00037 typedef std::list<AIConfigItem> AIConfigItemList;
00038
00039 class AIFileInfo : public AIObject {
00040 public:
00041 friend class AIInfo;
00042 friend class AILibrary;
00043
00044 AIFileInfo() : SQ_instance(NULL), main_script(NULL), author(NULL), name(NULL), short_name(NULL), description(NULL), date(NULL), instance_name(NULL) {};
00045 ~AIFileInfo();
00046
00050 const char *GetAuthor() const { return this->author; }
00051
00055 const char *GetName() const { return this->name; }
00056
00060 const char *GetShortName() const { return this->short_name; }
00061
00065 const char *GetDescription() const { return this->description; }
00066
00070 int GetVersion() const { return this->version; }
00071
00075 bool GetSettings();
00076
00080 const char *GetDate() const { return this->date; }
00081
00085 const char *GetInstanceName() const { return this->instance_name; }
00086
00090 const char *GetMainScript() const { return this->main_script; }
00091
00095 bool CheckMethod(const char *name) const;
00096
00100 static SQInteger Constructor(HSQUIRRELVM vm, AIFileInfo *info, bool library);
00101
00102 private:
00103 class Squirrel *engine;
00104 HSQOBJECT *SQ_instance;
00105 char *main_script;
00106 class AIScanner *base;
00107 const char *author;
00108 const char *name;
00109 const char *short_name;
00110 const char *description;
00111 const char *date;
00112 const char *instance_name;
00113 int version;
00114 };
00115
00116 class AIInfo : public AIFileInfo {
00117 public:
00118 static const char *GetClassName() { return "AIInfo"; }
00119
00120 ~AIInfo();
00121
00125 static SQInteger Constructor(HSQUIRRELVM vm);
00126 static SQInteger DummyConstructor(HSQUIRRELVM vm);
00127
00131 const AIConfigItemList *GetConfigList() const;
00132
00136 const AIConfigItem *GetConfigItem(const char *name) const;
00137
00141 bool CanLoadFromVersion(int version) const;
00142
00146 SQInteger AddSetting(HSQUIRRELVM vm);
00147
00151 SQInteger AddLabels(HSQUIRRELVM vm);
00152
00156 int GetSettingDefaultValue(const char *name) const;
00157
00158 private:
00159 AIConfigItemList config_list;
00160 int min_loadable_version;
00161 };
00162
00163 class AILibrary : public AIFileInfo {
00164 public:
00165 AILibrary() : AIFileInfo(), category(NULL) {};
00166 ~AILibrary();
00167
00171 static SQInteger Constructor(HSQUIRRELVM vm);
00172
00173 static SQInteger Import(HSQUIRRELVM vm);
00174
00178 const char *GetCategory() const { return this->category; }
00179
00180 private:
00181 const char *category;
00182 };
00183
00184 #endif