self:vibrate();
end
end"> <children>
-
-<!--Capture BPM-->
-<Layer Type="Quad"
- InitCommand="queuecommand,BPMCapture;"
- BPMCaptureCommand="%function(self)
- songBPM = SCREENMAN:GetTopScreen():GetChild('BPMDisplay'):GetChild('Text'):GetText();
- bpm[1] = string.gsub(songBPM,'-%d+','');
- bpm[2] = string.gsub(songBPM,'%d+-','');
- if bpm[2] == bpm[1] then bpm[2] = '';
- end
- end"
- CurrentSongChangedMessageCommand="queuecommand,BPMCapture"
- CurrentStepsP1ChangedMessageCommand="queuecommand,BPMCapture"
- CurrentStepsP2ChangedMessageCommand="queuecommand,BPMCapture"
-/>
-
+
<ActorFrame OnCommand="y,SCREEN_BOTTOM-17-18"> <children>
<Layer
Type="BitmapText"
GetGlobal( Name )\r
[returns a previously saved actor]\r
- Name: the name of the actor to retrieve.\r
+ \r
+RegisterGlobalCallback( Name, fn )\r
+[sets up a function to be called when a global is registered]\r
+ - Name: the name of the global to apply the callback to\r
+ - fn: the callback\r
\r
The intended way to use this API is by calling RegisterGlobal from your theme's\r
-metrics.ini. For example, to save away the song length to use later you would\r
+metrics.ini. For example, to save away the song bpm to use later you would\r
put this in metrics.ini under [ScreenSelectMusic]:\r
\r
-TotalTimeOnCommand=%function(self) RegisterGlobal(self, "TotalTime") end\r
+BPMDisplayOnCommand=%function(self) RegisterGlobal("HighBPM", self:GetChild('Text')); RegisterGlobal("LowBPM", self:GetChild('Text')); end\r
+BPMDisplayCurrentStepsP1ChangedMessageCommand=%function(self) RegisterGlobal("HighBPM", self:GetChild('Text')); RegisterGlobal("LowBPM", self:GetChild('Text')) end\r
+BPMDisplayCurrentStepsP2ChangedMessageCommand=%function(self) RegisterGlobal("HighBPM", self:GetChild('Text')); RegisterGlobal("LowBPM", self:GetChild('Text')) end\r
\r
-Then if you wanted to use the song length actor on the options screen, you can\r
-access it like this:\r
+(NB: RegisterGlobal must be called on CurrentStepsP[1/2]Changed since that message is broadcast AFTER\r
+the bpm display has been updated, therefore when we call RegisterGlobal it gets the correct value)\r
\r
-local SongLength = GetGlobal("TotalTime")\r
+Then we can set up callbacks to pull out the low and high BPMs like so:\r
+\r
+local function LowBPM( BPMDisplay )\r
+ local pos = string.find(BPMDisplay, "-")\r
+ if pos ~= nil then return string.sub(BPMDisplay,1,pos-1) else return BPMDisplay end\r
+end\r
+\r
+local function HighBPM( BPMDisplay )\r
+ local pos = string.find(BPMDisplay, "-")\r
+ if pos ~= nil then return string.sub(BPMDisplay,pos+1) else return BPMDisplay end\r
+end\r
+\r
+RegisterGlobalCallback("HighBPM", HighBPM)\r
+RegisterGlobalCallback("LowBPM", LowBPM)\r
+\r
+Then if you wanted to use the BPM on a different screen you could do it like this:\r
+\r
+local BPMDisplay = GetGlobal("LowBPM") .. "-" .. GetGlobal("HighBPM")\r
]]--\r
\r
local GlobalsTable = {}\r
+local CallbackTable = {}\r
\r
function RegisterGlobal( Name, Actor )\r
GlobalsTable[Name] = Actor:GetText()\r
+ \r
+ if CallbackTable[Name] ~= nil then GlobalsTable[Name] = CallbackTable[Name](GlobalsTable[Name]) end\r
end\r
\r
function GetGlobal(Name)\r
return GlobalsTable[Name]\r
+end\r
+\r
+function RegisterGlobalCallback(Name, fn)\r
+ assert(CallbackTable[Name] == nil, "Cannot re-register global callback " .. Name)\r
+ CallbackTable[Name] = fn\r
end
\ No newline at end of file
end
function DisplayBPM(pn)
- local lowBPM = bpm[1]
- local highBPM = bpm[2]
+ local lowBPM = GetGlobal("LowBPM")
+ local highBPM = GetGlobal("HighBPM")
+
+ if lowBPM == highBPM then highBPM = nil end
local rateMod = string.gsub(GetRateMod(),'x','')
lowScrollBPM = math.floor(lowBPM * rateMod)
- if highBPM ~= "" then highScrollBPM = math.floor(highBPM * rateMod) end
+ if highBPM then highScrollBPM = math.floor(highBPM * rateMod) end
- if highBPM == "" then return tostring(lowScrollBPM) else return lowScrollBPM .. "-" .. highScrollBPM end
+ if not highBPM then return tostring(lowScrollBPM) else return lowScrollBPM .. "-" .. highScrollBPM end
end
function DisplayScrollSpeed(pn)
- local lowBPM = bpm[1]
- local highBPM = bpm[2]
+ local lowBPM = GetGlobal("LowBPM")
+ local highBPM = GetGlobal("HighBPM")
+
+ if lowBPM == highBPM then highBPM = nil end
local rateMod = string.gsub(GetRateMod(),'x','')
lowScrollBPM = math.floor(lowBPM * speedMod * rateMod)
- if highBPM ~= "" then highScrollBPM = math.floor(highBPM *speedMod * rateMod) end
+ if highBPM then highScrollBPM = math.floor(highBPM *speedMod * rateMod) end
- if highBPM == "" then return tostring(lowScrollBPM) else return lowScrollBPM .. "-" .. highScrollBPM end
+ if not highBPM then return tostring(lowScrollBPM) else return lowScrollBPM .. "-" .. highScrollBPM end
end
function DisplaySongLength()
end
RegisterEasterEgg("BlazeIt", BlazeIt)
-RegisterEasterEgg("NoScope", NoScope)
\ No newline at end of file
+RegisterEasterEgg("NoScope", NoScope)
+
+--global variable callbacks
+local function LowBPM( BPMDisplay )
+ local pos = string.find(BPMDisplay, "-")
+ if pos ~= nil then return string.sub(BPMDisplay,1,pos-1) else return BPMDisplay end
+end
+
+local function HighBPM( BPMDisplay )
+ local pos = string.find(BPMDisplay, "-")
+ if pos ~= nil then return string.sub(BPMDisplay,pos+1) else return BPMDisplay end
+end
+
+RegisterGlobalCallback("HighBPM", HighBPM)
+RegisterGlobalCallback("LowBPM", LowBPM)
\ No newline at end of file
TotalTimeX=SCREEN_CENTER_X
TotalTimeY=SCREEN_CENTER_Y+10000
TotalTimeOnCommand=%function(self) self:diffusealpha(0); RegisterGlobal("TotalTime", self) end
+# We must use the CurrentSteps message command as this command is broadcast AFTER the bpm display updates
+TotalTimeCurrentStepsP1ChangedMessageCommand=%function(self) RegisterGlobal("TotalTime", self) end
+TotalTimeCurrentStepsP2ChangedMessageCommand=%function(self) RegisterGlobal("TotalTime", self) end
TotalTimeOffCommand=
CDTitleX=SCREEN_CENTER_X+268
CDTitleY=SCREEN_CENTER_Y-50
BPMDisplayX=SCREEN_CENTER_X-40
BPMDisplayY=SCREEN_CENTER_Y-40+17
BPMDisplayOffCommand=
-BPMDisplayOnCommand=%function(self) if GAMESTATE:GetEnv('Vibrate') == 'On' then self:vibrate(); end self:zoom(0.5) end
+BPMDisplayOnCommand=%function(self) RegisterGlobal("HighBPM", self:GetChild('Text')); RegisterGlobal("LowBPM", self:GetChild('Text')); if GAMESTATE:GetEnv('Vibrate') == 'On' then self:vibrate(); end self:zoom(0.5) end
+# See TotalTime for an explanation for this
+BPMDisplayCurrentStepsP1ChangedMessageCommand=%function(self) RegisterGlobal("HighBPM", self:GetChild('Text')); RegisterGlobal("LowBPM", self:GetChild('Text')) end
+BPMDisplayCurrentStepsP2ChangedMessageCommand=%function(self) RegisterGlobal("HighBPM", self:GetChild('Text')); RegisterGlobal("LowBPM", self:GetChild('Text')) end
DifficultyFrameP1OffCommand=
DifficultyFrameP1OnCommand=hidden,1
DifficultyFrameP2OffCommand=