Added code for setting player name plates with bpm info.
This commit is contained in:
@@ -341,6 +341,23 @@ function SpeedModIncLarge()
|
||||
return ret
|
||||
end
|
||||
|
||||
function GetSpeedModeAndValueFromPoptions(pn)
|
||||
local poptions= GAMESTATE:GetPlayerState(pn):GetPlayerOptions("ModsLevel_Preferred")
|
||||
local speed= nil
|
||||
local mode= nil
|
||||
if poptions:MaxScrollBPM() > 0 then
|
||||
mode= "m"
|
||||
speed= math.round(poptions:MaxScrollBPM())
|
||||
elseif poptions:TimeSpacing() > 0 then
|
||||
mode= "C"
|
||||
speed= math.round(poptions:ScrollBPM())
|
||||
else
|
||||
mode= "x"
|
||||
speed= math.round(poptions:ScrollSpeed() * 100)
|
||||
end
|
||||
return speed, mode
|
||||
end
|
||||
|
||||
function ArbitrarySpeedMods()
|
||||
-- If players are allowed to join while this option row is active, problems will probably occur.
|
||||
local increment= get_speed_increment()
|
||||
@@ -400,6 +417,7 @@ function ArbitrarySpeedMods()
|
||||
val.mode= ({"x", "C", "m"})[real_choice - 4]
|
||||
end
|
||||
self:GenChoices()
|
||||
MESSAGEMAN:Broadcast("SpeedChoiceChanged", {pn= pn, mode= val.mode, speed= val.speed})
|
||||
return true
|
||||
end,
|
||||
GenChoices= function(self)
|
||||
@@ -440,19 +458,7 @@ function ArbitrarySpeedMods()
|
||||
}
|
||||
for i, pn in ipairs(GAMESTATE:GetEnabledPlayers()) do
|
||||
if GAMESTATE:IsHumanPlayer(pn) then
|
||||
local poptions= GAMESTATE:GetPlayerState(pn):GetPlayerOptions("ModsLevel_Preferred")
|
||||
local speed= nil
|
||||
local mode= nil
|
||||
if poptions:MaxScrollBPM() > 0 then
|
||||
mode= "m"
|
||||
speed= math.round(poptions:MaxScrollBPM())
|
||||
elseif poptions:TimeSpacing() > 0 then
|
||||
mode= "C"
|
||||
speed= math.round(poptions:ScrollBPM())
|
||||
else
|
||||
mode= "x"
|
||||
speed= math.round(poptions:ScrollSpeed() * 100)
|
||||
end
|
||||
local speed, mode= GetSpeedModeAndValueFromPoptions(pn)
|
||||
ret.CurValues[pn]= {mode= mode, speed= speed}
|
||||
ret.NumPlayers= ret.NumPlayers + 1
|
||||
end
|
||||
|
||||
@@ -3,6 +3,24 @@ assert( PlayerNumber )
|
||||
|
||||
local bpm_text_zoom = 0.875
|
||||
|
||||
local song_bpms= {}
|
||||
local bpm_text= "??? - ???"
|
||||
local function format_bpm(bpm)
|
||||
return ("%.0f"):format(bpm)
|
||||
end
|
||||
|
||||
-- Courses don't have GetDisplayBpms.
|
||||
if GAMESTATE:GetCurrentSong() then
|
||||
song_bpms= GAMESTATE:GetCurrentSong():GetDisplayBpms()
|
||||
song_bpms[1]= math.round(song_bpms[1])
|
||||
song_bpms[2]= math.round(song_bpms[2])
|
||||
if song_bpms[1] == song_bpms[2] then
|
||||
bpm_text= format_bpm(song_bpms[1])
|
||||
else
|
||||
bpm_text= format_bpm(song_bpms[1]) .. " - " .. format_bpm(song_bpms[2])
|
||||
end
|
||||
end
|
||||
|
||||
local t = Def.ActorFrame {
|
||||
LoadActor(THEME:GetPathB("_frame","3x1"),"rounded fill", 192-8) .. {
|
||||
OnCommand=cmd(diffuse,color("#333333");diffusealpha,0.875);
|
||||
@@ -17,7 +35,7 @@ local t = Def.ActorFrame {
|
||||
OnCommand=cmd(diffuse,PlayerColor(PlayerNumber);shadowlength,1)
|
||||
},
|
||||
LoadFont("Common Normal") .. {
|
||||
Text="50 - 10000";
|
||||
Text=bpm_text;
|
||||
Name="BPMRangeOld",
|
||||
InitCommand=cmd(x,-40;maxwidth,88/bpm_text_zoom),
|
||||
OnCommand=cmd(shadowlength,1;zoom,bpm_text_zoom)
|
||||
@@ -29,10 +47,47 @@ local t = Def.ActorFrame {
|
||||
LoadFont("Common Normal") .. {
|
||||
Text="100 - 200000";
|
||||
Name="BPMRangeNew",
|
||||
InitCommand=cmd(x,68;maxwidth,88/bpm_text_zoom),
|
||||
OnCommand=cmd(shadowlength,1;zoom,bpm_text_zoom;queuecommand,"BPMWillChange"),
|
||||
InitCommand= function(self)
|
||||
self:x(68):maxwidth(88/bpm_text_zoom):shadowlength(1):zoom(bpm_text_zoom)
|
||||
local speed, mode= GetSpeedModeAndValueFromPoptions(PlayerNumber)
|
||||
self:playcommand("SpeedChoiceChanged", {pn= PlayerNumber, mode= mode, speed= speed})
|
||||
end,
|
||||
BPMWillNotChangeCommand=cmd(stopeffect),
|
||||
BPMWillChangeCommand=cmd(diffuseshift;effectcolor1,Color.White;effectcolor2,Color.Orange)
|
||||
BPMWillChangeCommand=cmd(diffuseshift;effectcolor1,Color.White;effectcolor2,Color.Orange),
|
||||
SpeedChoiceChangedMessageCommand= function(self, param)
|
||||
if param.pn ~= PlayerNumber then return end
|
||||
local text= ""
|
||||
local no_change= true
|
||||
if param.mode == "x" then
|
||||
if not song_bpms[1] then
|
||||
text= "??? - ???"
|
||||
elseif song_bpms[1] == song_bpms[2] then
|
||||
text= format_bpm(song_bpms[1] * param.speed*.01)
|
||||
else
|
||||
text= format_bpm(song_bpms[1] * param.speed*.01) .. " - " ..
|
||||
format_bpm(song_bpms[2] * param.speed*.01)
|
||||
end
|
||||
no_change= param.speed == 100
|
||||
elseif param.mode == "C" then
|
||||
text= param.mode .. param.speed
|
||||
no_change= param.speed == song_bpms[2] and song_bpms[1] == song_bpms[2]
|
||||
else
|
||||
no_change= param.speed == song_bpms[2]
|
||||
if song_bpms[1] == song_bpms[2] then
|
||||
text= param.mode .. param.speed
|
||||
else
|
||||
local factor= song_bpms[1] / song_bpms[2]
|
||||
text= param.mode .. format_bpm(param.speed * factor) .. " - "
|
||||
.. param.mode .. param.speed
|
||||
end
|
||||
end
|
||||
self:settext(text)
|
||||
if no_change then
|
||||
self:queuecommand("BPMWillNotChange")
|
||||
else
|
||||
self:queuecommand("BPMWillChange")
|
||||
end
|
||||
end
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user