mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-10 13:06:59 -04:00
Implemented CardList
git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@23 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
+5
-6
@@ -16,7 +16,7 @@
|
||||
class Game;
|
||||
DECLARE_POINTER_TYPE(Field);
|
||||
DECLARE_POINTER_TYPE(Value);
|
||||
DECLARE_POINTER_TYPE(CardStyle);
|
||||
DECLARE_POINTER_TYPE(StyleSheet);
|
||||
|
||||
// ----------------------------------------------------------------------------- : Card
|
||||
|
||||
@@ -34,17 +34,16 @@ class Card {
|
||||
/// Get an identification of the card, an identification is something like a name, title, etc.
|
||||
String identification() const;
|
||||
|
||||
private:
|
||||
/// The values on the fields of the card
|
||||
/// The indices should correspond to the cardFields in the Game
|
||||
/// The values on the fields of the card.
|
||||
/** The indices should correspond to the cardFields in the Game */
|
||||
IndexMap<FieldP, ValueP> data;
|
||||
|
||||
/// Notes for this card
|
||||
String notes;
|
||||
|
||||
/// Alternative style to use for this card
|
||||
/// Optional, if not set use the card style from the set
|
||||
CardStyleP style;
|
||||
/** Optional; if not set use the card style from the set */
|
||||
StyleSheetP stylesheet;
|
||||
|
||||
DECLARE_REFLECTION();
|
||||
};
|
||||
|
||||
@@ -8,6 +8,11 @@
|
||||
|
||||
#include <data/field.hpp>
|
||||
#include <data/field/text.hpp>
|
||||
#include <data/field/choice.hpp>
|
||||
#include <data/field/boolean.hpp>
|
||||
#include <data/field/image.hpp>
|
||||
#include <data/field/symbol.hpp>
|
||||
#include <data/field/color.hpp>
|
||||
#include <util/error.hpp>
|
||||
|
||||
// ----------------------------------------------------------------------------- : Field
|
||||
|
||||
+4
-1
@@ -81,7 +81,10 @@ class Value {
|
||||
|
||||
/// Create a copy of this value
|
||||
virtual ValueP clone() const = 0;
|
||||
|
||||
|
||||
/// Convert this value to a string for use in tables
|
||||
virtual String toString() const = 0;
|
||||
|
||||
private:
|
||||
DECLARE_REFLECTION_VIRTUAL();
|
||||
};
|
||||
|
||||
@@ -59,6 +59,9 @@ IMPLEMENT_REFLECTION(TextStyle) {
|
||||
ValueP TextValue::clone() const {
|
||||
return new_shared1<TextValue>(*this);
|
||||
}
|
||||
String TextValue::toString() const {
|
||||
return value();
|
||||
}
|
||||
|
||||
IMPLEMENT_REFLECTION(TextValue) {
|
||||
REFLECT_BASE(Value);
|
||||
|
||||
@@ -71,6 +71,7 @@ class TextValue : public Value {
|
||||
Defaultable<String> value; ///< The text of this value
|
||||
|
||||
virtual ValueP clone() const;
|
||||
virtual String toString() const;
|
||||
private:
|
||||
DECLARE_REFLECTION();
|
||||
};
|
||||
|
||||
@@ -22,8 +22,18 @@ bool Game::isMagic() const {
|
||||
return name() == _("magic");
|
||||
}
|
||||
|
||||
String Game::typeNameStatic() { return _("game"); }
|
||||
String Game::typeName() const { return _("game"); }
|
||||
|
||||
String Game::fullName() const { return full_name; }
|
||||
InputStreamP Game::openIconFile() {
|
||||
if (!icon_filename.empty()) {
|
||||
return openIn(icon_filename);
|
||||
} else {
|
||||
return InputStreamP();
|
||||
}
|
||||
}
|
||||
|
||||
IMPLEMENT_REFLECTION(Game) {
|
||||
// ioMseVersion(io, fileName, fileVersion);
|
||||
REFLECT(full_name);
|
||||
|
||||
+5
-1
@@ -32,8 +32,12 @@ class Game : public Packaged {
|
||||
/// Is this Magic the Gathering?
|
||||
bool isMagic() const;
|
||||
|
||||
static String typeNameStatic();
|
||||
virtual String typeName() const;
|
||||
virtual String fullName() const;
|
||||
virtual InputStreamP openIconFile();
|
||||
|
||||
protected:
|
||||
String typeName() const;
|
||||
void validate();
|
||||
|
||||
DECLARE_REFLECTION();
|
||||
|
||||
+21
-1
@@ -8,6 +8,7 @@
|
||||
|
||||
#include <data/settings.hpp>
|
||||
#include <data/game.hpp>
|
||||
#include <data/field.hpp>
|
||||
#include <util/reflect.hpp>
|
||||
#include <util/io/reader.hpp>
|
||||
#include <util/io/writer.hpp>
|
||||
@@ -23,6 +24,12 @@ IMPLEMENT_REFLECTION_ENUM(CheckUpdates) {
|
||||
VALUE_N("never", CHECK_NEVER);
|
||||
}
|
||||
|
||||
const int COLUMN_NOT_INITIALIZED = -100000;
|
||||
|
||||
ColumnSettings::ColumnSettings()
|
||||
: width(100), position(COLUMN_NOT_INITIALIZED), visible(false)
|
||||
{}
|
||||
|
||||
IMPLEMENT_REFLECTION(ColumnSettings) {
|
||||
REFLECT(width);
|
||||
REFLECT(position);
|
||||
@@ -37,7 +44,7 @@ IMPLEMENT_REFLECTION(GameSettings) {
|
||||
REFLECT(sort_cards_ascending);
|
||||
}
|
||||
|
||||
IMPLEMENT_REFLECTION(StyleSettings) {
|
||||
IMPLEMENT_REFLECTION(StyleSheetSettings) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
@@ -75,6 +82,19 @@ GameSettings& Settings::gameSettingsFor(const Game& game) {
|
||||
if (!gs) gs.reset(new GameSettings);
|
||||
return *gs;
|
||||
}
|
||||
ColumnSettings& Settings::columnSettingsFor(const Game& game, const Field& field) {
|
||||
// Get game info
|
||||
GameSettings& gs = gameSettingsFor(game);
|
||||
// Get column info
|
||||
ColumnSettings& cs = gs.columns[field.name];
|
||||
if (cs.position == COLUMN_NOT_INITIALIZED) {
|
||||
// column info not set, initialize based on the game
|
||||
cs.visible = field.card_list_column >= 0;
|
||||
cs.position = field.card_list_column;
|
||||
cs.width = field.card_list_width;
|
||||
}
|
||||
return cs;
|
||||
}
|
||||
/*
|
||||
StyleSettings& Settings::styleSettingsFor(const CardStyle& style) {
|
||||
StyleSettingsP& ss = settings.styleSettings#(style.name());
|
||||
|
||||
+23
-18
@@ -11,12 +11,14 @@
|
||||
|
||||
#include <util/prec.hpp>
|
||||
#include <util/reflect.hpp>
|
||||
#include <util/defaultable.hpp>
|
||||
|
||||
class Game;
|
||||
class CardStyle;
|
||||
class StyleSheet;
|
||||
class Field;
|
||||
|
||||
DECLARE_POINTER_TYPE(GameSettings);
|
||||
DECLARE_POINTER_TYPE(StyleSettings);
|
||||
DECLARE_POINTER_TYPE(StyleSheetSettings);
|
||||
|
||||
// ----------------------------------------------------------------------------- : Extra data structures
|
||||
|
||||
@@ -30,6 +32,7 @@ enum CheckUpdates
|
||||
/// Settings of a single column in the card list
|
||||
class ColumnSettings {
|
||||
public:
|
||||
ColumnSettings();
|
||||
UInt width;
|
||||
int position;
|
||||
bool visible;
|
||||
@@ -49,20 +52,20 @@ class GameSettings {
|
||||
DECLARE_REFLECTION();
|
||||
};
|
||||
|
||||
/// Settings for a Style
|
||||
class StyleSettings {
|
||||
/// Settings for a StyleSheet
|
||||
class StyleSheetSettings {
|
||||
public:
|
||||
// Rendering/display settings
|
||||
/* SimpleDefaultable<double> card_zoom = 1.0;
|
||||
SimpleDefaultable<int> card_angle = 0;
|
||||
SimpleDefaultable<bool> card_anti_alias = true;
|
||||
SimpleDefaultable<bool> card_borders = true;
|
||||
SimpleDefaultable<bool> card_normal_export = true;
|
||||
*/
|
||||
Defaultable<double> card_zoom;
|
||||
Defaultable<int> card_angle;
|
||||
Defaultable<bool> card_anti_alias;
|
||||
Defaultable<bool> card_borders;
|
||||
Defaultable<bool> card_normal_export;
|
||||
|
||||
DECLARE_REFLECTION();
|
||||
|
||||
// /// Where the settings are the default, use the value from ss
|
||||
// void useDefault(const StyleSettings& ss);
|
||||
// void useDefault(const StyleSheetSettings& ss);
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------- : Settings
|
||||
@@ -92,17 +95,19 @@ class Settings {
|
||||
// --------------------------------------------------- : Default pacakge selections
|
||||
String default_game;
|
||||
|
||||
// --------------------------------------------------- : Game/style specific
|
||||
// --------------------------------------------------- : Game/stylesheet specific
|
||||
|
||||
/// Get the settings object for a specific game
|
||||
GameSettings& gameSettingsFor(const Game& game);
|
||||
/// Get the settings object for a specific style
|
||||
StyleSettings& styleSettingsFor(const CardStyle& style);
|
||||
GameSettings& gameSettingsFor (const Game& game);
|
||||
/// Get the settings for a column for a specific field in a game
|
||||
ColumnSettings& columnSettingsFor (const Game& game, const Field& field);
|
||||
/// Get the settings object for a specific stylesheet
|
||||
StyleSheetSettings& styleSheetSettingsFor(const StyleSheet& stylesheet);
|
||||
|
||||
private:
|
||||
map<String,GameSettingsP> game_settings;
|
||||
map<String,StyleSettingsP> style_settings;
|
||||
StyleSettings default_style_settings;
|
||||
map<String,GameSettingsP> game_settings;
|
||||
map<String,StyleSheetSettingsP> stylesheet_settings;
|
||||
StyleSheetSettings default_stylesheet_settings;
|
||||
public:
|
||||
|
||||
// --------------------------------------------------- : Special game stuff
|
||||
|
||||
Reference in New Issue
Block a user