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:
twanvl
2007-02-07 16:17:15 +00:00
parent 504269e903
commit b93e5b2ae3
19 changed files with 109 additions and 33 deletions
+10
View File
@@ -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
}
+16
View File
@@ -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
View File
@@ -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
+3
View File
@@ -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();
+14 -6
View File
@@ -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;
+2
View File
@@ -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();
+2 -2
View File
@@ -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) {