mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-11 13:17:00 -04:00
Added position_hint to statistics categories, for customizable ordering of the items in the statistics panel
git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@452 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
@@ -17,15 +17,17 @@ DECLARE_TYPEOF_COLLECTION(ChoiceField::ChoiceP);
|
|||||||
// ----------------------------------------------------------------------------- : Statistics dimension
|
// ----------------------------------------------------------------------------- : Statistics dimension
|
||||||
|
|
||||||
StatsDimension::StatsDimension()
|
StatsDimension::StatsDimension()
|
||||||
: automatic (false)
|
: automatic (false)
|
||||||
, numeric (false)
|
, position_hint(0)
|
||||||
, show_empty(false)
|
, numeric (false)
|
||||||
|
, show_empty (false)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
StatsDimension::StatsDimension(const Field& field)
|
StatsDimension::StatsDimension(const Field& field)
|
||||||
: automatic (true)
|
: automatic (true)
|
||||||
, name (field.name)
|
, name (field.name)
|
||||||
, description (field.description)
|
, description (field.description)
|
||||||
|
, position_hint(0)
|
||||||
, icon_filename(field.icon_filename)
|
, icon_filename(field.icon_filename)
|
||||||
, numeric (false)
|
, numeric (false)
|
||||||
, show_empty (false)
|
, show_empty (false)
|
||||||
@@ -63,6 +65,7 @@ IMPLEMENT_REFLECTION_NO_GET_MEMBER(StatsDimension) {
|
|||||||
if (!automatic) {
|
if (!automatic) {
|
||||||
REFLECT(name);
|
REFLECT(name);
|
||||||
REFLECT(description);
|
REFLECT(description);
|
||||||
|
REFLECT(position_hint);
|
||||||
REFLECT_N("icon", icon_filename);
|
REFLECT_N("icon", icon_filename);
|
||||||
REFLECT(script);
|
REFLECT(script);
|
||||||
REFLECT(numeric);
|
REFLECT(numeric);
|
||||||
@@ -76,6 +79,7 @@ IMPLEMENT_REFLECTION_NO_GET_MEMBER(StatsDimension) {
|
|||||||
|
|
||||||
StatsCategory::StatsCategory()
|
StatsCategory::StatsCategory()
|
||||||
: automatic(false)
|
: automatic(false)
|
||||||
|
, position_hint(0)
|
||||||
, type(GRAPH_TYPE_BAR)
|
, type(GRAPH_TYPE_BAR)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
@@ -83,6 +87,7 @@ StatsCategory::StatsCategory(const StatsDimensionP& dim)
|
|||||||
: automatic(true)
|
: automatic(true)
|
||||||
, name (dim->name)
|
, name (dim->name)
|
||||||
, description (dim->description)
|
, description (dim->description)
|
||||||
|
, position_hint(dim->position_hint)
|
||||||
, icon_filename(dim->icon_filename)
|
, icon_filename(dim->icon_filename)
|
||||||
, dimensions(1, dim)
|
, dimensions(1, dim)
|
||||||
, type(GRAPH_TYPE_BAR)
|
, type(GRAPH_TYPE_BAR)
|
||||||
@@ -92,6 +97,7 @@ IMPLEMENT_REFLECTION_NO_GET_MEMBER(StatsCategory) {
|
|||||||
if (!automatic) {
|
if (!automatic) {
|
||||||
REFLECT(name);
|
REFLECT(name);
|
||||||
REFLECT(description);
|
REFLECT(description);
|
||||||
|
REFLECT(position_hint);
|
||||||
REFLECT_N("icon", icon_filename);
|
REFLECT_N("icon", icon_filename);
|
||||||
REFLECT(type);
|
REFLECT(type);
|
||||||
REFLECT_N("dimensions", dimension_names);
|
REFLECT_N("dimensions", dimension_names);
|
||||||
|
|||||||
@@ -27,9 +27,10 @@ class StatsDimension : public IntrusivePtrBase<StatsDimension> {
|
|||||||
StatsDimension();
|
StatsDimension();
|
||||||
StatsDimension(const Field&);
|
StatsDimension(const Field&);
|
||||||
|
|
||||||
bool automatic; ///< Based on a card field?
|
const bool automatic; ///< Based on a card field?
|
||||||
String name; ///< Name of this dimension
|
String name; ///< Name of this dimension
|
||||||
String description; ///< Description, used in status bar
|
String description; ///< Description, used in status bar
|
||||||
|
int position_hint; ///< Hint for the ordering
|
||||||
String icon_filename; ///< Icon for lists
|
String icon_filename; ///< Icon for lists
|
||||||
OptionalScript script; ///< Script that determines the value(s)
|
OptionalScript script; ///< Script that determines the value(s)
|
||||||
bool numeric; ///< Are the values numeric? If so, they require special sorting
|
bool numeric; ///< Are the values numeric? If so, they require special sorting
|
||||||
@@ -49,9 +50,10 @@ class StatsCategory : public IntrusivePtrBase<StatsCategory> {
|
|||||||
StatsCategory();
|
StatsCategory();
|
||||||
StatsCategory(const StatsDimensionP&);
|
StatsCategory(const StatsDimensionP&);
|
||||||
|
|
||||||
bool automatic; ///< Automatically generated?
|
const bool automatic; ///< Automatically generated?
|
||||||
String name; ///< Name/label
|
String name; ///< Name/label
|
||||||
String description; ///< Description, used in status bar
|
String description; ///< Description, used in status bar
|
||||||
|
int position_hint; ///< Hint for the ordering
|
||||||
String icon_filename; ///< Icon for lists
|
String icon_filename; ///< Icon for lists
|
||||||
Bitmap icon; ///< The loaded icon (optional of course)
|
Bitmap icon; ///< The loaded icon (optional of course)
|
||||||
vector<String> dimension_names;///< Names of the dimensions to use
|
vector<String> dimension_names;///< Names of the dimensions to use
|
||||||
|
|||||||
@@ -39,30 +39,39 @@ class StatCategoryList : public GalleryList {
|
|||||||
|
|
||||||
/// The selected category
|
/// The selected category
|
||||||
inline StatsCategory& getSelection() {
|
inline StatsCategory& getSelection() {
|
||||||
return *game->statistics_categories.at(selection);
|
return *categories.at(selection);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual size_t itemCount() const;
|
virtual size_t itemCount() const;
|
||||||
virtual void drawItem(DC& dc, int x, int y, size_t item, bool selected);
|
virtual void drawItem(DC& dc, int x, int y, size_t item, bool selected);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
GameP game;
|
GameP game;
|
||||||
|
vector<StatsCategoryP> categories; ///< Categories, sorted by position_hint
|
||||||
|
};
|
||||||
|
|
||||||
|
struct ComparePositionHint{
|
||||||
|
inline bool operator () (const StatsCategoryP& a, const StatsCategoryP& b) {
|
||||||
|
return a->position_hint < b->position_hint;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
void StatCategoryList::show(const GameP& game) {
|
void StatCategoryList::show(const GameP& game) {
|
||||||
this->game = game;
|
this->game = game;
|
||||||
|
categories = game->statistics_categories;
|
||||||
|
stable_sort(categories.begin(), categories.end(), ComparePositionHint());
|
||||||
update();
|
update();
|
||||||
// select first item
|
// select first item
|
||||||
selection = itemCount() > 0 ? 0 : NO_SELECTION;
|
selection = itemCount() > 0 ? 0 : NO_SELECTION;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t StatCategoryList::itemCount() const {
|
size_t StatCategoryList::itemCount() const {
|
||||||
return game ? game->statistics_categories.size() : 0;
|
return categories.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
void StatCategoryList::drawItem(DC& dc, int x, int y, size_t item, bool selected) {
|
void StatCategoryList::drawItem(DC& dc, int x, int y, size_t item, bool selected) {
|
||||||
StatsCategory& cat = *game->statistics_categories.at(item);
|
StatsCategory& cat = *categories.at(item);
|
||||||
// draw icon
|
// draw icon
|
||||||
if (!cat.icon_filename.empty() && !cat.icon.Ok()) {
|
if (!cat.icon_filename.empty() && !cat.icon.Ok()) {
|
||||||
InputStreamP file = game->openIn(cat.icon_filename);
|
InputStreamP file = game->openIn(cat.icon_filename);
|
||||||
|
|||||||
Reference in New Issue
Block a user