HedgeEditor: Show waypoint preview
authorWuzzy <Wuzzy2@mail.ru>
Thu, 08 Mar 2018 21:03:25 +0100
changeset 13127 a7b67247784d
parent 13126 b1de2f84e130
child 13128 2f7c8e2ebe8e
HedgeEditor: Show waypoint preview
share/hedgewars/Data/Scripts/Multiplayer/HedgeEditor.lua
--- a/share/hedgewars/Data/Scripts/Multiplayer/HedgeEditor.lua	Thu Mar 08 20:40:00 2018 +0100
+++ b/share/hedgewars/Data/Scripts/Multiplayer/HedgeEditor.lua	Thu Mar 08 21:03:25 2018 +0100
@@ -594,6 +594,7 @@
 local CG = nil -- this is the visual gear displayed at CursorX, CursorY
 local crateSprite = nil-- this is a visual gear aid for crate placement
 local crateSpriteBorer = nil
+local waypointPreviewSprite = nil
 
 local cGear = nil -- detects placement of girders and objects (using airattack)
 local curWep = amNothing
@@ -654,6 +655,8 @@
 local closestGear = nil
 local closestSpriteID = nil
 
+local wpRadius = 450
+
 ------------------------
 -- SOME GENERAL METHODS
 ------------------------
@@ -902,8 +905,8 @@
 	placedSprite[placedCount] = vgtCircle
 	placedSpec[placedCount] = AddVisualGear(x,y,vgtCircle,0,true)
 	placedTint[placedCount] = 0xFF0000FF
-	placedFrame[placedCount] = 1										--rad is 450
-	SetVisualGearValues(placedSpec[placedCount], x, y, 164, 224, 1, 10, 0, 450, 5, placedTint[placedCount])
+	placedFrame[placedCount] = 1
+	SetVisualGearValues(placedSpec[placedCount], x, y, 164, 224, 1, 10, 0, wpRadius, 5, placedTint[placedCount])
 	placedCount = placedCount +1
 
 end
@@ -2975,6 +2978,20 @@
 				end
 			end
 
+			-- Waypoint outline
+			if (cat[cIndex] == loc("Waypoint Editing Mode")) and (pMode[pIndex] == loc("Place Waypoint")) then
+				if not waypointPreviewSprite then
+					waypointPreviewSprite = AddVisualGear(CursorX, CursorY, vgtCircle, 1, true)
+					SetVisualGearValues(waypointPreviewSprite, CursorX, CursorY, 244, 224, 0, 0, 0, wpRadius/5, 5, 0xFF0000FF)
+				end
+			elseif waypointPreviewSprite then
+				DeleteVisualGear(waypointPreviewSprite)
+				waypointPreviewSprite = nil
+			end
+			if waypointPreviewSprite then
+				SetVisualGearValues(waypointPreviewSprite, CursorX, CursorY)
+			end
+
 		else
 			SetSoundMask(sndIncoming, false)
 			if CG ~= nil then