mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-10 13:06:59 -04:00
events on script update; fix in cycle_sort; card list updated on value action
git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@136 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
@@ -225,7 +225,7 @@ String spec_sort(const String& spec, const String& input) {
|
||||
} else if (c == _('(')) { // in a cycle
|
||||
size_t end = spec.find_first_of(_(')'));
|
||||
if (end == String::npos) throw ParseError(_("Expected ')' in sort_rule specification"));
|
||||
ret += cycle_sort(spec.substr(pos, end - pos - 1), input);
|
||||
ret += cycle_sort(spec.substr(pos + 1, end - pos - 1), input);
|
||||
pos = end;
|
||||
|
||||
} else { // single char
|
||||
|
||||
@@ -98,9 +98,6 @@ void SetScriptManager::onInit(const StyleSheetP& stylesheet, Context* ctx) {
|
||||
// find script dependencies
|
||||
initDependencies(*ctx, *set.game);
|
||||
initDependencies(*ctx, *stylesheet);
|
||||
// apply scripts to everything
|
||||
// TODO : don't updateAll here, it will be done repeatedly
|
||||
updateAll();
|
||||
} catch (Error e) {
|
||||
handle_error(e, false, false);
|
||||
}
|
||||
@@ -142,6 +139,9 @@ void SetScriptManager::onAction(const Action& action, bool undone) {
|
||||
}
|
||||
updateValue(*action.valueP, CardP());
|
||||
}
|
||||
TYPE_CASE_(action, ScriptValueEvent) {
|
||||
return; // Don't go into an infinite loop because of our own events
|
||||
}
|
||||
TYPE_CASE_(action, CardListAction) {
|
||||
updateAllDependend(set.game->dependent_scripts_cards);
|
||||
}
|
||||
@@ -209,8 +209,8 @@ void SetScriptManager::updateToUpdate(const ToUpdate& u, deque<ToUpdate>& to_upd
|
||||
Context& ctx = getContext(u.card);
|
||||
if (u.value->update(ctx)) {
|
||||
// changed, send event
|
||||
// ScriptValueEvent change(&*u.card, u.value);
|
||||
// set.actions.tellListeners(change);
|
||||
ScriptValueEvent change(u.card.get(), u.value);
|
||||
set.actions.tellListeners(change, false);
|
||||
// u.value has changed, also update values with a dependency on u.value
|
||||
alsoUpdate(to_update, u.value->fieldP->dependent_scripts, u.card);
|
||||
}
|
||||
|
||||
@@ -61,6 +61,12 @@ class SetScriptManager : public SetScriptContext, public ActionListener {
|
||||
// Update all styles for a particular card
|
||||
void updateStyles(const CardP& card);
|
||||
|
||||
/// Update all fields of all cards
|
||||
/** Update all set info fields
|
||||
* Doesn't update styles
|
||||
*/
|
||||
void updateAll();
|
||||
|
||||
private:
|
||||
virtual void onInit(const StyleSheetP& stylesheet, Context* ctx);
|
||||
|
||||
@@ -70,11 +76,6 @@ class SetScriptManager : public SetScriptContext, public ActionListener {
|
||||
/// Updates scripts, starting at some value
|
||||
/** if the value changes any dependend values are updated as well */
|
||||
void updateValue(Value& value, const CardP& card);
|
||||
/// Update all fields of all cards
|
||||
/** Update all set info fields
|
||||
* Doesn't update styles
|
||||
*/
|
||||
void updateAll();
|
||||
// Update all values with a specific dependency
|
||||
void updateAllDependend(const vector<Dependency>& dependent_scripts);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user