mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-12 05:36:59 -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
|
// ----------------------------------------------------------------------------- : Card
|
||||||
|
|
||||||
IMPLEMENT_DYNAMIC_ARG(Game*, game_for_new_cards, nullptr);
|
|
||||||
|
|
||||||
Card::Card() {
|
Card::Card() {
|
||||||
if (!game_for_new_cards()) {
|
if (!game_for_reading()) {
|
||||||
throw InternalError(_("game_for_new_cards not set"));
|
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) {
|
Card::Card(const Game& game) {
|
||||||
|
|||||||
@@ -11,7 +11,6 @@
|
|||||||
|
|
||||||
#include <util/string.hpp>
|
#include <util/string.hpp>
|
||||||
#include <util/reflect.hpp>
|
#include <util/reflect.hpp>
|
||||||
#include <util/dynamic_arg.hpp>
|
|
||||||
|
|
||||||
class Game;
|
class Game;
|
||||||
DECLARE_POINTER_TYPE(Field);
|
DECLARE_POINTER_TYPE(Field);
|
||||||
@@ -20,9 +19,6 @@ DECLARE_POINTER_TYPE(StyleSheet);
|
|||||||
|
|
||||||
// ----------------------------------------------------------------------------- : Card
|
// ----------------------------------------------------------------------------- : 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
|
/// A card from a card Set
|
||||||
class Card {
|
class Card {
|
||||||
public:
|
public:
|
||||||
|
|||||||
+2
-1
@@ -14,6 +14,8 @@
|
|||||||
|
|
||||||
// ----------------------------------------------------------------------------- : Game
|
// ----------------------------------------------------------------------------- : Game
|
||||||
|
|
||||||
|
IMPLEMENT_DYNAMIC_ARG(Game*, game_for_reading, nullptr);
|
||||||
|
|
||||||
GameP Game::byName(const String& name) {
|
GameP Game::byName(const String& name) {
|
||||||
return packages.open<Game>(name + _(".mse-game"));
|
return packages.open<Game>(name + _(".mse-game"));
|
||||||
}
|
}
|
||||||
@@ -35,7 +37,6 @@ InputStreamP Game::openIconFile() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
IMPLEMENT_REFLECTION(Game) {
|
IMPLEMENT_REFLECTION(Game) {
|
||||||
// ioMseVersion(io, fileName, fileVersion);
|
|
||||||
REFLECT(full_name);
|
REFLECT(full_name);
|
||||||
REFLECT_N("icon", icon_filename);
|
REFLECT_N("icon", icon_filename);
|
||||||
REFLECT(init_script);
|
REFLECT(init_script);
|
||||||
|
|||||||
+6
-1
@@ -12,15 +12,20 @@
|
|||||||
#include <util/prec.hpp>
|
#include <util/prec.hpp>
|
||||||
#include <util/io/package.hpp>
|
#include <util/io/package.hpp>
|
||||||
#include <script/scriptable.hpp>
|
#include <script/scriptable.hpp>
|
||||||
|
#include <util/dynamic_arg.hpp>
|
||||||
|
|
||||||
DECLARE_POINTER_TYPE(Field);
|
DECLARE_POINTER_TYPE(Field);
|
||||||
DECLARE_POINTER_TYPE(Game);
|
DECLARE_POINTER_TYPE(Game);
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------- : 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 {
|
class Game : public Packaged {
|
||||||
public:
|
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
|
String icon_filename; ///< Filename of icon to use in NewWindow
|
||||||
OptionalScript init_script; ///< Script of variables available to other scripts in this game
|
OptionalScript init_script; ///< Script of variables available to other scripts in this game
|
||||||
vector<FieldP> set_fields; ///< Fields for set information
|
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"); }
|
String Set::typeName() const { return _("set"); }
|
||||||
|
|
||||||
IMPLEMENT_REFLECTION(Set) {
|
IMPLEMENT_REFLECTION(Set) {
|
||||||
|
tag.addAlias(300, _("style"), _("stylesheet")); // < 0.3.0 used style instead of stylesheet
|
||||||
REFLECT(game);
|
REFLECT(game);
|
||||||
if (data.empty() && game) {
|
if (game) {
|
||||||
data.init(game->set_fields);
|
if (tag.reading()) {
|
||||||
}
|
data.init(game->set_fields);
|
||||||
REFLECT_N("set_info", data);
|
}
|
||||||
WITH_DYNAMIC_ARG(game_for_new_cards, game.get()) {
|
WITH_DYNAMIC_ARG(game_for_reading, game.get()) {
|
||||||
REFLECT(cards);
|
REFLECT(stylesheet);
|
||||||
|
REFLECT_N("set_info", data);
|
||||||
|
REFLECT(cards);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
REFLECT(apprentice_code);
|
REFLECT(apprentice_code);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,8 +7,70 @@
|
|||||||
// ----------------------------------------------------------------------------- : Includes
|
// ----------------------------------------------------------------------------- : Includes
|
||||||
|
|
||||||
#include <data/stylesheet.hpp>
|
#include <data/stylesheet.hpp>
|
||||||
|
#include <data/game.hpp>
|
||||||
|
#include <data/field.hpp>
|
||||||
|
#include <util/io/package_manager.hpp>
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------- : StyleSheet
|
// ----------------------------------------------------------------------------- : 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::typeNameStatic() { return _("style"); }
|
||||||
String StyleSheet::typeName() const { 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/prec.hpp>
|
||||||
#include <util/io/package.hpp>
|
#include <util/io/package.hpp>
|
||||||
|
#include <script/scriptable.hpp>
|
||||||
|
|
||||||
DECLARE_POINTER_TYPE(Game);
|
DECLARE_POINTER_TYPE(Game);
|
||||||
|
DECLARE_POINTER_TYPE(StyleSheet);
|
||||||
|
DECLARE_POINTER_TYPE(Field);
|
||||||
|
DECLARE_POINTER_TYPE(Style);
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------- : StyleSheet
|
// ----------------------------------------------------------------------------- : StyleSheet
|
||||||
|
|
||||||
/// A collection of style information for card and set fields
|
/// A collection of style information for card and set fields
|
||||||
class StyleSheet : public Packaged {
|
class StyleSheet : public Packaged {
|
||||||
public:
|
public:
|
||||||
GameP game;
|
StyleSheet();
|
||||||
double card_width; ///< The width of a card in pixels
|
|
||||||
double card_height; ///< The height of a card in pixels
|
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();
|
static String typeNameStatic();
|
||||||
virtual String typeName() const;
|
virtual String typeName() const;
|
||||||
virtual String fullName() const;
|
virtual String fullName() const;
|
||||||
virtual InputStreamP openIconFile();
|
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:
|
private:
|
||||||
DECLARE_REFLECTION();
|
DECLARE_REFLECTION();
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
//+----------------------------------------------------------------------------+
|
||||||
|
//| 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 <gui/control/card_editor.hpp>
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------- : DataEditor
|
||||||
|
|
||||||
|
DataEditor::DataEditor(Window* parent, int id, long style)
|
||||||
|
: CardViewer(parent, id, style)
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------- : Event table
|
||||||
|
|
||||||
|
BEGIN_EVENT_TABLE(DataEditor, CardViewer)
|
||||||
|
END_EVENT_TABLE ()
|
||||||
@@ -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_GUI_CONTROL_CARD_EDITOR
|
||||||
|
#define HEADER_GUI_CONTROL_CARD_EDITOR
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------- : Includes
|
||||||
|
|
||||||
|
#include <util/prec.hpp>
|
||||||
|
#include <gui/control/card_viewer.hpp>
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------- : DataEditor
|
||||||
|
|
||||||
|
/// An editor for data values (usually a card)
|
||||||
|
class DataEditor : public CardViewer {
|
||||||
|
public:
|
||||||
|
DataEditor(Window* parent, int id, long style = 0);
|
||||||
|
private:
|
||||||
|
DECLARE_EVENT_TABLE();
|
||||||
|
};
|
||||||
|
|
||||||
|
/// By default a DataEditor edits cards
|
||||||
|
typedef DataEditor CardEditor;
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------- : EOF
|
||||||
|
#endif
|
||||||
@@ -12,13 +12,17 @@
|
|||||||
|
|
||||||
// ----------------------------------------------------------------------------- : CardViewer
|
// ----------------------------------------------------------------------------- : CardViewer
|
||||||
|
|
||||||
CardViewer::CardViewer(Window* parent, int id, int style)
|
CardViewer::CardViewer(Window* parent, int id, long style)
|
||||||
: wxControl(parent, id, wxDefaultPosition, wxDefaultSize, style)
|
: wxControl(parent, id, wxDefaultPosition, wxDefaultSize, style)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
wxSize CardViewer::DoGetBestSize() const {
|
wxSize CardViewer::DoGetBestSize() const {
|
||||||
wxSize ws = GetSize(), cs = GetClientSize();
|
wxSize ws = GetSize(), cs = GetClientSize();
|
||||||
return wxSize(set->stylesheet->card_width, set->stylesheet->card_height) + ws - cs;
|
if (set && set->stylesheet) {
|
||||||
|
return wxSize(set->stylesheet->card_width, set->stylesheet->card_height) + ws - cs;
|
||||||
|
} else {
|
||||||
|
return cs;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CardViewer::onPaint(wxPaintEvent&) {
|
void CardViewer::onPaint(wxPaintEvent&) {
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
/// A control to view a single card
|
/// A control to view a single card
|
||||||
class CardViewer : public wxControl, public DataViewer {
|
class CardViewer : public wxControl, public DataViewer {
|
||||||
public:
|
public:
|
||||||
CardViewer(Window* parent, int id, int style);
|
CardViewer(Window* parent, int id, long style = 0);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/// Return the desired size of control
|
/// Return the desired size of control
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
#include <gui/set/cards_panel.hpp>
|
#include <gui/set/cards_panel.hpp>
|
||||||
#include <gui/control/card_list.hpp>
|
#include <gui/control/card_list.hpp>
|
||||||
|
#include <gui/control/card_editor.hpp>
|
||||||
#include <gui/icon_menu.hpp>
|
#include <gui/icon_menu.hpp>
|
||||||
#include <data/set.hpp>
|
#include <data/set.hpp>
|
||||||
#include <data/action/set.hpp>
|
#include <data/action/set.hpp>
|
||||||
@@ -21,8 +22,9 @@ CardsPanel::CardsPanel(Window* parent, int id)
|
|||||||
: SetWindowPanel(parent, id, false)
|
: SetWindowPanel(parent, id, false)
|
||||||
{
|
{
|
||||||
// init controls
|
// init controls
|
||||||
|
// Panel* notesP
|
||||||
|
editor = new CardEditor(this, ID_EDITOR);
|
||||||
// splitter = new SplitterWindow(&this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0);
|
// splitter = new SplitterWindow(&this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0);
|
||||||
// card_list = new EditCardList(splitter, idCardList);
|
|
||||||
// card_list = new EditCardList(splitter, ID_CARD_LIST);
|
// card_list = new EditCardList(splitter, ID_CARD_LIST);
|
||||||
card_list = new CardListBase(this, ID_CARD_LIST);
|
card_list = new CardListBase(this, ID_CARD_LIST);
|
||||||
// init splitter
|
// init splitter
|
||||||
@@ -37,6 +39,7 @@ CardsPanel::CardsPanel(Window* parent, int id)
|
|||||||
SetSizer(s);
|
SetSizer(s);
|
||||||
*/
|
*/
|
||||||
wxSizer* s = new wxBoxSizer(wxHORIZONTAL);
|
wxSizer* s = new wxBoxSizer(wxHORIZONTAL);
|
||||||
|
s->Add(editor, 0, wxRIGHT, 2);
|
||||||
s->Add(card_list, 1, wxEXPAND);
|
s->Add(card_list, 1, wxEXPAND);
|
||||||
SetSizer(s);
|
SetSizer(s);
|
||||||
}
|
}
|
||||||
@@ -46,7 +49,7 @@ CardsPanel::~CardsPanel() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void CardsPanel::onChangeSet() {
|
void CardsPanel::onChangeSet() {
|
||||||
// editor->setSet(set);
|
editor->setSet(set);
|
||||||
card_list->setSet(set);
|
card_list->setSet(set);
|
||||||
/* // resize editor
|
/* // resize editor
|
||||||
Sizer* s = sizer;
|
Sizer* s = sizer;
|
||||||
@@ -207,5 +210,5 @@ CardP CardsPanel::selectedCard() const {
|
|||||||
}
|
}
|
||||||
void CardsPanel::selectCard(const CardP& card) {
|
void CardsPanel::selectCard(const CardP& card) {
|
||||||
card_list->setCard(card);
|
card_list->setCard(card);
|
||||||
// editor->setCard(card);
|
editor->setCard(*card);
|
||||||
}
|
}
|
||||||
@@ -14,6 +14,7 @@
|
|||||||
|
|
||||||
class wxSplitterWindow;
|
class wxSplitterWindow;
|
||||||
class CardListBase;
|
class CardListBase;
|
||||||
|
class DataEditor;
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------- : CardsPanel
|
// ----------------------------------------------------------------------------- : CardsPanel
|
||||||
|
|
||||||
@@ -92,9 +93,9 @@ class CardsPanel : public SetWindowPanel {
|
|||||||
private:
|
private:
|
||||||
// --------------------------------------------------- : Controls
|
// --------------------------------------------------- : Controls
|
||||||
wxSplitterWindow* splitter;
|
wxSplitterWindow* splitter;
|
||||||
// Editor* editor;
|
DataEditor* editor;
|
||||||
CardListBase* card_list;
|
CardListBase* card_list;
|
||||||
// DataTextCtrl* notes;
|
// DataTextCtrl* notes;
|
||||||
|
|
||||||
// --------------------------------------------------- : Menus & tools
|
// --------------------------------------------------- : Menus & tools
|
||||||
wxMenu* cardMenu, formatMenu;
|
wxMenu* cardMenu, formatMenu;
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
#include <gui/set/set_info_panel.hpp>
|
#include <gui/set/set_info_panel.hpp>
|
||||||
#include <gui/set/style_panel.hpp>
|
#include <gui/set/style_panel.hpp>
|
||||||
#include <gui/set/stats_panel.hpp>
|
#include <gui/set/stats_panel.hpp>
|
||||||
|
#include <gui/control/card_list.hpp>
|
||||||
#include <gui/about_window.hpp>
|
#include <gui/about_window.hpp>
|
||||||
#include <gui/new_window.hpp>
|
#include <gui/new_window.hpp>
|
||||||
#include <gui/icon_menu.hpp>
|
#include <gui/icon_menu.hpp>
|
||||||
@@ -540,12 +541,18 @@ void SetWindow::onHelpAbout(wxCommandEvent&) {
|
|||||||
wnd.ShowModal();
|
wnd.ShowModal();
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------- : Window events - menu - for child panel
|
// ----------------------------------------------------------------------------- : Window events - other
|
||||||
|
|
||||||
void SetWindow::onChildMenu(wxCommandEvent& ev) {
|
void SetWindow::onChildMenu(wxCommandEvent& ev) {
|
||||||
current_panel->onCommand(ev.GetId());
|
current_panel->onCommand(ev.GetId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SetWindow::onCardSelect(CardSelectEvent& ev) {
|
||||||
|
FOR_EACH(p, panels) {
|
||||||
|
p->selectCard(ev.card);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------- : Event table
|
// ----------------------------------------------------------------------------- : Event table
|
||||||
|
|
||||||
BEGIN_EVENT_TABLE(SetWindow, wxFrame)
|
BEGIN_EVENT_TABLE(SetWindow, wxFrame)
|
||||||
@@ -586,5 +593,5 @@ BEGIN_EVENT_TABLE(SetWindow, wxFrame)
|
|||||||
EVT_CLOSE ( SetWindow::onClose)
|
EVT_CLOSE ( SetWindow::onClose)
|
||||||
// EVT_TIMER (wxID_ANY, SetWindow::onTick)
|
// EVT_TIMER (wxID_ANY, SetWindow::onTick)
|
||||||
// EVT_IDLE ( SetWindow::onIdle)
|
// EVT_IDLE ( SetWindow::onIdle)
|
||||||
// EVT_CARD_SELECT (wxID_ANY, SetWindow::onCardSelect)
|
EVT_CARD_SELECT (wxID_ANY, SetWindow::onCardSelect)
|
||||||
END_EVENT_TABLE ()
|
END_EVENT_TABLE ()
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
class IconMenu;
|
class IconMenu;
|
||||||
class SetWindowPanel;
|
class SetWindowPanel;
|
||||||
class wxFindDialogEvent;
|
class wxFindDialogEvent;
|
||||||
|
struct CardSelectEvent;
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------- : SetWindow
|
// ----------------------------------------------------------------------------- : SetWindow
|
||||||
|
|
||||||
@@ -150,9 +151,11 @@ class SetWindow : public wxFrame, public SetView {
|
|||||||
void onHelpIndex (wxCommandEvent&);
|
void onHelpIndex (wxCommandEvent&);
|
||||||
void onHelpAbout (wxCommandEvent&);
|
void onHelpAbout (wxCommandEvent&);
|
||||||
|
|
||||||
// --------------------------------------------------- : Window events - menu - for child panel
|
// --------------------------------------------------- : Window events - other
|
||||||
|
|
||||||
void onChildMenu (wxCommandEvent&);
|
void onChildMenu (wxCommandEvent&);
|
||||||
|
|
||||||
|
void onCardSelect (CardSelectEvent&);
|
||||||
};
|
};
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------- : EOF
|
// ----------------------------------------------------------------------------- : EOF
|
||||||
|
|||||||
@@ -362,6 +362,12 @@
|
|||||||
<Filter
|
<Filter
|
||||||
Name="control"
|
Name="control"
|
||||||
Filter="">
|
Filter="">
|
||||||
|
<File
|
||||||
|
RelativePath=".\gui\control\card_editor.cpp">
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\gui\control\card_editor.hpp">
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\gui\control\card_list.cpp">
|
RelativePath=".\gui\control\card_list.cpp">
|
||||||
</File>
|
</File>
|
||||||
|
|||||||
@@ -7,8 +7,14 @@
|
|||||||
// ----------------------------------------------------------------------------- : Includes
|
// ----------------------------------------------------------------------------- : Includes
|
||||||
|
|
||||||
#include <render/card/viewer.hpp>
|
#include <render/card/viewer.hpp>
|
||||||
|
#include <render/value/viewer.hpp>
|
||||||
|
#include <data/set.hpp>
|
||||||
|
#include <data/stylesheet.hpp>
|
||||||
|
#include <data/card.hpp>
|
||||||
#include <data/field.hpp>
|
#include <data/field.hpp>
|
||||||
|
|
||||||
|
DECLARE_TYPEOF_COLLECTION(ValueViewerP);
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------- : DataViewer
|
// ----------------------------------------------------------------------------- : DataViewer
|
||||||
|
|
||||||
|
|
||||||
@@ -28,9 +34,24 @@ Value* DataViewer::focusedValue() const { return nullptr; }
|
|||||||
|
|
||||||
// ----------------------------------------------------------------------------- : Setting data
|
// ----------------------------------------------------------------------------- : Setting data
|
||||||
|
|
||||||
|
void DataViewer::setCard(Card& card) {
|
||||||
|
assert(set);
|
||||||
|
setStyles(set->stylesheet->card_style);
|
||||||
|
setData(card.data);
|
||||||
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------- : Viewers
|
// ----------------------------------------------------------------------------- : Viewers
|
||||||
|
|
||||||
|
void DataViewer::setStyles(IndexMap<FieldP,StyleP>& styles) {
|
||||||
|
}
|
||||||
|
|
||||||
|
void DataViewer::setData(IndexMap<FieldP,ValueP>& values) {
|
||||||
|
FOR_EACH(v, viewers) {
|
||||||
|
v->setValue(values[v->getField()]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
ValueViewerP DataViewer::makeViewer(const StyleP& style) {
|
ValueViewerP DataViewer::makeViewer(const StyleP& style) {
|
||||||
return style->makeViewer(*this, style);
|
return style->makeViewer(*this, style);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,11 @@
|
|||||||
|
|
||||||
// ----------------------------------------------------------------------------- : ValueViewer
|
// ----------------------------------------------------------------------------- : ValueViewer
|
||||||
|
|
||||||
|
void ValueViewer::setValue(const ValueP& value) {
|
||||||
|
assert(value->fieldP == styleP->fieldP); // matching field
|
||||||
|
valueP = value;
|
||||||
|
onValueChange();
|
||||||
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------- : Development/debug
|
// ----------------------------------------------------------------------------- : Development/debug
|
||||||
|
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
#include <util/prec.hpp>
|
#include <util/prec.hpp>
|
||||||
#include <util/rotation.hpp>
|
#include <util/rotation.hpp>
|
||||||
#include <util/real_point.hpp>
|
#include <util/real_point.hpp>
|
||||||
|
#include <data/field.hpp>
|
||||||
|
|
||||||
class DataViewer;
|
class DataViewer;
|
||||||
class ValueAction;
|
class ValueAction;
|
||||||
@@ -26,7 +27,12 @@ class ValueViewer {
|
|||||||
public:
|
public:
|
||||||
/// Construct a ValueViewer, set the value at a later time
|
/// Construct a ValueViewer, set the value at a later time
|
||||||
ValueViewer(DataViewer& parent, const StyleP& style);
|
ValueViewer(DataViewer& parent, const StyleP& style);
|
||||||
virtual ~ValueViewer();
|
virtual ~ValueViewer() {}
|
||||||
|
|
||||||
|
/// Change the associated value
|
||||||
|
void setValue(const ValueP&);
|
||||||
|
/// Return the associated field
|
||||||
|
inline const FieldP& getField() const { return styleP->fieldP; }
|
||||||
|
|
||||||
// Draw this value
|
// Draw this value
|
||||||
virtual void draw(RotatedDC& dc) = 0;
|
virtual void draw(RotatedDC& dc) = 0;
|
||||||
@@ -46,13 +52,10 @@ class ValueViewer {
|
|||||||
/// Called when an action is performed on the associated value
|
/// Called when an action is performed on the associated value
|
||||||
virtual void onAction(const ValueAction&, bool undone) { onValueChange(); }
|
virtual void onAction(const ValueAction&, bool undone) { onValueChange(); }
|
||||||
|
|
||||||
/// Change the associated value
|
|
||||||
void setValue(const ValueP&);
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
DataViewer& viewer; ///< Our parent object
|
DataViewer& viewer; ///< Our parent object
|
||||||
StyleP style_; ///< The style of this viewer
|
StyleP styleP; ///< The style of this viewer
|
||||||
ValueP value_; ///< The value we are currently viewing
|
ValueP valueP; ///< The value we are currently viewing
|
||||||
|
|
||||||
/// Should this viewer render using a platform native look?
|
/// Should this viewer render using a platform native look?
|
||||||
bool nativeLook() const;
|
bool nativeLook() const;
|
||||||
@@ -70,8 +73,9 @@ class ValueViewer {
|
|||||||
public: \
|
public: \
|
||||||
Type(DataViewer& parent, const Type ## StyleP& style) \
|
Type(DataViewer& parent, const Type ## StyleP& style) \
|
||||||
private: \
|
private: \
|
||||||
inline Type##Style style() const { return *value_; } \
|
inline Type##Style& style() const { return *styleP; } \
|
||||||
inline Type##Value value() const { return *value_; }
|
inline Type##Value& value() const { return *valueP; } \
|
||||||
|
inline Type##Field& field() const { return styleP->field(); }
|
||||||
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------- : EOF
|
// ----------------------------------------------------------------------------- : EOF
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ class GetDefaultMember {
|
|||||||
/// Tell the reflection code we are not reading
|
/// Tell the reflection code we are not reading
|
||||||
inline bool reading() const { return false; }
|
inline bool reading() const { return false; }
|
||||||
inline bool isComplex() const { return false; }
|
inline bool isComplex() const { return false; }
|
||||||
|
inline void addAlias(int, const Char*, const Char*) {}
|
||||||
|
|
||||||
inline void handleAppVersion() {} // no effect
|
inline void handleAppVersion() {} // no effect
|
||||||
|
|
||||||
@@ -68,6 +69,7 @@ class GetMember : private GetDefaultMember {
|
|||||||
/// Tell the reflection code we are not reading
|
/// Tell the reflection code we are not reading
|
||||||
inline bool reading() const { return false; }
|
inline bool reading() const { return false; }
|
||||||
inline bool isComplex() const { return false; }
|
inline bool isComplex() const { return false; }
|
||||||
|
inline void addAlias(int, const Char*, const Char*) {}
|
||||||
|
|
||||||
/// The result, or script_nil if the member was not found
|
/// The result, or script_nil if the member was not found
|
||||||
inline ScriptValueP result() { return gdm.result(); }
|
inline ScriptValueP result() { return gdm.result(); }
|
||||||
|
|||||||
@@ -30,6 +30,11 @@ Reader::Reader(const String& filename)
|
|||||||
moveNext();
|
moveNext();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Reader::addAlias(Version end_version, const Char* a, const Char* b) {
|
||||||
|
if (app_version < end_version) {
|
||||||
|
aliasses[a] = b;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Reader::handleAppVersion() {
|
void Reader::handleAppVersion() {
|
||||||
if (enterBlock(_("mse_version"))) {
|
if (enterBlock(_("mse_version"))) {
|
||||||
@@ -113,6 +118,11 @@ void Reader::readLine() {
|
|||||||
}
|
}
|
||||||
key = cannocial_name_form(trim(line.substr(indent, pos - indent)));
|
key = cannocial_name_form(trim(line.substr(indent, pos - indent)));
|
||||||
value = pos == String::npos ? _("") : trim_left(line.substr(pos+1));
|
value = pos == String::npos ? _("") : trim_left(line.substr(pos+1));
|
||||||
|
// aliasses?
|
||||||
|
map<String,String>::const_iterator it = aliasses.find(key);
|
||||||
|
if (it != aliasses.end()) {
|
||||||
|
key = it->second;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Reader::unknownKey() {
|
void Reader::unknownKey() {
|
||||||
|
|||||||
@@ -46,6 +46,8 @@ class Reader {
|
|||||||
inline bool reading() const { return true; }
|
inline bool reading() const { return true; }
|
||||||
/// Is the thing currently being read 'complex', i.e. does it have children
|
/// Is the thing currently being read 'complex', i.e. does it have children
|
||||||
inline bool isComplex() const { return value.empty(); }
|
inline bool isComplex() const { return value.empty(); }
|
||||||
|
/// Add a as an alias for b, all keys a will be replaced with b, only if app_version < end_version
|
||||||
|
void addAlias(Version end_version, const Char* a, const Char* b);
|
||||||
|
|
||||||
/// Read and check the application version
|
/// Read and check the application version
|
||||||
void handleAppVersion();
|
void handleAppVersion();
|
||||||
@@ -80,7 +82,7 @@ class Reader {
|
|||||||
template <typename T> void handle(Scriptable<T>&);
|
template <typename T> void handle(Scriptable<T>&);
|
||||||
// special behaviour
|
// special behaviour
|
||||||
void handle(GameP&);
|
void handle(GameP&);
|
||||||
void handle(StyleSheet&);
|
void handle(StyleSheetP&);
|
||||||
|
|
||||||
// --------------------------------------------------- : Data
|
// --------------------------------------------------- : Data
|
||||||
/// App version this file was made with
|
/// App version this file was made with
|
||||||
@@ -98,6 +100,8 @@ class Reader {
|
|||||||
int expected_indent;
|
int expected_indent;
|
||||||
/// Did we just open a block (i.e. not read any more lines of it)?
|
/// Did we just open a block (i.e. not read any more lines of it)?
|
||||||
bool just_opened;
|
bool just_opened;
|
||||||
|
/// Aliasses for compatability
|
||||||
|
map<String, String> aliasses;
|
||||||
|
|
||||||
/// Filename for error messages
|
/// Filename for error messages
|
||||||
String filename;
|
String filename;
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ class Writer {
|
|||||||
/// Tell the reflection code we are not reading
|
/// Tell the reflection code we are not reading
|
||||||
inline bool reading() const { return false; }
|
inline bool reading() const { return false; }
|
||||||
inline bool isComplex() const { return false; }
|
inline bool isComplex() const { return false; }
|
||||||
|
inline void addAlias(int, const Char*, const Char*) {}
|
||||||
|
|
||||||
/// Write the application version
|
/// Write the application version
|
||||||
void handleAppVersion();
|
void handleAppVersion();
|
||||||
@@ -65,7 +66,7 @@ class Writer {
|
|||||||
template <typename T> void handle(const Scriptable<T>&);
|
template <typename T> void handle(const Scriptable<T>&);
|
||||||
// special behaviour
|
// special behaviour
|
||||||
void handle(const GameP&);
|
void handle(const GameP&);
|
||||||
void handle(const StyleSheet&);
|
void handle(const StyleSheetP&);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// --------------------------------------------------- : Data
|
// --------------------------------------------------- : Data
|
||||||
|
|||||||
Reference in New Issue
Block a user