Added ChangeKeywordModeAction;

Hopefully fixed the 'Invalid multibyte character' build error on linux (I was using left/right-angle-brackets in string constants);
Fixed 'cost' keywords;


git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@263 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
twanvl
2007-04-18 18:02:09 +00:00
parent 37fe4c84ae
commit c8fc427da3
12 changed files with 116 additions and 32 deletions
+14
View File
@@ -190,3 +190,17 @@ void KeywordReminderTextValue::highlight(const String& code, const vector<Script
// set
value = new_value;
}
// ----------------------------------------------------------------------------- : Changing keywords : mode
ChangeKeywordModeAction::ChangeKeywordModeAction(Keyword& keyword, const String& new_mode)
: keyword(keyword), mode(new_mode)
{}
String ChangeKeywordModeAction::getName(bool to_undo) const {
return _("Keyword mode");
}
void ChangeKeywordModeAction::perform(bool to_undo) {
swap(keyword.mode, mode);
}
+8
View File
@@ -99,7 +99,15 @@ class KeywordReminderTextValue : public KeywordTextValue {
/// Changing the mode of a keyword
class ChangeKeywordModeAction : public Action {
public:
ChangeKeywordModeAction(Keyword& keyword, const String& new_mode);
virtual String getName(bool to_undo) const;
virtual void perform(bool to_undo);
//private:
Keyword& keyword;
String mode;
};
// ----------------------------------------------------------------------------- : EOF
+21
View File
@@ -13,6 +13,7 @@ class KeywordTrie;
DECLARE_TYPEOF(map<Char COMMA KeywordTrie*>);
DECLARE_TYPEOF_COLLECTION(KeywordTrie*);
DECLARE_TYPEOF_COLLECTION(KeywordP);
DECLARE_TYPEOF_COLLECTION(KeywordModeP);
DECLARE_TYPEOF_COLLECTION(KeywordParamP);
DECLARE_TYPEOF_COLLECTION(const Keyword*);
@@ -66,6 +67,23 @@ IMPLEMENT_REFLECTION(Keyword) {
}
size_t Keyword::findMode(const vector<KeywordModeP>& modes) const {
// find
size_t id = 0;
FOR_EACH_CONST(m, modes) {
if (mode == m->name) return id;
++id;
}
// default
id = 0;
FOR_EACH_CONST(m, modes) {
if (m->is_default) return id;
++id;
}
// not found
return 0;
}
// ----------------------------------------------------------------------------- : Regex stuff
/// Make sure the given regex does no capturing
@@ -291,6 +309,7 @@ String KeywordDatabase::expand(const String& text,
s = remove_tag_contents(s, _("<atom-keyword>")); // OLD, TODO: REMOVEME
s = remove_tag_contents(s, _("<atom-kwpph>"));
s = remove_tag(s, _("<keyword-param"));
s = remove_tag(s, _("<param-"));
String untagged = untag_no_escape(s);
if (!root) return s;
@@ -386,6 +405,8 @@ String KeywordDatabase::expand(const String& text,
ctx.setVariable(_("input"), to_script(part));
param = kwp.script.invoke(ctx)->toString();
}
part = _("<param-") + kwp.name + _(">") + part + _("</param-") + kwp.name + _(">");
param = _("<param-") + kwp.name + _(">") + param + _("</param-") + kwp.name + _(">");
ctx.setVariable(String(_("param")) << (int)(j/2), to_script(param));
}
total += part;
+4
View File
@@ -70,6 +70,10 @@ class Keyword {
wxRegEx matchRe;
bool fixed; ///< Is this keyword uneditable? (true for game keywods, false for set keywords)
/// Find the index of the mode in a list of possibilities.
/** Returns the default if not found and 0 if there is no default */
size_t findMode(const vector<KeywordModeP>& modes) const;
/// Prepare the expansion: (re)generate matchRe and the list of parameters.
/** Throws when there is an error in the input
* @param param_types A list of all parameter types.