Progress on #13 and #11. EasterEggs api looking good.
authorCameron Ball <c.ball1729@gmail.com>
Tue, 10 Dec 2013 08:11:07 +0000 (16:11 +0800)
committerCameron Ball <c.ball1729@gmail.com>
Tue, 10 Dec 2013 08:11:07 +0000 (16:11 +0800)
Themes/GrooveNights/BGAnimations/ScreenPlayerOptions overlay/default.xml
Themes/GrooveNights/Scripts/EasterEggs.lua
Themes/GrooveNights/Scripts/Globals.lua
Themes/GrooveNights/Scripts/gnSystem.lua
Themes/GrooveNights/metrics.ini

index 6511659..305e87d 100644 (file)
                />
                
 <!--Blaze It P1 -->
-               <BitmapText
-                       Text="Blaze It!"
+               <Layer
+                        Type="BitmapText"
                        Condition="GAMESTATE:IsPlayerEnabled(PLAYER_1)"
                        File="_eurostile blue glow"
                        InitCommand="zoom,0.65; shadowlength,0; x,SCREEN_CENTER_X-303; y,SCREEN_CENTER_Y;diffusealpha,0"
                        OnCommand="horizalign,left;zoom,0.65;rainbow;"
                        SpeedModChangedMessageCommand="queuecommand,Update"
                        RateModChangedMessageCommand="queuecommand,Update"
-                       UpdateCommand="%function(self) if DoEasterEgg('BlazeIt', {pn = PLAYER_1}) then self:diffusealpha(1) else self:diffusealpha(0) end end"
+                       UpdateCommand="%function(self) DoEasterEgg('BlazeIt', { pn = PLAYER_1, Actor = self }) end"
                />
                
 <!--No Scope P1 -->            
                        OnCommand="horizalign,left;zoom,0.65;rainbow;"
                        SpeedModChangedMessageCommand="queuecommand,Update"
                        RateModChangedMessageCommand="queuecommand,Update"
-                       UpdateCommand="%function(self) if DoEasterEgg('NoScope', {pn = PLAYER_1}) then self:diffusealpha(1) else self:diffusealpha(0) end end"
+                       UpdateCommand="%function(self) DoEasterEgg('NoScope', { pn = PLAYER_1, Actor = self }) end"
                />
                        
 <!--Step Artists P1-->
                        OnCommand="horizalign,left;zoom,0.65;rainbow;"
                        SpeedModChangedMessageCommand="queuecommand,Update"
                        RateModChangedMessageCommand="queuecommand,Update"
-                       UpdateCommand="%function(self) if DoEasterEgg('BlazeIt', {pn = PLAYER_2}) then self:diffusealpha(1) else self:diffusealpha(0) end end"
+                       UpdateCommand="%function(self) DoEasterEgg('BlazeIt', { pn = PLAYER_2, Actor = self }) end"
                />
                
 <!--No Scope P2 -->            
                        OnCommand="horizalign,left;zoom,0.65;rainbow;"
                        SpeedModChangedMessageCommand="queuecommand,Update"
                        RateModChangedMessageCommand="queuecommand,Update"
-                       UpdateCommand="%function(self) if DoEasterEgg('NoScope', {pn = PLAYER_2}) then self:diffusealpha(1) else self:diffusealpha(0) end end"
+                       UpdateCommand="%function(self) DoEasterEgg('NoScope', { pn = PLAYER_2, Actor = self }) end"
                />
                
 <!--Step Artists P2-->
index 03aaa37..a93d992 100644 (file)
@@ -1,3 +1,57 @@
+--[[\r
+Simple API to set up easter eggs to apply to an actor for StepMania 3.95/OpenITG, version 1.0\r
+Licensed under Creative Commons Attribution-Share Alike 3.0 Unported\r
+(http://creativecommons.org/licenses/by-sa/3.0/)\r
+\r
+Options menu function to turn easter eggs on/off and globally callable functions\r
+to trigger pre-defined easter eggs.\r
+\r
+Written by Cameron Ball for OpenITG (http://www.boxorroxors.net/)\r
+All I ask is that you keep this notice intact and don't redistribute in bytecode.\r
+--]]\r
+\r
+--[[\r
+Callable functions:\r
+\r
+EasterEggsEnabled()\r
+[returns a boolean value depending on whether easter eggs have been enabled]\r
+\r
+ToggleEasterEggs()\r
+[turns easter eggs on/off]\r
+\r
+RegisterEasterEgg( Name, fn )\r
+[saves an easter egg function to be called later]\r
+        - Name: the name of the easter egg for later referene, must be unique.\r
+        - fn: the function to call when this easter egg is triggered.\r
+\r
+DoEasterEgg( Name )\r
+[runs a previously registered easter egg]\r
+        - Name: the name of the easter egg to run.\r
+\r
+You can use this API any number of ways, but the intended usage is to apply fun\r
+changes to Actors when criteria is met. You would usually set up a function similar\r
+to the following:\r
+\r
+local function MyEasterEgg(Params)\r
+    if GAMESTATE:PlayerIsUsingModifier(Params.pn, '69x') then\r
+        Params.Actor:settext("WOOOOO! SIXTY NINE!")\r
+        Params.Actor:diffusealpha(1)\r
+        Params.Actor:rainbow()\r
+    else \r
+        Params.Actor:diffusealpha(0)\r
+    end\r
+end\r
+\r
+RegisterEasterEgg(MyEasterEgg)\r
+\r
+Then on an Actor you could apply something like:\r
+\r
+UpdateCommand="%function(self) DoEasterEgg('MyEasterEgg', { pn = PLAYER_1, Actor = self }) end"\r
+\r
+Then whenever UpdateCommand is triggered, MyEasterEgg will be run and the corresponding\r
+logic will be applied.\r
+]]--\r
+\r
 -- This is purely for convenience\r
 local ProfileTable\r
 local FunctionTable = {}\r
@@ -7,9 +61,7 @@ if PROFILEMAN ~= nil then
     ProfileTable = PROFILEMAN:GetMachineProfile():GetSaved()\r
 end\r
 \r
--- Valid speed mod row type names.\r
 local choices = { "OFF", "ON" }\r
-\r
 local FunctionTable = {}\r
 \r
 function EasterEggsEnabled()\r
@@ -20,6 +72,10 @@ function EasterEggsEnabled()
 end\r
 \r
 function ToggleEasterEggs()\r
+    ProfileTable.EasterEggs = not ProfileTable.EasterEggs\r
+end\r
+\r
+function EasterEggsOptionsRow()\r
     local function Load(self, list, pn)\r
         if EasterEggsEnabled() then list[2] = true else list[1] = true end\r
     end\r
@@ -35,6 +91,7 @@ function ToggleEasterEggs()
 end\r
 \r
 function RegisterEasterEgg(Name, fn)\r
+    assert(FunctionTable[Name] == nil, "Cannot re-register easter egg " .. Name)\r
     FunctionTable[Name] = fn\r
 end\r
 \r
index 9395d78..166cc99 100644 (file)
@@ -1,5 +1,5 @@
 --[[\r
-Simple API to save screen elements for later use for 3.95/OpenITG, version 1.0\r
+Simple API to save screen elements for later use for StepMania 3.95/OpenITG, version 1.0\r
 Licensed under Creative Commons Attribution-Share Alike 3.0 Unported\r
 (http://creativecommons.org/licenses/by-sa/3.0/)\r
 \r
@@ -12,12 +12,12 @@ All I ask is that you keep this notice intact and don't redistribute in bytecode
 --[[\r
 Callable functions:\r
 \r
-RegisterGlobal( Actor, Name )\r
-[saves Actor for later use]\r
-        - Actor: the actor to save.\r
+RegisterGlobal( Name, Actor )\r
+[saves text from Actor for later use]\r
         - Name: the name of the actor for later reference, must be unique.\r
+        - Actor: the actor to save.\r
 \r
-GetGlobal( Names )\r
+GetGlobal( Name )\r
 [returns a previously saved actor]\r
         - Name: the name of the actor to retrieve.\r
 \r
@@ -35,7 +35,7 @@ local SongLength = GetGlobal("TotalTime")
 \r
 local GlobalsTable = {}\r
 \r
-function RegisterGlobal(Actor, Name)\r
+function RegisterGlobal( Name, Actor )\r
        GlobalsTable[Name] = Actor:GetText()\r
 end\r
 \r
index 5ebb241..46e0534 100644 (file)
@@ -349,17 +349,25 @@ end
 
 
 --easter eggs
-local function IsBlazed(Params)
-       if DisplayScrollSpeed(Params.pn) == '420' then return true end
-               
-       return false
+local function BlazeIt(Params)
+    if DisplayScrollSpeed(Params.pn) == '420' then
+        Params.Actor:settext("Blaze It!")
+        Params.Actor:diffusealpha(1)
+        Params.Actor:rainbow()
+    else 
+        Params.Actor:diffusealpha(0)
+    end
 end
 
-local function IsNoScoped(Params)
-       if DisplayScrollSpeed(Params.pn) == '360' then return true end
-               
-       return false
+local function NoScope(Params)
+    if DisplayScrollSpeed(Params.pn) == '360' then
+        Params.Actor:settext("No Scope!")
+        Params.Actor:diffusealpha(1)
+        Params.Actor:rainbow()
+    else 
+        Params.Actor:diffusealpha(0)
+    end
 end
 
-RegisterEasterEgg("BlazeIt", IsBlazed)
-RegisterEasterEgg("NoScope", IsNoScoped)
\ No newline at end of file
+RegisterEasterEgg("BlazeIt", BlazeIt)
+RegisterEasterEgg("NoScope", NoScope)
\ No newline at end of file
index 2d3143c..0e14937 100644 (file)
@@ -786,7 +786,7 @@ TipY=0
 [ScreenSelectMusic]
 TotalTimeX=SCREEN_CENTER_X 
 TotalTimeY=SCREEN_CENTER_Y+10000
-TotalTimeOnCommand=%function(self) self:diffusealpha(0); RegisterGlobal(self, "TotalTime") end
+TotalTimeOnCommand=%function(self) self:diffusealpha(0); RegisterGlobal("TotalTime", self) end
 TotalTimeOffCommand=
 CDTitleX=SCREEN_CENTER_X+268 
 CDTitleY=SCREEN_CENTER_Y-50
@@ -3956,7 +3956,7 @@ Line8=conf,JudgeDifficulty
 Line9=conf,DefaultFailType
 Line10=conf,Theme
 Line11=lua,SpeedModTypeRow()
-Line12=lua,ToggleEasterEggs()
+Line12=lua,EasterEggsOptionsRow()
 
 [ScreenGraphicOptions]
 Fallback=ScreenOptionsSubmenu