mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-10 04:57:00 -04:00
change the time_modified of cards in actions, and restore it on undo
git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@1324 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
#include <data/field/image.hpp>
|
||||
#include <data/field/symbol.hpp>
|
||||
#include <data/field/package_choice.hpp>
|
||||
#include <data/card.hpp>
|
||||
#include <util/tagged_string.hpp>
|
||||
#include <data/set.hpp> // for ValueActionPerformer
|
||||
|
||||
@@ -25,8 +26,14 @@ String ValueAction::getName(bool to_undo) const {
|
||||
return _ACTION_1_("change", valueP->fieldP->name);
|
||||
}
|
||||
|
||||
void ValueAction::perform(bool to_undo) {
|
||||
if (card) {
|
||||
swap(const_cast<Card*>(card)->time_modified, old_time_modified);
|
||||
}
|
||||
}
|
||||
|
||||
void ValueAction::isOnCard(Card* card) {
|
||||
const_cast<ValueAction*>(this)->card = card;
|
||||
this->card = card;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------- : Simple
|
||||
@@ -52,6 +59,7 @@ class SimpleValueAction : public ValueAction {
|
||||
{}
|
||||
|
||||
virtual void perform(bool to_undo) {
|
||||
ValueAction::perform(to_undo);
|
||||
swap_value(static_cast<T&>(*valueP), new_value);
|
||||
valueP->onAction(*this, to_undo); // notify value
|
||||
}
|
||||
@@ -95,6 +103,7 @@ TextValueAction::TextValueAction(const TextValueP& value, size_t start, size_t e
|
||||
String TextValueAction::getName(bool to_undo) const { return name; }
|
||||
|
||||
void TextValueAction::perform(bool to_undo) {
|
||||
ValueAction::perform(to_undo);
|
||||
swap_value(value(), new_value);
|
||||
swap(selection_end, new_selection_end);
|
||||
valueP->onAction(*this, to_undo); // notify value
|
||||
@@ -197,6 +206,7 @@ String TextToggleReminderAction::getName(bool to_undo) const {
|
||||
}
|
||||
|
||||
void TextToggleReminderAction::perform(bool to_undo) {
|
||||
ValueAction::perform(to_undo);
|
||||
TextValue& value = static_cast<TextValue&>(*valueP);
|
||||
String& val = value.value.mutate();
|
||||
assert(pos + 4 < val.size());
|
||||
|
||||
@@ -36,15 +36,20 @@ DECLARE_POINTER_TYPE(PackageChoiceValue);
|
||||
/// An Action the changes a Value
|
||||
class ValueAction : public Action {
|
||||
public:
|
||||
inline ValueAction(const ValueP& value) : valueP(value), card(nullptr) {}
|
||||
inline ValueAction(const ValueP& value)
|
||||
: valueP(value), card(nullptr), old_time_modified(wxDateTime::Now())
|
||||
{}
|
||||
|
||||
virtual String getName(bool to_undo) const;
|
||||
virtual void perform(bool to_undo);
|
||||
|
||||
/// We know that the value is on the given card, add that information
|
||||
void isOnCard(Card* card);
|
||||
|
||||
const ValueP valueP; ///< The modified value
|
||||
const Card* card; ///< The card the value is on, or null if it is not a card value
|
||||
private:
|
||||
wxDateTime old_time_modified;
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------- : Simple
|
||||
|
||||
Reference in New Issue
Block a user