[Supertux-Commit] r5848 - trunk/supertux-editor/supertux-editor/Editors
mmlosh at millhouse.dreamhost.com
mmlosh at millhouse.dreamhost.com
Thu Mar 12 12:44:31 PDT 2009
Author: mmlosh
Date: 2009-03-12 12:44:30 -0700 (Thu, 12 Mar 2009)
New Revision: 5848
Modified:
trunk/supertux-editor/supertux-editor/Editors/ObjectsEditor.cs
Log:
Fixed snapping when moving GameObjects, it behaves as expected now.
Fixed moving to negative coordinates (just to make it looking "normal" when it accidentaly happens)
Right mouse button can be used to cancel drag of GameObject.
Some very basic code for multi-selection
Modified: trunk/supertux-editor/supertux-editor/Editors/ObjectsEditor.cs
===================================================================
--- trunk/supertux-editor/supertux-editor/Editors/ObjectsEditor.cs 2009-03-12 16:51:26 UTC (rev 5847)
+++ trunk/supertux-editor/supertux-editor/Editors/ObjectsEditor.cs 2009-03-12 19:44:30 UTC (rev 5848)
@@ -141,8 +141,7 @@
private Vector pressPoint;
private RectangleF originalArea;
private bool dragging;
- // Used to make sure we just do undo snapshot when moving.
- //private bool moveStarted;
+ private bool selecting;
private List<ControlPoint> controlPoints = new List<ControlPoint>();
public event RedrawEventHandler Redraw;
@@ -177,31 +176,41 @@
public void OnMouseButtonPress(Vector mousePos, int button, ModifierType Modifiers)
{
- if(button == 1 || button == 3) {
- if (activeObject == null || !activeObject.Area.Contains(mousePos)) {
- MakeActive(FindNext(mousePos));
- }
+ if (button == 1) {
+ if (selecting) {
+ selecting = false;
+ } else {
+ if (activeObject == null || !activeObject.Area.Contains(mousePos)) {
+ MakeActive(FindNext(mousePos));
+ }
- if(activeObject != null && button == 1) {
- pressPoint = mousePos;
- originalArea = activeObject.Area;
- dragging = true;
+ if(activeObject != null && button == 1) {
+ pressPoint = mousePos;
+ originalArea = activeObject.Area;
+ dragging = true;
+ }
+
+ Redraw();
}
-
- Redraw();
}
- if(button == 3) {
- PopupMenu(button);
+ if (button == 3) {
+ if (dragging) {
+ activeObject.ChangeArea(originalArea);
+ dragging = false;
+ Redraw();
+ } else {
+ selecting = true;
+ Redraw();
+ }
}
}
public void OnMouseButtonRelease(Vector mousePos, int button, ModifierType Modifiers)
{
- if(dragging) {
+ if (button == 1 && dragging) {
dragging = false;
if (mousePos != pressPoint) {
- //moveStarted = false;
ObjectAreaChangeCommand command = new ObjectAreaChangeCommand(
"Moved Object " + activeObject,
originalArea,
@@ -214,15 +223,19 @@
Redraw();
}
}
+ if (button == 3 && selecting) {
+ selecting = false;
+ if (activeObject == null || !activeObject.Area.Contains(mousePos)) {
+ MakeActive(FindNext(mousePos));
+ Redraw();
+ }
+ PopupMenu(button);
+ }
}
public void OnMouseMotion(Vector mousePos, ModifierType Modifiers)
{
if(dragging) {
- //if (!moveStarted) {
- // application.TakeUndoSnapshot("Moved Object " + activeObject);
- // moveStarted = true;
- //}
moveObject(mousePos, SnapValue(Modifiers));
}
}
@@ -394,10 +407,12 @@
Vector spos = new Vector(originalArea.Left, originalArea.Top);
spos += mousePos - pressPoint;
if (snap > 0) {
+ spos.X += snap / 2; //PressPoint would be cutting edge instead of "center" without this correction
+ spos.Y += snap / 2;
// TODO: Get this right for area objects, they currently snap to the
// handle instead of the actual object...
- spos = new Vector((float) ((int) spos.X / snap) * snap,
- (float) ((int) spos.Y / snap) * snap);
+ spos = new Vector((float) ((int) spos.X / snap) * snap - ((spos.X<0)?snap:0),
+ (float) ((int) spos.Y / snap) * snap - ((spos.Y<0)?snap:0));
}
return new RectangleF(spos.X, spos.Y,
More information about the Supertux-Commit
mailing list