diff --git a/src/data/field/choice.cpp b/src/data/field/choice.cpp index 1104844f..5d052271 100644 --- a/src/data/field/choice.cpp +++ b/src/data/field/choice.cpp @@ -164,6 +164,7 @@ ChoiceStyle::ChoiceStyle(const ChoiceFieldP& field) : Style(field) , popup_style(POPUP_DROPDOWN) , render_style(RENDER_TEXT) + , choice_images_initialized(false) , combine(COMBINE_NORMAL) , alignment(ALIGN_STRETCH) , angle(0) @@ -179,10 +180,14 @@ bool ChoiceStyle::update(Context& ctx) { // Don't update the choice images, leave that to invalidate() bool change = Style ::update(ctx) | mask_filename.update(ctx); - FOR_EACH(ci, choice_images) { - if (ci.second.update(ctx)) { - change = true; - // TODO : remove this thumbnail + if (!choice_images_initialized) { + // we only want to do this once because it is rather slow, other updates are handled by dependencies + choice_images_initialized = true; + FOR_EACH(ci, choice_images) { + if (ci.second.update(ctx)) { + change = true; + // TODO : remove this thumbnail + } } } return change; diff --git a/src/data/field/choice.hpp b/src/data/field/choice.hpp index 6354eda2..3b8ec152 100644 --- a/src/data/field/choice.hpp +++ b/src/data/field/choice.hpp @@ -133,6 +133,7 @@ class ChoiceStyle : public Style { ChoiceRenderStyle render_style; ///< Style of rendering Font font; ///< Font for drawing text (when RENDER_TEXT) map choice_images; ///< Images for the various choices (when RENDER_IMAGE) + bool choice_images_initialized; Scriptable mask_filename; ///< Filename of an additional mask over the images ImageCombine combine; ///< Combining mode for drawing the images Alignment alignment; ///< Alignment of images diff --git a/src/data/graph_type.hpp b/src/data/graph_type.hpp new file mode 100644 index 00000000..5a4b7d21 --- /dev/null +++ b/src/data/graph_type.hpp @@ -0,0 +1,25 @@ +//+----------------------------------------------------------------------------+ +//| Description: Magic Set Editor - Program to make Magic (tm) cards | +//| Copyright: (C) 2001 - 2007 Twan van Laarhoven | +//| License: GNU General Public License 2 or later (see file COPYING) | +//+----------------------------------------------------------------------------+ + +#ifndef HEADER_DATA_GRAPH_TYPE +#define HEADER_DATA_GRAPH_TYPE + +// ----------------------------------------------------------------------------- : Includes + +#include + +// ----------------------------------------------------------------------------- : GraphType + +/// Types of graphs +enum GraphType +{ GRAPH_TYPE_BAR +, GRAPH_TYPE_PIE +, GRAPH_TYPE_STACK +, GRAPH_TYPE_SCATTER +}; + +// ----------------------------------------------------------------------------- : EOF +#endif diff --git a/src/data/statistics.cpp b/src/data/statistics.cpp index 43905185..7a894ca2 100644 --- a/src/data/statistics.cpp +++ b/src/data/statistics.cpp @@ -29,10 +29,14 @@ StatsDimension::StatsDimension(const Field& field) , numeric (false) , show_empty (false) { - // choice colors? + // choice field? const ChoiceField* choice_field = dynamic_cast(&field); if (choice_field) { colors = choice_field->choice_colors; + int count = choice_field->choices->lastId(); + for (int i = 0 ; i < count ; ++i) { + groups.push_back(choice_field->choices->choiceName(i)); + } } // initialize script, card.{field_name} Script& s = script.getScript(); @@ -50,6 +54,7 @@ IMPLEMENT_REFLECTION_NO_GET_MEMBER(StatsDimension) { REFLECT(numeric); REFLECT(show_empty); REFLECT(colors); + REFLECT(groups); } } @@ -69,13 +74,6 @@ StatsCategory::StatsCategory(const StatsDimensionP& dim) , type(GRAPH_TYPE_BAR) {} -IMPLEMENT_REFLECTION_ENUM(GraphType) { - VALUE_N("bar", GRAPH_TYPE_BAR); - VALUE_N("stack", GRAPH_TYPE_STACK); - VALUE_N("pie", GRAPH_TYPE_PIE); - VALUE_N("scatter", GRAPH_TYPE_SCATTER); -} - IMPLEMENT_REFLECTION_NO_GET_MEMBER(StatsCategory) { if (!automatic) { REFLECT(name); @@ -102,4 +100,13 @@ void StatsCategory::find_dimensions(const vector& available) { dimensions.push_back(dim); } } -} \ No newline at end of file +} + +// ----------------------------------------------------------------------------- : GraphType (from graph_type.hpp) + +IMPLEMENT_REFLECTION_ENUM(GraphType) { + VALUE_N("bar", GRAPH_TYPE_BAR); + VALUE_N("pie", GRAPH_TYPE_PIE); + VALUE_N("stack", GRAPH_TYPE_STACK); + VALUE_N("scatter", GRAPH_TYPE_SCATTER); +} diff --git a/src/data/statistics.hpp b/src/data/statistics.hpp index 5591f446..fba30c9d 100644 --- a/src/data/statistics.hpp +++ b/src/data/statistics.hpp @@ -11,6 +11,7 @@ #include #include +#include #include