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:
@@ -60,6 +60,10 @@ ValueViewer* DataEditor::focusedViewer() const {
|
||||
return FindFocus() == this ? current_viewer : nullptr;
|
||||
}
|
||||
|
||||
void DataEditor::addAction(Action* action) {
|
||||
set->actions.addAction(action);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------- : Selection
|
||||
|
||||
bool DataEditor::AcceptsFocus() const {
|
||||
|
||||
@@ -22,7 +22,7 @@ class DataEditor : public CardViewer {
|
||||
public:
|
||||
DataEditor(Window* parent, int id, long style = 0);
|
||||
|
||||
// --------------------------------------------------- : Utility for ValueViewers
|
||||
// --------------------------------------------------- : Utility for ValueViewers/Editors
|
||||
|
||||
virtual bool drawBorders() const;
|
||||
virtual bool drawEditing() const;
|
||||
@@ -30,6 +30,9 @@ class DataEditor : public CardViewer {
|
||||
virtual wxPen borderPen(bool active) const;
|
||||
virtual ValueViewer* focusedViewer() const;
|
||||
|
||||
virtual void addAction(Action* action);
|
||||
inline SetP getSetForActions() { return set; }
|
||||
|
||||
// --------------------------------------------------- : Selection
|
||||
|
||||
/// Select the given viewer, sends focus events
|
||||
|
||||
@@ -162,7 +162,7 @@ bool CardListBase::doPaste() {
|
||||
ok = data.getCards(set, new_cards);
|
||||
if (!ok) return false;
|
||||
// add card to set
|
||||
set->actions.add(new AddCardAction(ADD, *set, new_cards));
|
||||
set->actions.addAction(new AddCardAction(ADD, *set, new_cards));
|
||||
return true;
|
||||
}
|
||||
bool CardListBase::doDelete() {
|
||||
@@ -176,7 +176,7 @@ bool CardListBase::doDelete() {
|
||||
}
|
||||
if (cards_to_delete.empty()) return false;
|
||||
// delete cards
|
||||
set->actions.add(new AddCardAction(REMOVE, *set, cards_to_delete));
|
||||
set->actions.addAction(new AddCardAction(REMOVE, *set, cards_to_delete));
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -345,7 +345,7 @@ void CardListBase::onDrag(wxMouseEvent& ev) {
|
||||
findSelectedItemPos();
|
||||
if (item != selected_item_pos) {
|
||||
// move card in the set
|
||||
set->actions.add(new ReorderCardsAction(*set, item, selected_item_pos));
|
||||
set->actions.addAction(new ReorderCardsAction(*set, item, selected_item_pos));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -96,9 +96,9 @@ void KeywordList::updateUsageStatistics() {
|
||||
|
||||
// ----------------------------------------------------------------------------- : Clipboard
|
||||
|
||||
bool KeywordList::canCopy() const { return !!selected_item; }
|
||||
bool KeywordList::canCut() const { return canCopy() && !getKeyword()->fixed; }
|
||||
bool KeywordList::canPaste() const {
|
||||
bool KeywordList::canDelete() const { return !getKeyword()->fixed; }
|
||||
bool KeywordList::canCopy() const { return !!selected_item; }
|
||||
bool KeywordList::canPaste() const {
|
||||
return wxTheClipboard->IsSupported(KeywordDataObject::format);
|
||||
}
|
||||
|
||||
@@ -127,14 +127,14 @@ bool KeywordList::doPaste() {
|
||||
// add keyword to set
|
||||
KeywordP keyword = data.getKeyword(set);
|
||||
if (keyword) {
|
||||
set->actions.add(new AddKeywordAction(ADD, *set, keyword));
|
||||
set->actions.addAction(new AddKeywordAction(ADD, *set, keyword));
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
bool KeywordList::doDelete() {
|
||||
set->actions.add(new AddKeywordAction(REMOVE, *set, getKeyword()));
|
||||
set->actions.addAction(new AddKeywordAction(REMOVE, *set, getKeyword()));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -53,9 +53,9 @@ class KeywordList : public ItemList, public SetView {
|
||||
|
||||
// --------------------------------------------------- : Clipboard
|
||||
|
||||
bool canCut() const;
|
||||
bool canCopy() const;
|
||||
bool canPaste() const;
|
||||
bool canDelete() const;
|
||||
bool canCopy() const;
|
||||
bool canPaste() const;
|
||||
// Try to perform a clipboard operation, return success
|
||||
bool doCut();
|
||||
bool doCopy();
|
||||
|
||||
@@ -205,6 +205,12 @@ void SetInfoEditor::onChangeSet() {
|
||||
setData(set->data);
|
||||
}
|
||||
|
||||
Package& SetInfoEditor::getStylePackage() const {
|
||||
return DataEditor::getStylePackage();
|
||||
// TODO: Use the game
|
||||
//return getGame();
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------- : StylingEditor
|
||||
|
||||
StylingEditor::StylingEditor(Window* parent, int id, long style)
|
||||
@@ -232,7 +238,11 @@ ExportOptionsEditor::ExportOptionsEditor(Window* parent, int id, long style)
|
||||
{}
|
||||
|
||||
void ExportOptionsEditor::showExport(const ExportTemplateP& export_template) {
|
||||
this->export_template = export_template;
|
||||
setStyles(set->stylesheet, export_template->option_style);
|
||||
setData(settings.exportOptionsFor(*export_template));
|
||||
}
|
||||
|
||||
Package& ExportOptionsEditor::getStylePackage() const {
|
||||
return *export_template;
|
||||
}
|
||||
|
||||
@@ -58,6 +58,8 @@ class NativeLookEditor : public DataEditor {
|
||||
class SetInfoEditor : public NativeLookEditor {
|
||||
public:
|
||||
SetInfoEditor(Window* parent, int id, long style = 0);
|
||||
|
||||
virtual Package& getStylePackage() const;
|
||||
protected:
|
||||
virtual void onChangeSet();
|
||||
};
|
||||
@@ -73,7 +75,6 @@ class StylingEditor : public NativeLookEditor {
|
||||
void showStylesheet(const StyleSheetP& stylesheet);
|
||||
/// Show the styling for given card
|
||||
void showCard(const CardP& card);
|
||||
|
||||
protected:
|
||||
virtual void onChangeSet();
|
||||
};
|
||||
@@ -87,6 +88,10 @@ class ExportOptionsEditor : public NativeLookEditor {
|
||||
|
||||
/// Show the options for given export template
|
||||
void showExport(const ExportTemplateP& export_template);
|
||||
|
||||
virtual Package& getStylePackage() const;
|
||||
private:
|
||||
ExportTemplateP export_template;
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------- : EOF
|
||||
|
||||
Reference in New Issue
Block a user