adding & editing custom pack types now works.

git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@1328 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
twanvl
2009-01-10 01:37:03 +00:00
parent d3922cb59d
commit e3cdb2bea7
11 changed files with 152 additions and 23 deletions
+31
View File
@@ -10,11 +10,13 @@
#include <data/action/set.hpp>
#include <data/set.hpp>
#include <data/card.hpp>
#include <data/pack.hpp>
#include <data/stylesheet.hpp>
#include <util/error.hpp>
DECLARE_TYPEOF_COLLECTION(IndexMap<FieldP COMMA ValueP>);
DECLARE_TYPEOF_COLLECTION(CardP);
DECLARE_TYPEOF_COLLECTION(PackTypeP);
DECLARE_TYPEOF_COLLECTION(int);
// ----------------------------------------------------------------------------- : Add card
@@ -135,3 +137,32 @@ void ChangeCardHasStylingAction::perform(bool to_undo) {
card->has_styling = !card->has_styling;
swap(card->styling_data, styling_data);
}
// ----------------------------------------------------------------------------- : Pack types
AddPackAction::AddPackAction(AddingOrRemoving ar, Set& set, const PackTypeP& pack)
: PackTypesAction(set)
, action(ar, pack, set.pack_types)
{}
String AddPackAction::getName(bool to_undo) const {
return action.getName();
}
void AddPackAction::perform(bool to_undo) {
action.perform(set.pack_types, to_undo);
}
ChangePackAction::ChangePackAction(Set& set, size_t pos, const PackTypeP& pack)
: PackTypesAction(set)
, pos(pos), pack(pack)
{}
String ChangePackAction::getName(bool to_undo) const {
return _ACTION_1_("change",type_name(pack));
}
void ChangePackAction::perform(bool to_undo) {
swap(set.pack_types.at(pos), pack);
}