DEADSOFTWARE

Movement: Implement WASD move/resize
authorbinarymaster <x86corez@gmail.com>
Fri, 29 Sep 2017 19:59:51 +0000 (22:59 +0300)
committerbinarymaster <x86corez@gmail.com>
Fri, 29 Sep 2017 19:59:51 +0000 (22:59 +0300)
http://doom2d.org/forum/viewtopic.php?f=12&t=1483

src/editor/f_main.pas

index 8158c03344f380660a7de069841ce8357aedb984..63f31f4a83d7edc3aaa77513e34b171e75e1f2e1 100644 (file)
@@ -435,6 +435,7 @@ var
   MouseRDown: Boolean;
   MouseLDownPos: Types.TPoint;
   MouseRDownPos: Types.TPoint;
+  WASDOffset: TPoint;
 
   SelectFlag: Byte = SELECTFLAG_NONE;
   MouseAction: Byte = MOUSEACTION_NONE;
@@ -3982,8 +3983,10 @@ begin
       if MouseAction = MOUSEACTION_MOVEOBJ then
         begin
           MoveSelectedObjects(ssShift in Shift, ssCtrl in Shift,
-                              MousePos.X-LastMovePoint.X,
-                              MousePos.Y-LastMovePoint.Y);
+                              MousePos.X-LastMovePoint.X+WASDOffset.X,
+                              MousePos.Y-LastMovePoint.Y+WASDOffset.Y);
+          WASDOffset.X := 0;
+          WASDOffset.Y := 0;
         end
       else
       // Меняем размер выделенного объекта:
@@ -3992,8 +3995,10 @@ begin
           if (SelectedObjectCount = 1) and
              (SelectedObjects[GetFirstSelected].Live) then
           begin
-            dWidth := MousePos.X-LastMovePoint.X;
-            dHeight := MousePos.Y-LastMovePoint.Y;
+            dWidth := MousePos.X-LastMovePoint.X+WASDOffset.X;
+            dHeight := MousePos.Y-LastMovePoint.Y+WASDOffset.Y;
+            WASDOffset.X := 0;
+            WASDOffset.Y := 0;
 
             case ResizeType of
               RESIZETYPE_VERTICAL: dWidth := 0;
@@ -4215,12 +4220,22 @@ begin
       begin
         if Key = Ord('W') then
         begin
+          if (MouseLDown or MouseRDown) and (Position >= DotStep) then
+          begin
+            Dec(WASDOffset.Y, DotStep);
+            RenderPanelMouseMove(Sender, Shift, LastMovePoint.X, LastMovePoint.Y);
+          end;
           Position := IfThen(Position > DotStep, Position-DotStep, 0);
           MapOffset.Y := -Round(Position/16) * 16;
         end;
 
         if Key = Ord('S') then
         begin
+          if (MouseLDown or MouseRDown) and (Position+DotStep <= Max) then
+          begin
+            Inc(WASDOffset.Y, DotStep);
+            RenderPanelMouseMove(Sender, Shift, LastMovePoint.X, LastMovePoint.Y);
+          end;
           Position := IfThen(Position+DotStep < Max, Position+DotStep, Max);
           MapOffset.Y := -Round(Position/16) * 16;
         end;
@@ -4231,12 +4246,22 @@ begin
       begin
         if Key = Ord('A') then
         begin
+          if (MouseLDown or MouseRDown) and (Position >= DotStep) then
+          begin
+            Dec(WASDOffset.X, DotStep);
+            RenderPanelMouseMove(Sender, Shift, LastMovePoint.X, LastMovePoint.Y);
+          end;
           Position := IfThen(Position > DotStep, Position-DotStep, 0);
           MapOffset.X := -Round(Position/16) * 16;
         end;
 
         if Key = Ord('D') then
         begin
+          if (MouseLDown or MouseRDown) and (Position+DotStep <= Max) then
+          begin
+            Inc(WASDOffset.X, DotStep);
+            RenderPanelMouseMove(Sender, Shift, LastMovePoint.X, LastMovePoint.Y);
+          end;
           Position := IfThen(Position+DotStep < Max, Position+DotStep, Max);
           MapOffset.X := -Round(Position/16) * 16;
         end;