Rejigged the bpm calculations and that.
authorCameron Ball <c.ball1729@gmail.com>
Wed, 4 Dec 2013 18:59:37 +0000 (02:59 +0800)
committerCameron Ball <c.ball1729@gmail.com>
Wed, 4 Dec 2013 19:09:03 +0000 (03:09 +0800)
Themes/GrooveNights/BGAnimations/ScreenPlayerOptions overlay/default.xml
Themes/GrooveNights/BGAnimations/ScreenSelectMusic overlay/default.xml [new file with mode: 0644]
Themes/GrooveNights/Graphics/ScreenSelectMusic banner frame/default.xml
Themes/GrooveNights/Scripts/GrooveNights.lua
Themes/GrooveNights/Scripts/Other.lua
Themes/GrooveNights/metrics.ini

index d96e2f5..2b1a8d0 100644 (file)
                        Text=""
                        Condition="GAMESTATE:IsPlayerEnabled(PLAYER_1)"
                        File="_eurostile blue glow"
-                       InitCommand="%function(self) self:stoptweening(); self:zoom(0.5); self:shadowlength(0); self:x(SCREEN_CENTER_X-200); self:y(SCREEN_CENTER_Y+118); if lowBPM == highBPM then self:settext(math.ceil(highBPM*curRate)); else self:settext(math.ceil(lowBPM*curRate)..'-'..math.ceil(highBPM*curRate)) end self:maxwidth(140);  self:sleep(0.1); self:queuecommand('Init'); end"
+                       InitCommand="%function(self) self:stoptweening(); self:zoom(0.5); self:shadowlength(0); self:x(SCREEN_CENTER_X-200); self:y(SCREEN_CENTER_Y+118); self:maxwidth(140); end"
+                       SpeedModChangedMessageCommand="queuecommand,Update"
+                       RateModChangedMessageCommand="queuecommand,Update"
+                       UpdateCommand="%function(self) self:settext(DisplayBPM(1, true, false)) end"
                        OnCommand="horizalign,left;zoom,0.5;"                   
                />
                <BitmapText
                        Condition="GAMESTATE:IsPlayerEnabled(PLAYER_1)"
                        File="_eurostile blue glow"
                        InitCommand="%function(self) self:zoom(0.5); self:shadowlength(0); self:x(SCREEN_CENTER_X-200); self:y(SCREEN_CENTER_Y+134); p1Distance=0; end"
-                       OnCommand="horizalign,left;zoom,0.5;"
+                       OnCommand="horizalign,left;zoom,0.5;queuecommand,loop;"
+                       SpeedModChangedMessageCommand="queuecommand,Update"
+                       RateModChangedMessageCommand="queuecommand,Update"
+                       UpdateCommand="%function(self) self:settext(DisplayBPM(1, true, true)) end"                     
                        
-                       SpeedModChangedMessageCommand="%function(self)
-                       if gnOptionModType == 'x' then
-                       gnOptionMod = gnOptionMod*highBPM*curRate;
-                       end
-                       if gnOptionModType == 'c' then
-                       gnOptionMod = gnOptionMod
-                       end
-                       if gnOptionModType == 'm' then
-                       gnOptionMod = gnOptionMod*curRate;
-                       end
-                       self:settext(gnOptionMod);
+                       loopCommand="%function(self)
+                       getModP1 = 0;
+                       if setModP1 == nil then
+                               setModP1 = 0;
+                               end
+                       if modStyleP1 == nil then
+                               modStyleP1 = 0;
+                               end
+                       if addModP1 == nil then
+                               addModP1 = 0;
+                               end
+                       if curRate == nil then
+                               curRate = 1;
+                               end
+                       if modStyleP1 == 1 then
+                               if addModP1 <= 1 then
+                                       self:settext(''..math.ceil((setModP1+addModP1)*highBPM*curRate)..'');
+                                       gnP1Speed = setModP1+addModP1..'X';
+                                       gnBlazeP1 = math.ceil((setModP1+addModP1)*highBPM*curRate)
+                                       else
+                                       self:settext(''..math.ceil((setModP1)*highBPM*curRate)..'');
+                                       gnP1Speed = setModP1..'X';
+                                       gnBlazeP1 = math.ceil((setModP1)*highBPM*curRate)
+                                       end
+                               end
+                       if modStyleP1 == 2 then
+                               if addModP1 > 1 then
+                                       self:settext(''..math.ceil((setModP1+addModP1) * curRate)..'');
+                                       gnP1Speed = 'C'..setModP1+addModP1;
+                                       gnBlazeP1 = math.ceil((setModP1+addModP1) * curRate)
+                                       else
+                                       self:settext(''..math.ceil((setModP1) * curRate)..'');
+                                       gnP1Speed = 'C'..setModP1;
+                                       gnBlazeP1 = math.ceil((setModP1) * curRate)
+                                       end
+                               end
                        end"
                />
 <!--Step Artists P1-->
                        Text=""
                        Condition="GAMESTATE:IsPlayerEnabled(PLAYER_2)"
                        File="_eurostile blue glow"
-                       InitCommand="%function(self) self:stoptweening(); self:zoom(0.5); self:shadowlength(0); self:x(SCREEN_CENTER_X+119); self:y(SCREEN_CENTER_Y+118); if lowBPM == highBPM then self:settext(math.ceil(highBPM*curRate)); else self:settext(math.ceil(lowBPM*curRate)..'-'..math.ceil(highBPM*curRate)) end self:maxwidth(140); self:sleep(0.1); self:queuecommand('Init'); end"
+                       InitCommand="%function(self) self:stoptweening(); self:zoom(0.5); self:shadowlength(0); self:x(SCREEN_CENTER_X+119); self:y(SCREEN_CENTER_Y+118); self:maxwidth(140); end"
                        OnCommand="horizalign,left;zoom,0.5;"                   
+                       SpeedModChangedMessageCommand="queuecommand,Update"
+                       RateModChangedMessageCommand="queuecommand,Update"
+                       UpdateCommand="%function(self) self:settext(DisplayBPM(2, true, false)) end"
                />
                <BitmapText
                        Text="Speed:"
                        Text=""
                        Condition="GAMESTATE:IsPlayerEnabled(PLAYER_2)"
                        File="_eurostile blue glow"
-                       InitCommand="%function(self)  self:zoom(0.5); self:shadowlength(0); self:x(SCREEN_CENTER_X+119); self:y(SCREEN_CENTER_Y+134); self:queuecommand('loop'); end"
+                       InitCommand="%function(self)  self:zoom(0.5); self:shadowlength(0); self:x(SCREEN_CENTER_X+119); self:y(SCREEN_CENTER_Y+134); end"
                        OnCommand="horizalign,left;zoom,0.5;queuecommand,loop;"
+                       SpeedModChangedMessageCommand="queuecommand,Update"
+                       RateModChangedMessageCommand="queuecommand,Update"
+                       UpdateCommand="%function(self) self:settext(DisplayBPM(2, true, true)) end"                     
                        
                        loopCommand="%function(self)
                        getModP2 = 0;
                                        gnBlazeP2 = math.ceil((setModP2) * curRate)
                                        end
                                end
-                       self:stoptweening();
-                       self:sleep(0.1);
-                       self:queuecommand('loop');
                        end"
                />
 
diff --git a/Themes/GrooveNights/BGAnimations/ScreenSelectMusic overlay/default.xml b/Themes/GrooveNights/BGAnimations/ScreenSelectMusic overlay/default.xml
new file mode 100644 (file)
index 0000000..59117f1
--- /dev/null
@@ -0,0 +1,21 @@
+<ActorFrame> <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
+               bpm[3] = SCREENMAN:GetTopScreen():GetChild('BPMDisplay'):GetChild('Text'):GetText();
+                       if not OPENITG then bpm[3] = math.floor(bpm[3] * modRate + 0.5)
+                       end
+               end"
+       CurrentSongChangedMessageCommand="queuecommand,BPMCapture"
+       CurrentStepsP1ChangedMessageCommand="queuecommand,BPMCapture"
+       CurrentStepsP2ChangedMessageCommand="queuecommand,BPMCapture"
+/>
+
+</children></ActorFrame>
\ No newline at end of file
index 675481c..715bad0 100644 (file)
@@ -125,30 +125,6 @@ end"
                        Text=""
                        File="_eurostile blue glow"
                        InitCommand="%function(self)  self:x(100) self:shadowlength(0) self:draworder(10000); self:addy(21); self:queuecommand('Update'); end"
-                       CurrentSongChangedMessageCommand="queuecommand,Update"
-                       UpdateCommand="%function(self)
-                       lowBPM = tostring(SCREENMAN:GetTopScreen():GetChild('BPMDisplay'):GetChild('Text'):GetText());
-                       
-                       if lowBPM == nil then
-                               lowBPM = '0';
-                               end
-                       
-                       if lowBPM == '...' then
-                               lowBPM = '0';
-                               end
-                               
-                       highBPM = lowBPM
-                        
-                       delimPos = string.find(lowBPM, '-')
-                       if delimPos==1 then
-                               delimPos = string.find(lowBPM, '-',2)
-                       end
-                        
-                       if delimPos then
-                               lowBPM = string.sub(lowBPM, 1, delimPos-1)
-                               highBPM = string.sub(highBPM, delimPos+1, string.len(highBPM))
-                       end
-                       end"
                />
 <!--Timer Recorder-->
        <Layer Type="Quad"
index 84a8a0d..1938127 100644 (file)
@@ -71,13 +71,6 @@ return "GrooveNights Theme by Jayce"
 end
 
 
-
--- ===CHANGE THE RATE MODS===
-Rate = { "1.0x", "1.1x", "1.2x", "1.3x", "1.4x", "1.5x", "1.6x", "1.7x", "2.0x"}
-
-
-
-
 -- ===SHOW/HIDE ARROW SPEED INDICATORS===
 -- If you want the Arrow Speed Indicators to appear in the options menu you can switch them on here.
 -- It has been reported that they can sometimes cause lag during 2-Player mode so I opted to disable it by default.
@@ -1255,46 +1248,50 @@ return 0;
 
 end
 
+       
+       bpm = { "1", "2", "3" }
+       Rate = { "1.0", "1.1", "1.2", "1.3", "1.4", "1.5", "1.6", "1.7", "2.0"}
 
+function RateMods()
+       local modList = Rate
 
-function RateMod()
-       local ModList = Rate
-       local t = {
-               Name = "Rate",
-               LayoutType = "ShowAllInRow",
-               SelectType = "SelectOne",
-               OneChoiceForAllPlayers = true,
-               ExportOnChange = false,
-               Choices = ModList,
-
-               LoadSelections = function(self, list, pn)
-               for n = 1, table.getn(ModList) do
-                       if GAMESTATE:PlayerIsUsingModifier(pn,ModList[n]..'music') then
-                               list[n] = true; 
-                               s = string.gsub(ModList[n],'x','');
-                               ModRate = tonumber(s);
-                               else 
-                               list[n] = false ;
-                               end
-                       end
-               end,
+       local function Load(self, list, pn)
+               for n = 1, table.getn(modList) do
+                       if GAMESTATE:PlayerIsUsingModifier(pn,modList[n]..'xmusic') then list[n] = true; modRate = modList[n] else list[n] = false end
+               end
+       end
 
-               SaveSelections = function(self, list, pn)
-               p = pn + 1;
-               for n = 1, table.getn(ModList) do
-                       if list[n] then
-                               s = ModList[n];
-                               end
+       local function Save(self, list, pn)
+               for n = 1, table.getn(modList) do
+                       if list[n] then s = modList[n] end
                end
-               s = string.gsub(s,'x','');
-               ModRate = s;
-               GAMESTATE:ApplyGameCommand('mod, 1.0xmusic',p);
-               GAMESTATE:ApplyGameCommand('mod,'..ModRate..'xmusic',p);
-               GAMESTATE:SetEnv('RateMod','1');
+               modRate = s
+               GAMESTATE:ApplyGameCommand('mod,'..s..'xmusic',pn+1)
+               ApplyRateAdjust()
+               MESSAGEMAN:Broadcast('RateModChanged')
+       end
+
+       local Params = { Name = "Rate" }
+       return CreateOptionRow( Params, modList, Load, Save )
+end
+
+function ApplyRateAdjust()
+       for pn=1, 2 do
+               if GAMESTATE:IsPlayerEnabled( pn - 1 ) then
+                       speed = string.gsub(modSpeed[pn],modType[pn],"")
+                       if modType[pn] == "x" then speed = math.ceil(100*speed/modRate)/100 .. "x" end
+                       if modType[pn] == "c" then speed = "c" .. math.ceil(speed/modRate) end
+                       if modType[pn] == "m" then speed = "m" .. math.ceil(speed/modRate) end
+                       GAMESTATE:ApplyGameCommand('mod,' .. speed,pn)
                end
-       }
-       setmetatable(t, t)
-       return t
+       end
+end
+
+-- I doubt we will ever use this but it's nice to have for completeness
+function RevertRateAdjust()
+       for pn=1, 2 do
+               if modSpeed and modSpeed[pn] then GAMESTATE:ApplyGameCommand('mod,' .. modSpeed[pn],pn) end
+       end
 end
 
 
index 6929e2d..f40ba30 100644 (file)
@@ -614,4 +614,87 @@ function InitSpeedMods()
     else
         typeSpeed = { "x-mod", "c-mod" }
     end
+end
+
+function DisplayBPM(pn, includeRate, includeSpeed)      
+        local lowBPM = bpm[1]
+        local highBPM = bpm[2]
+               local speedMod = 1
+               local rateMod = 1
+               
+               if includeRate then rateMod = modRate end
+               
+               if includeSpeed then
+                       speedMod = modSpeed[pn]
+                       speedMod = string.gsub(speedMod,'x','')
+                       speedMod = string.gsub(speedMod,'c','')
+                       speedMod = string.gsub(speedMod,'m','')
+               end
+
+        if modType[pn] == "x-mod" then
+
+                if lowBPM == "Various" or lowBPM == "..." or lowBPM == nil then
+                return "???"
+                end
+                
+                lowScrollBPM = lowBPM * speedMod * rateMod
+        
+                if string.sub(lowScrollBPM, 2, 2) == "." then
+                lowScrollBPM = string.sub(lowScrollBPM, 1, 1)
+                end
+                
+                if string.sub(lowScrollBPM, 3, 3) == "." then
+                lowScrollBPM = string.sub(lowScrollBPM, 1, 2)
+                end
+        
+                if string.sub(lowScrollBPM, 4, 4) == "." then
+                lowScrollBPM = string.sub(lowScrollBPM, 1, 3)
+                end
+                
+                if string.sub(lowScrollBPM, 5, 5) == "." then
+                lowScrollBPM = string.sub(lowScrollBPM, 1, 4)
+                end
+                
+                if string.sub(lowScrollBPM, 6, 6) == "." then
+                lowScrollBPM = string.sub(lowScrollBPM, 1, 5)
+                end
+
+                if highBPM ~= "" then
+
+                        highScrollBPM = highBPM * speedMod * rateMod
+                
+                        if string.sub(highScrollBPM, 2, 2) == "." then
+                        highScrollBPM = string.sub(highScrollBPM, 1, 1)
+                        end
+
+                        if string.sub(highScrollBPM, 3, 3) == "." then
+                        highScrollBPM = string.sub(highScrollBPM, 1, 2)
+                        end
+
+                        if string.sub(highScrollBPM, 4, 4) == "." then
+                        highScrollBPM = string.sub(highScrollBPM, 1, 3)
+                        end
+        
+                        if string.sub(highScrollBPM, 5, 5) == "." then
+                        highScrollBPM = string.sub(highScrollBPM, 1, 4)
+                        end
+                
+                        if string.sub(highScrollBPM, 6, 6) == "." then
+                        highScrollBPM = string.sub(highScrollBPM, 1, 5)
+                        end
+                
+                end
+
+                if highBPM == "" then
+                return lowScrollBPM
+                else
+                return lowScrollBPM .. "-" .. highScrollBPM
+                end
+        end
+
+        if modType[pn] == "c-mod" or modType[pn] == "m-mod" then
+        return speedMod
+        end
+
+        return "???"
 end
\ No newline at end of file
index 59b7ec4..99be75f 100644 (file)
@@ -4032,7 +4032,7 @@ Line1=lua,SpeedMods('Base')
 Line2=lua,SpeedMods('Extra')
 Line3=lua,SpeedMods('Type')
 Line4=list,Persp
-Line5=lua,RateMod()
+Line5=lua,RateMods()
 Line6=list,NoteSkins2
 Line7=list,Accel
 Line8=list,Mini