mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-10 13:06:59 -04:00
Scripts depending on content_something are re-updating after updating the content properties
git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@480 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
+27
-15
@@ -40,30 +40,23 @@ void DataViewer::draw(RotatedDC& dc, const Color& background) {
|
||||
// fill with background color
|
||||
clearDC(dc.getDC(), background);
|
||||
// update style scripts
|
||||
try {
|
||||
if (card) {
|
||||
set->updateStyles(card);
|
||||
} else {
|
||||
Context& ctx = getContext();
|
||||
FOR_EACH(v, viewers) {
|
||||
if (v->getStyle()->update(ctx)) {
|
||||
v->getStyle()->tellListeners();
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (const Error& e) {
|
||||
handle_error(e, false, false);
|
||||
}
|
||||
updateStyles(false);
|
||||
// prepare viewers
|
||||
bool changed_content_properties = false;
|
||||
FOR_EACH(v, viewers) { // draw low z index fields first
|
||||
if (v->getStyle()->visible) {
|
||||
try {
|
||||
v->prepare(dc);
|
||||
if (v->prepare(dc)) {
|
||||
changed_content_properties = true;
|
||||
}
|
||||
} catch (const Error& e) {
|
||||
handle_error(e, false, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (changed_content_properties) {
|
||||
updateStyles(true);
|
||||
}
|
||||
// draw viewers
|
||||
FOR_EACH(v, viewers) { // draw low z index fields first
|
||||
if (v->getStyle()->visible) {// visible
|
||||
@@ -80,6 +73,25 @@ void DataViewer::drawViewer(RotatedDC& dc, ValueViewer& v) {
|
||||
v.draw(dc);
|
||||
}
|
||||
|
||||
void DataViewer::updateStyles(bool only_content_dependent) {
|
||||
try {
|
||||
if (card) {
|
||||
set->updateStyles(card, only_content_dependent);
|
||||
} else {
|
||||
Context& ctx = getContext();
|
||||
FOR_EACH(v, viewers) {
|
||||
Style& s = *v->getStyle();
|
||||
if (only_content_dependent && !s.content_dependent) continue;
|
||||
if (s.update(ctx)) {
|
||||
s.tellListeners();
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (const Error& e) {
|
||||
handle_error(e, false, false);
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------- : Utility for ValueViewers
|
||||
|
||||
bool DataViewer::nativeLook() const { return false; }
|
||||
|
||||
Reference in New Issue
Block a user