mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-10 04:57:00 -04:00
Cleanup: rename ValueViewer::viewer -> parent; store CardP in ValueAction
This commit is contained in:
@@ -23,18 +23,23 @@
|
||||
|
||||
// ----------------------------------------------------------------------------- : ValueAction
|
||||
|
||||
ValueAction::ValueAction(const ValueP& value)
|
||||
: valueP(value), card(nullptr), old_time_modified(wxDateTime::Now())
|
||||
{}
|
||||
ValueAction::~ValueAction() {} // here because we need the destructor of Card
|
||||
|
||||
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);
|
||||
swap(card->time_modified, old_time_modified);
|
||||
}
|
||||
}
|
||||
|
||||
void ValueAction::isOnCard(Card* card) {
|
||||
this->card = card;
|
||||
void ValueAction::setCard(CardP const& card) {
|
||||
const_cast<CardP&>(this->card) = card;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------- : Simple
|
||||
@@ -253,13 +258,13 @@ void ScriptStyleEvent::perform(bool) {
|
||||
|
||||
// ----------------------------------------------------------------------------- : Action performer
|
||||
|
||||
ValueActionPerformer::ValueActionPerformer(const ValueP& value, Card* card, const SetP& set)
|
||||
ValueActionPerformer::ValueActionPerformer(const ValueP& value, CardP const& card, const SetP& set)
|
||||
: value(value), card(card), set(set)
|
||||
{}
|
||||
ValueActionPerformer::~ValueActionPerformer() {}
|
||||
|
||||
void ValueActionPerformer::addAction(unique_ptr<ValueAction>&& action) {
|
||||
action->isOnCard(card);
|
||||
action->setCard(card);
|
||||
set->actions.addAction(move(action));
|
||||
}
|
||||
|
||||
|
||||
@@ -17,9 +17,9 @@
|
||||
#include <util/action_stack.hpp>
|
||||
#include <util/defaultable.hpp>
|
||||
|
||||
class Card;
|
||||
class StyleSheet;
|
||||
class LocalFileName;
|
||||
DECLARE_POINTER_TYPE(Card);
|
||||
DECLARE_POINTER_TYPE(Set);
|
||||
DECLARE_POINTER_TYPE(Value);
|
||||
DECLARE_POINTER_TYPE(Style);
|
||||
@@ -36,18 +36,17 @@ DECLARE_POINTER_TYPE(PackageChoiceValue);
|
||||
/// An Action the changes a Value
|
||||
class ValueAction : public Action {
|
||||
public:
|
||||
inline ValueAction(const ValueP& value)
|
||||
: valueP(value), card(nullptr), old_time_modified(wxDateTime::Now())
|
||||
{}
|
||||
ValueAction(const ValueP& value);
|
||||
~ValueAction();
|
||||
|
||||
String getName(bool to_undo) const override;
|
||||
void perform(bool to_undo) override;
|
||||
|
||||
/// We know that the value is on the given card, add that information
|
||||
void isOnCard(Card* card);
|
||||
void setCard(CardP const& 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
|
||||
const CardP card; ///< The card the value is on, or null if it is not a card value
|
||||
private:
|
||||
wxDateTime old_time_modified;
|
||||
};
|
||||
@@ -166,7 +165,7 @@ public:
|
||||
/** Used to reduce coupling */
|
||||
class ValueActionPerformer {
|
||||
public:
|
||||
ValueActionPerformer(const ValueP& value, Card* card, const SetP& set);
|
||||
ValueActionPerformer(const ValueP& value, CardP const& card, const SetP& set);
|
||||
~ValueActionPerformer();
|
||||
/// Perform an action. The performer takes ownerwhip of the action.
|
||||
void addAction(unique_ptr<ValueAction>&& action);
|
||||
@@ -174,7 +173,7 @@ public:
|
||||
const ValueP value; ///< The value
|
||||
Package& getLocalPackage();
|
||||
private:
|
||||
Card* card; ///< Card the value is on (if any)
|
||||
SetP set; ///< Set for the actions
|
||||
CardP card; ///< Card the value is on (if any)
|
||||
SetP set; ///< Set for the actions
|
||||
};
|
||||
|
||||
|
||||
@@ -32,13 +32,15 @@ public:
|
||||
Rotation getRotation() const override;
|
||||
private:
|
||||
bool use_zoom_settings;
|
||||
double zoom = 1.0;
|
||||
double angle = 0.0;
|
||||
};
|
||||
Rotation UnzoomedDataViewer::getRotation() const {
|
||||
if (use_zoom_settings) {
|
||||
return DataViewer::getRotation();
|
||||
} else {
|
||||
if (!stylesheet) stylesheet = set->stylesheet;
|
||||
return Rotation(0, stylesheet->getCardRect(), 1.0, 1.0, ROTATION_ATTACH_TOP_LEFT);
|
||||
return Rotation(angle, stylesheet->getCardRect(), zoom, 1.0, ROTATION_ATTACH_TOP_LEFT);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user