Removed redundant global variables plus implemented a nicer way of getting the curren...
authorCameron Ball <c.ball1729@gmail.com>
Thu, 5 Dec 2013 16:08:36 +0000 (00:08 +0800)
committerCameron Ball <c.ball1729@gmail.com>
Thu, 5 Dec 2013 16:08:36 +0000 (00:08 +0800)
Themes/GrooveNights/BGAnimations/ScreenEvaluation overlay.xml
Themes/GrooveNights/BGAnimations/ScreenSelectMusic overlay.xml
Themes/GrooveNights/BGAnimations/ScreenSelectMusic overlay/default.xml [deleted file]
Themes/GrooveNights/Graphics/ScreenEvaluation grade frame p1/default.xml
Themes/GrooveNights/Graphics/ScreenNameEntryTraditional header.xml
Themes/GrooveNights/Graphics/ScreenPlayerOptions header.xml
Themes/GrooveNights/Graphics/ScreenSelectMusic banner frame/default.xml
Themes/GrooveNights/Scripts/GrooveNights.lua
Themes/GrooveNights/Scripts/Other.lua
Themes/GrooveNights/Scripts/gnSystem.lua

index dfb981f..75f14ae 100644 (file)
@@ -220,51 +220,7 @@ end">
                gnModHeight = self:GetHeight();
        end"
        OffCommand="accelerate,0.3;addx,EvalTweenDistance()"
-       />
-       
-       <!--[OBSOLETE BUT HAS CALCULATIONS] Restore Rate Mod-->
-       <BitmapText Font="_eurostile normal" Text=""
-       Condition="GAMESTATE:IsPlayerEnabled(PLAYER_1)"
-       OnCommand="%function(self)
-       if GetRateMod() ~= '1' or gnRateRestore == 1 then
-               GAMESTATE:ApplyGameCommand('mod, 1.0xmusic',1);
-               self:hidden(1);
-               self:settext(GetRateMod()..'X Rate');
-               self:zoom(0.5);
-                       self:x(SCREEN_CENTER_X-154);
-                       self:y(SCREEN_CENTER_Y-92);
-                       self:shadowlength(0);
-                       self:horizalign('center');
-                       self:draworder(6);
-               gnRateRestore = 1;
-               end     
-       end"
-       />
-       <BitmapText Font="_eurostile normal" Text=""
-       Condition="GAMESTATE:IsPlayerEnabled(PLAYER_2)"
-       OnCommand="%function(self)
-       if GetRateMod() ~= '1' or gnRateRestore == 1 then
-               GAMESTATE:ApplyGameCommand('mod, 1.0xmusic',2);
-               self:hidden(1);
-               self:settext(GetRateMod() .. 'X Rate');
-               self:zoom(0.5);
-                       self:x(SCREEN_CENTER_X+155);
-                       self:y(SCREEN_CENTER_Y-92);
-                       self:shadowlength(0);
-                       self:horizalign('center');
-                       self:draworder(6);
-               gnRateRestore = 1;
-               end     
-       end"
-       />
-       
-       <BitmapText Font="_eurostile normal" Text=""
-       OnCommand="%function(self)
-       if GetRateMod() ~= '1' then
-               curRate = 1;
-               end
-       end"
-       />
+       />      
        
 <!--Current Song-->
                <BitmapText
@@ -308,10 +264,10 @@ end">
 
                             local bpm = DisplayBPM(pn, true, false)
 
-                            if GetRateMod() ~= '1' then
+                            if GetRateMod() ~= '1.0x' then
                                 gnSongLengthDisplay = string.gsub(gnSongLength,'Patched','Length Patched');
                                 gnSongLengthDisplay = string.gsub(gnSongLength,'Length Length Patched','Length Patched');
-                                self:settext(bpm .. ' BPM ('..GetRateMod()..'x Music Rate) - '..gnSongLengthDisplay);
+                                self:settext(bpm .. ' BPM ('..GetRateMod()..' Music Rate) - '..gnSongLengthDisplay);
                             else
                                 gnSongLengthDisplay = string.gsub(gnSongLength,'Patched','Length Patched');
                                 gnSongLengthDisplay = string.gsub(gnSongLength,'Length Length Patched','Length Patched');
index af1e87e..c9ef1bc 100644 (file)
@@ -13,9 +13,6 @@ end"> <children>
                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"
diff --git a/Themes/GrooveNights/BGAnimations/ScreenSelectMusic overlay/default.xml b/Themes/GrooveNights/BGAnimations/ScreenSelectMusic overlay/default.xml
deleted file mode 100644 (file)
index 59117f1..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-<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 626d957..ae2029b 100644 (file)
@@ -5,10 +5,6 @@ self:queuecommand('Calculate');
 end"
 
 CalculateCommand="%function(self)
-if gnRateRestore == nil then
-       gnRateRestore = 0;
-       end
-
 gnJudgeTotal = tonumber(SCREENMAN:GetTopScreen():GetChild('MarvelousNumberP'..gnPlayerCount):GetText()) + tonumber(SCREENMAN:GetTopScreen():GetChild('PerfectNumberP'..gnPlayerCount):GetText()) + tonumber(SCREENMAN:GetTopScreen():GetChild('GreatNumberP'..gnPlayerCount):GetText()) + tonumber(SCREENMAN:GetTopScreen():GetChild('GoodNumberP'..gnPlayerCount):GetText()) + tonumber(SCREENMAN:GetTopScreen():GetChild('BooNumberP'..gnPlayerCount):GetText()) + tonumber(SCREENMAN:GetTopScreen():GetChild('MissNumberP'..gnPlayerCount):GetText());
 
 gnJumpsNumber = SCREENMAN:GetTopScreen():GetChild('JumpsTextP'..gnPlayerCount):GetText();
@@ -65,14 +61,8 @@ gnPath = getSystemSound('gnJudgeBar', '0');
 SOUND:PlayOnce(gnPath);
 end"> <children>
 <!--Rate Message-->
-       <Layer Type="Quad"
-       InitCommand="%function(self)
-       self:diffusealpha(0);
-       if gnRateRestore == 1 then
-               SCREENMAN:SystemMessage('Rate Modifier has been restored to 1.0x'); 
-               end
-       end"
-       />
+       <Layer Type="Quad" InitCommand="%function(self) if GetRateMod() ~= '1.0x' then GAMESTATE:ApplyGameCommand('mod, 1.0xmusic',1); SCREENMAN:SystemMessage('Rate Modifier has been restored to 1.0x') end end" />
+
        <Layer File="base frame B" InitCommand="@'diffuse,'..BackgroundColor()..';'"/>
        <Layer File="base frame F" InitCommand="@'diffuse,'..FrameColor()..';'"/>
        <!-- +7s are for 4:3, will need to make them +6s if using widescreen -->
index efb2d25..eb64696 100644 (file)
@@ -9,14 +9,6 @@ end">
                        
                        OffCommand=""
                />
-<!--Remove any restoration messages-->
-               <Layer
-                       Type="Quad"
-                       InitCommand="%function(self)
-                       self:diffusealpha(0);
-                       gnRateRestore = 0;
-                       end"
-               />
                
                <Layer File="ScreenNameEntryTraditional banner frame p1"
                InitCommand="@'x,SCREEN_CENTER_X-18;y,SCREEN_CENTER_Y-134-41;diffuse,'..FrameColor()..';'"
index 1d98548..1c59c95 100644 (file)
@@ -10,16 +10,6 @@ end">
                        OnCommand="shadowlength,0;diffusealpha,0;Decelerate,0.3;diffusealpha,1;"
                        OffCommand="accelerate,0.3;diffusealpha,0;"
                />
-<!--Rate Message-->
-       <Layer Type="Quad"
-       InitCommand="%function(self)
-       self:diffusealpha(0);
-       if gnRateRestore == 1 then
-               SCREENMAN:SystemMessage('Rate Modifier has been restored to 1.0x'); 
-               gnRateRestore = 0;
-               end
-       end"
-       />
 
 <!--Avatar + Info Display-->
                <Layer
index 715bad0..33f0913 100644 (file)
@@ -142,15 +142,7 @@ end"
        self:queuecommand('CountDown');
        end"
        />
-<!--Rate Message-->
-       <Layer Type="Quad"
-       InitCommand="%function(self)
-       self:diffusealpha(0);
-       if gnRateRestore == 1 then
-               SCREENMAN:SystemMessage('Rate Modifier has been restored to 1.0x'); 
-               end
-       end"
-       />
+
                                <Layer 
                                        File="../ScreenSelectMusic divider B"
                                        InitCommand="@'x,-120;y,18;diffuse,'..BackgroundColor()..';draworder,-1000;'"
index ea7e318..71a9cd9 100644 (file)
@@ -1250,27 +1250,28 @@ end
 
        
 bpm = { "1", "2", "3" }
-Rate = { "1.0x", "1.1x", "1.2x", "1.3x", "1.4x", "1.5x", "1.6x", "1.7x", "2.0x"}
+
+function GetRateMods()
+       return { "1.0x", "1.1x", "1.2x", "1.3x", "1.4x", "1.5x", "1.6x", "1.7x", "2.0x"}
+end
 
 function RateMods()
-       local modList = Rate
+       local modList = GetRateMods();
 
        local function Load(self, list, pn)
                for n = 1, table.getn(modList) do
-                        s = string.gsub(modList[n],'x','')
-                       if GAMESTATE:PlayerIsUsingModifier(pn,modList[n]..'music') then list[n] = true; modRate = tonumber(s) else list[n] = false end
+                       if GAMESTATE:PlayerIsUsingModifier(pn,modList[n]..'music') then list[n] = true else list[n] = false end
                end
        end
 
        local function Save(self, list, pn)
                for n = 1, table.getn(modList) do
-                       if list[n] then s = modList[n] end
+                       if list[n] then
+                               GAMESTATE:ApplyGameCommand('mod,'..modList[n]..'music',pn+1)
+                               ApplyRateAdjust()
+                               MESSAGEMAN:Broadcast('RateModChanged')
+                       end
                end
-                s = string.gsub(s,'x','')
-               modRate = s
-               GAMESTATE:ApplyGameCommand('mod,'..s..'xmusic',pn+1)
-               ApplyRateAdjust()
-               MESSAGEMAN:Broadcast('RateModChanged')
        end
 
        local Params = { Name = "Rate" }
@@ -1278,12 +1279,15 @@ function RateMods()
 end
 
 function ApplyRateAdjust()
+       local rateMod = string.gsub(GetRateMod(),'x','')
+       rateMod = tonumber(rateMod)
+
        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
+                       if modType[pn] == "x" then speed = math.ceil(100*speed/RateMod)/100 .. "x" end
+                       if modType[pn] == "c" then speed = "c" .. math.ceil(speed/RateMod) end
+                       if modType[pn] == "m" then speed = "m" .. math.ceil(speed/RateMod) end
                        GAMESTATE:ApplyGameCommand('mod,' .. speed,pn)
                end
        end
index b84ecbe..4049999 100644 (file)
@@ -428,33 +428,15 @@ function GetModifierNames( num )
        return s
 end
 
-function GetRateModHelper( rate )
-   return GAMESTATE:PlayerIsUsingModifier(0, rate) or GAMESTATE:PlayerIsUsingModifier(1, rate)
-end
-
-
 function GetRateMod()
-   if GetRateModHelper('1.0xmusic') then return '1'
-   elseif GetRateModHelper('1.1xmusic') then return '1.1' 
-   elseif GetRateModHelper('1.2xmusic') then return '1.2' 
-   elseif GetRateModHelper('1.3xmusic') then return '1.3' 
-   elseif GetRateModHelper('1.4xmusic') then return '1.4' 
-   elseif GetRateModHelper('1.5xmusic') then return '1.5' 
-   elseif GetRateModHelper('1.6xmusic') then return '1.6' 
-   elseif GetRateModHelper('1.7xmusic') then return '1.7' 
-   elseif GetRateModHelper('1.8xmusic') then return '1.8' 
-   elseif GetRateModHelper('1.9xmusic') then return '1.9' 
-   elseif GetRateModHelper('2.0xmusic') then return '2' 
-   elseif GetRateModHelper('0.1xmusic') then return '0.1' 
-   elseif GetRateModHelper('0.2xmusic') then return '0.2' 
-   elseif GetRateModHelper('0.3xmusic') then return '0.3' 
-   elseif GetRateModHelper('0.4xmusic') then return '0.4' 
-   elseif GetRateModHelper('0.5xmusic') then return '0.5' 
-   elseif GetRateModHelper('0.6xmusic') then return '0.6' 
-   elseif GetRateModHelper('0.7xmusic') then return '0.7' 
-   elseif GetRateModHelper('0.8xmusic') then return '0.8' 
-   elseif GetRateModHelper('0.9xmusic') then return '0.9' 
-   else return '(Unknown rate mod)' end
+       local RateMods = GetRateMods()
+       for n = 1, table.getn(RateMods) do
+               if GAMESTATE:PlayerIsUsingModifier(0, RateMods[n] .. 'music') or GAMESTATE:PlayerIsUsingModifier(1, RateMods[n] .. 'music') then
+                       return RateMods[n]
+               end
+       end
+
+       return '(Unknown rate mod)'
 end
 
 function oitgACoptions()
@@ -569,6 +551,8 @@ function SpeedMods(name)
 end
 
 function ApplySpeedMods()
+       local modRate = GetRateMod()
+
     for pn=1, 2 do
         if GAMESTATE:IsPlayerEnabled( pn - 1 ) then
             speed = string.gsub(modSpeed[pn],modType[pn],"")
@@ -618,8 +602,9 @@ end
 
 function DisplayBPM(pn, includeRate, includeSpeed) 
         local lowBPM = bpm[1]
-        local highBPM = bpm[2]        
-        local rateMod = modRate
+        local highBPM = bpm[2]  
+               local rateMod = string.gsub(GetRateMod(),'x','')
+        rateMod = tonumber(rateMod)
         local speedMod = modSpeed[pn]
 
         speedMod = string.gsub(speedMod,'x','')
index 1c9c39c..91f9bf9 100644 (file)
@@ -146,9 +146,6 @@ end
 
 
 if scn == 'ScreenSelectMusic' then
-       if gnRateRestore == nil then
-               gnRateRestore = 0;
-               end
        if curRate == nil then curRate = 1 end
        gnBlazedP1 = 0;
        gnBlazedP2 = 0;
@@ -165,9 +162,6 @@ end
 
 
 if scn == 'ScreenPlayerOptions' then
-       if gnRateRestore == nil then
-               gnRateRestore = 0;
-               end
        if GAMESTATE:IsPlayerEnabled(PLAYER_1) then
                gnP1Sound = 0;
                else
@@ -254,7 +248,6 @@ if scn == 'ScreenGameplay' then
        gnSameGrade = 0;
        gnSoundCheck = true;
        gnAward = 0;
-       if modRate == nil then modRate = 1 end
 end