HedgeEditor: Remove gear info tags
authorWuzzy <Wuzzy2@mail.ru>
Sun, 07 Apr 2019 19:31:58 +0200
changeset 14756 430c90fa6062
parent 14755 ab7bf5036314
child 14757 56098968df90
HedgeEditor: Remove gear info tags Because gear info tags are now supported in the engine
share/hedgewars/Data/Scripts/Multiplayer/HedgeEditor.lua
--- a/share/hedgewars/Data/Scripts/Multiplayer/HedgeEditor.lua	Sun Apr 07 19:26:16 2019 +0200
+++ b/share/hedgewars/Data/Scripts/Multiplayer/HedgeEditor.lua	Sun Apr 07 19:31:58 2019 +0200
@@ -297,8 +297,6 @@
 
 -- Misc. state variables
 local hedgeEditorMissionPanelShown = false
-local tagGears = {}
-local showGearTags = true
 
 local tagCursorX, tagCursorY
 
@@ -2540,7 +2538,6 @@
 				loc("Deletion Mode: [5]") .. "|" ..
 				" " .. "|" ..
 				loc("Toggle Help: [Precise]+[1]") .. "|" ..
-				loc("Toggle Gear Information: [Precise]+[3]") .. "|" ..
 				"", -amGirder, 60000, not helpDisabled
 				)
 		hedgeEditorMissionPanelShown = false
@@ -2558,7 +2555,6 @@
 				loc("Deletion Mode: [5]") .. "|" ..
 				" " .. "|" ..
 				loc("Toggle Help: [Precise]+[1]") .. "|" ..
-				loc("Toggle Gear Information: [Precise]+[3]") .. "|" ..
 				"", -amRubber, 60000, not helpDisabled
 				)
 		hedgeEditorMissionPanelShown = false
@@ -2573,7 +2569,6 @@
 				" " .. "|" ..
 				loc("Change Placement Mode: [Up], [Down]") .. "|" ..
 				loc("Toggle Help: [Precise]+[1]") .. "|" ..
-				loc("Toggle Gear Information: [Precise]+[3]") .. "|" ..
 				"", 8, 60000, not helpDisabled
 				)
 		hedgeEditorMissionPanelShown = false
@@ -2587,7 +2582,6 @@
 				" " .. "|" ..
 				loc("Change Placement Mode: [Up], [Down]") .. "|" ..
 				loc("Toggle Help: [Precise]+[1]") .. "|" ..
-				loc("Toggle Gear Information: [Precise]+[3]") .. "|" ..
 				"", -amKnife, 60000, not helpDisabled
 				)
 		hedgeEditorMissionPanelShown = false
@@ -2601,7 +2595,6 @@
 				" " .. "|" ..
 				loc("Change Placement Mode: [Up], [Down]") .. "|" ..
 				loc("Toggle Help: [Precise]+[1]") .. "|" ..
-				loc("Toggle Gear Information: [Precise]+[3]") .. "|" ..
 				"", 1, 60000, not helpDisabled
 				)
 		hedgeEditorMissionPanelShown = false
@@ -2616,7 +2609,6 @@
 				" " .. "|" ..
 				loc("Change Placement Mode: [Up], [Down]") .. "|" ..
 				loc("Toggle Help: [Precise]+[1]") .. "|" ..
-				loc("Toggle Gear Information: [Precise]+[3]") .. "|" ..
 				"", -amCMGearPlacementTool, 60000, not helpDisabled
 				)
 		hedgeEditorMissionPanelShown = false
@@ -2631,7 +2623,6 @@
 				" " .. "|" ..
 				loc("Change Placement Mode: [Up], [Down]") .. "|" ..
 				loc("Toggle Help: [Precise]+[1]") .. "|" ..
-				loc("Toggle Gear Information: [Precise]+[3]") .. "|" ..
 				"", -amMine, 60000, not helpDisabled
 				)
 		hedgeEditorMissionPanelShown = false
@@ -2646,7 +2637,6 @@
 				" " .. "|" ..
 				loc("Change Placement Mode: [Up], [Down]") .. "|" ..
 				loc("Toggle Help: [Precise]+[1]") .. "|" ..
-				loc("Toggle Gear Information: [Precise]+[3]") .. "|" ..
 				"", 9, 60000, not helpDisabled
 				)
 		hedgeEditorMissionPanelShown = false
@@ -2661,7 +2651,6 @@
 				" " .. "|" ..
 				loc("Change Placement Mode: [Up], [Down]") .. "|" ..
 				loc("Toggle Help: [Precise]+[1]") .. "|" ..
-				loc("Toggle Gear Information: [Precise]+[3]") .. "|" ..
 				"", -amSMine, 60000, not helpDisabled
 				)
 		hedgeEditorMissionPanelShown = false
@@ -2676,7 +2665,6 @@
 				" " .. "|" ..
 				loc("Change Placement Mode: [Up], [Down]") .. "|" ..
 				loc("Toggle Help: [Precise]+[1]") .. "|" ..
-				loc("Toggle Gear Information: [Precise]+[3]") .. "|" ..
 				"", -amAirMine, 60000, not helpDisabled
 				)
 		hedgeEditorMissionPanelShown = false
@@ -2691,7 +2679,6 @@
 				" " .. "|" ..
 				loc("Change Placement Mode: [Up], [Down]") .. "|" ..
 				loc("Toggle Help: [Precise]+[1]") .. "|" ..
-				loc("Toggle Gear Information: [Precise]+[3]") .. "|" ..
 				"", 7, 60000, not helpDisabled
 				)
 		hedgeEditorMissionPanelShown = false
@@ -2706,7 +2693,6 @@
 				" " .. "|" ..
 				loc("Change Placement Mode: [Up], [Down]") .. "|" ..
 				loc("Toggle Help: [Precise]+[1]") .. "|" ..
-				loc("Toggle Gear Information: [Precise]+[3]") .. "|" ..
 				"", 5, 60000, not helpDisabled
 				)
 		hedgeEditorMissionPanelShown = false
@@ -2721,7 +2707,6 @@
 				" " .. "|" ..
 				loc("Change Placement Mode: [Up], [Down]") .. "|" ..
 				loc("Toggle Help: [Precise]+[1]") .. "|" ..
-				loc("Toggle Gear Information: [Precise]+[3]") .. "|" ..
 				"", 6, 60000, not helpDisabled
 				)
 		hedgeEditorMissionPanelShown = false
@@ -2736,7 +2721,6 @@
 				" " .. "|" ..
 				loc("Change Placement Mode: [Up], [Down]") .. "|" ..
 				loc("Toggle Help: [Precise]+[1]") .. "|" ..
-				loc("Toggle Gear Information: [Precise]+[3]") .. "|" ..
 				"", -amCMGearPlacementTool, 60000, not helpDisabled
 				)
 		hedgeEditorMissionPanelShown = false
@@ -2757,7 +2741,6 @@
 				" " .. "|" ..
 				loc("Change Placement Mode: [Up], [Down]") .. "|" ..
 				loc("Toggle Help: [Precise]+[1]") .. "|" ..
-				loc("Toggle Gear Information: [Precise]+[3]") .. "|" ..
 				"", 2, 60000, not helpDisabled
 				)
 		hedgeEditorMissionPanelShown = false
@@ -2778,7 +2761,6 @@
 				" " .. "|" ..
 				loc("Change Placement Mode: [Up], [Down]") .. "|" ..
 				loc("Toggle Help: [Precise]+[1]") .. "|" ..
-				loc("Toggle Gear Information: [Precise]+[3]") .. "|" ..
 				"", -amCMGearPlacementTool, 60000, not helpDisabled
 				)
 		hedgeEditorMissionPanelShown = false
@@ -2793,7 +2775,6 @@
 				" " .. "|" ..
 				loc("Change Placement Mode: [Up], [Down]") .. "|" ..
 				loc("Toggle Help: [Precise]+[1]") .. "|" ..
-				loc("Toggle Gear Information: [Precise]+[3]") .. "|" ..
 				"", 0, 60000, not helpDisabled
 				)
 		hedgeEditorMissionPanelShown = false
@@ -2807,7 +2788,6 @@
 				" " .. "|" ..
 				loc("Change Placement Mode: [Up], [Down]") .. "|" ..
 				loc("Toggle Help: [Precise]+[1]") .. "|" ..
-				loc("Toggle Gear Information: [Precise]+[3]") .. "|" ..
 				"", 3, 60000, not helpDisabled
 				)
 		hedgeEditorMissionPanelShown = false
@@ -2822,7 +2802,6 @@
 				" " .. "|" ..
 				loc("Change Placement Mode: [Up], [Down]") .. "|" ..
 				loc("Toggle Help: [Precise]+[1]") .. "|" ..
-				loc("Toggle Gear Information: [Precise]+[3]") .. "|" ..
 				"", 3, 60000, not helpDisabled
 				)
 		hedgeEditorMissionPanelShown = false
@@ -2837,7 +2816,6 @@
 				" " .. "|" ..
 				loc("Change Placement Mode: [Up], [Down]") .. "|" ..
 				loc("Toggle Help: [Precise]+[1]") .. "|" ..
-				loc("Toggle Gear Information: [Precise]+[3]") .. "|" ..
 				"", 2, 60000, not helpDisabled
 				)
 		hedgeEditorMissionPanelShown = false
@@ -3109,116 +3087,6 @@
 	-- Show cursor coords
 	updateCursorCoords()
 
-	-- Barrel health tags, mine timer tags and health crate health tags
-	if GameTime % 20 == 0 then
-		local actualValue	-- internal value
-		local printedValue	-- value exposed to HUD
-		for g, v in pairs(tagGears) do
-			local gt = GetGearType(g)
-			if v == -1 then
-				if gt == gtCase then
-					if(band(GetGearPos(g), 0x2) ~= 0) and (band(GetState(g), gstFrozen) == 0) then
-						v = AddVisualGear(0, 0, vgtHealthTag, GetHealth(g), true)
-						SetVisualGearValues(v, nil, nil, 0, 0, nil, 0, 1, nil, 240000, 0x808080FF)
-						tagGears[g] = v
-					else
-						tagGears[g] = nil
-					end
-				else
-					if gt == gtMine and GetHealth(g) == 0 then
-						local _, damage, health
-						_, _, _, _, _, _, _, _, _, _, _, damage = GetGearValues(g)
-						health = 36 - damage
-						v = AddVisualGear(0, 0, vgtHealthTag, health, true)
-						SetVisualGearValues(v, nil, nil, 0, 0, nil, 0, 1, nil, 240000, 0x808080FF)
-						tagGears[g] = v
-					end
-				end
-			end
-			-- Delete tag for drowning gears
-			if(band(GetState(g), gstDrowning) ~= 0) then
-				DeleteVisualGear(v)
-				tagGears[g] = nil
-			-- Delete tag for frozen sticky mines, air mines and crates
-			elseif(band(GetState(g), gstFrozen) ~= 0 and (gt == gtAirMine or gt == gtSMine or gt == gtCase)) then
-				DeleteVisualGear(v)
-				tagGears[g] = nil
-			elseif(tagGears[g] ~= nil and tagGears[g] ~= -1) then
-				local tag, actualvalue, offset_x, offset_y
-				tag = GetState(v)
-				if(gt == gtExplosives) then
-					actualValue = GetHealth(g)
-					printedValue = actualValue
-					offset_y = -20
-					offset_x = 0
-				elseif(gt == gtAirMine) then
-					if(band(GetState(g), gstAttacking) ~= 0) then
-						actualValue = GetTimer(g)
-						printedValue = actualValue
-					else
-						local _
-						_, _, actualValue = GetGearValues(g)
-						printedValue = actualValue
-					end
-					offset_y = 28
-					offset_x = 16
-				elseif(gt == gtCase) then
-					actualValue = GetHealth(g)
-					printedValue = actualValue
-					offset_y = -20
-					offset_x = 1
-				elseif(gt == gtMine) then
-					if(GetHealth(g) ~= 0) then
-						-- Non-dud: Show timer
-						actualValue = GetTimer(g)
-						printedValue = actualValue
-						offset_y = 28
-						offset_x = 16
-					else
-						-- Dud: Show health
-						local _
-						_, _, _, _, _, _, _, _, _, _, _, actualValue = GetGearValues(g)
-						printedValue = 36 - actualValue
-						offset_y = -12
-						offset_x = 0
-					end
-				elseif(gt == gtSMine) then
-					actualValue = GetTimer(g)
-					printedValue = actualValue
-					offset_y = 28
-					offset_x = 16
-				end
-				local tint
-				if(not showGearTags) then
-					-- Hide the tags
-					tint = 0x00000000
-				elseif(gt == gtCase) then
-					tint = 0x80FF80FF
-				elseif(gt == gtExplosives or (gt == gtMine and GetHealth(g) == 0)) then
-					tint = 0x808080FF
-				elseif(band(GetState(g), gstAttacking) ~= 0) then
-					if(actualValue % 1000 > 500) then
-						tint = 0xFFA0A0FF
-					else
-						tint = 0xFF4040FF
-					end
-				else
-					tint = 0xFFFFFFFF
-				end
-				if(actualValue ~= tag) then
-					--[[ If timer/health changed, delete visual gear and add it again.
-					Changing the visual gear state does not have any effect, so we need this hack ]]
-					DeleteVisualGear(v)
-					v = AddVisualGear(GetX(g)+offset_x, GetY(g)+offset_y, vgtHealthTag, printedValue, true)
-					SetVisualGearValues(v, nil, nil, 0, 0, nil, 0, 1, nil, 240000, tint)
-					tagGears[g] = v
-				else
-					-- Just update position if the health did not change
-					SetVisualGearValues(v, GetX(g)+offset_x, GetY(g)+offset_y, 0, 0, nil, 0, 1, nil, 240000, tint)
-				end
-			end
-		end
-	end
 end
 
 --------------------------------------------------
@@ -3254,14 +3122,6 @@
 			AddCaption(loc("Help Enabled"), colorInfoMessage, capgrpVolume)
 		end
 		updateHelp()
-	elseif (preciseOn == true) and (s == 3) then
-		showGearTags = not(showGearTags)
-		if showGearTags then
-			AddCaption(loc("Gear information shown"), colorInfoMessage, capgrpVolume)
-		else
-			AddCaption(loc("Gear information hidden"), colorInfoMessage, capgrpVolume)
-		end
-
 	elseif (cat[cIndex] == loc("Sprite Placement Mode")) or (cat[cIndex] == loc("Girder Placement Mode")) or (cat[cIndex] == loc("Rubber Placement Mode")) or (cat[cIndex] == loc("Sprite Modification Mode")) then
 
 		if (cat[cIndex] == loc("Rubber Placement Mode")) then
@@ -3507,7 +3367,6 @@
 		loc("Place Rubber: Rubber") .. "|" ..
 		loc("Place Gears (and more): Gear Placement Tool") .. "|" ..
 		loc("Toggle Help: [Precise]+[1]") .. "|" ..
-		loc("Toggle Gear Information: [Precise]+[3]") .. "|" ..
 		" " .. "|" ..
 		loc("Editing Commands: (Use while no weapon is selected)") .. "|" ..
 		loc("Save Level: [Precise]+[4]") .. "|" ..
@@ -3843,34 +3702,6 @@
 	end
 
 	local tagTint
-	if showGearTags then
-		tagTint = 0xFFFFFFFF
-	else
-		tagTint = 0x00000000
-	end
-	if ((GetGearType(gear) == gtMine and GetHealth(gear) ~= 0) or (GetGearType(gear) == gtSMine and band(GetState(gear), gstFrozen) == 0)) then
-		local v = AddVisualGear(0, 0, vgtHealthTag, GetTimer(gear), true)
-		SetVisualGearValues(v, nil, nil, 0, 0, nil, 0, 1, nil, 240000, tagTint)
-		tagGears[gear] = v
-	elseif ((GetGearType(gear) == gtMine and GetHealth(gear) == 0)) then
-		local _, dmg
-		_, _, _, _, _, _, _, _, _, _, dmg = GetGearValues(gear)
-		local v = AddVisualGear(0, 0, vgtHealthTag, 36 - dmg, true)
-		SetVisualGearValues(v, nil, nil, 0, 0, nil, 0, 1, nil, 240000, tagTint)
-		tagGears[gear] = v
-	elseif (GetGearType(gear) == gtAirMine and band(GetState(gear), gstFrozen) == 0) then
-		local _, wdTimer
-		_, _, wdTimer = GetGearValues(gear)
-		local v = AddVisualGear(0, 0, vgtHealthTag, wdTimer, true)
-		SetVisualGearValues(v, nil, nil, 0, 0, nil, 0, 1, nil, 240000, tagTint)
-		tagGears[gear] = v
-	elseif (GetGearType(gear) == gtCase) then
-		tagGears[gear] = -1
-	elseif (GetGearType(gear) == gtExplosives) then 
-		local v = AddVisualGear(0, 0, vgtHealthTag, GetHealth(gear), true)
-		SetVisualGearValues(v, nil, nil, 0, 0, nil, 0, 1, nil, 240000, tagTint)
-		tagGears[gear] = v
-	end
 
 	if isATrackedGear(gear) then
 		trackGear(gear)
@@ -3894,14 +3725,6 @@
 		cGear = nil
 	end
 
-	if (gt == gtMine or gt == gtSMine or gt == gtAirMine or gt == gtExplosives or gt == gtCase) then 
-		if(tagGears[gear] ~= -1) then
-			DeleteVisualGear(tagGears[gear])
-		end
-		tagGears[gear] = nil
-	end
-
-
 	if isATrackedGear(gear) then
 
 		if getGearValue(gear, "tCirc") ~= nil then