mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-11 05:07:00 -04:00
Added Statistics dimension/categories
git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@84 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
@@ -42,6 +42,7 @@ IMPLEMENT_REFLECTION(Field) {
|
||||
REFLECT(name);
|
||||
if (tag.reading()) name = cannocial_name_form(name);
|
||||
REFLECT(description);
|
||||
REFLECT_N("icon", icon_filename);
|
||||
REFLECT(editable);
|
||||
REFLECT(save_value);
|
||||
REFLECT(show_statistics);
|
||||
|
||||
@@ -38,6 +38,7 @@ class Field {
|
||||
size_t index; ///< Used by IndexMap
|
||||
String name; ///< Name of the field, for refering to it from scripts and files
|
||||
String description; ///< Description, used in status bar
|
||||
String icon_filename; ///< Filename for an icon (for list of fields)
|
||||
bool editable; ///< Can values of this field be edited?
|
||||
bool save_value; ///< Should values of this field be written to files? Can be false for script generated fields.
|
||||
bool show_statistics; ///< Should this field appear as a group by choice in the statistics panel?
|
||||
|
||||
@@ -8,10 +8,14 @@
|
||||
|
||||
#include <data/game.hpp>
|
||||
#include <data/field.hpp>
|
||||
#include <data/statistics.hpp>
|
||||
#include <util/io/package_manager.hpp>
|
||||
#include <script/script.hpp>
|
||||
#include <script/value.hpp>
|
||||
|
||||
DECLARE_TYPEOF_COLLECTION(FieldP);
|
||||
DECLARE_TYPEOF_COLLECTION(StatsDimensionP);
|
||||
|
||||
// ----------------------------------------------------------------------------- : Game
|
||||
|
||||
IMPLEMENT_DYNAMIC_ARG(Game*, game_for_reading, nullptr);
|
||||
@@ -46,6 +50,8 @@ IMPLEMENT_REFLECTION(Game) {
|
||||
REFLECT(init_script);
|
||||
REFLECT(set_fields);
|
||||
REFLECT(card_fields);
|
||||
REFLECT(statistics_dimensions);
|
||||
REFLECT(statistics_categories);
|
||||
// REFLECT_N("keyword parameter type", keyword_params);
|
||||
// REFLECT_N("keyword separator type", keyword_separators);
|
||||
// REFLECT(keywords);
|
||||
@@ -55,8 +61,28 @@ IMPLEMENT_REFLECTION(Game) {
|
||||
void Game::validate(Version) {
|
||||
// a default for the full name
|
||||
if (full_name.empty()) full_name = name();
|
||||
// automatic statistics dimensions
|
||||
{
|
||||
vector<StatsDimensionP> dims;
|
||||
FOR_EACH(f, card_fields) {
|
||||
if (f->show_statistics) {
|
||||
dims.push_back(new_shared1<StatsDimension>(*f));
|
||||
}
|
||||
}
|
||||
statistics_dimensions.insert(statistics_dimensions.begin(), dims.begin(), dims.end()); // push front
|
||||
}
|
||||
// automatic statistics categories
|
||||
{
|
||||
vector<StatsCategoryP> cats;
|
||||
FOR_EACH(dim, statistics_dimensions) {
|
||||
cats.push_back(new_shared1<StatsCategory>(dim));
|
||||
}
|
||||
statistics_categories.insert(statistics_categories.begin(), cats.begin(), cats.end()); // push front
|
||||
}
|
||||
}
|
||||
|
||||
void addStatsDimensionsForFields();
|
||||
|
||||
// special behaviour of reading/writing GamePs: only read/write the name
|
||||
|
||||
void Reader::handle(GameP& game) {
|
||||
|
||||
@@ -17,6 +17,8 @@
|
||||
|
||||
DECLARE_POINTER_TYPE(Field);
|
||||
DECLARE_POINTER_TYPE(Game);
|
||||
DECLARE_POINTER_TYPE(StatsDimension);
|
||||
DECLARE_POINTER_TYPE(StatsCategory);
|
||||
|
||||
// ----------------------------------------------------------------------------- : Game
|
||||
|
||||
@@ -33,6 +35,8 @@ class Game : public Packaged {
|
||||
OptionalScript init_script; ///< Script of variables available to other scripts in this game
|
||||
vector<FieldP> set_fields; ///< Fields for set information
|
||||
vector<FieldP> card_fields; ///< Fields on each card
|
||||
vector<StatsDimensionP> statistics_dimensions; ///< (Additional) statistics dimensions
|
||||
vector<StatsCategoryP> statistics_categories; ///< (Additional) statistics categories
|
||||
|
||||
vector<Dependency> dependent_scripts_cards; ///< scripts that depend on the card list
|
||||
vector<Dependency> dependent_scripts_keywords; ///< scripts that depend on the keywords
|
||||
|
||||
+2
-2
@@ -43,8 +43,8 @@ Set::~Set() {}
|
||||
Context& Set::getContext() {
|
||||
return script_manager->getContext(stylesheet);
|
||||
}
|
||||
Context& Set::getContext(const Card& card) {
|
||||
return script_manager->getContext(card.stylesheet ? card.stylesheet : stylesheet);
|
||||
Context& Set::getContext(const CardP& card) {
|
||||
return script_manager->getContext(card);
|
||||
}
|
||||
void Set::updateFor(const CardP& card) {
|
||||
script_manager->updateStyles(card);
|
||||
|
||||
+1
-1
@@ -60,7 +60,7 @@ class Set : public Packaged {
|
||||
Context& getContext();
|
||||
/// A context for performing scripts on a particular card
|
||||
/** Should only be used from the main thread! */
|
||||
Context& getContext(const Card& card);
|
||||
Context& getContext(const CardP& card);
|
||||
/// Update styles for a card
|
||||
void updateFor(const CardP& card);
|
||||
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
//+----------------------------------------------------------------------------+
|
||||
//| Description: Magic Set Editor - Program to make Magic (tm) cards |
|
||||
//| Copyright: (C) 2001 - 2006 Twan van Laarhoven |
|
||||
//| License: GNU General Public License 2 or later (see file COPYING) |
|
||||
//+----------------------------------------------------------------------------+
|
||||
|
||||
// ----------------------------------------------------------------------------- : Includes
|
||||
|
||||
#include <data/statistics.hpp>
|
||||
#include <data/field.hpp>
|
||||
|
||||
// ----------------------------------------------------------------------------- : Statistics dimension
|
||||
|
||||
StatsDimension::StatsDimension()
|
||||
: automatic(false)
|
||||
{}
|
||||
|
||||
StatsDimension::StatsDimension(const Field& field)
|
||||
: automatic(true)
|
||||
, name (field.name)
|
||||
, description (field.description)
|
||||
, icon_filename(field.icon_filename)
|
||||
{
|
||||
// init script!
|
||||
}
|
||||
|
||||
IMPLEMENT_REFLECTION(StatsDimension) {
|
||||
REFLECT(name);
|
||||
REFLECT(description);
|
||||
REFLECT_N("icon", icon_filename);
|
||||
REFLECT(script);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------- : Statistics category
|
||||
|
||||
StatsCategory::StatsCategory()
|
||||
: automatic(false)
|
||||
, type(GRAPH_TYPE_BAR)
|
||||
{}
|
||||
|
||||
StatsCategory::StatsCategory(const StatsDimensionP& dim)
|
||||
: automatic(true)
|
||||
, name (dim->name)
|
||||
, description (dim->description)
|
||||
, icon_filename(dim->icon_filename)
|
||||
, type(GRAPH_TYPE_BAR)
|
||||
, dimensions(1, dim)
|
||||
{}
|
||||
|
||||
IMPLEMENT_REFLECTION_ENUM(GraphType) {
|
||||
VALUE_N("bar", GRAPH_TYPE_BAR);
|
||||
VALUE_N("pie", GRAPH_TYPE_PIE);
|
||||
}
|
||||
|
||||
IMPLEMENT_REFLECTION(StatsCategory) {
|
||||
REFLECT(name);
|
||||
REFLECT(description);
|
||||
REFLECT_N("icon", icon_filename);
|
||||
REFLECT(type);
|
||||
REFLECT(dimensions);
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
//+----------------------------------------------------------------------------+
|
||||
//| Description: Magic Set Editor - Program to make Magic (tm) cards |
|
||||
//| Copyright: (C) 2001 - 2006 Twan van Laarhoven |
|
||||
//| License: GNU General Public License 2 or later (see file COPYING) |
|
||||
//+----------------------------------------------------------------------------+
|
||||
|
||||
#ifndef HEADER_DATA_STATISTICS
|
||||
#define HEADER_DATA_STATISTICS
|
||||
|
||||
// ----------------------------------------------------------------------------- : Includes
|
||||
|
||||
#include <util/prec.hpp>
|
||||
#include <util/reflect.hpp>
|
||||
#include <script/scriptable.hpp>
|
||||
|
||||
class Field;
|
||||
DECLARE_POINTER_TYPE(StatsDimension);
|
||||
DECLARE_POINTER_TYPE(StatsCategory);
|
||||
|
||||
// ----------------------------------------------------------------------------- : Statistics dimension
|
||||
|
||||
/// A dimension that can be plotted as an axis in a graph
|
||||
/** Dimensions can be generated automatically based on card fields */
|
||||
class StatsDimension {
|
||||
public:
|
||||
StatsDimension();
|
||||
StatsDimension(const Field&);
|
||||
|
||||
String name; ///< Name of this dimension
|
||||
String description; ///< Description, used in status bar
|
||||
String icon_filename; ///< Icon for lists
|
||||
OptionalScript script; ///< Script that determines the value(s)
|
||||
bool automatic; ///< Based on a card field?
|
||||
|
||||
DECLARE_REFLECTION();
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------- : Statistics category
|
||||
|
||||
/// Types of graphs
|
||||
enum GraphType
|
||||
{ GRAPH_TYPE_BAR
|
||||
, GRAPH_TYPE_PIE
|
||||
};
|
||||
|
||||
/// A category for statistics
|
||||
/** Can be generated automatically based on a dimension */
|
||||
class StatsCategory {
|
||||
public:
|
||||
StatsCategory();
|
||||
StatsCategory(const StatsDimensionP&);
|
||||
|
||||
String name; ///< Name/label
|
||||
String description; ///< Description, used in status bar
|
||||
String icon_filename; ///< Icon for lists
|
||||
Bitmap icon; ///< The loaded icon (optional of course)
|
||||
vector<StatsDimensionP> dimensions; ///< The dimensions to use, higher dimensions may be null
|
||||
GraphType type; ///< Type of graph to use
|
||||
bool automatic; ///< Automatically generated?
|
||||
|
||||
DECLARE_REFLECTION();
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------- : EOF
|
||||
#endif
|
||||
Reference in New Issue
Block a user