share/hedgewars/Data/Scripts/Multiplayer/HedgeEditor.lua
changeset 13033 a823de31240e
parent 12976 4772eb3c9929
child 13125 c8c8f856e236
equal deleted inserted replaced
13032:91f23558c936 13033:a823de31240e
   299 
   299 
   300 -- Misc. state variables
   300 -- Misc. state variables
   301 local hedgeEditorMissionPanelShown = false
   301 local hedgeEditorMissionPanelShown = false
   302 local tagGears = {}
   302 local tagGears = {}
   303 local showGearTags = true
   303 local showGearTags = true
       
   304 
       
   305 local tagCursorX, tagCursorY
   304 
   306 
   305 ---------------------------------
   307 ---------------------------------
   306 -- crates are made of this stuff
   308 -- crates are made of this stuff
   307 ---------------------------------
   309 ---------------------------------
   308 
   310 
  2805 function onSlot()
  2807 function onSlot()
  2806 	curWep = GetCurAmmoType()
  2808 	curWep = GetCurAmmoType()
  2807 	updateHelp(ammoType)
  2809 	updateHelp(ammoType)
  2808 end
  2810 end
  2809 
  2811 
       
  2812 function onScreenResize()
       
  2813 	updateCursorCoords()
       
  2814 end
       
  2815 
       
  2816 -- Display the X and Y coordinates of the cursor while the cursor is active
       
  2817 function updateCursorCoords()
       
  2818 	if band(GetState(CurrentHedgehog), gstChooseTarget) ~= 0 and CursorX ~= -2147483648 then
       
  2819 		local x1, y = 12, 24
       
  2820 		if tagCursorX then
       
  2821 			DeleteVisualGear(tagCursorX)
       
  2822 		end
       
  2823 		tagCursorX = AddVisualGear(-div(ScreenWidth, 2)+x1, y, vgtHealthTag, CursorX, true)
       
  2824 		SetVisualGearValues(tagCursorX, nil, nil, 0, 0, nil, 1, nil, nil, 240000, 0xFFFFFFFF)
       
  2825 
       
  2826 		local x2
       
  2827 		if string.len(tostring(CursorX)) > 6 then
       
  2828 			x2 = x1 + 100
       
  2829 		else
       
  2830 			x2 = x1 + 60
       
  2831 		end
       
  2832 		if tagCursorY then
       
  2833 			DeleteVisualGear(tagCursorY)
       
  2834 		end
       
  2835 		tagCursorY = AddVisualGear(-div(ScreenWidth, 2)+x2, y, vgtHealthTag, CursorY, true)
       
  2836 		SetVisualGearValues(tagCursorY, nil, nil, 0, 0, nil, 1, nil, nil, 240000, 0xFFFFFFFF)
       
  2837 	else
       
  2838 		if tagCursorX then
       
  2839 			DeleteVisualGear(tagCursorX)
       
  2840 		end
       
  2841 		if tagCursorY then
       
  2842 			DeleteVisualGear(tagCursorY)
       
  2843 		end
       
  2844 	end
       
  2845 end
       
  2846 
  2810 -- called in onGameTick()
  2847 -- called in onGameTick()
  2811 function HandleHedgeEditor()
  2848 function HandleHedgeEditor()
  2812 
       
  2813 	if CurrentHedgehog ~= nil then
  2849 	if CurrentHedgehog ~= nil then
  2814 
  2850 
  2815 		genTimer = genTimer + 1
  2851 		genTimer = genTimer + 1
  2816 
  2852 
  2817 
  2853 
  2995 			-- improve rectangle test based on CGR when you can be bothered
  3031 			-- improve rectangle test based on CGR when you can be bothered
  2996 			PlaceObject(x, y)
  3032 			PlaceObject(x, y)
  2997 		end
  3033 		end
  2998 
  3034 
  2999 	end
  3035 	end
       
  3036 
       
  3037 	-- Show cursor coords
       
  3038 	updateCursorCoords()
  3000 
  3039 
  3001 	-- Barrel health tags, mine timer tags and health crate health tags
  3040 	-- Barrel health tags, mine timer tags and health crate health tags
  3002 	do
  3041 	do
  3003 		local actualValue	-- internal value
  3042 		local actualValue	-- internal value
  3004 		local printedValue	-- value exposed to HUD
  3043 		local printedValue	-- value exposed to HUD
  3108 					SetVisualGearValues(v, GetX(g)+offset_x, GetY(g)+offset_y, 0, 0, nil, nil, nil, nil, 240000, tint)
  3147 					SetVisualGearValues(v, GetX(g)+offset_x, GetY(g)+offset_y, 0, 0, nil, nil, nil, nil, 240000, tint)
  3109 				end
  3148 				end
  3110 			end
  3149 			end
  3111 		end
  3150 		end
  3112 	end
  3151 	end
  3113 
       
  3114 end
  3152 end
  3115 
  3153 
  3116 --------------------------------------------------
  3154 --------------------------------------------------
  3117 -- EVENT HANDLERS
  3155 -- EVENT HANDLERS
  3118 --------------------------------------------------
  3156 --------------------------------------------------
  3806 
  3844 
  3807 	end
  3845 	end
  3808 
  3846 
  3809 end
  3847 end
  3810 
  3848 
       
  3849 function onVisualGearDelete(vGear)
       
  3850 	if vGear == tagCursorX then
       
  3851 		tagCursorX = nil
       
  3852 	end
       
  3853 	if vGear == tagCursorY then
       
  3854 		tagCursorY = nil
       
  3855 	end
       
  3856 end