added 'string mode' to script parser; added Keyword and related classes

git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@85 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
twanvl
2006-11-21 14:35:14 +00:00
parent b6f1a9aac7
commit 7148d90bcb
14 changed files with 221 additions and 36 deletions
+4 -3
View File
@@ -8,6 +8,7 @@
#include <data/game.hpp>
#include <data/field.hpp>
#include <data/keyword.hpp>
#include <data/statistics.hpp>
#include <util/io/package_manager.hpp>
#include <script/script.hpp>
@@ -52,9 +53,9 @@ IMPLEMENT_REFLECTION(Game) {
REFLECT(card_fields);
REFLECT(statistics_dimensions);
REFLECT(statistics_categories);
// REFLECT_N("keyword parameter type", keyword_params);
// REFLECT_N("keyword separator type", keyword_separators);
// REFLECT(keywords);
REFLECT(keyword_parameter_types);
REFLECT(keyword_modes);
REFLECT(keywords);
// REFLECT(word_lists);
}
+7
View File
@@ -19,6 +19,9 @@ DECLARE_POINTER_TYPE(Field);
DECLARE_POINTER_TYPE(Game);
DECLARE_POINTER_TYPE(StatsDimension);
DECLARE_POINTER_TYPE(StatsCategory);
DECLARE_POINTER_TYPE(KeywordParam);
DECLARE_POINTER_TYPE(KeywordMode);
DECLARE_POINTER_TYPE(Keyword);
// ----------------------------------------------------------------------------- : Game
@@ -38,6 +41,10 @@ class Game : public Packaged {
vector<StatsDimensionP> statistics_dimensions; ///< (Additional) statistics dimensions
vector<StatsCategoryP> statistics_categories; ///< (Additional) statistics categories
vector<KeywordParamP> keyword_parameter_types;///< Types of keyword parameters
vector<KeywordModeP> keyword_modes; ///< Modes of keywords
vector<KeywordP> keywords; ///< Keywords for use in text
vector<Dependency> dependent_scripts_cards; ///< scripts that depend on the card list
vector<Dependency> dependent_scripts_keywords; ///< scripts that depend on the keywords
bool dependencies_initialized; ///< are the script dependencies comming from this game all initialized?
+35
View File
@@ -0,0 +1,35 @@
//+----------------------------------------------------------------------------+
//| Description: Magic Set Editor - Program to make Magic (tm) cards |
//| Copyright: (C) 2001 - 2006 Twan van Laarhoven |
//| License: GNU General Public License 2 or later (see file COPYING) |
//+----------------------------------------------------------------------------+
// ----------------------------------------------------------------------------- : Includes
#include <data/keyword.hpp>
// ----------------------------------------------------------------------------- : Reflection
IMPLEMENT_REFLECTION(KeywordParam) {
REFLECT(name);
REFLECT(description);
REFLECT(match);
REFLECT(in_reminder);
}
IMPLEMENT_REFLECTION(KeywordMode) {
REFLECT(name);
REFLECT(description);
}
IMPLEMENT_REFLECTION(KeywordExpansion) {
REFLECT(before);
REFLECT(after);
REFLECT(reminder);
}
IMPLEMENT_REFLECTION(Keyword) {
REFLECT(keyword);
REFLECT(expansions);
REFLECT(rules);
REFLECT(mode);
}
// ----------------------------------------------------------------------------- : Using keywords
+77
View File
@@ -0,0 +1,77 @@
//+----------------------------------------------------------------------------+
//| Description: Magic Set Editor - Program to make Magic (tm) cards |
//| Copyright: (C) 2001 - 2006 Twan van Laarhoven |
//| License: GNU General Public License 2 or later (see file COPYING) |
//+----------------------------------------------------------------------------+
#ifndef HEADER_DATA_KEYWORD
#define HEADER_DATA_KEYWORD
// ----------------------------------------------------------------------------- : Includes
#include <util/prec.hpp>
#include <script/scriptable.hpp>
#include <wx/regex.h>
DECLARE_POINTER_TYPE(KeywordParam);
DECLARE_POINTER_TYPE(KeywordExpansion);
DECLARE_POINTER_TYPE(KeywordMode);
// ----------------------------------------------------------------------------- : Keyword components
/// Parameter type of keywords
class KeywordParam {
public:
String name; ///< Name of the parameter type
String description; ///< Description of the type
String match; ///< Uncompiled regex
wxRegEx matchRe; ///< Regular expression to match
OptionalScript in_reminder; ///< Transformation of the value for showing in the reminder text
DECLARE_REFLECTION();
};
// ----------------------------------------------------------------------------- : Keyword mode
/// Information on when and how to use a keyword
class KeywordMode {
String name; ///< Name of the mode
String description; ///< Description of the type
DECLARE_REFLECTION();
};
// ----------------------------------------------------------------------------- : Keyword expansion
/// A way to use a keyword
class KeywordExpansion {
public:
String before; ///< Components before the keyword: parameters and separators (tagged string)
String after; ///< Components after the keyword: parameters and separators
vector<KeywordParamP> parameters; ///< The types of parameters
wxRegEx splitter; ///< Regular expression to split/match the components, automatically generated
OptionalScript reminder; ///< Reminder text of the keyword
DECLARE_REFLECTION();
};
// ----------------------------------------------------------------------------- : Keyword
/// A keyword for a set or a game
class Keyword {
public:
String keyword; ///< The keyword
vector<KeywordExpansionP> expansions; ///< Expansions, i.e. ways to use this keyword
String rules; ///< Rules/explanation
String mode; ///< Mode of use, can be used by scripts (only gives the name)
DECLARE_REFLECTION();
};
// ----------------------------------------------------------------------------- : Using keywords
/// Expand/update all keywords in the given string
String expand_keywords(const String& text);
// ----------------------------------------------------------------------------- : EOF
#endif
+2
View File
@@ -10,6 +10,7 @@
#include <data/game.hpp>
#include <data/stylesheet.hpp>
#include <data/card.hpp>
#include <data/keyword.hpp>
#include <data/field.hpp>
#include <data/field/text.hpp> // for 0.2.7 fix
#include <script/value.hpp>
@@ -116,6 +117,7 @@ IMPLEMENT_REFLECTION(Set) {
REFLECT_N("styling", styling_data);
}
REFLECT(cards);
REFLECT(keywords);
}
reflect_set_info_get_member(tag,data);
REFLECT(apprentice_code);
+7 -10
View File
@@ -22,6 +22,7 @@ DECLARE_POINTER_TYPE(StyleSheet);
DECLARE_POINTER_TYPE(Styling);
DECLARE_POINTER_TYPE(Field);
DECLARE_POINTER_TYPE(Value);
DECLARE_POINTER_TYPE(Keyword);
class ScriptManager;
class Context;
@@ -38,22 +39,18 @@ class Set : public Packaged {
Set(const StyleSheetP& stylesheet);
~Set();
/// The game this set uses
GameP game;
/// The default stylesheet
StyleSheetP stylesheet;
GameP game; ///< The game this set uses
StyleSheetP stylesheet; ///< The default stylesheet
/// The values on the fields of the set
/** The indices should correspond to the set_fields in the Game */
IndexMap<FieldP, ValueP> data;
/// Extra values for specitic stylesheets, indexed by stylesheet name
DECLARE_POINTER_TYPE(Styling);
map<String, StylingP> styling_data;
/// The cards in the set
vector<CardP> cards;
/// Code to use for apprentice (Magic only)
String apprentice_code;
/// Actions performed on this set and the cards in it
ActionStack actions;
vector<CardP> cards; ///< The cards in the set
vector<KeywordP> keywords; ///< Additional keywords used in this set
String apprentice_code; ///< Code to use for apprentice (Magic only)
ActionStack actions; ///< Actions performed on this set and the cards in it
/// A context for performing scripts
/** Should only be used from the main thread! */