mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-10 04:57:00 -04:00
actions for changing the style
git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@140 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
@@ -13,7 +13,9 @@
|
||||
#include <util/window_id.hpp>
|
||||
#include <data/set.hpp>
|
||||
#include <data/game.hpp>
|
||||
#include <data/card.hpp>
|
||||
#include <data/stylesheet.hpp>
|
||||
#include <data/action/set.hpp>
|
||||
|
||||
// ----------------------------------------------------------------------------- : StylePanel
|
||||
|
||||
@@ -41,14 +43,54 @@ StylePanel::StylePanel(Window* parent, int id)
|
||||
|
||||
void StylePanel::onChangeSet() {
|
||||
list->showData<StyleSheet>(set->game->name() + _("-*"));
|
||||
list->select(set->stylesheet->name());
|
||||
list->select(set->stylesheet->name(), false);
|
||||
editor->setSet(set);
|
||||
preview->setSet(set);
|
||||
card.reset();
|
||||
use_for_all->Enable(false);
|
||||
}
|
||||
|
||||
void StylePanel::onAction(const Action& action, bool undone) {
|
||||
TYPE_CASE_(action, ChangeSetStyleAction) {
|
||||
list->select(set->stylesheetFor(card)->name(), false);
|
||||
// updateSize();
|
||||
}
|
||||
TYPE_CASE(action, ChangeCardStyleAction) {
|
||||
if (action.card == card) {
|
||||
// preview->onAction(action, undone); // update the preview control before we determine our new size
|
||||
list->select(set->stylesheetFor(card)->name(), false);
|
||||
// updateSize();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------- : Selection
|
||||
|
||||
void StylePanel::selectCard(const CardP& card) {
|
||||
this->card = card;
|
||||
preview->setCard(card);
|
||||
list->select(set->stylesheetFor(card)->name());
|
||||
list->select(set->stylesheetFor(card)->name(), false);
|
||||
use_for_all->Enable(card && card->stylesheet);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------- : Events
|
||||
|
||||
void StylePanel::onStyleSelect(wxCommandEvent&) {
|
||||
if (list->hasSelection()) {
|
||||
StyleSheetP stylesheet = list->getSelection<StyleSheet>();
|
||||
if (stylesheet == set->stylesheet) {
|
||||
// select no special style when selecting the same style as the set default
|
||||
stylesheet = StyleSheetP();
|
||||
}
|
||||
set->actions.add(new ChangeCardStyleAction(card, stylesheet));
|
||||
}
|
||||
}
|
||||
|
||||
void StylePanel::onUseForAll(wxCommandEvent&) {
|
||||
set->actions.add(new ChangeSetStyleAction(*set, card));
|
||||
}
|
||||
|
||||
BEGIN_EVENT_TABLE(StylePanel, wxPanel)
|
||||
EVT_GALLERY_SELECT(wxID_ANY, StylePanel::onStyleSelect)
|
||||
EVT_BUTTON (ID_STYLE_USE_FOR_ALL, StylePanel::onUseForAll)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
@@ -24,15 +24,22 @@ class StylePanel : public SetWindowPanel {
|
||||
StylePanel(Window* parent, int id);
|
||||
|
||||
virtual void onChangeSet();
|
||||
virtual void onAction(const Action&, bool undone);
|
||||
|
||||
// --------------------------------------------------- : Selection
|
||||
virtual void selectCard(const CardP& card);
|
||||
|
||||
private:
|
||||
DECLARE_EVENT_TABLE();
|
||||
|
||||
CardViewer* preview; ///< Card preview
|
||||
PackageList* list; ///< List of stylesheets
|
||||
StylingEditor* editor; ///< Editor for styling information
|
||||
wxButton* use_for_all;
|
||||
CardP card; ///< Card we are working on
|
||||
|
||||
void onStyleSelect(wxCommandEvent&);
|
||||
void onUseForAll(wxCommandEvent&);
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------- : EOF
|
||||
|
||||
Reference in New Issue
Block a user