Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- **BPM Display**
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- Better optimized frame update bpm display.
- ]]
- local BPM
- local a = GAMESTATE:GetPlayerState(PLAYER_1):GetSongPosition()
- local r = GAMESTATE:GetSongOptionsObject("ModsLevel_Current"):MusicRate() * 60
- local GetBPS = SongPosition.GetCurBPS
- local function UpdateBPM(self)
- local bpm = GetBPS(a) * r
- settextf("%4.1f BPM",GetBPS(a) * r)
- end
- t[#t + 1] =
- Def.ActorFrame {
- Name = "BPMText",
- InitCommand = function(self)
- BPM = self:GetChild("BPM")
- if (allowedCustomization) then
- Movable.DeviceButton_x.element = self
- Movable.DeviceButton_c.element = self
- Movable.DeviceButton_x.condition = true
- Movable.DeviceButton_c.condition = true
- Movable.DeviceButton_x.Border = self:GetChild("Border")
- Movable.DeviceButton_c.Border = self:GetChild("Border")
- end
- self:x(MovableValues.BPMTextX):y(MovableValues.BPMTextY):zoom(MovableValues.BPMTextZoom)
- if #GAMESTATE:GetCurrentSong():GetTimingData():GetBPMs() > 1 then -- dont bother updating for single bpm files
- self:SetUpdateFunction(UpdateBPM)
- self:SetUpdateRate(0.5)
- BPM:settextf("%4.1f BPM",GetBPS(a) * r)
- else
- BPM:settextf("%4.1f BPM", GetBPS(a) * r) -- i wasn't thinking when i did this, we don't need to avoid formatting for performance because we only call this once -mina
- end
- end,
- LoadFont("Common Normal") ..
- {
- Name = "BPMText2",
- InitCommand = function(self)
- self:halign(1):zoom(1)
- end,
- OnCommand = function(self)
- if allowedCustomization then
- setBorderToText(self:GetParent():GetChild("Border"), self)
- end
- end
- },
- DoneLoadingNextSongMessageCommand = function(self)
- self:queuecommand("Init")
- end,
- -- basically a copy of the init
- CurrentRateChangedMessageCommand = function(self)
- r = GAMESTATE:GetSongOptionsObject("ModsLevel_Current"):MusicRate() * 60
- if #GAMESTATE:GetCurrentSong():GetTimingData():GetBPMs() > 1 then
- self:SetUpdateFunction(UpdateBPM)
- self:SetUpdateRate(0.5)
- BPM:settextf("%4.1f BPM",GetBPS(a) * r)
- else
- BPM:settextf("%4.1f BPM", GetBPS(a) * r)
- end
- end,
- PracticeModeReloadMessageCommand = function(self)
- self:playcommand("CurrentRateChanged")
- end,
- MovableBorder(40, 13, 1, 0, 0)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement