mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-10 04:57:00 -04:00
Content dependent scripted images of (multiple) choice values are now updated correctly
git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@1064 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
@@ -234,6 +234,13 @@ void ChoiceStyle::initDependencies(Context& ctx, const Dependency& dep) const {
|
||||
ci.second.initDependencies(ctx, dep);
|
||||
}
|
||||
}
|
||||
void ChoiceStyle::checkContentDependencies(Context& ctx, const Dependency& dep) const {
|
||||
Style::checkContentDependencies(ctx, dep);
|
||||
image.initDependencies(ctx, dep);
|
||||
FOR_EACH_CONST(ci, choice_images) {
|
||||
ci.second.initDependencies(ctx, dep);
|
||||
}
|
||||
}
|
||||
void ChoiceStyle::invalidate() {
|
||||
// TODO : this is also done in update(), once should be enough
|
||||
// Update choice images and thumbnails
|
||||
|
||||
@@ -162,6 +162,7 @@ class ChoiceStyle : public Style {
|
||||
|
||||
virtual int update(Context&);
|
||||
virtual void initDependencies(Context&, const Dependency&) const;
|
||||
virtual void checkContentDependencies(Context&, const Dependency&) const;
|
||||
virtual void invalidate();
|
||||
};
|
||||
|
||||
|
||||
@@ -59,6 +59,12 @@ void draw_choice_viewer(RotatedDC& dc, ValueViewer& viewer, ChoiceStyle& style,
|
||||
if (style.render_style & RENDER_IMAGE) {
|
||||
// draw image
|
||||
CachedScriptableImage& img = style.image;
|
||||
if (style.content_dependent) {
|
||||
// re run script
|
||||
Context& ctx = viewer.viewer.getContext();
|
||||
ctx.setVariable(SCRIPT_VAR_input, to_script(value));
|
||||
img.update(ctx);
|
||||
}
|
||||
if (img.isReady()) {
|
||||
GeneratedImage::Options img_options;
|
||||
get_options(dc, viewer, style, img_options);
|
||||
|
||||
@@ -82,3 +82,8 @@ void MultipleChoiceValueViewer::drawChoice(RotatedDC& dc, RealPoint& pos, const
|
||||
// next position
|
||||
pos = move_in_direction(style().direction, pos, size, style().spacing);
|
||||
}
|
||||
|
||||
void MultipleChoiceValueViewer::onStyleChange(int changes) {
|
||||
if (changes & CHANGE_MASK) style().image.clearCache();
|
||||
ValueViewer::onStyleChange(changes);
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ class MultipleChoiceValueViewer : public ValueViewer {
|
||||
|
||||
virtual bool prepare(RotatedDC& dc);
|
||||
virtual void draw(RotatedDC& dc);
|
||||
virtual void onStyleChange(int);
|
||||
protected:
|
||||
double item_height; ///< Height of a single item, or 0 if non uniform
|
||||
private:
|
||||
|
||||
Reference in New Issue
Block a user