mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-12 21:47:00 -04:00
Fix reading of symbols: perform after_reading for derived classes
This commit is contained in:
+16
-8
@@ -144,6 +144,10 @@ SymbolPartP read_new<SymbolPart>(Reader& reader) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void after_reading(SymbolPart& part, Version v) {
|
||||||
|
part.after_reading(v);
|
||||||
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------- : SymbolShape
|
// ----------------------------------------------------------------------------- : SymbolShape
|
||||||
|
|
||||||
IMPLEMENT_REFLECTION_ENUM(SymbolShapeCombine) {
|
IMPLEMENT_REFLECTION_ENUM(SymbolShapeCombine) {
|
||||||
@@ -161,22 +165,22 @@ IMPLEMENT_REFLECTION(SymbolShape) {
|
|||||||
REFLECT(points);
|
REFLECT(points);
|
||||||
}
|
}
|
||||||
|
|
||||||
void after_reading(SymbolShape& shape, Version version) {
|
void SymbolShape::after_reading(Version version) {
|
||||||
// Fixes after reading
|
// Fixes after reading
|
||||||
// enforce constraints
|
// enforce constraints
|
||||||
shape.enforceConstraints();
|
enforceConstraints();
|
||||||
if (version == Version()) {
|
if (version == Version()) {
|
||||||
// this is a <= 0.1.2 symbol, points range [0...500] instead of [0...1]
|
// this is a <= 0.1.2 symbol, points range [0...500] instead of [0...1]
|
||||||
shape.updateBounds();
|
updateBounds();
|
||||||
if (shape.bounds.max.x < 100 || shape.bounds.max.y < 100) return;
|
if (bounds.max.x < 100 || bounds.max.y < 100) return;
|
||||||
// adjust it
|
// adjust it
|
||||||
FOR_EACH(p, shape.points) {
|
FOR_EACH(p, points) {
|
||||||
p->pos /= 500.0;
|
p->pos /= 500.0;
|
||||||
p->delta_before /= 500.0;
|
p->delta_before /= 500.0;
|
||||||
p->delta_after /= 500.0;
|
p->delta_after /= 500.0;
|
||||||
}
|
}
|
||||||
if (shape.name.empty()) shape.name = _("Shape");
|
if (name.empty()) name = _("Shape");
|
||||||
shape.updateBounds();
|
updateBounds();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -325,7 +329,11 @@ IMPLEMENT_REFLECTION(SymbolGroup) {
|
|||||||
|
|
||||||
IMPLEMENT_REFLECTION(Symbol) {
|
IMPLEMENT_REFLECTION(Symbol) {
|
||||||
REFLECT(parts);
|
REFLECT(parts);
|
||||||
REFLECT_IF_READING updateBounds();
|
}
|
||||||
|
|
||||||
|
void Symbol::after_reading(Version v) {
|
||||||
|
SymbolGroup::after_reading(v);
|
||||||
|
updateBounds();
|
||||||
}
|
}
|
||||||
|
|
||||||
double Symbol::aspectRatio() const {
|
double Symbol::aspectRatio() const {
|
||||||
|
|||||||
+5
-1
@@ -169,9 +169,12 @@ class SymbolPart : public IntrusivePtrVirtualBase {
|
|||||||
virtual Bounds calculateBounds(const Vector2D& origin, const Matrix2D& m, bool is_identity) = 0;
|
virtual Bounds calculateBounds(const Vector2D& origin, const Matrix2D& m, bool is_identity) = 0;
|
||||||
|
|
||||||
DECLARE_REFLECTION_VIRTUAL();
|
DECLARE_REFLECTION_VIRTUAL();
|
||||||
|
virtual void after_reading(Version) {}
|
||||||
|
friend void after_reading(SymbolPart&, Version);
|
||||||
};
|
};
|
||||||
|
|
||||||
template <> SymbolPartP read_new<SymbolPart>(Reader& reader);
|
template <> SymbolPartP read_new<SymbolPart>(Reader& reader);
|
||||||
|
void after_reading(SymbolPart&, Version);
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------- : SymbolShape
|
// ----------------------------------------------------------------------------- : SymbolShape
|
||||||
|
|
||||||
@@ -221,8 +224,8 @@ class SymbolShape : public SymbolPart {
|
|||||||
virtual Bounds calculateBounds(const Vector2D& origin, const Matrix2D& m, bool is_identity);
|
virtual Bounds calculateBounds(const Vector2D& origin, const Matrix2D& m, bool is_identity);
|
||||||
|
|
||||||
DECLARE_REFLECTION_OVERRIDE();
|
DECLARE_REFLECTION_OVERRIDE();
|
||||||
|
void after_reading(Version) override;
|
||||||
};
|
};
|
||||||
void after_reading(SymbolShape&, Version);
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------- : SymbolGroup
|
// ----------------------------------------------------------------------------- : SymbolGroup
|
||||||
|
|
||||||
@@ -289,6 +292,7 @@ class Symbol : public SymbolGroup {
|
|||||||
double aspectRatio() const;
|
double aspectRatio() const;
|
||||||
|
|
||||||
DECLARE_REFLECTION_OVERRIDE();
|
DECLARE_REFLECTION_OVERRIDE();
|
||||||
|
void after_reading(Version) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
/// A default symbol: a square
|
/// A default symbol: a square
|
||||||
|
|||||||
Reference in New Issue
Block a user