mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-10 04:57:00 -04:00
Added dummy CardEditor, implemented Stylesheet loading
git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@50 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
+3
-5
@@ -16,13 +16,11 @@ DECLARE_TYPEOF_COLLECTION(FieldP);
|
||||
|
||||
// ----------------------------------------------------------------------------- : Card
|
||||
|
||||
IMPLEMENT_DYNAMIC_ARG(Game*, game_for_new_cards, nullptr);
|
||||
|
||||
Card::Card() {
|
||||
if (!game_for_new_cards()) {
|
||||
throw InternalError(_("game_for_new_cards not set"));
|
||||
if (!game_for_reading()) {
|
||||
throw InternalError(_("game_for_reading not set"));
|
||||
}
|
||||
data.init(game_for_new_cards()->card_fields);
|
||||
data.init(game_for_reading()->card_fields);
|
||||
}
|
||||
|
||||
Card::Card(const Game& game) {
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
|
||||
#include <util/string.hpp>
|
||||
#include <util/reflect.hpp>
|
||||
#include <util/dynamic_arg.hpp>
|
||||
|
||||
class Game;
|
||||
DECLARE_POINTER_TYPE(Field);
|
||||
@@ -20,9 +19,6 @@ DECLARE_POINTER_TYPE(StyleSheet);
|
||||
|
||||
// ----------------------------------------------------------------------------- : Card
|
||||
|
||||
/// Game that is used for cards constructed with the default constructor
|
||||
DECLARE_DYNAMIC_ARG(Game*, game_for_new_cards);
|
||||
|
||||
/// A card from a card Set
|
||||
class Card {
|
||||
public:
|
||||
|
||||
+2
-1
@@ -14,6 +14,8 @@
|
||||
|
||||
// ----------------------------------------------------------------------------- : Game
|
||||
|
||||
IMPLEMENT_DYNAMIC_ARG(Game*, game_for_reading, nullptr);
|
||||
|
||||
GameP Game::byName(const String& name) {
|
||||
return packages.open<Game>(name + _(".mse-game"));
|
||||
}
|
||||
@@ -35,7 +37,6 @@ InputStreamP Game::openIconFile() {
|
||||
}
|
||||
|
||||
IMPLEMENT_REFLECTION(Game) {
|
||||
// ioMseVersion(io, fileName, fileVersion);
|
||||
REFLECT(full_name);
|
||||
REFLECT_N("icon", icon_filename);
|
||||
REFLECT(init_script);
|
||||
|
||||
+6
-1
@@ -12,15 +12,20 @@
|
||||
#include <util/prec.hpp>
|
||||
#include <util/io/package.hpp>
|
||||
#include <script/scriptable.hpp>
|
||||
#include <util/dynamic_arg.hpp>
|
||||
|
||||
DECLARE_POINTER_TYPE(Field);
|
||||
DECLARE_POINTER_TYPE(Game);
|
||||
|
||||
// ----------------------------------------------------------------------------- : Game
|
||||
|
||||
/// Game that is used for cards constructed with the default constructor, as well as for reading stylesheets
|
||||
DECLARE_DYNAMIC_ARG(Game*, game_for_reading);
|
||||
|
||||
/// A description of a card game
|
||||
class Game : public Packaged {
|
||||
public:
|
||||
String full_name; ///< Name of this game for menus etc.
|
||||
String full_name; ///< Name of this game, for menus etc.
|
||||
String icon_filename; ///< Filename of icon to use in NewWindow
|
||||
OptionalScript init_script; ///< Script of variables available to other scripts in this game
|
||||
vector<FieldP> set_fields; ///< Fields for set information
|
||||
|
||||
+10
-6
@@ -29,13 +29,17 @@ Set::Set(const StyleSheetP& stylesheet)
|
||||
String Set::typeName() const { return _("set"); }
|
||||
|
||||
IMPLEMENT_REFLECTION(Set) {
|
||||
tag.addAlias(300, _("style"), _("stylesheet")); // < 0.3.0 used style instead of stylesheet
|
||||
REFLECT(game);
|
||||
if (data.empty() && game) {
|
||||
data.init(game->set_fields);
|
||||
}
|
||||
REFLECT_N("set_info", data);
|
||||
WITH_DYNAMIC_ARG(game_for_new_cards, game.get()) {
|
||||
REFLECT(cards);
|
||||
if (game) {
|
||||
if (tag.reading()) {
|
||||
data.init(game->set_fields);
|
||||
}
|
||||
WITH_DYNAMIC_ARG(game_for_reading, game.get()) {
|
||||
REFLECT(stylesheet);
|
||||
REFLECT_N("set_info", data);
|
||||
REFLECT(cards);
|
||||
}
|
||||
}
|
||||
REFLECT(apprentice_code);
|
||||
}
|
||||
|
||||
@@ -7,8 +7,70 @@
|
||||
// ----------------------------------------------------------------------------- : Includes
|
||||
|
||||
#include <data/stylesheet.hpp>
|
||||
#include <data/game.hpp>
|
||||
#include <data/field.hpp>
|
||||
#include <util/io/package_manager.hpp>
|
||||
|
||||
// ----------------------------------------------------------------------------- : StyleSheet
|
||||
|
||||
StyleSheet::StyleSheet()
|
||||
: card_width(100), card_height(100)
|
||||
, card_dpi(96), card_background(*wxWHITE)
|
||||
{}
|
||||
|
||||
StyleSheetP StyleSheet::byGameAndName(const Game& game, const String& name) {
|
||||
return packages.open<StyleSheet>(game.name() + _("-") + name + _(".mse-style"));
|
||||
}
|
||||
|
||||
String StyleSheet::typeNameStatic() { return _("style"); }
|
||||
String StyleSheet::typeName() const { return _("style"); }
|
||||
|
||||
String StyleSheet::fullName() const { return full_name; }
|
||||
InputStreamP StyleSheet::openIconFile() {
|
||||
if (!icon_filename.empty()) {
|
||||
return openIn(icon_filename);
|
||||
} else {
|
||||
return game->openIconFile(); // use game icon by default
|
||||
}
|
||||
}
|
||||
IMPLEMENT_REFLECTION(StyleSheet) {
|
||||
// < 0.3.0 didn't use card_ prefix
|
||||
tag.addAlias(300, _("width"), _("card_width"));
|
||||
tag.addAlias(300, _("height"), _("card_height"));
|
||||
tag.addAlias(300, _("dpi"), _("card_dpi"));
|
||||
tag.addAlias(300, _("background"), _("card_background"));
|
||||
tag.addAlias(300, _("info_style"), _("set_info_style"));
|
||||
|
||||
REFLECT(game);
|
||||
REFLECT(full_name);
|
||||
REFLECT_N("icon", icon_filename);
|
||||
REFLECT(init_script);
|
||||
REFLECT(card_width);
|
||||
REFLECT(card_height);
|
||||
REFLECT(card_dpi);
|
||||
REFLECT(card_background);
|
||||
if (game) {
|
||||
if (tag.reading()) {
|
||||
card_style .init(game->card_fields);
|
||||
set_info_style.init(game->set_fields);
|
||||
}
|
||||
REFLECT(card_style);
|
||||
REFLECT(set_info_style);
|
||||
}
|
||||
// io(_("extra field"), extraSetFields);
|
||||
// extraInfoStyle.init(extraSetFields);
|
||||
// io(_("extra style"), extraInfoStyle);
|
||||
}
|
||||
|
||||
|
||||
// special behaviour of reading/writing StyleSheetPs: only read/write the name
|
||||
|
||||
void Reader::handle(StyleSheetP& stylesheet) {
|
||||
if (!game_for_reading()) {
|
||||
throw InternalError(_("game_for_reading not set"));
|
||||
}
|
||||
stylesheet = StyleSheet::byGameAndName(*game_for_reading(), value);
|
||||
}
|
||||
void Writer::handle(const StyleSheetP& stylesheet) {
|
||||
handle(stylesheet->name());
|
||||
}
|
||||
|
||||
+26
-3
@@ -11,23 +11,46 @@
|
||||
|
||||
#include <util/prec.hpp>
|
||||
#include <util/io/package.hpp>
|
||||
#include <script/scriptable.hpp>
|
||||
|
||||
DECLARE_POINTER_TYPE(Game);
|
||||
DECLARE_POINTER_TYPE(StyleSheet);
|
||||
DECLARE_POINTER_TYPE(Field);
|
||||
DECLARE_POINTER_TYPE(Style);
|
||||
|
||||
// ----------------------------------------------------------------------------- : StyleSheet
|
||||
|
||||
/// A collection of style information for card and set fields
|
||||
class StyleSheet : public Packaged {
|
||||
public:
|
||||
GameP game;
|
||||
double card_width; ///< The width of a card in pixels
|
||||
double card_height; ///< The height of a card in pixels
|
||||
StyleSheet();
|
||||
|
||||
GameP game; ///< The game this stylesheet is made for
|
||||
String full_name; ///< Name of this game, for menus etc.
|
||||
String icon_filename; ///< Filename of icon to use in NewWindow
|
||||
OptionalScript init_script; ///< Script of variables available to other scripts in this stylesheet
|
||||
double card_width; ///< The width of a card in pixels
|
||||
double card_height; ///< The height of a card in pixels
|
||||
double card_dpi; ///< The resolution of a card in dots per inch
|
||||
Color card_background; ///< The background color of cards
|
||||
/// The styling for card fields
|
||||
/** The indices should correspond to the set_fields in the Game */
|
||||
IndexMap<FieldP, StyleP> card_style;
|
||||
/// The styling for set info fields
|
||||
/** The indices should correspond to the set_fields in the Game */
|
||||
IndexMap<FieldP, StyleP> set_info_style;
|
||||
|
||||
static String typeNameStatic();
|
||||
virtual String typeName() const;
|
||||
virtual String fullName() const;
|
||||
virtual InputStreamP openIconFile();
|
||||
|
||||
/// Load a StyleSheet, given a Game and the name of the StyleSheet
|
||||
static StyleSheetP byGameAndName(const Game& game, const String& name);
|
||||
|
||||
/// name of the package without the game name
|
||||
String styleName();
|
||||
|
||||
private:
|
||||
DECLARE_REFLECTION();
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user