From: Cameron Ball Date: Tue, 10 Dec 2013 08:11:07 +0000 (+0800) Subject: Progress on #13 and #11. EasterEggs api looking good. X-Git-Url: https://git.cameron1729.xyz/?a=commitdiff_plain;h=abba9989f72db135848f5570f5530fab385f5d7e;p=GrooveNights.git Progress on #13 and #11. EasterEggs api looking good. --- diff --git a/Themes/GrooveNights/BGAnimations/ScreenPlayerOptions overlay/default.xml b/Themes/GrooveNights/BGAnimations/ScreenPlayerOptions overlay/default.xml index 6511659..305e87d 100644 --- a/Themes/GrooveNights/BGAnimations/ScreenPlayerOptions overlay/default.xml +++ b/Themes/GrooveNights/BGAnimations/ScreenPlayerOptions overlay/default.xml @@ -502,15 +502,15 @@ /> - @@ -522,7 +522,7 @@ 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" /> @@ -624,7 +624,7 @@ 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" /> @@ -636,7 +636,7 @@ 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" /> diff --git a/Themes/GrooveNights/Scripts/EasterEggs.lua b/Themes/GrooveNights/Scripts/EasterEggs.lua index 03aaa37..a93d992 100644 --- a/Themes/GrooveNights/Scripts/EasterEggs.lua +++ b/Themes/GrooveNights/Scripts/EasterEggs.lua @@ -1,3 +1,57 @@ +--[[ +Simple API to set up easter eggs to apply to an actor for StepMania 3.95/OpenITG, version 1.0 +Licensed under Creative Commons Attribution-Share Alike 3.0 Unported +(http://creativecommons.org/licenses/by-sa/3.0/) + +Options menu function to turn easter eggs on/off and globally callable functions +to trigger pre-defined easter eggs. + +Written by Cameron Ball for OpenITG (http://www.boxorroxors.net/) +All I ask is that you keep this notice intact and don't redistribute in bytecode. +--]] + +--[[ +Callable functions: + +EasterEggsEnabled() +[returns a boolean value depending on whether easter eggs have been enabled] + +ToggleEasterEggs() +[turns easter eggs on/off] + +RegisterEasterEgg( Name, fn ) +[saves an easter egg function to be called later] + - Name: the name of the easter egg for later referene, must be unique. + - fn: the function to call when this easter egg is triggered. + +DoEasterEgg( Name ) +[runs a previously registered easter egg] + - Name: the name of the easter egg to run. + +You can use this API any number of ways, but the intended usage is to apply fun +changes to Actors when criteria is met. You would usually set up a function similar +to the following: + +local function MyEasterEgg(Params) + if GAMESTATE:PlayerIsUsingModifier(Params.pn, '69x') then + Params.Actor:settext("WOOOOO! SIXTY NINE!") + Params.Actor:diffusealpha(1) + Params.Actor:rainbow() + else + Params.Actor:diffusealpha(0) + end +end + +RegisterEasterEgg(MyEasterEgg) + +Then on an Actor you could apply something like: + +UpdateCommand="%function(self) DoEasterEgg('MyEasterEgg', { pn = PLAYER_1, Actor = self }) end" + +Then whenever UpdateCommand is triggered, MyEasterEgg will be run and the corresponding +logic will be applied. +]]-- + -- This is purely for convenience local ProfileTable local FunctionTable = {} @@ -7,9 +61,7 @@ if PROFILEMAN ~= nil then ProfileTable = PROFILEMAN:GetMachineProfile():GetSaved() end --- Valid speed mod row type names. local choices = { "OFF", "ON" } - local FunctionTable = {} function EasterEggsEnabled() @@ -20,6 +72,10 @@ function EasterEggsEnabled() end function ToggleEasterEggs() + ProfileTable.EasterEggs = not ProfileTable.EasterEggs +end + +function EasterEggsOptionsRow() local function Load(self, list, pn) if EasterEggsEnabled() then list[2] = true else list[1] = true end end @@ -35,6 +91,7 @@ function ToggleEasterEggs() end function RegisterEasterEgg(Name, fn) + assert(FunctionTable[Name] == nil, "Cannot re-register easter egg " .. Name) FunctionTable[Name] = fn end diff --git a/Themes/GrooveNights/Scripts/Globals.lua b/Themes/GrooveNights/Scripts/Globals.lua index 9395d78..166cc99 100644 --- a/Themes/GrooveNights/Scripts/Globals.lua +++ b/Themes/GrooveNights/Scripts/Globals.lua @@ -1,5 +1,5 @@ --[[ -Simple API to save screen elements for later use for 3.95/OpenITG, version 1.0 +Simple API to save screen elements for later use for StepMania 3.95/OpenITG, version 1.0 Licensed under Creative Commons Attribution-Share Alike 3.0 Unported (http://creativecommons.org/licenses/by-sa/3.0/) @@ -12,12 +12,12 @@ All I ask is that you keep this notice intact and don't redistribute in bytecode --[[ Callable functions: -RegisterGlobal( Actor, Name ) -[saves Actor for later use] - - Actor: the actor to save. +RegisterGlobal( Name, Actor ) +[saves text from Actor for later use] - Name: the name of the actor for later reference, must be unique. + - Actor: the actor to save. -GetGlobal( Names ) +GetGlobal( Name ) [returns a previously saved actor] - Name: the name of the actor to retrieve. @@ -35,7 +35,7 @@ local SongLength = GetGlobal("TotalTime") local GlobalsTable = {} -function RegisterGlobal(Actor, Name) +function RegisterGlobal( Name, Actor ) GlobalsTable[Name] = Actor:GetText() end diff --git a/Themes/GrooveNights/Scripts/gnSystem.lua b/Themes/GrooveNights/Scripts/gnSystem.lua index 5ebb241..46e0534 100644 --- a/Themes/GrooveNights/Scripts/gnSystem.lua +++ b/Themes/GrooveNights/Scripts/gnSystem.lua @@ -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 diff --git a/Themes/GrooveNights/metrics.ini b/Themes/GrooveNights/metrics.ini index 2d3143c..0e14937 100644 --- a/Themes/GrooveNights/metrics.ini +++ b/Themes/GrooveNights/metrics.ini @@ -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