mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-11 13:17:00 -04:00
Reverted resource references for combine_something, you can't use tool_image here, because on MSW that only works for .bmps'
Added dependency stuff to invalidate Choice images; Fixed 'duplicate' in symbol editor git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@197 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
@@ -143,6 +143,7 @@ TextValueAction* typing_action(const TextValueP& value, size_t start, size_t end
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------- : Event
|
||||
|
||||
String ScriptValueEvent::getName(bool) const {
|
||||
@@ -152,3 +153,12 @@ String ScriptValueEvent::getName(bool) const {
|
||||
void ScriptValueEvent::perform(bool) {
|
||||
assert(false); // this action is just an event, it should not be performed
|
||||
}
|
||||
|
||||
|
||||
String ScriptStyleEvent::getName(bool) const {
|
||||
assert(false); // this action is just an event, getName shouldn't be called
|
||||
throw InternalError(_("ScriptStyleEvent::getName"));
|
||||
}
|
||||
void ScriptStyleEvent::perform(bool) {
|
||||
assert(false); // this action is just an event, it should not be performed
|
||||
}
|
||||
|
||||
@@ -19,7 +19,9 @@
|
||||
#include <util/defaultable.hpp>
|
||||
|
||||
class Card;
|
||||
class StyleSheet;
|
||||
DECLARE_POINTER_TYPE(Value);
|
||||
DECLARE_POINTER_TYPE(Style);
|
||||
DECLARE_POINTER_TYPE(TextValue);
|
||||
DECLARE_POINTER_TYPE(ChoiceValue);
|
||||
DECLARE_POINTER_TYPE(ColorValue);
|
||||
@@ -87,5 +89,19 @@ class ScriptValueEvent : public Action {
|
||||
const Value* value; ///< The modified value
|
||||
};
|
||||
|
||||
/// Notification that a script caused a style to change
|
||||
class ScriptStyleEvent : public Action {
|
||||
public:
|
||||
inline ScriptStyleEvent(const StyleSheet* stylesheet, const Style* style)
|
||||
: stylesheet(stylesheet), style(style)
|
||||
{}
|
||||
|
||||
virtual String getName(bool to_undo) const;
|
||||
virtual void perform(bool to_undo);
|
||||
|
||||
const StyleSheet* stylesheet; ///< StyleSheet the style is for
|
||||
const Style* style; ///< The modified style
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------- : EOF
|
||||
#endif
|
||||
|
||||
+5
-5
@@ -111,11 +111,11 @@ bool Style::update(Context& ctx) {
|
||||
}
|
||||
|
||||
void Style::initDependencies(Context& ctx, const Dependency& dep) const {
|
||||
left .initDependencies(ctx,dep);
|
||||
top .initDependencies(ctx,dep);
|
||||
width .initDependencies(ctx,dep);
|
||||
height .initDependencies(ctx,dep);
|
||||
visible.initDependencies(ctx,dep);
|
||||
/// left .initDependencies(ctx,dep);
|
||||
// top .initDependencies(ctx,dep);
|
||||
// width .initDependencies(ctx,dep);
|
||||
// height .initDependencies(ctx,dep);
|
||||
// visible.initDependencies(ctx,dep);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------- : Value
|
||||
|
||||
@@ -102,7 +102,10 @@ class Style {
|
||||
/// Update scripted values of this style, return true if anything has changed
|
||||
virtual bool update(Context&);
|
||||
/// Add the given dependency to the dependent_scripts list for the variables this style depends on
|
||||
/** Only use for things that need invalidate() */
|
||||
virtual void initDependencies(Context&, const Dependency&) const;
|
||||
/// Invalidate scripted images for this style
|
||||
virtual void invalidate() {}
|
||||
|
||||
private:
|
||||
DECLARE_REFLECTION_VIRTUAL();
|
||||
|
||||
@@ -167,19 +167,15 @@ ChoiceStyle::ChoiceStyle(const ChoiceFieldP& field)
|
||||
, combine(COMBINE_NORMAL)
|
||||
, alignment(ALIGN_STRETCH)
|
||||
, thumbnails(nullptr)
|
||||
, thumbnail_age(1) // thumbnails were made before the beginning of time
|
||||
, invalidated_images(false)
|
||||
{}
|
||||
|
||||
ChoiceStyle::~ChoiceStyle() {
|
||||
delete thumbnails;
|
||||
}
|
||||
|
||||
// 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);
|
||||
@@ -190,6 +186,18 @@ void ChoiceStyle::initDependencies(Context& ctx, const Dependency& dep) const {
|
||||
ci.second.initDependencies(ctx, dep);
|
||||
}
|
||||
}
|
||||
void ChoiceStyle::invalidate() {
|
||||
// rebuild choice images
|
||||
// TODO: Don't use this; rely on upToDate() instead
|
||||
FOR_EACH(ci, choice_images) {
|
||||
// TODO : only invalidate images that actually have dependencies
|
||||
ci.second.invalidate();
|
||||
}
|
||||
if (thumbnails) {
|
||||
thumbnails->RemoveAll();
|
||||
}
|
||||
invalidated_images = true;
|
||||
}
|
||||
|
||||
void ChoiceStyle::loadMask(Package& pkg) {
|
||||
if (mask.Ok() || mask_filename.empty()) return;
|
||||
|
||||
@@ -129,12 +129,14 @@ class ChoiceStyle : public Style {
|
||||
Image mask; ///< The actual mask image
|
||||
wxImageList* thumbnails; ///< Thumbnails for the choices
|
||||
Age thumbnail_age; ///< Age the thumbnails were generated
|
||||
bool invalidated_images; ///< Have the images been invalidated?
|
||||
|
||||
/// Load the mask image, if it's not already done
|
||||
void loadMask(Package& pkg);
|
||||
|
||||
virtual bool update(Context&);
|
||||
virtual void initDependencies(Context&, const Dependency&) const;
|
||||
virtual void invalidate();
|
||||
|
||||
private:
|
||||
DECLARE_REFLECTION();
|
||||
|
||||
@@ -62,8 +62,8 @@ bool TextStyle::update(Context& ctx) {
|
||||
}
|
||||
void TextStyle::initDependencies(Context& ctx, const Dependency& dep) const {
|
||||
Style ::initDependencies(ctx, dep);
|
||||
font .initDependencies(ctx, dep);
|
||||
symbol_font.initDependencies(ctx, dep);
|
||||
// font .initDependencies(ctx, dep);
|
||||
// symbol_font.initDependencies(ctx, dep);
|
||||
}
|
||||
|
||||
IMPLEMENT_REFLECTION(TextStyle) {
|
||||
|
||||
Reference in New Issue
Block a user