made dependency analysis work without errors for magic-new (except for a few script functions); implemented the rest of the ScriptManager

git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@71 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
twanvl
2006-11-01 16:41:50 +00:00
parent 2dd93a91fb
commit f18bdafab1
17 changed files with 280 additions and 45 deletions
+31
View File
@@ -9,6 +9,8 @@
#include <data/field/choice.hpp>
DECLARE_TYPEOF_COLLECTION(ChoiceField::ChoiceP);
typedef map<String,ScriptableImage> map_String_ScriptableImage;
DECLARE_TYPEOF(map_String_ScriptableImage);
// ----------------------------------------------------------------------------- : ChoiceField
@@ -23,6 +25,12 @@ String ChoiceField::typeName() const {
return _("choice");
}
void ChoiceField::initDependencies(Context& ctx, const Dependency& dep) const {
Field ::initDependencies(ctx, dep);
script .initDependencies(ctx, dep);
default_script.initDependencies(ctx, dep);
}
IMPLEMENT_REFLECTION(ChoiceField) {
REFLECT_BASE(Field);
REFLECT_N("choices", choices->choices);
@@ -156,6 +164,24 @@ ChoiceStyle::ChoiceStyle(const ChoiceFieldP& field)
, colors_card_list(false)
{}
// TODO
/*
void ChoiceStyle::invalidate() {
// rebuild choice images
}
}
*/
bool ChoiceStyle::update(Context& ctx) {
// Don't update the choice images, leave that to invalidate()
return Style::update(ctx);
}
void ChoiceStyle::initDependencies(Context& ctx, const Dependency& dep) const {
Style::initDependencies(ctx, dep);
FOR_EACH_CONST(ci, choice_images) {
ci.second.initDependencies(ctx, dep);
}
}
IMPLEMENT_REFLECTION_ENUM(ChoicePopupStyle) {
VALUE_N("dropdown", POPUP_DROPDOWN);
VALUE_N("menu", POPUP_MENU);
@@ -190,6 +216,11 @@ IMPLEMENT_REFLECTION(ChoiceStyle) {
String ChoiceValue::toString() const {
return value();
}
bool ChoiceValue::update(Context& ctx) {
Value::update(ctx);
return field().default_script.invokeOnDefault(ctx, value)
| field(). script.invokeOn(ctx, value);
}
IMPLEMENT_REFLECTION_NAMELESS(ChoiceValue) {
REFLECT_NAMELESS(value);