Engine:
authorsmaxx
Tue, 03 Aug 2010 02:33:57 +0200
changeset 3714 c407f00d2851
parent 3713 f8778904600d
child 3715 53896622d60b
Engine: * Rewrote sticky mine code including simple orientation adjustment Frontend: * Skinned slider control
QTfrontend/main.cpp
QTfrontend/pages.cpp
hedgewars/GSHandlers.inc
--- a/QTfrontend/main.cpp	Tue Aug 03 01:33:20 2010 +0200
+++ b/QTfrontend/main.cpp	Tue Aug 03 02:33:57 2010 +0200
@@ -294,6 +294,18 @@
             "SquareLabel, ItemNum {"
                 "background-color: #000000;"
             "}"
+            "QSlider::groove::horizontal {"
+                "height: 2px;"
+                "margin: 2px 0px;"
+                "background-color: #ffcc00;"
+            "}"
+            "QSlider::handle::horizontal {"
+                "border: 0px;"
+                "margin: -2px 0px;"
+                "border-radius: 3px;"
+                "background-color: #ffcc00;"
+                "width: 8px;"
+            "}"
             )
         );
 
--- a/QTfrontend/pages.cpp	Tue Aug 03 01:33:20 2010 +0200
+++ b/QTfrontend/pages.cpp	Tue Aug 03 02:33:57 2010 +0200
@@ -611,6 +611,7 @@
 
             QLabel * quality = new QLabel(AGGroupBox);
             quality->setText(QLabel::tr("Quality"));
+            quality->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
             GBAqualayout->addWidget(quality);
             
             SLQuality = new QSlider(Qt::Horizontal, AGGroupBox);
--- a/hedgewars/GSHandlers.inc	Tue Aug 03 01:33:20 2010 +0200
+++ b/hedgewars/GSHandlers.inc	Tue Aug 03 02:33:57 2010 +0200
@@ -1441,15 +1441,66 @@
 end;
 
 ////////////////////////////////////////////////////////////////////////////////
-procedure doStepSMine(Gear: PGear); forward;
-procedure doStepSMineSticked(Gear: PGear);
+procedure doStepSMine(Gear: PGear);
 begin
-    if (hwAbs(Gear^.dX) > _0) or (hwAbs(Gear^.dY) > _0) then // moving - "unstick" (better solution?)
+    DeleteCI(Gear);
+    // TODO: do real calculation?
+    if TestCollisionXwithGear(Gear, 2) and TestCollisionYwithGear(Gear, -2) then
+    begin
+        Gear^.dX:= _0;
+        Gear^.dY:= _0;
+        Gear^.DirAngle:= 225
+    end
+    else if TestCollisionXwithGear(Gear, -2) and TestCollisionYwithGear(Gear, -2) then
+    begin
+        Gear^.dX:= _0;
+        Gear^.dY:= _0;
+        Gear^.DirAngle:= 135
+    end
+    else if TestCollisionXwithGear(Gear, 2) and TestCollisionYwithGear(Gear, 2) then
+    begin
+        Gear^.dX:= _0;
+        Gear^.dY:= _0;
+        Gear^.DirAngle:= 315
+    end
+    else if TestCollisionXwithGear(Gear, -2) and TestCollisionYwithGear(Gear, 2) then
+    begin
+        Gear^.dX:= _0;
+        Gear^.dY:= _0;
+        Gear^.DirAngle:= 45
+    end
+    else if TestCollisionYwithGear(Gear, -2) then
     begin
-        Gear^.doStep:= @doStepSMine;
-        Gear^.doStep(Gear);
-        exit;
+        Gear^.dX:= _0;
+        Gear^.dY:= _0;
+        Gear^.DirAngle:= 180
+    end
+    else if TestCollisionYwithGear(Gear, 2) then
+    begin
+        Gear^.dX:= _0;
+        Gear^.dY:= _0;
+        Gear^.DirAngle:= 0
+    end
+    else if TestCollisionXwithGear(Gear, -2) then
+    begin
+        Gear^.dX:= _0;
+        Gear^.dY:= _0;
+        Gear^.DirAngle:= 90
+    end
+    else if TestCollisionXwithGear(Gear, 2) then
+    begin
+        Gear^.dX:= _0;
+        Gear^.dY:= _0;
+        Gear^.DirAngle:= 270
+    end
+    else
+    begin
+        doStepFallingGear(Gear);
+        AllInactive := false;
+        CalcRotationDirAngle(Gear);
     end;
+    AddGearCI(Gear);
+
     if ((Gear^.State and gsttmpFlag) <> 0) and (Gear^.Health <> 0) then
         if ((Gear^.State and gstAttacking) = 0) then
         begin
@@ -1473,27 +1524,6 @@
         if TurnTimeLeft = 0 then Gear^.State := Gear^.State or gsttmpFlag;
 end;
 
-procedure doStepSMine(Gear: PGear);
-begin
-    if ((Gear^.State and gstCollision) <> 0) and (Gear^.dX < _0_2) and (Gear^.dY < _0_2) then
-    begin
-        Gear^.dX:= _0;
-        Gear^.dY:= _0;
-        Gear^.doStep:= @doStepSMineSticked;
-        Gear^.doStep(Gear);
-        exit
-    end;
-    if (Gear^.State and gstMoving) <> 0 then
-    begin
-        DeleteCI(Gear);
-        doStepFallingGear(Gear);
-        if (Gear^.State and gstMoving) = 0 then
-            AddGearCI(Gear);
-    end;
-    CalcRotationDirAngle(Gear);
-    AllInactive := false
-end;
-
 ////////////////////////////////////////////////////////////////////////////////
 procedure doStepDynamite(Gear: PGear);
 begin