Scripting: Update screen dimensions on screen resize and introduce onScreenResize() event.
authorsheepluva
Fri, 09 Sep 2011 15:36:30 +0200
changeset 5825 a6eab1b7c00d
parent 5823 f906f6645e02
child 5827 a416f1070fdf
Scripting: Update screen dimensions on screen resize and introduce onScreenResize() event. I implemented that event in Tumber and Space Invasion already in order to update HUD locations properly. (mikade: deal with it $
hedgewars/hwengine.pas
hedgewars/uScript.pas
share/hedgewars/Data/Scripts/Multiplayer/Space_Invasion.lua
share/hedgewars/Data/Scripts/Multiplayer/Tumbler.lua
--- a/hedgewars/hwengine.pas	Fri Sep 09 03:57:45 2011 +0200
+++ b/hedgewars/hwengine.pas	Fri Sep 09 15:36:30 2011 +0200
@@ -204,6 +204,7 @@
 
             ParseCommand('fullscr '+intToStr(LongInt(cFullScreen)), true);
             WriteLnToConsole('window resize: ' + IntToStr(cScreenWidth) + ' x ' + IntToStr(cScreenHeight));
+            ScriptOnScreenResize();
             InitCameraBorders()
             end;
 
--- a/hedgewars/uScript.pas	Fri Sep 09 03:57:45 2011 +0200
+++ b/hedgewars/uScript.pas	Fri Sep 09 15:36:30 2011 +0200
@@ -36,6 +36,7 @@
 
 procedure ScriptLoad(name : shortstring);
 procedure ScriptOnGameInit;
+procedure ScriptOnScreenResize();
 
 procedure ScriptCall(fname : shortstring);
 function ScriptCall(fname : shortstring; par1: LongInt) : LongInt;
@@ -1624,6 +1625,16 @@
 ScriptSetInteger('TeamsCount', TeamsCount)
 end;
 
+
+// Update values of screen dimensions and allow script to react to resolution change
+procedure ScriptOnScreenResize();
+begin
+ScriptSetInteger('ScreenHeight', cScreenHeight);
+ScriptSetInteger('ScreenWidth', cScreenWidth);
+ScriptCall('onScreenResize');
+end;
+
+
 procedure ScriptLoad(name : shortstring);
 var ret : LongInt;
       s : shortstring;
--- a/share/hedgewars/Data/Scripts/Multiplayer/Space_Invasion.lua	Fri Sep 09 03:57:45 2011 +0200
+++ b/share/hedgewars/Data/Scripts/Multiplayer/Space_Invasion.lua	Fri Sep 09 15:36:30 2011 +0200
@@ -5,7 +5,7 @@
 ---------------------------------------------------
 ---------------------------------------------------
 ---------------------------------------------------
---- Space Invasion Code Follows (0.8)
+--- Space Invasion Code Follows (0.8.1)
 ---------------------------------------------------
 ---------------------------------------------------
 -- VERSION HISTORY
@@ -106,6 +106,13 @@
 -- added a HUD for turntimeleft, ammo, shield
 -- shieldhealth hits 0 properly
 
+------------------------
+-- version 0.8.1
+------------------------
+
+-- stop hiding non-existant 4th Tag
+-- redraw HUD on screen resolution change
+
 --------------------------
 --notes for later
 --------------------------
@@ -301,7 +308,7 @@
 
 function HideTags()
 
-	for i = 0, 3 do 	
+	for i = 0, 2 do
 		SetVisualGearValues(vTag[i],0,0,0,0,0,1,0, 0, 240000, 0xffffff00)
 	end
 
@@ -797,6 +804,16 @@
 
 end
 
+function onScreenResize()
+
+	-- redraw Tags so that their screen locations are updated
+	if (CurrentHedgehog ~= nil) and (tumbleStarted == true) then
+			DrawTag(0)
+			DrawTag(1)
+			DrawTag(2)
+	end
+
+end
 
 function onNewTurn()
 
--- a/share/hedgewars/Data/Scripts/Multiplayer/Tumbler.lua	Fri Sep 09 03:57:45 2011 +0200
+++ b/share/hedgewars/Data/Scripts/Multiplayer/Tumbler.lua	Fri Sep 09 15:36:30 2011 +0200
@@ -1,6 +1,6 @@
 ------------------------------------
 -- TUMBLER
--- v.0.7
+-- v.0.7.1
 ------------------------------------
 
 loadfile(GetDataPath() .. "Scripts/Locale.lua")()
@@ -110,6 +110,12 @@
 -- Performance tweaks
 -- Variety of small gameplay changes
 
+------------------------
+-- version 0.7.1
+------------------------
+
+-- redraw HUD on screen resolution change
+
 ---------------------------
 -- some other ideas/things
 ---------------------------
@@ -493,6 +499,16 @@
 
 end
 
+function onScreenResize()
+
+	-- redraw Tags so that their screen locations are updated
+	if (CurrentHedgehog ~= nil) and (tumbleStarted == true) then
+		for i = 0, 3 do
+			DrawTag(i)
+		end
+	end
+
+end
 
 function onNewTurn()