Editor shapes: Update shape if value changed by script

directional-lights
Sven Eberhardt 2016-11-12 21:51:56 -05:00
parent 91af5a95be
commit 1621e984a9
2 changed files with 13 additions and 0 deletions

View File

@ -2713,6 +2713,7 @@ bool C4ConsoleQtPropListModel::AddPropertyGroup(C4PropList *add_proplist, int32_
C4PropertyDelegateFactory *factory = this->delegate_factory;
new_shape_delegate->ConnectSignals(shape, prop->shape_property_path);
prop->shape->Set(shape);
prop->shape->SetLastValue(v);
}
}
else
@ -2722,7 +2723,14 @@ bool C4ConsoleQtPropListModel::AddPropertyGroup(C4PropList *add_proplist, int32_
}
if (prop->shape)
{
// Mark this shape to be kept aftre update is complete
prop->shape->visit();
// Update shape by value if it was changed externally
if (!prop->shape->GetLastValue().IsIdenticalTo(v))
{
prop->shape->Get()->SetValue(v);
prop->shape->SetLastValue(v);
}
}
}
return true;

View File

@ -322,6 +322,7 @@ class C4ConsoleQtShapeHolder
{
C4ConsoleQtShape *shape;
bool last_visit;
C4Value last_value;
static bool last_visit_flag;
@ -337,6 +338,10 @@ public:
void visit() { last_visit = last_visit_flag; }
bool was_visited() const { return last_visit == last_visit_flag; }
static void begin_visit() { last_visit_flag = !last_visit_flag; }
// Remember pointer to last proplist or array set in value to reflect scripted updates
const C4Value &GetLastValue() const { return last_value; }
void SetLastValue(const C4Value &new_val) { last_value = new_val; }
};