mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-10 04:57:00 -04:00
settings get read&written
git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@11 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
@@ -7,9 +7,21 @@
|
|||||||
// ----------------------------------------------------------------------------- : Includes
|
// ----------------------------------------------------------------------------- : Includes
|
||||||
|
|
||||||
#include <data/game.hpp>
|
#include <data/game.hpp>
|
||||||
|
#include <util/io/package_manager.hpp>
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------- : Game
|
// ----------------------------------------------------------------------------- : Game
|
||||||
|
|
||||||
|
GameP Game::byName(const String& name) {
|
||||||
|
return packages.open<Game>(name + _(".mse-game"));
|
||||||
|
}
|
||||||
|
|
||||||
bool Game::isMagic() const {
|
bool Game::isMagic() const {
|
||||||
return name() == _("magic");
|
return name() == _("magic");
|
||||||
|
}
|
||||||
|
|
||||||
|
String Game::typeName() const { return _("game"); }
|
||||||
|
|
||||||
|
IMPLEMENT_REFLECTION(Game) {
|
||||||
|
REFLECT_N("full name", fullName);
|
||||||
|
REFLECT_N("icon", iconFilename);
|
||||||
}
|
}
|
||||||
+10
-3
@@ -12,9 +12,8 @@
|
|||||||
#include <util/prec.hpp>
|
#include <util/prec.hpp>
|
||||||
#include <util/io/package.hpp>
|
#include <util/io/package.hpp>
|
||||||
|
|
||||||
#ifndef HEADER_DATA_CARD
|
|
||||||
DECLARE_POINTER_TYPE(Field);
|
DECLARE_POINTER_TYPE(Field);
|
||||||
#endif
|
DECLARE_POINTER_TYPE(Game);
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------- : Game
|
// ----------------------------------------------------------------------------- : Game
|
||||||
|
|
||||||
@@ -25,8 +24,16 @@ class Game : public Packaged {
|
|||||||
vector<FieldP> setFields;
|
vector<FieldP> setFields;
|
||||||
vector<FieldP> cardFields;
|
vector<FieldP> cardFields;
|
||||||
|
|
||||||
// Is this Magic the Gathering?
|
/// Loads the game with a particular name, for example "magic"
|
||||||
|
static GameP byName(const String& name);
|
||||||
|
|
||||||
|
/// Is this Magic the Gathering?
|
||||||
bool isMagic() const;
|
bool isMagic() const;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
String typeName() const;
|
||||||
|
|
||||||
|
DECLARE_REFLECTION();
|
||||||
};
|
};
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------- : EOF
|
// ----------------------------------------------------------------------------- : EOF
|
||||||
|
|||||||
@@ -11,12 +11,21 @@
|
|||||||
|
|
||||||
// ----------------------------------------------------------------------------- : Set
|
// ----------------------------------------------------------------------------- : Set
|
||||||
|
|
||||||
|
Set::Set(const GameP& game)
|
||||||
|
: game(game)
|
||||||
|
{}
|
||||||
|
|
||||||
|
Set::Set() {}
|
||||||
|
|
||||||
|
String Set::typeName() const { return _("set"); }
|
||||||
|
|
||||||
IMPLEMENT_REFLECTION(Set) {
|
IMPLEMENT_REFLECTION(Set) {
|
||||||
WITH_DYNAMIC_ARG(game_for_new_cards, game.get()) {
|
WITH_DYNAMIC_ARG(game_for_new_cards, game.get()) {
|
||||||
REFLECT_N("card", cards);
|
REFLECT_N("card", cards);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------- : SetView
|
// ----------------------------------------------------------------------------- : SetView
|
||||||
|
|
||||||
SetView::SetView() {}
|
SetView::SetView() {}
|
||||||
|
|||||||
@@ -23,6 +23,9 @@ DECLARE_POINTER_TYPE(Game);
|
|||||||
/// A set of cards
|
/// A set of cards
|
||||||
class Set : public Packaged {
|
class Set : public Packaged {
|
||||||
public:
|
public:
|
||||||
|
/// Create a set using the given game
|
||||||
|
Set(const GameP& game);
|
||||||
|
|
||||||
/// The game this set uses
|
/// The game this set uses
|
||||||
GameP game;
|
GameP game;
|
||||||
/// The cards in the set
|
/// The cards in the set
|
||||||
@@ -30,6 +33,12 @@ class Set : public Packaged {
|
|||||||
/// Actions performed on this set and the cards in it
|
/// Actions performed on this set and the cards in it
|
||||||
ActionStack actions;
|
ActionStack actions;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
String typeName() const;
|
||||||
|
|
||||||
|
// default constructor accessible to Reader
|
||||||
|
Set();
|
||||||
|
|
||||||
DECLARE_REFLECTION();
|
DECLARE_REFLECTION();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ class SetWindowPanel : public wxPanel, public SetView {
|
|||||||
SetWindowPanel(Window* parent, int id, bool autoTabbing = false);
|
SetWindowPanel(Window* parent, int id, bool autoTabbing = false);
|
||||||
|
|
||||||
/// We will probably want to respond to set changes
|
/// We will probably want to respond to set changes
|
||||||
virtual void onSetChange();
|
virtual void onSetChange() {}
|
||||||
|
|
||||||
// --------------------------------------------------- : Meta information
|
// --------------------------------------------------- : Meta information
|
||||||
|
|
||||||
@@ -50,6 +50,8 @@ class SetWindowPanel : public wxPanel, public SetView {
|
|||||||
|
|
||||||
/// Should return true if this panel wants to get focus to show an action
|
/// Should return true if this panel wants to get focus to show an action
|
||||||
virtual bool wantsToHandle(const Action&) { return false; }
|
virtual bool wantsToHandle(const Action&) { return false; }
|
||||||
|
/// Handle an action that changes the current set
|
||||||
|
virtual void onAction(const Action&) {}
|
||||||
/// The settings for rendering cards have changed, refresh card viewers/editors
|
/// The settings for rendering cards have changed, refresh card viewers/editors
|
||||||
virtual void onRenderSettingsChange() {}
|
virtual void onRenderSettingsChange() {}
|
||||||
|
|
||||||
|
|||||||
@@ -9,3 +9,7 @@
|
|||||||
#include <gui/set/stats_panel.hpp>
|
#include <gui/set/stats_panel.hpp>
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------- : StatsPanel
|
// ----------------------------------------------------------------------------- : StatsPanel
|
||||||
|
|
||||||
|
StatsPanel::StatsPanel(Window* parent, int id)
|
||||||
|
: SetWindowPanel(parent, id)
|
||||||
|
{}
|
||||||
|
|||||||
@@ -14,6 +14,12 @@
|
|||||||
|
|
||||||
// ----------------------------------------------------------------------------- : StatsPanel
|
// ----------------------------------------------------------------------------- : StatsPanel
|
||||||
|
|
||||||
|
class StatsPanel : public SetWindowPanel {
|
||||||
|
public:
|
||||||
|
StatsPanel(Window* parent, int id);
|
||||||
|
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------- : EOF
|
// ----------------------------------------------------------------------------- : EOF
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
+20
-16
@@ -24,7 +24,7 @@ DECLARE_TYPEOF_COLLECTION(SetWindowPanel*);
|
|||||||
|
|
||||||
// ----------------------------------------------------------------------------- : Constructor
|
// ----------------------------------------------------------------------------- : Constructor
|
||||||
|
|
||||||
SetWindow::SetWindow(Window* parent)
|
SetWindow::SetWindow(Window* parent, const SetP& set)
|
||||||
: wxFrame(parent, wxID_ANY, _("Magic Set Editor"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_STYLE | wxNO_FULL_REPAINT_ON_RESIZE)
|
: wxFrame(parent, wxID_ANY, _("Magic Set Editor"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_STYLE | wxNO_FULL_REPAINT_ON_RESIZE)
|
||||||
, currentPanel(nullptr)
|
, currentPanel(nullptr)
|
||||||
, findDialog(nullptr)
|
, findDialog(nullptr)
|
||||||
@@ -120,13 +120,16 @@ SetWindow::SetWindow(Window* parent)
|
|||||||
// addPanel(menuWindow, tabBar, new StatsPanel (this, wxID_ANY), 3, _("F9"));
|
// addPanel(menuWindow, tabBar, new StatsPanel (this, wxID_ANY), 3, _("F9"));
|
||||||
//addPanel(*s, *menuWindow, *tabBar, new DraftPanel (&this, wxID_ANY), 4, _("F10"))
|
//addPanel(*s, *menuWindow, *tabBar, new DraftPanel (&this, wxID_ANY), 4, _("F10"))
|
||||||
// selectPanel(idWindowMin + 4); // select cards panel
|
// selectPanel(idWindowMin + 4); // select cards panel
|
||||||
|
|
||||||
|
addPanel(menuWindow, tabBar, new StatsPanel (this, wxID_ANY), 0, _("F9"));
|
||||||
|
selectPanel(ID_WINDOW_MIN); // test
|
||||||
|
|
||||||
// loose ends
|
// loose ends
|
||||||
tabBar->Realize();
|
tabBar->Realize();
|
||||||
// setSize(settings.SetWindowWidth, settings.SetWindowHeight);
|
SetSize(settings.setWindowWidth, settings.setWindowHeight);
|
||||||
// if (settings.SetWindowMaximized) {
|
if (settings.setWindowMaximized) {
|
||||||
// maximize();
|
Maximize();
|
||||||
// }
|
}
|
||||||
// SetWindows.push_back(&this); // register this window
|
// SetWindows.push_back(&this); // register this window
|
||||||
// timer.owner = &this;
|
// timer.owner = &this;
|
||||||
// timer.start(10);
|
// timer.start(10);
|
||||||
@@ -134,20 +137,22 @@ SetWindow::SetWindow(Window* parent)
|
|||||||
// note: this still sends events for menu and toolbar items!
|
// note: this still sends events for menu and toolbar items!
|
||||||
wxUpdateUIEvent::SetMode(wxUPDATE_UI_PROCESS_SPECIFIED);
|
wxUpdateUIEvent::SetMode(wxUPDATE_UI_PROCESS_SPECIFIED);
|
||||||
SetExtraStyle(wxWS_EX_PROCESS_UI_UPDATES);
|
SetExtraStyle(wxWS_EX_PROCESS_UI_UPDATES);
|
||||||
|
|
||||||
|
setSet(set);
|
||||||
}
|
}
|
||||||
|
|
||||||
SetWindow::~SetWindow() {
|
SetWindow::~SetWindow() {
|
||||||
// store window size in settings
|
// store window size in settings
|
||||||
// wxSize s = getSize();
|
wxSize s = GetSize();
|
||||||
// settings.SetWindowMaximized = isMaximized();
|
settings.setWindowMaximized = IsMaximized();
|
||||||
// if (!isMaximized()) {
|
if (!IsMaximized()) {
|
||||||
// settings.SetWindowWidth = s.GetWidth();
|
settings.setWindowWidth = s.GetWidth();
|
||||||
// settings.SetWindowHeight = s.GetHeight();
|
settings.setWindowHeight = s.GetHeight();
|
||||||
// }
|
}
|
||||||
// // destroy ui of selected panel
|
// destroy ui of selected panel
|
||||||
// currentPanel->destroyUI(GetToolBar(), GetMenuBar());
|
currentPanel->destroyUI(GetToolBar(), GetMenuBar());
|
||||||
// cleanup (see find stuff)
|
// cleanup (see find stuff)
|
||||||
// delete findDialog;
|
delete findDialog;
|
||||||
// remove from list of main windows
|
// remove from list of main windows
|
||||||
// SetWindows.erase(remove(SetWindows.begin(), SetWindows.end(), &this));
|
// SetWindows.erase(remove(SetWindows.begin(), SetWindows.end(), &this));
|
||||||
// stop updating
|
// stop updating
|
||||||
@@ -511,8 +516,7 @@ void SetWindow::onEditPreferences(wxCommandEvent&) {
|
|||||||
// ----------------------------------------------------------------------------- : Window events - menu - window
|
// ----------------------------------------------------------------------------- : Window events - menu - window
|
||||||
|
|
||||||
void SetWindow::onWindowNewWindow(wxCommandEvent&) {
|
void SetWindow::onWindowNewWindow(wxCommandEvent&) {
|
||||||
SetWindow* newWindow = new SetWindow(nullptr);
|
SetWindow* newWindow = new SetWindow(nullptr, set);
|
||||||
newWindow->setSet(set);
|
|
||||||
newWindow->Show();
|
newWindow->Show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ class wxFindDialogEvent;
|
|||||||
class SetWindow : public wxFrame, public SetView {
|
class SetWindow : public wxFrame, public SetView {
|
||||||
public:
|
public:
|
||||||
/// Construct a SetWindow
|
/// Construct a SetWindow
|
||||||
SetWindow(Window* parent);
|
SetWindow(Window* parent, const SetP& set);
|
||||||
~SetWindow();
|
~SetWindow();
|
||||||
|
|
||||||
// --------------------------------------------------- : Set actions
|
// --------------------------------------------------- : Set actions
|
||||||
|
|||||||
+11
-4
@@ -6,7 +6,12 @@
|
|||||||
|
|
||||||
// ----------------------------------------------------------------------------- : Includes
|
// ----------------------------------------------------------------------------- : Includes
|
||||||
|
|
||||||
#include "util/prec.hpp"
|
#include <util/prec.hpp>
|
||||||
|
#include <data/game.hpp>
|
||||||
|
#include <data/set.hpp>
|
||||||
|
#include <data/settings.hpp>
|
||||||
|
#include <data/format/formats.hpp>
|
||||||
|
#include <gui/set/window.hpp>
|
||||||
#include <gui/symbol/window.hpp>
|
#include <gui/symbol/window.hpp>
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------- : Main function/class
|
// ----------------------------------------------------------------------------- : Main function/class
|
||||||
@@ -30,8 +35,10 @@ IMPLEMENT_APP(MSE)
|
|||||||
|
|
||||||
bool MSE::OnInit() {
|
bool MSE::OnInit() {
|
||||||
wxInitAllImageHandlers();
|
wxInitAllImageHandlers();
|
||||||
//initFileFilters()
|
initFileFormats();
|
||||||
Window* wnd = new SymbolWindow(0);
|
settings.read();
|
||||||
|
//Window* wnd = new SymbolWindow(nullptr);
|
||||||
|
Window* wnd = new SetWindow(nullptr, new_shared1<Set>(Game::byName(_("magic"))));
|
||||||
wnd->Show();
|
wnd->Show();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -39,7 +46,7 @@ bool MSE::OnInit() {
|
|||||||
// ----------------------------------------------------------------------------- : Exit
|
// ----------------------------------------------------------------------------- : Exit
|
||||||
|
|
||||||
int MSE::OnExit() {
|
int MSE::OnExit() {
|
||||||
// settings.write();
|
settings.write();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -328,6 +328,9 @@
|
|||||||
<File
|
<File
|
||||||
RelativePath=".\gui\set\cards_panel.hpp">
|
RelativePath=".\gui\set\cards_panel.hpp">
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\gui\set\panel.cpp">
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\gui\set\panel.hpp">
|
RelativePath=".\gui\set\panel.hpp">
|
||||||
</File>
|
</File>
|
||||||
@@ -768,6 +771,12 @@
|
|||||||
<File
|
<File
|
||||||
RelativePath=".\util\io\package.hpp">
|
RelativePath=".\util\io\package.hpp">
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\util\io\package_manager.cpp">
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\util\io\package_manager.hpp">
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\util\io\reader.cpp">
|
RelativePath=".\util\io\reader.cpp">
|
||||||
<FileConfiguration
|
<FileConfiguration
|
||||||
|
|||||||
@@ -111,6 +111,11 @@ template <> void Reader::handle(int& i) {
|
|||||||
value.ToLong(&l);
|
value.ToLong(&l);
|
||||||
i = l;
|
i = l;
|
||||||
}
|
}
|
||||||
|
template <> void Reader::handle(unsigned int& i) {
|
||||||
|
long l = 0;
|
||||||
|
value.ToLong(&l);
|
||||||
|
i = abs(l); // abs, because it will seem strange if -1 comes out as MAX_INT
|
||||||
|
}
|
||||||
template <> void Reader::handle(double& d) {
|
template <> void Reader::handle(double& d) {
|
||||||
value.ToDouble(&d);
|
value.ToDouble(&d);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -92,6 +92,9 @@ void Writer::handle(const String& value) {
|
|||||||
template <> void Writer::handle(const int& value) {
|
template <> void Writer::handle(const int& value) {
|
||||||
handle(String() << value);
|
handle(String() << value);
|
||||||
}
|
}
|
||||||
|
template <> void Writer::handle(const unsigned int& value) {
|
||||||
|
handle(String() << value);
|
||||||
|
}
|
||||||
template <> void Writer::handle(const double& value) {
|
template <> void Writer::handle(const double& value) {
|
||||||
handle(String() << value);
|
handle(String() << value);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user