2009-01-12 17:11:45 +00:00
|
|
|
/* $Id$ */
|
|
|
|
|
|
|
|
/** @file ai_info.hpp AIInfo keeps track of all information of an AI, like Author, Description, ... */
|
|
|
|
|
|
|
|
#ifndef AI_INFO
|
|
|
|
#define AI_INFO
|
|
|
|
|
|
|
|
#include <list>
|
2009-02-06 00:25:37 +00:00
|
|
|
#include "../core/smallmap_type.hpp"
|
2009-01-12 17:11:45 +00:00
|
|
|
#include "api/ai_object.hpp"
|
|
|
|
|
|
|
|
enum AIConfigFlags {
|
|
|
|
AICONFIG_NONE = 0x0,
|
|
|
|
AICONFIG_RANDOM = 0x1, //!< When randomizing the AI, pick any value between min_value and max_value when on custom difficulty setting.
|
|
|
|
AICONFIG_BOOLEAN = 0x2, //!< This value is a boolean (either 0 (false) or 1 (true) ).
|
|
|
|
};
|
|
|
|
|
2009-02-06 00:25:37 +00:00
|
|
|
typedef SmallMap<int, char *> LabelMapping;
|
|
|
|
|
2009-01-12 17:11:45 +00:00
|
|
|
struct AIConfigItem {
|
|
|
|
const char *name; //!< The name of the configuration setting.
|
|
|
|
const char *description; //!< The description of the configuration setting.
|
|
|
|
int min_value; //!< The minimal value this configuration setting can have.
|
|
|
|
int max_value; //!< The maximal value this configuration setting can have.
|
|
|
|
int custom_value; //!< The default value on custom difficulty setting.
|
|
|
|
int easy_value; //!< The default value on easy difficulty setting.
|
|
|
|
int medium_value; //!< The default value on medium difficulty setting.
|
|
|
|
int hard_value; //!< The default value on hard difficulty setting.
|
2009-01-13 16:53:03 +00:00
|
|
|
int random_deviation; //!< The maximum random deviation from the default value.
|
2009-01-13 18:26:58 +00:00
|
|
|
int step_size; //!< The step size in the gui.
|
2009-01-12 17:11:45 +00:00
|
|
|
AIConfigFlags flags; //!< Flags for the configuration setting.
|
2009-02-06 00:25:37 +00:00
|
|
|
LabelMapping *labels; //!< Text labels for the integer values.
|
2009-01-12 17:11:45 +00:00
|
|
|
};
|
|
|
|
|
2009-01-20 16:49:10 +00:00
|
|
|
extern AIConfigItem _start_date_config;
|
|
|
|
|
2009-01-12 17:11:45 +00:00
|
|
|
typedef std::list<AIConfigItem> AIConfigItemList;
|
|
|
|
|
|
|
|
class AIFileInfo : public AIObject {
|
|
|
|
public:
|
|
|
|
friend class AIInfo;
|
|
|
|
friend class AILibrary;
|
|
|
|
|
2009-01-23 15:38:13 +00:00
|
|
|
AIFileInfo() : SQ_instance(NULL), main_script(NULL), author(NULL), name(NULL), short_name(NULL), description(NULL), date(NULL), instance_name(NULL) {};
|
2009-01-12 17:11:45 +00:00
|
|
|
~AIFileInfo();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the Author of the AI.
|
|
|
|
*/
|
2009-02-13 02:11:54 +00:00
|
|
|
const char *GetAuthor() const { return this->author; }
|
2009-01-12 17:11:45 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the Name of the AI.
|
|
|
|
*/
|
2009-02-13 02:11:54 +00:00
|
|
|
const char *GetName() const { return this->name; }
|
2009-01-12 17:11:45 +00:00
|
|
|
|
2009-01-15 14:37:44 +00:00
|
|
|
/**
|
|
|
|
* Get the 4 character long short name of the AI.
|
|
|
|
*/
|
2009-02-13 02:11:54 +00:00
|
|
|
const char *GetShortName() const { return this->short_name; }
|
2009-01-15 14:37:44 +00:00
|
|
|
|
2009-01-12 17:11:45 +00:00
|
|
|
/**
|
|
|
|
* Get the description of the AI.
|
|
|
|
*/
|
2009-02-13 02:11:54 +00:00
|
|
|
const char *GetDescription() const { return this->description; }
|
2009-01-12 17:11:45 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the version of the AI.
|
|
|
|
*/
|
2009-02-13 02:11:54 +00:00
|
|
|
int GetVersion() const { return this->version; }
|
2009-01-12 17:11:45 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the settings of the AI.
|
|
|
|
*/
|
2009-02-13 17:17:34 +00:00
|
|
|
bool GetSettings();
|
2009-01-12 17:11:45 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the date of the AI.
|
|
|
|
*/
|
2009-02-13 02:11:54 +00:00
|
|
|
const char *GetDate() const { return this->date; }
|
2009-01-12 17:11:45 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the name of the instance of the AI to create.
|
|
|
|
*/
|
2009-02-13 02:11:54 +00:00
|
|
|
const char *GetInstanceName() const { return this->instance_name; }
|
2009-01-12 17:11:45 +00:00
|
|
|
|
|
|
|
/**
|
2009-01-15 18:15:12 +00:00
|
|
|
* Get the filename of the main.nut script.
|
2009-01-12 17:11:45 +00:00
|
|
|
*/
|
2009-02-13 02:11:54 +00:00
|
|
|
const char *GetMainScript() const { return this->main_script; }
|
2009-01-12 17:11:45 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Check if a given method exists.
|
|
|
|
*/
|
2009-02-13 02:11:54 +00:00
|
|
|
bool CheckMethod(const char *name) const;
|
2009-01-12 17:11:45 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Process the creation of a FileInfo object.
|
|
|
|
*/
|
2009-01-15 15:56:10 +00:00
|
|
|
static SQInteger Constructor(HSQUIRRELVM vm, AIFileInfo *info, bool library);
|
2009-01-12 17:11:45 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
class Squirrel *engine;
|
|
|
|
HSQOBJECT *SQ_instance;
|
2009-01-15 18:15:12 +00:00
|
|
|
char *main_script;
|
2009-01-12 17:11:45 +00:00
|
|
|
class AIScanner *base;
|
|
|
|
const char *author;
|
|
|
|
const char *name;
|
2009-01-15 14:37:44 +00:00
|
|
|
const char *short_name;
|
2009-01-12 17:11:45 +00:00
|
|
|
const char *description;
|
|
|
|
const char *date;
|
|
|
|
const char *instance_name;
|
2009-02-13 01:44:56 +00:00
|
|
|
int version;
|
2009-01-12 17:11:45 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class AIInfo : public AIFileInfo {
|
|
|
|
public:
|
|
|
|
static const char *GetClassName() { return "AIInfo"; }
|
|
|
|
|
|
|
|
~AIInfo();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create an AI, using this AIInfo as start-template.
|
|
|
|
*/
|
|
|
|
static SQInteger Constructor(HSQUIRRELVM vm);
|
|
|
|
static SQInteger DummyConstructor(HSQUIRRELVM vm);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the config list for this AI.
|
|
|
|
*/
|
2009-02-13 02:11:54 +00:00
|
|
|
const AIConfigItemList *GetConfigList() const;
|
2009-01-12 17:11:45 +00:00
|
|
|
|
2009-01-13 13:09:49 +00:00
|
|
|
/**
|
|
|
|
* Get the description of a certain ai config option.
|
|
|
|
*/
|
2009-02-13 02:11:54 +00:00
|
|
|
const AIConfigItem *GetConfigItem(const char *name) const;
|
2009-01-13 13:09:49 +00:00
|
|
|
|
2009-02-13 01:44:56 +00:00
|
|
|
/**
|
|
|
|
* Check if we can start this AI.
|
|
|
|
*/
|
2009-02-13 02:11:54 +00:00
|
|
|
bool CanLoadFromVersion(int version) const;
|
2009-02-13 01:44:56 +00:00
|
|
|
|
2009-01-12 17:11:45 +00:00
|
|
|
/**
|
|
|
|
* Set a setting.
|
|
|
|
*/
|
|
|
|
SQInteger AddSetting(HSQUIRRELVM vm);
|
|
|
|
|
2009-02-06 00:25:37 +00:00
|
|
|
/**
|
|
|
|
* Add labels for a setting.
|
|
|
|
*/
|
|
|
|
SQInteger AddLabels(HSQUIRRELVM vm);
|
|
|
|
|
2009-01-12 17:11:45 +00:00
|
|
|
/**
|
|
|
|
* Get the default value for a setting.
|
|
|
|
*/
|
2009-02-13 02:11:54 +00:00
|
|
|
int GetSettingDefaultValue(const char *name) const;
|
2009-01-12 17:11:45 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
AIConfigItemList config_list;
|
2009-02-13 01:44:56 +00:00
|
|
|
int min_loadable_version;
|
2009-01-12 17:11:45 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class AILibrary : public AIFileInfo {
|
|
|
|
public:
|
2009-01-15 15:56:10 +00:00
|
|
|
AILibrary() : AIFileInfo(), category(NULL) {};
|
2009-01-15 18:15:12 +00:00
|
|
|
~AILibrary();
|
2009-01-15 15:56:10 +00:00
|
|
|
|
2009-01-12 17:11:45 +00:00
|
|
|
/**
|
|
|
|
* Create an AI, using this AIInfo as start-template.
|
|
|
|
*/
|
|
|
|
static SQInteger Constructor(HSQUIRRELVM vm);
|
|
|
|
|
|
|
|
static SQInteger Import(HSQUIRRELVM vm);
|
2009-01-15 15:56:10 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the category this library is in.
|
|
|
|
*/
|
2009-02-13 02:11:54 +00:00
|
|
|
const char *GetCategory() const { return this->category; }
|
2009-01-15 15:56:10 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
const char *category;
|
2009-01-12 17:11:45 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* AI_INFO */
|