mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-10 13:06:59 -04:00
Switched to a new coding style, which plays nicely with the Reader/Writer. This new style allows REFLECT to be used instead of REFLECT_N in most places.
git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@15 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
+37
-37
@@ -23,15 +23,15 @@ SymbolPartMoveAction::SymbolPartMoveAction(const set<SymbolPartP>& parts)
|
||||
, constrain(false)
|
||||
{}
|
||||
|
||||
String SymbolPartMoveAction::getName(bool toUndo) const {
|
||||
String SymbolPartMoveAction::getName(bool to_undo) const {
|
||||
return parts.size() == 1 ? _("Move shape") : _("Move shapes");
|
||||
}
|
||||
|
||||
void SymbolPartMoveAction::perform(bool toUndo) {
|
||||
void SymbolPartMoveAction::perform(bool to_undo) {
|
||||
// move the points back
|
||||
FOR_EACH(p, parts) {
|
||||
p->minPos -= moved;
|
||||
p->maxPos -= moved;
|
||||
p->min_pos -= moved;
|
||||
p->max_pos -= moved;
|
||||
FOR_EACH(pnt, p->points) {
|
||||
pnt->pos -= moved;
|
||||
}
|
||||
@@ -45,8 +45,8 @@ void SymbolPartMoveAction::move(const Vector2D& deltaDelta) {
|
||||
Vector2D d = constrainVector(delta, constrain);
|
||||
Vector2D dd = d - moved;
|
||||
FOR_EACH(p, parts) {
|
||||
p->minPos += dd;
|
||||
p->maxPos += dd;
|
||||
p->min_pos += dd;
|
||||
p->max_pos += dd;
|
||||
FOR_EACH(pnt, p->points) {
|
||||
pnt->pos += dd;
|
||||
}
|
||||
@@ -66,8 +66,8 @@ void SymbolPartMatrixAction::transform(const Vector2D& mx, const Vector2D& my) {
|
||||
FOR_EACH(p, parts) {
|
||||
FOR_EACH(pnt, p->points) {
|
||||
pnt->pos = (pnt->pos - center).mul(mx,my) + center;
|
||||
pnt->deltaBefore = pnt->deltaBefore.mul(mx,my);
|
||||
pnt->deltaAfter = pnt->deltaAfter .mul(mx,my);
|
||||
pnt->delta_before = pnt->delta_before.mul(mx,my);
|
||||
pnt->delta_after = pnt->delta_after .mul(mx,my);
|
||||
}
|
||||
// bounds change after transforming
|
||||
p->calculateBounds();
|
||||
@@ -81,11 +81,11 @@ SymbolPartRotateAction::SymbolPartRotateAction(const set<SymbolPartP>& parts, co
|
||||
, angle(0)
|
||||
{}
|
||||
|
||||
String SymbolPartRotateAction::getName(bool toUndo) const {
|
||||
String SymbolPartRotateAction::getName(bool to_undo) const {
|
||||
return parts.size() == 1 ? _("Rotate shape") : _("Rotate shapes");
|
||||
}
|
||||
|
||||
void SymbolPartRotateAction::perform(bool toUndo) {
|
||||
void SymbolPartRotateAction::perform(bool to_undo) {
|
||||
// move the points back
|
||||
rotateBy(-angle);
|
||||
angle = -angle;
|
||||
@@ -119,11 +119,11 @@ SymbolPartShearAction::SymbolPartShearAction(const set<SymbolPartP>& parts, cons
|
||||
, constrain(false)
|
||||
{}
|
||||
|
||||
String SymbolPartShearAction::getName(bool toUndo) const {
|
||||
String SymbolPartShearAction::getName(bool to_undo) const {
|
||||
return parts.size() == 1 ? _("Shear shape") : _("Shear shapes");
|
||||
}
|
||||
|
||||
void SymbolPartShearAction::perform(bool toUndo) {
|
||||
void SymbolPartShearAction::perform(bool to_undo) {
|
||||
// move the points back
|
||||
// the vector shear = (x,y) is used as:
|
||||
// <1 x>
|
||||
@@ -161,19 +161,19 @@ SymbolPartScaleAction::SymbolPartScaleAction(const set<SymbolPartP>& parts, int
|
||||
oldMin = Vector2D::infinity();
|
||||
Vector2D oldMax = -Vector2D::infinity();
|
||||
FOR_EACH(p, parts) {
|
||||
oldMin = piecewise_min(oldMin, p->minPos);
|
||||
oldMax = piecewise_max(oldMax, p->maxPos);
|
||||
oldMin = piecewise_min(oldMin, p->min_pos);
|
||||
oldMax = piecewise_max(oldMax, p->max_pos);
|
||||
}
|
||||
// new == old
|
||||
newMin = newRealMin = oldMin;
|
||||
newSize = newRealSize = oldSize = oldMax - oldMin;
|
||||
}
|
||||
|
||||
String SymbolPartScaleAction::getName(bool toUndo) const {
|
||||
String SymbolPartScaleAction::getName(bool to_undo) const {
|
||||
return parts.size() == 1 ? _("Scale shape") : _("Scale shapes");
|
||||
}
|
||||
|
||||
void SymbolPartScaleAction::perform(bool toUndo) {
|
||||
void SymbolPartScaleAction::perform(bool to_undo) {
|
||||
swap(oldMin, newMin);
|
||||
swap(oldSize, newSize);
|
||||
transformAll();
|
||||
@@ -207,17 +207,17 @@ void SymbolPartScaleAction::update() {
|
||||
void SymbolPartScaleAction::transformAll() {
|
||||
Vector2D scale = newSize.div(oldSize);
|
||||
FOR_EACH(p, parts) {
|
||||
p->minPos = transform(p->minPos);
|
||||
p->maxPos = transform(p->maxPos);
|
||||
p->min_pos = transform(p->min_pos);
|
||||
p->max_pos = transform(p->max_pos);
|
||||
// make sure that max >= min
|
||||
if (p->minPos.x > p->maxPos.x) swap(p->minPos.x, p->maxPos.x);
|
||||
if (p->minPos.y > p->maxPos.y) swap(p->minPos.y, p->maxPos.y);
|
||||
if (p->min_pos.x > p->max_pos.x) swap(p->min_pos.x, p->max_pos.x);
|
||||
if (p->min_pos.y > p->max_pos.y) swap(p->min_pos.y, p->max_pos.y);
|
||||
// scale all points
|
||||
FOR_EACH(pnt, p->points) {
|
||||
pnt->pos = transform(pnt->pos);
|
||||
// also scale handles
|
||||
pnt->deltaBefore = pnt->deltaBefore.mul(scale);
|
||||
pnt->deltaAfter = pnt->deltaAfter .mul(scale);
|
||||
pnt->delta_before = pnt->delta_before.mul(scale);
|
||||
pnt->delta_after = pnt->delta_after .mul(scale);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -230,11 +230,11 @@ CombiningModeAction::CombiningModeAction(const set<SymbolPartP>& parts, SymbolPa
|
||||
}
|
||||
}
|
||||
|
||||
String CombiningModeAction::getName(bool toUndo) const {
|
||||
String CombiningModeAction::getName(bool to_undo) const {
|
||||
return _("Change combine mode");
|
||||
}
|
||||
|
||||
void CombiningModeAction::perform(bool toUndo) {
|
||||
void CombiningModeAction::perform(bool to_undo) {
|
||||
FOR_EACH(pm, parts) {
|
||||
swap(pm.first->combine, pm.second);
|
||||
}
|
||||
@@ -246,11 +246,11 @@ SymbolPartNameAction::SymbolPartNameAction(const SymbolPartP& part, const String
|
||||
: part(part), partName(name)
|
||||
{}
|
||||
|
||||
String SymbolPartNameAction::getName(bool toUndo) const {
|
||||
String SymbolPartNameAction::getName(bool to_undo) const {
|
||||
return _("Change shape name");
|
||||
}
|
||||
|
||||
void SymbolPartNameAction::perform(bool toUndo) {
|
||||
void SymbolPartNameAction::perform(bool to_undo) {
|
||||
swap(part->name, partName);
|
||||
}
|
||||
|
||||
@@ -260,12 +260,12 @@ AddSymbolPartAction::AddSymbolPartAction(Symbol& symbol, const SymbolPartP& part
|
||||
: symbol(symbol), part(part)
|
||||
{}
|
||||
|
||||
String AddSymbolPartAction::getName(bool toUndo) const {
|
||||
String AddSymbolPartAction::getName(bool to_undo) const {
|
||||
return _("Add ") + part->name;
|
||||
}
|
||||
|
||||
void AddSymbolPartAction::perform(bool toUndo) {
|
||||
if (toUndo) {
|
||||
void AddSymbolPartAction::perform(bool to_undo) {
|
||||
if (to_undo) {
|
||||
assert(!symbol.parts.empty());
|
||||
symbol.parts.erase (symbol.parts.begin());
|
||||
} else {
|
||||
@@ -287,12 +287,12 @@ RemoveSymbolPartsAction::RemoveSymbolPartsAction(Symbol& symbol, const set<Symbo
|
||||
}
|
||||
}
|
||||
|
||||
String RemoveSymbolPartsAction::getName(bool toUndo) const {
|
||||
String RemoveSymbolPartsAction::getName(bool to_undo) const {
|
||||
return removals.size() == 1 ? _("Remove shape") : _("Remove shapes");
|
||||
}
|
||||
|
||||
void RemoveSymbolPartsAction::perform(bool toUndo) {
|
||||
if (toUndo) {
|
||||
void RemoveSymbolPartsAction::perform(bool to_undo) {
|
||||
if (to_undo) {
|
||||
// reinsert the parts
|
||||
// ascending order, this is the reverse of removal
|
||||
FOR_EACH(r, removals) {
|
||||
@@ -325,12 +325,12 @@ DuplicateSymbolPartsAction::DuplicateSymbolPartsAction(Symbol& symbol, const set
|
||||
}
|
||||
}
|
||||
|
||||
String DuplicateSymbolPartsAction::getName(bool toUndo) const {
|
||||
String DuplicateSymbolPartsAction::getName(bool to_undo) const {
|
||||
return duplications.size() == 1 ? _("Duplicate shape") : _("Duplicate shapes");
|
||||
}
|
||||
|
||||
void DuplicateSymbolPartsAction::perform(bool toUndo) {
|
||||
if (toUndo) {
|
||||
void DuplicateSymbolPartsAction::perform(bool to_undo) {
|
||||
if (to_undo) {
|
||||
// remove the clones
|
||||
// walk in reverse order, otherwise we will shift the vector
|
||||
FOR_EACH_REVERSE(d, duplications) {
|
||||
@@ -359,11 +359,11 @@ ReorderSymbolPartsAction::ReorderSymbolPartsAction(Symbol& symbol, size_t partId
|
||||
: symbol(symbol), partId1(partId1), partId2(partId2)
|
||||
{}
|
||||
|
||||
String ReorderSymbolPartsAction::getName(bool toUndo) const {
|
||||
String ReorderSymbolPartsAction::getName(bool to_undo) const {
|
||||
return _("Reorder");
|
||||
}
|
||||
|
||||
void ReorderSymbolPartsAction::perform(bool toUndo) {
|
||||
void ReorderSymbolPartsAction::perform(bool to_undo) {
|
||||
assert(partId1 < symbol.parts.size());
|
||||
assert(partId2 < symbol.parts.size());
|
||||
swap(symbol.parts[partId1], symbol.parts[partId2]);
|
||||
|
||||
+20
-20
@@ -33,8 +33,8 @@ class SymbolPartMoveAction : public SymbolPartAction {
|
||||
public:
|
||||
SymbolPartMoveAction(const set<SymbolPartP>& parts);
|
||||
|
||||
virtual String getName(bool toUndo) const;
|
||||
virtual void perform(bool toUndo);
|
||||
virtual String getName(bool to_undo) const;
|
||||
virtual void perform(bool to_undo);
|
||||
|
||||
/// Update this action to move some more
|
||||
void move(const Vector2D& delta);
|
||||
@@ -70,8 +70,8 @@ class SymbolPartRotateAction : public SymbolPartMatrixAction {
|
||||
public:
|
||||
SymbolPartRotateAction(const set<SymbolPartP>& parts, const Vector2D& center);
|
||||
|
||||
virtual String getName(bool toUndo) const;
|
||||
virtual void perform(bool toUndo);
|
||||
virtual String getName(bool to_undo) const;
|
||||
virtual void perform(bool to_undo);
|
||||
|
||||
/// Update this action to rotate to a different angle
|
||||
void rotateTo(double newAngle);
|
||||
@@ -93,8 +93,8 @@ class SymbolPartShearAction : public SymbolPartMatrixAction {
|
||||
public:
|
||||
SymbolPartShearAction(const set<SymbolPartP>& parts, const Vector2D& center);
|
||||
|
||||
virtual String getName(bool toUndo) const;
|
||||
virtual void perform(bool toUndo);
|
||||
virtual String getName(bool to_undo) const;
|
||||
virtual void perform(bool to_undo);
|
||||
|
||||
/// Change shear by a given amount
|
||||
void move(const Vector2D& deltaShear);
|
||||
@@ -114,8 +114,8 @@ class SymbolPartScaleAction : public SymbolPartAction {
|
||||
public:
|
||||
SymbolPartScaleAction(const set<SymbolPartP>& parts, int scaleX, int scaleY);
|
||||
|
||||
virtual String getName(bool toUndo) const;
|
||||
virtual void perform(bool toUndo);
|
||||
virtual String getName(bool to_undo) const;
|
||||
virtual void perform(bool to_undo);
|
||||
|
||||
/// Change min and max coordinates
|
||||
void move(const Vector2D& deltaMin, const Vector2D& deltaMax);
|
||||
@@ -145,8 +145,8 @@ class CombiningModeAction : public SymbolPartListAction {
|
||||
public:
|
||||
CombiningModeAction(const set<SymbolPartP>& parts, SymbolPartCombine mode);
|
||||
|
||||
virtual String getName(bool toUndo) const;
|
||||
virtual void perform(bool toUndo);
|
||||
virtual String getName(bool to_undo) const;
|
||||
virtual void perform(bool to_undo);
|
||||
|
||||
private:
|
||||
vector<pair<SymbolPartP,SymbolPartCombine> > parts; ///< Affected parts with new combining modes
|
||||
@@ -159,8 +159,8 @@ class SymbolPartNameAction : public SymbolPartListAction {
|
||||
public:
|
||||
SymbolPartNameAction(const SymbolPartP& part, const String& name);
|
||||
|
||||
virtual String getName(bool toUndo) const;
|
||||
virtual void perform(bool toUndo);
|
||||
virtual String getName(bool to_undo) const;
|
||||
virtual void perform(bool to_undo);
|
||||
|
||||
private:
|
||||
SymbolPartP part; ///< Affected part
|
||||
@@ -174,8 +174,8 @@ class AddSymbolPartAction : public SymbolPartListAction {
|
||||
public:
|
||||
AddSymbolPartAction(Symbol& symbol, const SymbolPartP& part);
|
||||
|
||||
virtual String getName(bool toUndo) const;
|
||||
virtual void perform(bool toUndo);
|
||||
virtual String getName(bool to_undo) const;
|
||||
virtual void perform(bool to_undo);
|
||||
|
||||
private:
|
||||
Symbol& symbol; ///< Symbol to add the part to
|
||||
@@ -189,8 +189,8 @@ class RemoveSymbolPartsAction : public SymbolPartListAction {
|
||||
public:
|
||||
RemoveSymbolPartsAction(Symbol& symbol, const set<SymbolPartP>& parts);
|
||||
|
||||
virtual String getName(bool toUndo) const;
|
||||
virtual void perform(bool toUndo);
|
||||
virtual String getName(bool to_undo) const;
|
||||
virtual void perform(bool to_undo);
|
||||
|
||||
private:
|
||||
Symbol& symbol;
|
||||
@@ -205,8 +205,8 @@ class DuplicateSymbolPartsAction : public SymbolPartListAction {
|
||||
public:
|
||||
DuplicateSymbolPartsAction(Symbol& symbol, const set<SymbolPartP>& parts);
|
||||
|
||||
virtual String getName(bool toUndo) const;
|
||||
virtual void perform(bool toUndo);
|
||||
virtual String getName(bool to_undo) const;
|
||||
virtual void perform(bool to_undo);
|
||||
|
||||
/// Fill a set with all the new parts
|
||||
void getParts(set<SymbolPartP>& parts);
|
||||
@@ -225,8 +225,8 @@ class ReorderSymbolPartsAction : public SymbolPartListAction {
|
||||
public:
|
||||
ReorderSymbolPartsAction(Symbol& symbol, size_t partId1, size_t partId2);
|
||||
|
||||
virtual String getName(bool toUndo) const;
|
||||
virtual void perform(bool toUndo);
|
||||
virtual String getName(bool to_undo) const;
|
||||
virtual void perform(bool to_undo);
|
||||
|
||||
private:
|
||||
Symbol& symbol; ///< Symbol to swap the parts in
|
||||
|
||||
@@ -43,11 +43,11 @@ ControlPointMoveAction::ControlPointMoveAction(const set<ControlPointP>& points)
|
||||
}
|
||||
}
|
||||
|
||||
String ControlPointMoveAction::getName(bool toUndo) const {
|
||||
String ControlPointMoveAction::getName(bool to_undo) const {
|
||||
return points.size() == 1 ? _("Move point") : _("Move points");
|
||||
}
|
||||
|
||||
void ControlPointMoveAction::perform(bool toUndo) {
|
||||
void ControlPointMoveAction::perform(bool to_undo) {
|
||||
/*
|
||||
set<ControlPointP>::const_iterator it = points.begin();
|
||||
vector<Vector2D> ::iterator it2 = oldValues.begin();
|
||||
@@ -77,23 +77,23 @@ void ControlPointMoveAction::move (const Vector2D& deltaDelta) {
|
||||
HandleMoveAction::HandleMoveAction(const SelectedHandle& handle)
|
||||
: handle(handle)
|
||||
, constrain(false)
|
||||
, oldHandle(handle.getHandle())
|
||||
, oldOther (handle.getOther())
|
||||
, old_handle(handle.getHandle())
|
||||
, old_other (handle.getOther())
|
||||
{}
|
||||
|
||||
String HandleMoveAction::getName(bool toUndo) const {
|
||||
String HandleMoveAction::getName(bool to_undo) const {
|
||||
return _("Move handle");
|
||||
}
|
||||
|
||||
void HandleMoveAction::perform(bool toUndo) {
|
||||
swap(oldHandle, handle.getHandle());
|
||||
swap(oldOther, handle.getOther());
|
||||
void HandleMoveAction::perform(bool to_undo) {
|
||||
swap(old_handle, handle.getHandle());
|
||||
swap(old_other, handle.getOther());
|
||||
}
|
||||
|
||||
void HandleMoveAction::move(const Vector2D& deltaDelta) {
|
||||
delta += deltaDelta;
|
||||
handle.getHandle() = constrainVector(oldHandle + delta, constrain);
|
||||
handle.getOther() = oldOther;
|
||||
handle.getHandle() = constrainVector(old_handle + delta, constrain);
|
||||
handle.getOther() = old_other;
|
||||
handle.onUpdateHandle();
|
||||
}
|
||||
|
||||
@@ -113,25 +113,25 @@ void ControlPointUpdate::perform() {
|
||||
SegmentModeAction::SegmentModeAction(const ControlPointP& p1, const ControlPointP& p2, SegmentMode mode)
|
||||
: point1(p1), point2(p2)
|
||||
{
|
||||
if (p1->segmentAfter == mode) return;
|
||||
point1.other.segmentAfter = point2.other.segmentBefore = mode;
|
||||
if (p1->segment_after == mode) return;
|
||||
point1.other.segment_after = point2.other.segment_before = mode;
|
||||
if (mode == SEGMENT_LINE) {
|
||||
point1.other.deltaAfter = Vector2D(0,0);
|
||||
point2.other.deltaBefore = Vector2D(0,0);
|
||||
point1.other.delta_after = Vector2D(0,0);
|
||||
point2.other.delta_before = Vector2D(0,0);
|
||||
point1.other.lock = LOCK_FREE;
|
||||
point2.other.lock = LOCK_FREE;
|
||||
} else if (mode == SEGMENT_CURVE) {
|
||||
point1.other.deltaAfter = (p2->pos - p1->pos) / 3.0f;
|
||||
point2.other.deltaBefore = (p1->pos - p2->pos) / 3.0f;
|
||||
point1.other.delta_after = (p2->pos - p1->pos) / 3.0f;
|
||||
point2.other.delta_before = (p1->pos - p2->pos) / 3.0f;
|
||||
}
|
||||
}
|
||||
String SegmentModeAction::getName(bool toUndo) const {
|
||||
SegmentMode mode = toUndo ? point1.point->segmentAfter : point1.other.segmentAfter;
|
||||
String SegmentModeAction::getName(bool to_undo) const {
|
||||
SegmentMode mode = to_undo ? point1.point->segment_after : point1.other.segment_after;
|
||||
if (mode == SEGMENT_LINE) return _("Convert to line");
|
||||
else return _("Convert to curve");
|
||||
}
|
||||
|
||||
void SegmentModeAction::perform(bool toUndo) {
|
||||
void SegmentModeAction::perform(bool to_undo) {
|
||||
point1.perform();
|
||||
point2.perform();
|
||||
}
|
||||
@@ -146,11 +146,11 @@ LockModeAction::LockModeAction(const ControlPointP& p, LockMode lock)
|
||||
point.other.onUpdateLock();
|
||||
}
|
||||
|
||||
String LockModeAction::getName(bool toUndo) const {
|
||||
String LockModeAction::getName(bool to_undo) const {
|
||||
return _("Lock point");
|
||||
}
|
||||
|
||||
void LockModeAction::perform(bool toUndo) {
|
||||
void LockModeAction::perform(bool to_undo) {
|
||||
point.perform();
|
||||
}
|
||||
|
||||
@@ -161,12 +161,12 @@ CurveDragAction::CurveDragAction(const ControlPointP& point1, const ControlPoint
|
||||
: SegmentModeAction(point1, point2, SEGMENT_CURVE)
|
||||
{}
|
||||
|
||||
String CurveDragAction::getName(bool toUndo) const {
|
||||
String CurveDragAction::getName(bool to_undo) const {
|
||||
return _("Move curve");
|
||||
}
|
||||
|
||||
void CurveDragAction::perform(bool toUndo) {
|
||||
SegmentModeAction::perform(toUndo);
|
||||
void CurveDragAction::perform(bool to_undo) {
|
||||
SegmentModeAction::perform(to_undo);
|
||||
}
|
||||
|
||||
void CurveDragAction::move(const Vector2D& delta, double t) {
|
||||
@@ -186,8 +186,8 @@ void CurveDragAction::move(const Vector2D& delta, double t) {
|
||||
// delta = p' - p
|
||||
// pointDelta = x * t * (1-t)
|
||||
Vector2D pointDelta = delta / (3 * (t * t + (1-t) * (1-t)));
|
||||
point1.point->deltaAfter += pointDelta / t;
|
||||
point2.point->deltaBefore += pointDelta / (1-t);
|
||||
point1.point->delta_after += pointDelta / t;
|
||||
point2.point->delta_before += pointDelta / (1-t);
|
||||
point1.point->onUpdateHandle(HANDLE_AFTER);
|
||||
point2.point->onUpdateHandle(HANDLE_BEFORE);
|
||||
}
|
||||
@@ -195,40 +195,40 @@ void CurveDragAction::move(const Vector2D& delta, double t) {
|
||||
|
||||
// ----------------------------------------------------------------------------- : Add control point
|
||||
|
||||
ControlPointAddAction::ControlPointAddAction(const SymbolPartP& part, UInt insertAfter, double t)
|
||||
: point1(part->getPoint(insertAfter))
|
||||
, point2(part->getPoint(insertAfter + 1))
|
||||
ControlPointAddAction::ControlPointAddAction(const SymbolPartP& part, UInt insert_after, double t)
|
||||
: point1(part->getPoint(insert_after))
|
||||
, point2(part->getPoint(insert_after + 1))
|
||||
, part(part)
|
||||
, insertAfter(insertAfter)
|
||||
, newPoint(new ControlPoint())
|
||||
, insert_after(insert_after)
|
||||
, new_point(new ControlPoint())
|
||||
{
|
||||
// calculate new point
|
||||
if (point1.other.segmentAfter == SEGMENT_CURVE) {
|
||||
if (point1.other.segment_after == SEGMENT_CURVE) {
|
||||
// calculate new handles using de Casteljau's subdivision algorithm
|
||||
deCasteljau(point1.other, point2.other, t, *newPoint);
|
||||
deCasteljau(point1.other, point2.other, t, *new_point);
|
||||
// unlock if needed
|
||||
if (point1.other.lock == LOCK_SIZE) point1.other.lock = LOCK_DIR;
|
||||
if (point2.other.lock == LOCK_SIZE) point2.other.lock = LOCK_DIR;
|
||||
newPoint->lock = LOCK_DIR;
|
||||
newPoint->segmentBefore = SEGMENT_CURVE;
|
||||
newPoint->segmentAfter = SEGMENT_CURVE;
|
||||
new_point->lock = LOCK_DIR;
|
||||
new_point->segment_before = SEGMENT_CURVE;
|
||||
new_point->segment_after = SEGMENT_CURVE;
|
||||
} else {
|
||||
newPoint->pos = point1.other.pos * (1 - t) + point2.other.pos * t;
|
||||
newPoint->lock = LOCK_FREE;
|
||||
newPoint->segmentBefore = SEGMENT_LINE;
|
||||
newPoint->segmentAfter = SEGMENT_LINE;
|
||||
new_point->pos = point1.other.pos * (1 - t) + point2.other.pos * t;
|
||||
new_point->lock = LOCK_FREE;
|
||||
new_point->segment_before = SEGMENT_LINE;
|
||||
new_point->segment_after = SEGMENT_LINE;
|
||||
}
|
||||
}
|
||||
|
||||
String ControlPointAddAction::getName(bool toUndo) const {
|
||||
String ControlPointAddAction::getName(bool to_undo) const {
|
||||
return _("Add control point");
|
||||
}
|
||||
|
||||
void ControlPointAddAction::perform(bool toUndo) {
|
||||
if (toUndo) { // remove the point
|
||||
part->points.erase( part->points.begin() + insertAfter + 1);
|
||||
void ControlPointAddAction::perform(bool to_undo) {
|
||||
if (to_undo) { // remove the point
|
||||
part->points.erase( part->points.begin() + insert_after + 1);
|
||||
} else {
|
||||
part->points.insert(part->points.begin() + insertAfter + 1, newPoint);
|
||||
part->points.insert(part->points.begin() + insert_after + 1, new_point);
|
||||
}
|
||||
// update points before/after
|
||||
point1.perform();
|
||||
@@ -249,8 +249,8 @@ class SinglePointRemoveAction : public Action {
|
||||
public:
|
||||
SinglePointRemoveAction(const SymbolPartP& part, UInt position);
|
||||
|
||||
virtual String getName(bool toUndo) const { return _("Delete point"); }
|
||||
virtual void perform(bool toUndo);
|
||||
virtual String getName(bool to_undo) const { return _("Delete point"); }
|
||||
virtual void perform(bool to_undo);
|
||||
|
||||
private:
|
||||
SymbolPartP part;
|
||||
@@ -266,21 +266,21 @@ SinglePointRemoveAction::SinglePointRemoveAction(const SymbolPartP& part, UInt p
|
||||
, point1(part->getPoint(position - 1))
|
||||
, point2(part->getPoint(position + 1))
|
||||
{
|
||||
if (point1.other.segmentAfter == SEGMENT_CURVE || point2.other.segmentBefore == SEGMENT_CURVE) {
|
||||
if (point1.other.segment_after == SEGMENT_CURVE || point2.other.segment_before == SEGMENT_CURVE) {
|
||||
// try to preserve curve
|
||||
Vector2D before = point->deltaBefore;
|
||||
Vector2D after = point->deltaAfter;
|
||||
Vector2D before = point->delta_before;
|
||||
Vector2D after = point->delta_after;
|
||||
|
||||
// convert both segments to curves first
|
||||
if (point1.other.segmentAfter != SEGMENT_CURVE) {
|
||||
point1.other.deltaAfter = -
|
||||
if (point1.other.segment_after != SEGMENT_CURVE) {
|
||||
point1.other.delta_after = -
|
||||
before = (point1.other.pos - point->pos) / 3.0;
|
||||
point1.other.segmentAfter = SEGMENT_CURVE;
|
||||
point1.other.segment_after = SEGMENT_CURVE;
|
||||
}
|
||||
if (point2.other.segmentBefore != SEGMENT_CURVE) {
|
||||
point2.other.deltaBefore = -
|
||||
if (point2.other.segment_before != SEGMENT_CURVE) {
|
||||
point2.other.delta_before = -
|
||||
after = (point2.other.pos - point->pos) / 3.0;
|
||||
point2.other.segmentBefore = SEGMENT_CURVE;
|
||||
point2.other.segment_before = SEGMENT_CURVE;
|
||||
}
|
||||
|
||||
// The inverse of adding a point, reconstruct the original handles
|
||||
@@ -290,8 +290,8 @@ SinglePointRemoveAction::SinglePointRemoveAction(const SymbolPartP& part, UInt p
|
||||
double al = after .length() + 0.00000001;
|
||||
double totl = bl + al;
|
||||
// set new handle sizes
|
||||
point1.other.deltaAfter *= totl / bl;
|
||||
point2.other.deltaBefore *= totl / al;
|
||||
point1.other.delta_after *= totl / bl;
|
||||
point2.other.delta_before *= totl / al;
|
||||
|
||||
// Also take in acount cases where the point does not correspond to a freshly added point.
|
||||
// distance from the point to the curve as it would be in the above case can be used,
|
||||
@@ -301,8 +301,8 @@ SinglePointRemoveAction::SinglePointRemoveAction(const SymbolPartP& part, UInt p
|
||||
Vector2D p = c.pointAt(t);
|
||||
Vector2D distP = point->pos - p;
|
||||
// adjust handle sizes
|
||||
point1.other.deltaAfter *= ssqrt(distP.dot(point1.other.deltaAfter) /point1.other.deltaAfter.lengthSqr()) + 1;
|
||||
point2.other.deltaBefore *= ssqrt(distP.dot(point2.other.deltaBefore)/point2.other.deltaBefore.lengthSqr()) + 1;
|
||||
point1.other.delta_after *= ssqrt(distP.dot(point1.other.delta_after) /point1.other.delta_after.lengthSqr()) + 1;
|
||||
point2.other.delta_before *= ssqrt(distP.dot(point2.other.delta_before)/point2.other.delta_before.lengthSqr()) + 1;
|
||||
|
||||
// unlock if needed
|
||||
if (point1.other.lock == LOCK_SIZE) point1.other.lock = LOCK_DIR;
|
||||
@@ -312,8 +312,8 @@ SinglePointRemoveAction::SinglePointRemoveAction(const SymbolPartP& part, UInt p
|
||||
}
|
||||
}
|
||||
|
||||
void SinglePointRemoveAction::perform(bool toUndo) {
|
||||
if (toUndo) {
|
||||
void SinglePointRemoveAction::perform(bool to_undo) {
|
||||
if (to_undo) {
|
||||
// reinsert the point
|
||||
part->points.insert(part->points.begin() + position, point);
|
||||
} else {
|
||||
@@ -336,8 +336,8 @@ class ControlPointRemoveAction : public Action {
|
||||
public:
|
||||
ControlPointRemoveAction(const SymbolPartP& part, const set<ControlPointP>& toDelete);
|
||||
|
||||
virtual String getName(bool toUndo) const;
|
||||
virtual void perform(bool toUndo);
|
||||
virtual String getName(bool to_undo) const;
|
||||
virtual void perform(bool to_undo);
|
||||
|
||||
private:
|
||||
vector<SinglePointRemoveActionP> removals;
|
||||
@@ -355,17 +355,17 @@ ControlPointRemoveAction::ControlPointRemoveAction(const SymbolPartP& part, cons
|
||||
}
|
||||
}
|
||||
|
||||
String ControlPointRemoveAction::getName(bool toUndo) const {
|
||||
String ControlPointRemoveAction::getName(bool to_undo) const {
|
||||
return removals.size() == 1 ? _("Delete point") : _("Delete points");
|
||||
}
|
||||
|
||||
void ControlPointRemoveAction::perform(bool toUndo) {
|
||||
if (toUndo) {
|
||||
FOR_EACH(r, removals) r->perform(toUndo);
|
||||
void ControlPointRemoveAction::perform(bool to_undo) {
|
||||
if (to_undo) {
|
||||
FOR_EACH(r, removals) r->perform(to_undo);
|
||||
} else {
|
||||
// in reverse order, because positions of later points will
|
||||
// change after removal of earlier points.
|
||||
FOR_EACH_REVERSE(r, removals) r->perform(toUndo);
|
||||
FOR_EACH_REVERSE(r, removals) r->perform(to_undo);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -31,8 +31,8 @@ class ControlPointMoveAction : public Action {
|
||||
public:
|
||||
ControlPointMoveAction(const set<ControlPointP>& points);
|
||||
|
||||
virtual String getName(bool toUndo) const;
|
||||
virtual void perform(bool toUndo);
|
||||
virtual String getName(bool to_undo) const;
|
||||
virtual void perform(bool to_undo);
|
||||
|
||||
/// Update this action to move some more
|
||||
void move(const Vector2D& delta);
|
||||
@@ -52,16 +52,16 @@ class HandleMoveAction : public Action {
|
||||
public:
|
||||
HandleMoveAction(const SelectedHandle& handle);
|
||||
|
||||
virtual String getName(bool toUndo) const;
|
||||
virtual void perform(bool toUndo);
|
||||
virtual String getName(bool to_undo) const;
|
||||
virtual void perform(bool to_undo);
|
||||
|
||||
/// Update this action to move some more
|
||||
void move(const Vector2D& delta);
|
||||
|
||||
private:
|
||||
SelectedHandle handle; ///< The handle to move
|
||||
Vector2D oldHandle; ///< Old value of this handle
|
||||
Vector2D oldOther; ///< Old value of other handle, needed for contraints
|
||||
Vector2D old_handle; ///< Old value of this handle
|
||||
Vector2D old_other; ///< Old value of other handle, needed for contraints
|
||||
Vector2D delta; ///< Amount we moved
|
||||
public:
|
||||
bool constrain; ///< Constrain movement?
|
||||
@@ -90,8 +90,8 @@ class SegmentModeAction : public Action {
|
||||
public:
|
||||
SegmentModeAction(const ControlPointP& p1, const ControlPointP& p2, SegmentMode mode);
|
||||
|
||||
virtual String getName(bool toUndo) const;
|
||||
virtual void perform(bool toUndo);
|
||||
virtual String getName(bool to_undo) const;
|
||||
virtual void perform(bool to_undo);
|
||||
|
||||
protected:
|
||||
ControlPointUpdate point1, point2;
|
||||
@@ -104,8 +104,8 @@ class LockModeAction : public Action {
|
||||
public:
|
||||
LockModeAction(const ControlPointP& p, LockMode mode);
|
||||
|
||||
virtual String getName(bool toUndo) const;
|
||||
virtual void perform(bool toUndo);
|
||||
virtual String getName(bool to_undo) const;
|
||||
virtual void perform(bool to_undo);
|
||||
|
||||
private:
|
||||
ControlPointUpdate point; ///< The affected point
|
||||
@@ -120,8 +120,8 @@ class CurveDragAction : public SegmentModeAction {
|
||||
public:
|
||||
CurveDragAction(const ControlPointP& point1, const ControlPointP& point2);
|
||||
|
||||
virtual String getName(bool toUndo) const;
|
||||
virtual void perform(bool toUndo);
|
||||
virtual String getName(bool to_undo) const;
|
||||
virtual void perform(bool to_undo);
|
||||
|
||||
// Move the curve by this much, it is grabbed at time t
|
||||
void move(const Vector2D& delta, double t);
|
||||
@@ -133,17 +133,17 @@ class CurveDragAction : public SegmentModeAction {
|
||||
class ControlPointAddAction : public Action {
|
||||
public:
|
||||
/// Insert a new point in part, after position insertAfter_, at the time t on the segment
|
||||
ControlPointAddAction(const SymbolPartP& part, UInt insertAfter, double t);
|
||||
ControlPointAddAction(const SymbolPartP& part, UInt insert_after, double t);
|
||||
|
||||
virtual String getName(bool toUndo) const;
|
||||
virtual void perform(bool toUndo);
|
||||
virtual String getName(bool to_undo) const;
|
||||
virtual void perform(bool to_undo);
|
||||
|
||||
inline ControlPointP getNewPoint() const { return newPoint; }
|
||||
inline ControlPointP getNewPoint() const { return new_point; }
|
||||
|
||||
private:
|
||||
SymbolPartP part; ///< SymbolPart we are in
|
||||
ControlPointP newPoint; ///< The point to insert
|
||||
UInt insertAfter; ///< Insert after index .. in the array
|
||||
ControlPointP new_point; ///< The point to insert
|
||||
UInt insert_after; ///< Insert after index .. in the array
|
||||
ControlPointUpdate point1, point2; ///< Update the points around the new point
|
||||
};
|
||||
|
||||
|
||||
+2
-2
@@ -22,11 +22,11 @@ Card::Card() {
|
||||
if (!game_for_new_cards()) {
|
||||
throw InternalError(_("game_for_new_cards not set"));
|
||||
}
|
||||
data.init(game_for_new_cards()->cardFields);
|
||||
data.init(game_for_new_cards()->card_fields);
|
||||
}
|
||||
|
||||
Card::Card(const Game& game) {
|
||||
data.init(game.cardFields);
|
||||
data.init(game.card_fields);
|
||||
}
|
||||
|
||||
String Card::identification() const {
|
||||
|
||||
+24
-11
@@ -12,16 +12,16 @@
|
||||
// ----------------------------------------------------------------------------- : Field
|
||||
|
||||
Field::Field()
|
||||
: index (0) // sensible default?
|
||||
, editable (true)
|
||||
, saveValue (true)
|
||||
, showStatistics (true)
|
||||
, identifying (false)
|
||||
, cardListColumn (-1)
|
||||
, cardListWidth (100)
|
||||
, cardListAllow (true)
|
||||
// , cardListAlign (ALIGN_LEFT)
|
||||
, tabIndex (0)
|
||||
: index (0) // sensible default?
|
||||
, editable (true)
|
||||
, save_value (true)
|
||||
, show_statistics (true)
|
||||
, identifying (false)
|
||||
, card_list_column (-1)
|
||||
, card_list_width (100)
|
||||
, card_list_allow (true)
|
||||
// , card_list_align (ALIGN_LEFT)
|
||||
, tab_index (0)
|
||||
{}
|
||||
|
||||
Field::~Field() {}
|
||||
@@ -29,8 +29,17 @@ Field::~Field() {}
|
||||
IMPLEMENT_REFLECTION(Field) {
|
||||
if (!tag.reading()) {
|
||||
String type = typeName();
|
||||
REFLECT_N("type", type);
|
||||
REFLECT(type);
|
||||
}
|
||||
REFLECT(editable);
|
||||
REFLECT(save_value);
|
||||
REFLECT(show_statistics);
|
||||
REFLECT(identifying);
|
||||
REFLECT(card_list_column);
|
||||
REFLECT(card_list_width);
|
||||
REFLECT(card_list_allow);
|
||||
// REFLECT(card_list_align);
|
||||
REFLECT(tab_index);
|
||||
}
|
||||
|
||||
template <>
|
||||
@@ -49,6 +58,8 @@ shared_ptr<Field> read_new<Field>(Reader& reader) {
|
||||
|
||||
// ----------------------------------------------------------------------------- : Style
|
||||
|
||||
Style::~Style() {}
|
||||
|
||||
IMPLEMENT_REFLECTION(Style) {
|
||||
}
|
||||
|
||||
@@ -58,6 +69,8 @@ void initObject(const FieldP& field, StyleP& style) {
|
||||
|
||||
// ----------------------------------------------------------------------------- : Value
|
||||
|
||||
Value::~Value() {}
|
||||
|
||||
IMPLEMENT_REFLECTION(Value) {
|
||||
}
|
||||
|
||||
|
||||
+13
-13
@@ -24,19 +24,19 @@ class Field {
|
||||
Field();
|
||||
virtual ~Field();
|
||||
|
||||
UInt index; ///< Used by IndexMap
|
||||
String name; ///< Name of the field, for refering to it from scripts and files
|
||||
String description; ///< Description, used in status bar
|
||||
bool editable; ///< Can values of this field be edited?
|
||||
bool saveValue; ///< Should values of this field be written to files? Can be false for script generated fields.
|
||||
bool showStatistics; ///< Should this field appear as a group by choice in the statistics panel?
|
||||
bool identifying; ///< Does this field give Card::identification()?
|
||||
int cardListColumn; ///< What column to use in the card list? -1 = don't list
|
||||
UInt cardListWidth; ///< Width of the card list column (pixels).
|
||||
bool cardListAllow; ///< Is this field allowed to appear in the card list.
|
||||
String cardListName; ///< Alternate name to use in card list.
|
||||
// Alignment cardListAlign; ///< Alignment of the card list colummn.
|
||||
int tabIndex; ///< Tab index in editor
|
||||
UInt index; ///< Used by IndexMap
|
||||
String name; ///< Name of the field, for refering to it from scripts and files
|
||||
String description; ///< Description, used in status bar
|
||||
bool editable; ///< Can values of this field be edited?
|
||||
bool save_value; ///< Should values of this field be written to files? Can be false for script generated fields.
|
||||
bool show_statistics; ///< Should this field appear as a group by choice in the statistics panel?
|
||||
bool identifying; ///< Does this field give Card::identification()?
|
||||
int card_list_column; ///< What column to use in the card list? -1 = don't list
|
||||
UInt card_list_width; ///< Width of the card list column (pixels).
|
||||
bool card_list_allow; ///< Is this field allowed to appear in the card list.
|
||||
String card_list_name; ///< Alternate name to use in card list.
|
||||
// Alignment card_list_align; ///< Alignment of the card list colummn.
|
||||
int tab_index; ///< Tab index in editor
|
||||
// Vector<DependendScript> dependendScripts; // scripts that depend on values of this field
|
||||
|
||||
/// Creates a new Value corresponding to this Field
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
//+----------------------------------------------------------------------------+
|
||||
//| Description: Magic Set Editor - Program to make Magic (tm) cards |
|
||||
//| Copyright: (C) 2001 - 2006 Twan van Laarhoven |
|
||||
//| License: GNU General Public License 2 or later (see file COPYING) |
|
||||
//+----------------------------------------------------------------------------+
|
||||
|
||||
// ----------------------------------------------------------------------------- : Includes
|
||||
|
||||
#include <data/field/text.hpp>
|
||||
|
||||
// ----------------------------------------------------------------------------- : TextField
|
||||
|
||||
TextField::TextField()
|
||||
: multi_line(false), move_cursor_with_sort(false)
|
||||
, default_name(_("Default"))
|
||||
{}
|
||||
|
||||
StyleP TextField::newStyle(const FieldP& thisP) const {
|
||||
assert(thisP.get() == this);
|
||||
return new_shared<TextStyle>();
|
||||
}
|
||||
|
||||
ValueP TextField::newValue(const FieldP& thisP) const {
|
||||
assert(thisP.get() == this);
|
||||
return new_shared<TextValue>();
|
||||
}
|
||||
|
||||
FieldP TextField::clone() const {
|
||||
return new_shared1<TextField>(*this);
|
||||
}
|
||||
|
||||
String TextField::typeName() const {
|
||||
return _("text");
|
||||
}
|
||||
|
||||
|
||||
IMPLEMENT_REFLECTION(TextField) {
|
||||
REFLECT_BASE(Field);
|
||||
REFLECT(multi_line);
|
||||
// REFLECT(script);
|
||||
// REFLECT_N("default", default_script);
|
||||
REFLECT(move_cursor_with_sort);
|
||||
REFLECT(default_name);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------- : TextStyle
|
||||
|
||||
StyleP TextStyle::clone() const {
|
||||
return new_shared1<TextStyle>(*this);
|
||||
}
|
||||
|
||||
IMPLEMENT_REFLECTION(TextStyle) {
|
||||
REFLECT_BASE(Style);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------- : TextValue
|
||||
|
||||
ValueP TextValue::clone() const {
|
||||
return new_shared1<TextValue>(*this);
|
||||
}
|
||||
|
||||
IMPLEMENT_REFLECTION(TextValue) {
|
||||
REFLECT_BASE(Value);
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
//+----------------------------------------------------------------------------+
|
||||
//| Description: Magic Set Editor - Program to make Magic (tm) cards |
|
||||
//| Copyright: (C) 2001 - 2006 Twan van Laarhoven |
|
||||
//| License: GNU General Public License 2 or later (see file COPYING) |
|
||||
//+----------------------------------------------------------------------------+
|
||||
|
||||
#ifndef HEADER_DATA_FIELD_TEXT
|
||||
#define HEADER_DATA_FIELD_TEXT
|
||||
|
||||
// ----------------------------------------------------------------------------- : Includes
|
||||
|
||||
#include <util/prec.hpp>
|
||||
#include <data/field.hpp>
|
||||
|
||||
// ----------------------------------------------------------------------------- : TextField
|
||||
|
||||
/// A field that stores tagged text
|
||||
class TextField : public Field {
|
||||
public:
|
||||
TextField();
|
||||
|
||||
// Script script;
|
||||
// Script default_script;
|
||||
bool multi_line; ///< Are newlines allowed in the text?
|
||||
bool move_cursor_with_sort; ///< When the text is reordered by a script should the cursor position be updated?
|
||||
String default_name; ///< Name of "default" value
|
||||
|
||||
virtual ValueP newValue(const FieldP& thisP) const;
|
||||
virtual StyleP newStyle(const FieldP& thisP) const;
|
||||
virtual FieldP clone() const;
|
||||
virtual String typeName() const;
|
||||
|
||||
private:
|
||||
DECLARE_REFLECTION();
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------- : TextStyle
|
||||
|
||||
/// The Style for a TextField
|
||||
class TextStyle : public Style {
|
||||
public:
|
||||
// FontInfo font; ///< Font to use for the text
|
||||
// SymbolFontInfo symbol_font; ///< Symbol font for symbols in the text
|
||||
bool always_symbol; ///< Should everything be drawn as symbols?
|
||||
bool allow_formatting; ///< Is formating (bold/italic/..) allowed?
|
||||
// Alignment alignment; ///< Alignment inside the box
|
||||
int angle; ///< Angle of the text inside the box
|
||||
int padding_left, padding_left_min; ///< Padding
|
||||
int padding_right, padding_right_min; ///< Padding
|
||||
int padding_top, padding_top_min; ///< Padding
|
||||
int padding_bottom, padding_bottom_min; ///< Padding
|
||||
double line_height_soft; ///< Line height for soft linebreaks
|
||||
double line_height_hard; ///< Line height for hard linebreaks
|
||||
double line_height_line; ///< Line height for <line> tags
|
||||
String mask_filename; ///< Filename of the mask
|
||||
// ContourMaskP mask; ///< Mask to fit the text to (may be null)
|
||||
|
||||
virtual StyleP clone() const;
|
||||
|
||||
private:
|
||||
DECLARE_REFLECTION();
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------- : TextValue
|
||||
|
||||
/// The Value in a TextField
|
||||
class TextValue : public Value {
|
||||
public:
|
||||
virtual ValueP clone() const;
|
||||
|
||||
String value;
|
||||
private:
|
||||
DECLARE_REFLECTION();
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------- : EOF
|
||||
#endif
|
||||
+9
-9
@@ -25,18 +25,18 @@ String Game::typeName() const { return _("game"); }
|
||||
|
||||
IMPLEMENT_REFLECTION(Game) {
|
||||
// ioMseVersion(io, fileName, fileVersion);
|
||||
REFLECT_N("full name", fullName);
|
||||
REFLECT_N("icon", iconFilename);
|
||||
// REFLECT_N("init script", initScript);
|
||||
REFLECT_N("set field", setFields);
|
||||
REFLECT_N("card field", cardFields);
|
||||
// REFLECT_N("keyword parameter type", keywordParams);
|
||||
// REFLECT_N("keyword separator type", keywordSeparators);
|
||||
REFLECT(full_name);
|
||||
REFLECT_N("icon", icon_filename);
|
||||
// REFLECT(init_script);
|
||||
REFLECT(set_fields);
|
||||
REFLECT(card_fields);
|
||||
// REFLECT_N("keyword parameter type", keyword_params);
|
||||
// REFLECT_N("keyword separator type", keyword_separators);
|
||||
// REFLECT_N("keyword", keywords);
|
||||
// REFLECT_N("word list", wordLists);
|
||||
// REFLECT_N("word list", word_lists);
|
||||
}
|
||||
|
||||
void Game::validate() {
|
||||
// a default for the full name
|
||||
if (fullName.empty()) fullName = name();
|
||||
if (full_name.empty()) full_name = name();
|
||||
}
|
||||
+4
-4
@@ -19,10 +19,10 @@ DECLARE_POINTER_TYPE(Game);
|
||||
|
||||
class Game : public Packaged {
|
||||
public:
|
||||
String fullName;
|
||||
String iconFilename;
|
||||
vector<FieldP> setFields;
|
||||
vector<FieldP> cardFields;
|
||||
String full_name;
|
||||
String icon_filename;
|
||||
vector<FieldP> set_fields;
|
||||
vector<FieldP> card_fields;
|
||||
|
||||
/// Loads the game with a particular name, for example "magic"
|
||||
static GameP byName(const String& name);
|
||||
|
||||
+31
-31
@@ -30,11 +30,11 @@ IMPLEMENT_REFLECTION(ColumnSettings) {
|
||||
}
|
||||
|
||||
IMPLEMENT_REFLECTION(GameSettings) {
|
||||
REFLECT_N("default style", defaultStyle);
|
||||
REFLECT_N("default export", defaultExport);
|
||||
REFLECT(default_style);
|
||||
REFLECT(default_export);
|
||||
// REFLECT_N("cardlist columns", columns);
|
||||
REFLECT_N("sort cards by", sortCardsBy);
|
||||
REFLECT_N("sort cards ascending", sortCardsAscending);
|
||||
REFLECT(sort_cards_by);
|
||||
REFLECT(sort_cards_ascending);
|
||||
}
|
||||
|
||||
IMPLEMENT_REFLECTION(StyleSettings) {
|
||||
@@ -46,12 +46,12 @@ IMPLEMENT_REFLECTION(StyleSettings) {
|
||||
Settings settings;
|
||||
|
||||
Settings::Settings()
|
||||
: setWindowMaximized (false)
|
||||
, setWindowWidth (790)
|
||||
, setWindowHeight (300)
|
||||
, cardNotesHeight (40)
|
||||
, updatesUrl (_("http://magicseteditor.sourceforge.net/updates"))
|
||||
, checkUpdates (CHECK_IF_CONNECTED)
|
||||
: set_window_maximized (false)
|
||||
, set_window_width (790)
|
||||
, set_window_height (300)
|
||||
, card_notes_height (40)
|
||||
, updates_url (_("http://magicseteditor.sourceforge.net/updates"))
|
||||
, check_updates (CHECK_IF_CONNECTED)
|
||||
{}
|
||||
|
||||
void Settings::addRecentFile(const String& filename) {
|
||||
@@ -60,18 +60,18 @@ void Settings::addRecentFile(const String& filename) {
|
||||
fn.Normalize();
|
||||
String filenameAbs = fn.GetFullPath();
|
||||
// remove duplicates
|
||||
recentSets.erase(
|
||||
remove(recentSets.begin(), recentSets.end(), filenameAbs),
|
||||
recentSets.end()
|
||||
recent_sets.erase(
|
||||
remove(recent_sets.begin(), recent_sets.end(), filenameAbs),
|
||||
recent_sets.end()
|
||||
);
|
||||
// add to front of list
|
||||
recentSets.insert(recentSets.begin(), filenameAbs);
|
||||
recent_sets.insert(recent_sets.begin(), filenameAbs);
|
||||
// enforce size limit
|
||||
if (recentSets.size() > maxRecentSets) recentSets.resize(maxRecentSets);
|
||||
if (recent_sets.size() > max_recent_sets) recent_sets.resize(max_recent_sets);
|
||||
}
|
||||
|
||||
GameSettings& Settings::gameSettingsFor(const Game& game) {
|
||||
GameSettingsP& gs = settings.gameSettings[game.name()];
|
||||
GameSettingsP& gs = settings.game_settings[game.name()];
|
||||
if (!gs) gs.reset(new GameSettings);
|
||||
return *gs;
|
||||
}
|
||||
@@ -84,29 +84,29 @@ StyleSettings& Settings::styleSettingsFor(const CardStyle& style) {
|
||||
}
|
||||
*/
|
||||
|
||||
String userSettingsDir() {
|
||||
String user_settings_dir() {
|
||||
return _(""); // TODO
|
||||
}
|
||||
|
||||
String Settings::settingsFile() {
|
||||
// return userSettingsDir() + _("mse.config");
|
||||
return userSettingsDir() + _("mse8.config"); // use different file during development of C++ port
|
||||
// return user_settings_dir() + _("mse.config");
|
||||
return user_settings_dir() + _("mse8.config"); // use different file during development of C++ port
|
||||
}
|
||||
|
||||
IMPLEMENT_REFLECTION(Settings) {
|
||||
// ioMseVersion(io, "settings", fileVersion);
|
||||
REFLECT_N("recent set", recentSets);
|
||||
REFLECT_N("window maximized", setWindowMaximized);
|
||||
REFLECT_N("window width", setWindowWidth);
|
||||
REFLECT_N("window height", setWindowHeight);
|
||||
REFLECT_N("card notes height", cardNotesHeight);
|
||||
REFLECT_N("default game", defaultGame);
|
||||
REFLECT_N("apprentice location", apprenticeLocation);
|
||||
REFLECT_N("updates url", updatesUrl);
|
||||
REFLECT_N("check updates", checkUpdates);
|
||||
// ioAll(io, "game settings", gameSettings);
|
||||
// ioMseVersion(io, "settings", file_version);
|
||||
REFLECT_N("recent_set", recent_sets);
|
||||
REFLECT(set_window_maximized);
|
||||
REFLECT(set_window_width);
|
||||
REFLECT(set_window_height);
|
||||
REFLECT(card_notes_height);
|
||||
REFLECT(default_game);
|
||||
REFLECT(apprentice_location);
|
||||
REFLECT(updates_url);
|
||||
REFLECT(check_updates);
|
||||
// ioAll(io, game_settings);
|
||||
// ioStyleSettings(io);
|
||||
// REFLECT_N("default style settings", defaultStyleSettings);
|
||||
// REFLECT(default_style_settings);
|
||||
}
|
||||
|
||||
void Settings::read() {
|
||||
|
||||
+23
-23
@@ -40,11 +40,11 @@ class ColumnSettings {
|
||||
/// Settings for a Game
|
||||
class GameSettings {
|
||||
public:
|
||||
String defaultStyle;
|
||||
String defaultExport;
|
||||
String default_style;
|
||||
String default_export;
|
||||
map<String, ColumnSettings> columns;
|
||||
String sortCardsBy;
|
||||
bool sortCardsAscending;
|
||||
String sort_cards_by;
|
||||
bool sort_cards_ascending;
|
||||
|
||||
DECLARE_REFLECTION();
|
||||
};
|
||||
@@ -53,11 +53,11 @@ class GameSettings {
|
||||
class StyleSettings {
|
||||
public:
|
||||
// Rendering/display settings
|
||||
/* SimpleDefaultable<double> cardZoom = 1.0;
|
||||
SimpleDefaultable<int> cardAngle = 0;
|
||||
SimpleDefaultable<bool> cardAntiAlias = true;
|
||||
SimpleDefaultable<bool> cardBorders = true;
|
||||
SimpleDefaultable<bool> cardNormalExport = true;
|
||||
/* SimpleDefaultable<double> card_zoom = 1.0;
|
||||
SimpleDefaultable<int> card_angle = 0;
|
||||
SimpleDefaultable<bool> card_anti_alias = true;
|
||||
SimpleDefaultable<bool> card_borders = true;
|
||||
SimpleDefaultable<bool> card_normal_export = true;
|
||||
*/
|
||||
DECLARE_REFLECTION();
|
||||
|
||||
@@ -77,20 +77,20 @@ class Settings {
|
||||
Settings();
|
||||
|
||||
// --------------------------------------------------- : Recently opened sets
|
||||
vector<String> recentSets;
|
||||
static const UInt maxRecentSets = 4; // store this many recent sets
|
||||
vector<String> recent_sets;
|
||||
static const UInt max_recent_sets = 4; // store this many recent sets
|
||||
|
||||
/// Add a file to the list of recent files
|
||||
void addRecentFile(const String& filename);
|
||||
|
||||
// --------------------------------------------------- : Set window size
|
||||
bool setWindowMaximized;
|
||||
UInt setWindowWidth;
|
||||
UInt setWindowHeight;
|
||||
UInt cardNotesHeight;
|
||||
bool set_window_maximized;
|
||||
UInt set_window_width;
|
||||
UInt set_window_height;
|
||||
UInt card_notes_height;
|
||||
|
||||
// --------------------------------------------------- : Default pacakge selections
|
||||
String defaultGame;
|
||||
String default_game;
|
||||
|
||||
// --------------------------------------------------- : Game/style specific
|
||||
|
||||
@@ -100,18 +100,18 @@ class Settings {
|
||||
StyleSettings& styleSettingsFor(const CardStyle& style);
|
||||
|
||||
private:
|
||||
map<String,GameSettingsP> gameSettings;
|
||||
map<String,StyleSettingsP> styleSettings;
|
||||
StyleSettings defaultStyleSettings;
|
||||
map<String,GameSettingsP> game_settings;
|
||||
map<String,StyleSettingsP> style_settings;
|
||||
StyleSettings default_style_settings;
|
||||
public:
|
||||
|
||||
// --------------------------------------------------- : Special game stuff
|
||||
String apprenticeLocation;
|
||||
String mwsLocation;
|
||||
String apprentice_location;
|
||||
String mws_location;
|
||||
|
||||
// --------------------------------------------------- : Update checking
|
||||
String updatesUrl;
|
||||
CheckUpdates checkUpdates;
|
||||
String updates_url;
|
||||
CheckUpdates check_updates;
|
||||
|
||||
// --------------------------------------------------- : The io
|
||||
|
||||
|
||||
+30
-30
@@ -27,30 +27,30 @@ IMPLEMENT_REFLECTION_ENUM(SegmentMode) {
|
||||
IMPLEMENT_REFLECTION(ControlPoint) {
|
||||
REFLECT_N("position", pos);
|
||||
REFLECT_N("lock", lock);
|
||||
REFLECT_N("line after", segmentAfter);
|
||||
if (tag.reading() || segmentBefore == SEGMENT_CURVE) {
|
||||
REFLECT_N("handle before", deltaBefore);
|
||||
REFLECT_N("line_after", segment_after);
|
||||
if (tag.reading() || segment_before == SEGMENT_CURVE) {
|
||||
REFLECT_N("handle_before", delta_before);
|
||||
}
|
||||
if (tag.reading() || segmentAfter == SEGMENT_CURVE) {
|
||||
REFLECT_N("handle after", deltaAfter);
|
||||
if (tag.reading() || segment_after == SEGMENT_CURVE) {
|
||||
REFLECT_N("handle_after", delta_after);
|
||||
}
|
||||
}
|
||||
|
||||
ControlPoint::ControlPoint()
|
||||
: segmentBefore(SEGMENT_LINE), segmentAfter(SEGMENT_LINE)
|
||||
: segment_before(SEGMENT_LINE), segment_after(SEGMENT_LINE)
|
||||
, lock(LOCK_FREE)
|
||||
{}
|
||||
ControlPoint::ControlPoint(double x, double y)
|
||||
: segmentBefore(SEGMENT_LINE), segmentAfter(SEGMENT_LINE)
|
||||
: segment_before(SEGMENT_LINE), segment_after(SEGMENT_LINE)
|
||||
, lock(LOCK_FREE)
|
||||
, pos(x,y)
|
||||
{}
|
||||
ControlPoint::ControlPoint(double x, double y, double xb, double yb, double xa, double ya, LockMode lock)
|
||||
: segmentBefore(SEGMENT_CURVE), segmentAfter(SEGMENT_CURVE)
|
||||
: segment_before(SEGMENT_CURVE), segment_after(SEGMENT_CURVE)
|
||||
, lock(lock)
|
||||
, pos(x,y)
|
||||
, deltaBefore(xb,yb)
|
||||
, deltaAfter(xa,ya)
|
||||
, delta_before(xb,yb)
|
||||
, delta_after(xa,ya)
|
||||
{}
|
||||
|
||||
void ControlPoint::onUpdateHandle(WhichHandle wh) {
|
||||
@@ -64,31 +64,31 @@ void ControlPoint::onUpdateHandle(WhichHandle wh) {
|
||||
void ControlPoint::onUpdateLock() {
|
||||
// The lock has changed, avarage the handle values
|
||||
if (lock == LOCK_DIR) {
|
||||
// deltaBefore = x * deltaAfter
|
||||
Vector2D dir = (deltaBefore - deltaAfter).normalized();
|
||||
deltaBefore = dir * deltaBefore.length();
|
||||
deltaAfter = dir * -deltaAfter.length();
|
||||
// delta_before = x * delta_after
|
||||
Vector2D dir = (delta_before - delta_after).normalized();
|
||||
delta_before = dir * delta_before.length();
|
||||
delta_after = dir * -delta_after.length();
|
||||
} else if (lock == LOCK_SIZE) {
|
||||
// deltaBefore = -deltaAfter
|
||||
deltaBefore = (deltaBefore - deltaAfter) * 0.5;
|
||||
deltaAfter = -deltaBefore;
|
||||
// delta_before = -delta_after
|
||||
delta_before = (delta_before - delta_after) * 0.5;
|
||||
delta_after = -delta_before;
|
||||
}
|
||||
}
|
||||
|
||||
Vector2D& ControlPoint::getHandle(WhichHandle wh) {
|
||||
if (wh == HANDLE_BEFORE) {
|
||||
return deltaBefore;
|
||||
return delta_before;
|
||||
} else {
|
||||
assert(wh == HANDLE_AFTER);
|
||||
return deltaAfter;
|
||||
return delta_after;
|
||||
}
|
||||
}
|
||||
Vector2D& ControlPoint::getOther(WhichHandle wh) {
|
||||
if (wh == HANDLE_BEFORE) {
|
||||
return deltaAfter;
|
||||
return delta_after;
|
||||
} else {
|
||||
assert(wh == HANDLE_AFTER);
|
||||
return deltaBefore;
|
||||
return delta_before;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -112,13 +112,13 @@ IMPLEMENT_REFLECTION(SymbolPart) {
|
||||
// enforce constraints
|
||||
enforceConstraints();
|
||||
calculateBounds();
|
||||
if (maxPos.x > 100 && maxPos.y > 100) {
|
||||
if (max_pos.x > 100 && max_pos.y > 100) {
|
||||
// this is a <= 0.1.2 symbol, points range [0...500] instead of [0...1]
|
||||
// adjust it
|
||||
FOR_EACH(p, points) {
|
||||
p->pos /= 500.0;
|
||||
p->deltaBefore /= 500.0;
|
||||
p->deltaAfter /= 500.0;
|
||||
p->pos /= 500.0;
|
||||
p->delta_before /= 500.0;
|
||||
p->delta_after /= 500.0;
|
||||
}
|
||||
if (name.empty()) name = _("Shape");
|
||||
calculateBounds();
|
||||
@@ -127,7 +127,7 @@ IMPLEMENT_REFLECTION(SymbolPart) {
|
||||
}
|
||||
|
||||
SymbolPart::SymbolPart()
|
||||
: combine(PART_OVERLAP), rotationCenter(.5, .5)
|
||||
: combine(PART_OVERLAP), rotation_center(.5, .5)
|
||||
{}
|
||||
|
||||
SymbolPartP SymbolPart::clone() const {
|
||||
@@ -143,16 +143,16 @@ void SymbolPart::enforceConstraints() {
|
||||
for (int i = 0 ; i < (int)points.size() ; ++i) {
|
||||
ControlPointP p1 = getPoint(i);
|
||||
ControlPointP p2 = getPoint(i + 1);
|
||||
p2->segmentBefore = p1->segmentAfter;
|
||||
p2->segment_before = p1->segment_after;
|
||||
p1->onUpdateLock();
|
||||
}
|
||||
}
|
||||
|
||||
void SymbolPart::calculateBounds() {
|
||||
minPos = Vector2D::infinity();
|
||||
maxPos = -Vector2D::infinity();
|
||||
min_pos = Vector2D::infinity();
|
||||
max_pos = -Vector2D::infinity();
|
||||
for (int i = 0 ; i < (int)points.size() ; ++i) {
|
||||
segmentBounds(*getPoint(i), *getPoint(i + 1), minPos, maxPos);
|
||||
segment_bounds(*getPoint(i), *getPoint(i + 1), min_pos, max_pos);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+10
-10
@@ -21,12 +21,12 @@ DECLARE_POINTER_TYPE(Symbol);
|
||||
// ----------------------------------------------------------------------------- : ControlPoint
|
||||
|
||||
/// Mode of locking for control points in a bezier curve
|
||||
/** Specificly: the relation between deltaBefore and deltaAfter
|
||||
/** Specificly: the relation between delta_before and delta_after
|
||||
*/
|
||||
enum LockMode
|
||||
{ LOCK_FREE ///< no locking
|
||||
, LOCK_DIR ///< deltaBefore = x * deltaAfter
|
||||
, LOCK_SIZE ///< deltaBefore = -deltaAfter
|
||||
, LOCK_DIR ///< delta_before = x * delta_after
|
||||
, LOCK_SIZE ///< delta_before = -delta_after
|
||||
};
|
||||
|
||||
/// Is the segment between two ControlPoints a line or a curve?
|
||||
@@ -47,19 +47,19 @@ enum WhichHandle
|
||||
class ControlPoint {
|
||||
public:
|
||||
Vector2D pos; ///< position of the control point itself
|
||||
Vector2D deltaBefore; ///< delta to bezier control point, for curve before point
|
||||
Vector2D deltaAfter; ///< delta to bezier control point, for curve after point
|
||||
SegmentMode segmentBefore, segmentAfter;
|
||||
Vector2D delta_before; ///< delta to bezier control point, for curve before point
|
||||
Vector2D delta_after; ///< delta to bezier control point, for curve after point
|
||||
SegmentMode segment_before, segment_after;
|
||||
LockMode lock;
|
||||
|
||||
/// Default constructor
|
||||
ControlPoint();
|
||||
/// Constructor for straight lines, takes only the position
|
||||
ControlPoint(double x, double y);
|
||||
/// Constructor for curves lines, takes postions, deltaBefore, deltaAfter and lock mode
|
||||
/// Constructor for curves lines, takes postions, delta_before, delta_after and lock mode
|
||||
ControlPoint(double x, double y, double xb, double yb, double xa, double ya, LockMode lock = LOCK_FREE);
|
||||
|
||||
/// Must be called after deltaBefore/deltaAfter has changed, enforces lock constraints
|
||||
/// Must be called after delta_before/delta_after has changed, enforces lock constraints
|
||||
void onUpdateHandle(WhichHandle wh);
|
||||
/// Must be called after lock has changed, enforces lock constraints
|
||||
void onUpdateLock();
|
||||
@@ -124,10 +124,10 @@ class SymbolPart {
|
||||
/// How is this part combined with parts below it?
|
||||
SymbolPartCombine combine;
|
||||
// Center of rotation, relative to the part, when the part is scaled to [0..1]
|
||||
Vector2D rotationCenter;
|
||||
Vector2D rotation_center;
|
||||
/// Position and size of the part
|
||||
/// this is the smallest axis aligned bounding box that fits around the part
|
||||
Vector2D minPos, maxPos;
|
||||
Vector2D min_pos, max_pos;
|
||||
|
||||
SymbolPart();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user