mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-10 04:57:00 -04:00
Some more data types; dynamic arguments
git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@5 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
@@ -324,7 +324,6 @@ void SinglePointRemoveAction::perform(bool toUndo) {
|
||||
}
|
||||
|
||||
DECLARE_POINTER_TYPE(SinglePointRemoveAction);
|
||||
DECLARE_TYPEOF_COLLECTION(SinglePointRemoveActionP);
|
||||
|
||||
|
||||
// Remove a set of points from a symbol part.
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
//+----------------------------------------------------------------------------+
|
||||
//| 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/card.hpp>
|
||||
#include <data/game.hpp>
|
||||
#include <data/field.hpp>
|
||||
#include <util/error.hpp>
|
||||
|
||||
// ----------------------------------------------------------------------------- : 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"));
|
||||
}
|
||||
data.init(game_for_new_cards()->cardFields);
|
||||
}
|
||||
|
||||
Card::Card(const Game& game) {
|
||||
data.init(game.cardFields);
|
||||
}
|
||||
|
||||
String Card::identification() const {
|
||||
return _("TODO");
|
||||
}
|
||||
|
||||
IMPLEMENT_REFLECTION(Card) {
|
||||
REFLECT(notes);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
//+----------------------------------------------------------------------------+
|
||||
//| 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_CARD
|
||||
#define HEADER_DATA_CARD
|
||||
|
||||
// ----------------------------------------------------------------------------- : Includes
|
||||
|
||||
#include <util/string.hpp>
|
||||
#include <util/reflect.hpp>
|
||||
#include <util/dynamic_arg.hpp>
|
||||
|
||||
class Game;
|
||||
DECLARE_POINTER_TYPE(Field);
|
||||
DECLARE_POINTER_TYPE(Value);
|
||||
DECLARE_POINTER_TYPE(CardStyle);
|
||||
|
||||
// ----------------------------------------------------------------------------- : 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:
|
||||
/// Default constructor, uses game_for_new_cards to make the game
|
||||
Card();
|
||||
/// Creates a card using the given game
|
||||
Card(const Game& game);
|
||||
|
||||
/// 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
|
||||
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;
|
||||
|
||||
DECLARE_REFLECTION();
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------- : EOF
|
||||
#endif
|
||||
@@ -0,0 +1,16 @@
|
||||
//+----------------------------------------------------------------------------+
|
||||
//| 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/field.hpp>
|
||||
|
||||
// ----------------------------------------------------------------------------- : Field
|
||||
// ----------------------------------------------------------------------------- : Value
|
||||
|
||||
void initObject(const FieldP& field, ValueP& value) {
|
||||
value = new_shared<Value>();
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
//+----------------------------------------------------------------------------+
|
||||
//| 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_FIELD
|
||||
#define HEADER_DATA_FIELD
|
||||
|
||||
// ----------------------------------------------------------------------------- : Includes
|
||||
|
||||
#include <util/prec.hpp>
|
||||
|
||||
#ifndef HEADER_DATA_CARD
|
||||
DECLARE_POINTER_TYPE(Field);
|
||||
DECLARE_POINTER_TYPE(Value);
|
||||
#endif
|
||||
|
||||
// ----------------------------------------------------------------------------- : Field
|
||||
|
||||
class Field {
|
||||
public:
|
||||
UInt index; // used by IndexMap
|
||||
};
|
||||
|
||||
class Value {
|
||||
};
|
||||
|
||||
void initObject(const FieldP&, ValueP&);
|
||||
|
||||
// ----------------------------------------------------------------------------- : EOF
|
||||
#endif
|
||||
@@ -0,0 +1,11 @@
|
||||
//+----------------------------------------------------------------------------+
|
||||
//| 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/game.hpp>
|
||||
|
||||
// ----------------------------------------------------------------------------- : Game
|
||||
@@ -0,0 +1,29 @@
|
||||
//+----------------------------------------------------------------------------+
|
||||
//| 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_GAME
|
||||
#define HEADER_DATA_GAME
|
||||
|
||||
// ----------------------------------------------------------------------------- : Includes
|
||||
|
||||
#include <util/prec.hpp>
|
||||
|
||||
#ifndef HEADER_DATA_CARD
|
||||
DECLARE_POINTER_TYPE(Field);
|
||||
#endif
|
||||
|
||||
// ----------------------------------------------------------------------------- : Game
|
||||
|
||||
class Game {
|
||||
public:
|
||||
String fullName;
|
||||
String iconFilename;
|
||||
vector<FieldP> setFields;
|
||||
vector<FieldP> cardFields;
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------- : EOF
|
||||
#endif
|
||||
@@ -0,0 +1,35 @@
|
||||
//+----------------------------------------------------------------------------+
|
||||
//| 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/set.hpp>
|
||||
#include <data/card.hpp>
|
||||
|
||||
// ----------------------------------------------------------------------------- : Set
|
||||
|
||||
IMPLEMENT_REFLECTION(Set) {
|
||||
WITH_DYNAMIC_ARG(game_for_new_cards, game.get()) {
|
||||
REFLECT_N("card", cards);
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------- : SetView
|
||||
|
||||
SetView::SetView() {}
|
||||
|
||||
SetView::~SetView() {
|
||||
if (set) set->actions.removeListener(this);
|
||||
}
|
||||
|
||||
void SetView::setSet(const SetP& newSet) {
|
||||
// no longer listening to old set
|
||||
if (set) set->actions.removeListener(this);
|
||||
set = newSet;
|
||||
// start listening to new set
|
||||
if (set) set->actions.addListener(this);
|
||||
onChangeSet();
|
||||
}
|
||||
@@ -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) |
|
||||
//+----------------------------------------------------------------------------+
|
||||
|
||||
#ifndef HEADER_DATA_SET
|
||||
#define HEADER_DATA_SET
|
||||
|
||||
// ----------------------------------------------------------------------------- : Includes
|
||||
|
||||
#include <util/prec.hpp>
|
||||
#include <util/reflect.hpp>
|
||||
#include <util/action_stack.hpp>
|
||||
|
||||
DECLARE_POINTER_TYPE(Card);
|
||||
DECLARE_POINTER_TYPE(Set);
|
||||
DECLARE_POINTER_TYPE(Game);
|
||||
|
||||
// ----------------------------------------------------------------------------- : Set
|
||||
|
||||
/// A set of cards
|
||||
class Set {
|
||||
public:
|
||||
/// The game this set uses
|
||||
GameP game;
|
||||
/// The cards in the set
|
||||
vector<CardP> cards;
|
||||
/// Actions performed on this set and the cards in it
|
||||
ActionStack actions;
|
||||
|
||||
DECLARE_REFLECTION();
|
||||
};
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------- : SetView
|
||||
|
||||
/// A 'view' of a Set, is notified when the Set is updated
|
||||
/** To listen to events, derived classes should override onAction(const Action&)
|
||||
*/
|
||||
class SetView : public ActionListener {
|
||||
public:
|
||||
SetView();
|
||||
~SetView();
|
||||
|
||||
/// Get the set that is currently being viewed
|
||||
inline SetP getSet() { return set; }
|
||||
/// Change the set that is being viewed
|
||||
void setSet(const SetP& set);
|
||||
|
||||
protected:
|
||||
/// The set that is currently being viewed, should not be modified directly!
|
||||
SetP set;
|
||||
|
||||
/// Called when another set is being viewn (using setSet)
|
||||
virtual void onChangeSet() {}
|
||||
};
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------- : EOF
|
||||
#endif
|
||||
+2
-8
@@ -163,21 +163,15 @@ IMPLEMENT_REFLECTION(Symbol) {
|
||||
|
||||
SymbolView::SymbolView() {}
|
||||
|
||||
SymbolView::SymbolView(SymbolP symbol)
|
||||
: symbol(symbol)
|
||||
{
|
||||
if (symbol) symbol->actions.addListener(this);
|
||||
}
|
||||
|
||||
SymbolView::~SymbolView() {
|
||||
if (symbol) symbol->actions.removeListener(this);
|
||||
}
|
||||
|
||||
void SymbolView::setSymbol(SymbolP newSymbol) {
|
||||
void SymbolView::setSymbol(const SymbolP& newSymbol) {
|
||||
// no longer listening to old symbol
|
||||
if (symbol) symbol->actions.removeListener(this);
|
||||
symbol = newSymbol;
|
||||
// start listening to new symbol
|
||||
if (symbol) symbol->actions.addListener(this);
|
||||
onSymbolChange();
|
||||
onChangeSymbol();
|
||||
}
|
||||
|
||||
+5
-6
@@ -17,8 +17,6 @@
|
||||
DECLARE_POINTER_TYPE(ControlPoint);
|
||||
DECLARE_POINTER_TYPE(SymbolPart);
|
||||
DECLARE_POINTER_TYPE(Symbol);
|
||||
DECLARE_TYPEOF_COLLECTION(ControlPointP);
|
||||
DECLARE_TYPEOF_COLLECTION(SymbolPartP);
|
||||
|
||||
// ----------------------------------------------------------------------------- : ControlPoint
|
||||
|
||||
@@ -168,23 +166,24 @@ class Symbol {
|
||||
// ----------------------------------------------------------------------------- : SymbolView
|
||||
|
||||
/// A 'view' of a symbol, is notified when the symbol is updated
|
||||
/** To listen to events, derived classes should override onAction(const Action&)
|
||||
*/
|
||||
class SymbolView : public ActionListener {
|
||||
public:
|
||||
SymbolView();
|
||||
SymbolView(SymbolP symbol);
|
||||
~SymbolView();
|
||||
|
||||
/// Get the symbol that is currently being viewed
|
||||
inline SymbolP getSymbol() { return symbol; }
|
||||
/// Change the symbol that is being viewed
|
||||
void setSymbol(SymbolP symbol);
|
||||
void setSymbol(const SymbolP& symbol);
|
||||
|
||||
protected:
|
||||
/// The symbol that is currently being viewed, should not be modified directly!
|
||||
SymbolP symbol;
|
||||
|
||||
/// Called when the associated symbol is changed, but not when it is initially set!
|
||||
virtual void onSymbolChange() {}
|
||||
/// Called when another symbol is being viewn (using setSymbol)
|
||||
virtual void onChangeSymbol() {}
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user