From dcd086398b882214a29d6659ff623a723b2c7c3b Mon Sep 17 00:00:00 2001 From: AJ Kelly Date: Sun, 5 Jun 2011 00:46:21 -0500 Subject: [PATCH] show two different BPMDisplays if two players are playing songs with differing timing --- .../Graphics/ScreenGameplay BPMDisplay.lua | 61 ++++++++++++++++++- 1 file changed, 60 insertions(+), 1 deletion(-) diff --git a/Themes/default/Graphics/ScreenGameplay BPMDisplay.lua b/Themes/default/Graphics/ScreenGameplay BPMDisplay.lua index 4b927fb10a..2b242dd9fb 100644 --- a/Themes/default/Graphics/ScreenGameplay BPMDisplay.lua +++ b/Themes/default/Graphics/ScreenGameplay BPMDisplay.lua @@ -1,4 +1,7 @@ -return Def.SongBPMDisplay { +-- check if players are playing steps with different timingdata. +local numPlayers = GAMESTATE:GetNumPlayersEnabled() + +local displaySingle = Def.SongBPMDisplay { File=THEME:GetPathF("BPMDisplay", "bpm"); Name="BPMDisplay"; InitCommand=cmd(zoom,0.675;shadowlength,1); @@ -6,3 +9,59 @@ return Def.SongBPMDisplay { CurrentSongChangedMessageCommand=cmd(playcommand,"Set"); CurrentCourseChangedMessageCommand=cmd(playcommand,"Set"); }; + +if numPlayers == 1 then + return displaySingle +else + -- check if both players are playing the same steps + local stepsP1 = GAMESTATE:GetCurrentSteps(PLAYER_1) + local stepsP2 = GAMESTATE:GetCurrentSteps(PLAYER_2) + + local stP1 = stepsP1:GetStepsType() + local stP2 = stepsP2:GetStepsType() + + local diffP1 = stepsP1:GetDifficulty() + local diffP2 = stepsP2:GetDifficulty() + + if stP1 == stP2 and diffP1 == diffP2 then + -- both players are using the same steps; only need one. + return displaySingle + end + + -- otherwise, we have some more work to do. + local timingP1 = stepsP1:GetTimingData() + local timingP2 = stepsP2:GetTimingData() + + local function UpdateBPM(self) + local dispP1 = self:GetChild("DisplayP1") + local dispP2 = self:GetChild("DisplayP2") + + -- needs current bpm for p1 and p2 + for pn in ivalues(PlayerNumber) do + local bpmDisplay = (pn == PLAYER_1) and dispP1 or dispP2 + local pState = GAMESTATE:GetPlayerState(pn); + local songPosition = pState:GetSongPosition() + local bpm = songPosition:GetCurBPS() * 60 + bpmDisplay:settext( string.format("%.2f",bpm) ) + end + end + + local displayTwoPlayers = Def.ActorFrame{ + -- manual bpm displays + LoadFont("BPMDisplay", "bpm")..{ + Name="DisplayP1"; + InitCommand=cmd(x,-32;zoom,0.625;shadowlength,1); + }; + LoadFont("BPMDisplay", "bpm")..{ + Name="DisplayP2"; + InitCommand=cmd(x,32;zoom,0.625;shadowlength,1); + }; + }; + + displayTwoPlayers.InitCommand=cmd(SetUpdateFunction,UpdateBPM); + + return displayTwoPlayers +end + +-- should not get here +-- return Def.ActorFrame{} \ No newline at end of file