mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-11 05:07:00 -04:00
Reduce coupling between ValueEditors/Viewers and Set and StyleSheet.
- Adding of actions is done with an addAction function
- Files are read from
- getStylePackage for styling stuff (this is stylesheet)
- getLocalPackage for symbol and image values (this was the set)
git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@970 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
@@ -207,7 +207,7 @@ void CardsPanel::onCommand(int id) {
|
||||
card_list->selectNext();
|
||||
break;
|
||||
case ID_CARD_ADD:
|
||||
set->actions.add(new AddCardAction(*set));
|
||||
set->actions.addAction(new AddCardAction(*set));
|
||||
break;
|
||||
case ID_CARD_REMOVE:
|
||||
card_list->doDelete();
|
||||
|
||||
@@ -154,12 +154,12 @@ void KeywordsPanel::onCommand(int id) {
|
||||
list->selectNext();
|
||||
break;
|
||||
case ID_KEYWORD_ADD:
|
||||
set->actions.add(new AddKeywordAction(*set));
|
||||
set->actions.addAction(new AddKeywordAction(*set));
|
||||
break;
|
||||
case ID_KEYWORD_REMOVE:
|
||||
if (!list->getKeyword()->fixed) {
|
||||
if (list->canDelete()) {
|
||||
// only remove set keywords
|
||||
set->actions.add(new AddKeywordAction(REMOVE, *set, list->getKeyword()));
|
||||
list->doDelete();
|
||||
}
|
||||
break;
|
||||
case ID_KEYWORD_ADD_PARAM: {
|
||||
@@ -336,7 +336,7 @@ void KeywordsPanel::onModeChange(wxCommandEvent& ev) {
|
||||
if (!list->getKeyword()) return;
|
||||
int sel = mode->GetSelection();
|
||||
if (sel >= 0 && (size_t)sel < set->game->keyword_modes.size()) {
|
||||
set->actions.add(new ChangeKeywordModeAction(*list->getKeyword(), set->game->keyword_modes[sel]->name));
|
||||
set->actions.addAction(new ChangeKeywordModeAction(*list->getKeyword(), set->game->keyword_modes[sel]->name));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
//+----------------------------------------------------------------------------+
|
||||
//| Description: Magic Set Editor - Program to make Magic (tm) cards |
|
||||
//| Copyright: (C) 2001 - 2008 Twan van Laarhoven and "coppro" |
|
||||
//| License: GNU General Public License 2 or later (see file COPYING) |
|
||||
//+----------------------------------------------------------------------------+
|
||||
|
||||
// ----------------------------------------------------------------------------- : Includes
|
||||
|
||||
#include <util/prec.hpp>
|
||||
#include <gui/set/random_pack_panel.hpp>
|
||||
#include <gui/control/card_viewer.hpp>
|
||||
#include <gui/control/filtered_card_list.hpp>
|
||||
|
||||
// ----------------------------------------------------------------------------- : RandomPackPanel
|
||||
|
||||
RandomPackPanel::RandomPackPanel(Window* parent, int id)
|
||||
: SetWindowPanel(parent, id)
|
||||
{
|
||||
// init controls
|
||||
preview = new CardViewer(this, wxID_ANY);
|
||||
card_list = new FilteredCardList(this, wxID_ANY);
|
||||
// init sizer
|
||||
wxSizer* s = new wxBoxSizer(wxHORIZONTAL);
|
||||
s->Add(preview, 0, wxRIGHT, 2);
|
||||
wxSizer* s2 = new wxBoxSizer(wxVERTICAL);
|
||||
s2->Add(card_list, 1, wxEXPAND | wxTOP, 4);
|
||||
s->Add(s2, 1, wxEXPAND, 8);
|
||||
s->SetSizeHints(this);
|
||||
SetSizer(s);
|
||||
}
|
||||
|
||||
void RandomPackPanel::onChangeSet() {
|
||||
preview ->setSet(set);
|
||||
card_list->setSet(set);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------- : UI
|
||||
|
||||
void RandomPackPanel::initUI(wxToolBar* tb, wxMenuBar* mb) {
|
||||
// ?
|
||||
}
|
||||
|
||||
void RandomPackPanel::destroyUI(wxToolBar* tb, wxMenuBar* mb) {
|
||||
// ?
|
||||
}
|
||||
|
||||
void RandomPackPanel::onUpdateUI(wxUpdateUIEvent& ev) {
|
||||
// ?
|
||||
}
|
||||
|
||||
void RandomPackPanel::onCommand(int id) {
|
||||
// ?
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------- : Clipboard
|
||||
|
||||
bool RandomPackPanel::canCopy() const { return card_list->canCopy(); }
|
||||
void RandomPackPanel::doCopy() { card_list->doCopy(); }
|
||||
@@ -0,0 +1,45 @@
|
||||
//+----------------------------------------------------------------------------+
|
||||
//| Description: Magic Set Editor - Program to make Magic (tm) cards |
|
||||
//| Copyright: (C) 2001 - 2008 Twan van Laarhoven and "coppro" |
|
||||
//| License: GNU General Public License 2 or later (see file COPYING) |
|
||||
//+----------------------------------------------------------------------------+
|
||||
|
||||
#ifndef HEADER_GUI_SET_RANDOM_PACK_PANEL
|
||||
#define HEADER_GUI_SET_RANDOM_PACK_PANEL
|
||||
|
||||
// ----------------------------------------------------------------------------- : Includes
|
||||
|
||||
#include <util/prec.hpp>
|
||||
#include <gui/set/panel.hpp>
|
||||
|
||||
class CardViewer;
|
||||
class FilteredCardList;
|
||||
|
||||
// ----------------------------------------------------------------------------- : RandomPackPanel
|
||||
|
||||
/// A SetWindowPanel for creating random booster packs
|
||||
class RandomPackPanel : public SetWindowPanel {
|
||||
public:
|
||||
RandomPackPanel(Window* parent, int id);
|
||||
|
||||
// --------------------------------------------------- : UI
|
||||
|
||||
virtual void onChangeSet();
|
||||
|
||||
virtual void initUI (wxToolBar* tb, wxMenuBar* mb);
|
||||
virtual void destroyUI(wxToolBar* tb, wxMenuBar* mb);
|
||||
virtual void onUpdateUI(wxUpdateUIEvent&);
|
||||
virtual void onCommand(int id);
|
||||
|
||||
// --------------------------------------------------- : Clipboard
|
||||
|
||||
virtual bool canCopy() const;
|
||||
virtual void doCopy();
|
||||
|
||||
private:
|
||||
CardViewer* preview; ///< Card preview
|
||||
FilteredCardList* card_list; ///< The list of cards
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------- : EOF
|
||||
#endif
|
||||
@@ -131,18 +131,18 @@ void StylePanel::onStyleSelect(wxCommandEvent&) {
|
||||
// select no special style when selecting the same style as the set default
|
||||
stylesheet = StyleSheetP();
|
||||
}
|
||||
set->actions.add(new ChangeCardStyleAction(card, stylesheet));
|
||||
set->actions.addAction(new ChangeCardStyleAction(card, stylesheet));
|
||||
Layout();
|
||||
}
|
||||
}
|
||||
|
||||
void StylePanel::onUseForAll(wxCommandEvent&) {
|
||||
set->actions.add(new ChangeSetStyleAction(*set, card));
|
||||
set->actions.addAction(new ChangeSetStyleAction(*set, card));
|
||||
Layout();
|
||||
}
|
||||
|
||||
void StylePanel::onUseCustom(wxCommandEvent&) {
|
||||
set->actions.add(new ChangeCardHasStylingAction(*set, card));
|
||||
set->actions.addAction(new ChangeCardHasStylingAction(*set, card));
|
||||
}
|
||||
|
||||
BEGIN_EVENT_TABLE(StylePanel, wxPanel)
|
||||
|
||||
Reference in New Issue
Block a user