Progress on #7. The options screen crashes as soon as you choose a speed mod, but...
authorCameron Ball <c.ball1729@gmail.com>
Fri, 6 Dec 2013 07:00:43 +0000 (15:00 +0800)
committerCameron Ball <c.ball1729@gmail.com>
Fri, 6 Dec 2013 07:00:43 +0000 (15:00 +0800)
Themes/GrooveNights/BGAnimations/ScreenEvaluation overlay.xml
Themes/GrooveNights/BGAnimations/ScreenPlayerOptions overlay/default.xml
Themes/GrooveNights/Scripts/GrooveNights.lua
Themes/GrooveNights/Scripts/Other.lua
Themes/GrooveNights/Scripts/gnCustomOptions.lua
Themes/GrooveNights/Scripts/gnSystem.lua

index 75f14ae..65965a7 100644 (file)
@@ -258,9 +258,9 @@ end">
                             self:x(SCREEN_CENTER_X);
                             self:y(SCREEN_CENTER_Y-146+60+4);
 
-                            local pn = 1
+                            local pn = PLAYER_1
                             
-                            if GAMESTATE:IsPlayerEnabled(PLAYER_2) then pn = 2 end
+                            if GAMESTATE:IsPlayerEnabled(PLAYER_2) then pn = PLAYER_2 end
 
                             local bpm = DisplayBPM(pn, true, false)
 
index 239c6e9..16ff89c 100644 (file)
                
        <Layer File="../ScreenOptions overlay"/>
 
-<!--Apply Mods-->
-       <Layer Type="Quad"
-       Condition="GAMESTATE:IsPlayerEnabled(PLAYER_1)"
-       InitCommand="diffusealpha,0;hibernate,0.01;queuecommand,Mods;"
-       ModsCommand="%function(self)
-               self:stoptweening();
-               GAMESTATE:ApplyGameCommand('mod, 1x',1);
-               if addModP1 < 4 then
-                       if setModP1 < 50 then
-                               GAMESTATE:ApplyGameCommand('mod,'..setModP1+addModP1..'x',1);
-                               else
-                               GAMESTATE:ApplyGameCommand('mod,c'..setModP1,1);
-                               end
-                       else
-                       if setModP1 < 50 then
-                               GAMESTATE:ApplyGameCommand('mod,'..setModP1..'x',1);
-                               else
-                               GAMESTATE:ApplyGameCommand('mod,c'..setModP1+addModP1,1);
-                               end
-                       end
-               hideBGp1 = 0;
-               for getModP1=0, 100, 5 do
-                       if GAMESTATE:PlayerIsUsingModifier(PLAYER_1,''..(getModP1/100)..'% cross') then 
-                               hideBGp1 = getModP1;
-                               break
-                               end
-                       end
-               self:sleep(0.1);
-               self:queuecommand('Mods');
-       end"
-       />
-
-       <Layer Type="Quad"
-       Condition="GAMESTATE:IsPlayerEnabled(PLAYER_2)"
-       InitCommand="diffusealpha,0;hibernate,0.01;queuecommand,Mods;"
-       ModsCommand="%function(self)
-               self:stoptweening();
-               GAMESTATE:ApplyGameCommand('mod, 1x',2);
-               if addModP2 < 4 then
-                       if setModP2 < 50 then
-                               GAMESTATE:ApplyGameCommand('mod,'..setModP2+addModP2..'x',2);
-                               else
-                               GAMESTATE:ApplyGameCommand('mod,c'..setModP2,2);
-                               end
-                       else
-                       if setModP2 < 50 then
-                               GAMESTATE:ApplyGameCommand('mod,'..setModP2..'x',2);
-                               else
-                               GAMESTATE:ApplyGameCommand('mod,c'..setModP2+addModP2,2);
-                               end
-                       end
-               hideBGp2 = 0;
-               for getModP2=0, 100, 5 do
-                       if GAMESTATE:PlayerIsUsingModifier(PLAYER_2,''..(getModP2/100)..'% cross') then 
-                               hideBGp2 = getModP2;
-                               break
-                               end
-                       end
-               self:sleep(0.1);
-               self:queuecommand('Mods');
-       end"
-       />
 <!--Timer Recorder-->
        <Layer Type="Quad"
        InitCommand="diffusealpha,0;sleep,0.01;queuecommand,CountDown;"
index cbc3220..ef14d90 100644 (file)
@@ -1256,38 +1256,38 @@ function GetRateMods()
 end
 
 function GetBaseSpeeds()
-    if GetSpeedModType() == "pro" then
+    if GetSpeedModRowType() == "pro" then
         return { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16" }
     end
         
-    if GetSpeedModType() == "advanced" then
+    if GetSpeedModRowType() == "advanced" then
         if OPENITG then baseSpeed = { "0.25x", "0.5x", "0.75x", "1x", "1.25x", "1.5x", "1.75x", "2x", "2.25x", "2.5x", "2.75x", "3x", "3.25x", "3.5x", "3.75x", "4x", "4.25x", "4.5x", "4.75x", "5x", "5.25x", "5.5x", "5.75x", "6x", "6.25x", "6.5x", "6.75x", "7x", "c400", "c425", "c450", "c475", "c500", "c525", "c550", "c575", "c600", "c625", "c650", "c675", "c700", "c725", "c750", "c775", "c800", "c825", "c850", "c875", "c900", "c925", "c950", "c975", "c1000", "m400", "m425", "m450", "m475", "m500", "m525", "m550", "m575", "m600", "m625", "m650", "m675", "m700", "m725", "m750", "m775", "m800", "m825", "m850", "m875", "m900", "m925", "m950", "m975", "m1000" }
         else baseSpeed = { "0.25x", "0.5x", "0.75x", "1x", "1.25x", "1.5x", "1.75x", "2x", "2.25x", "2.5x", "2.75x", "3x", "3.25x", "3.5x", "3.75x", "4x", "4.25x", "4.5x", "4.75x", "5x", "5.25x", "5.5x", "5.75x", "6x", "6.25x", "6.5x", "6.75x", "7x", "c400", "c425", "c450", "c475", "c500", "c525", "c550", "c575", "c600", "c625", "c650", "c675", "c700", "c725", "c750", "c775", "c800", "c825", "c850", "c875", "c900", "c925", "c950", "c975", "c1000" }
         end
     end
 
-    if GetSpeedModType() == "basic" then
+    if GetSpeedModRowType() == "basic" then
         if OPENITG then baseSpeed = { "1x", "1.5x", "2x", "2.5x", "3x", "3.5x", "4x", "4.5x", "5x", "6x", "c450", "m450" }
         else baseSpeed = { "1x", "1.5x", "2x", "2.5x", "3x", "3.5x", "4x", "4.5x", "5x", "5.5x", "6x", "c450" }
         end
     end
 end   
 
-function GetExtraSpeeds() {
-       if GetSpeedModType() == "pro" then 
+function GetExtraSpeeds()
+       if GetSpeedModRowType() == "pro" then 
                return { "0", "+0.25", "+0.5", "+0.75", "+0.1", "+0.2", "+0.3", "+0.4", "+0.6", "+0.7", "+0.8", "+0.9" }
        end
        
-       if GetSpeedModType() == "advanced" then
+       if GetSpeedModRowType() == "advanced" then
                return { "0" }
        end
        
-       if GetSpeedModType() == "basic" then
+       if GetSpeedModRowType() == "basic" then
                return { "0" }
        end
-}
+end
 
-function GetSpeedModTypes() {
+function GetSpeedModTypes() 
     if OPENITG then
         return { "x-mod", "c-mod", "m-mod" }
     else
@@ -1307,8 +1307,8 @@ function RateMods()
        local function Save(self, list, pn)
                for n = 1, table.getn(modList) do
                        if list[n] then
-                               GAMESTATE:ApplyGameCommand('mod,'..modList[n]..'music',pn+1)
-                               ApplyRateAdjust()
+                               GAMESTATE:ApplyGameCommand('mod,'..modList[n]..'music',pn)
+                               --ApplyRateAdjust()
                                MESSAGEMAN:Broadcast('RateModChanged')
                        end
                end
index c7b7128..3ef9007 100644 (file)
@@ -439,8 +439,95 @@ function GetRateMod()
        return '(Unknown rate mod)'
 end
 
-function GetSpeedMod()
---hello
+function GetSpeedMod(pn)
+    local BaseSpeeds = GetBaseSpeeds()
+    local ExtraSpeeds = GetExtraSpeeds()    
+    for n = 1, table.getn(BaseSpeeds) do
+        if GetSpeedModRowType() == "basic" or GetSpeedModRowType() == "advanced" then
+            if GAMESTATE:PlayerIsUsingModifier(pn, BaseSpeeds[n]) then return BaseSpeeds[n] end
+        end
+
+        if GetSpeedModRowType() == "pro" then
+            for m = 1, table.getn(ExtraSpeeds) do
+                local ExtraSpeed = string.gsub(ExtraSpeeds[m],'+0', '')
+                if ExtraSpeed == "0" then ExtraSpeed = ".0" end
+
+                local CombinedSpeeds = tonumber(BaseSpeeds[n])*100 + tonumber(ExtraSpeed)*100 --combines the speeds in to things like 450
+
+                --check x-mods
+                Trace('Checking the swag for ' .. pn .. ' ' .. BaseSpeeds[n] .. ExtraSpeed .. 'x')
+                if GAMESTATE:PlayerIsUsingModifier(pn, BaseSpeeds[n] .. ExtraSpeed .. 'x') then
+                    Trace("Returning the swag " .. BaseSpeeds[n] .. ExtraSpeed .. 'x')
+                    return BaseSpeeds[n] .. ExtraSpeed .. 'x'
+                end
+
+                --check c-mods
+                Trace('Checking the swag for ' .. pn .. ' c' .. CombinedSpeeds)
+                if GAMESTATE:PlayerIsUsingModifier(pn, 'c' .. CombinedSpeeds) then 
+                    Trace("Returning the swag c" .. CombinedSpeeds)
+                    return 'c' .. CombinedSpeeds
+                end
+
+                --check m-mods (for some reason m0 is always applied, so skip it)
+                Trace('Checking the swag for ' .. pn .. ' m' .. CombinedSpeeds)
+                if GAMESTATE:PlayerIsUsingModifier(pn, 'm' .. CombinedSpeeds) and CombinedSpeeds ~= 0 then 
+                    Trace("Returning the swag m" .. CombinedSpeeds)
+                    return 'm' .. CombinedSpeeds
+                end
+            end
+       end  
+    end
+
+    --If we got here, chances are that we ignored m0, so return that
+    return "m0"
+end
+
+function GetSpeedModBase(pn)
+    local SpeedMod = GetSpeedMod(pn)
+    SpeedMod = string.gsub(SpeedMod, 'c', '')
+    SpeedMod = string.gsub(SpeedMod, 'm', '')
+
+    local SpeedModType = GetSpeedModType(pn)
+    
+    if SpeedModType == 'x-mod' then
+        local pos = string.find(SpeedMod, '.', 1, true)
+        return string.sub(SpeedMod, 1, pos-1)
+    end
+
+    if SpeedModType == 'c-mod' or SpeedModType == 'm-mod' then
+        SpeedMod = tonumber(SpeedMod)/100
+        SpeedMod = tostring(SpeedMod)
+        local pos = string.find(SpeedMod, '.', 1, true)
+
+        if pos ~= nil then return string.sub(pos, 1, pos-1) else return SpeedMod end
+    end
+end
+
+function GetSpeedModExtra(pn)
+    local SpeedMod = GetSpeedMod(pn)
+    local SpeedModBase = GetSpeedModBase(pn)
+
+    Trace('GETSPEEDMODEXTRA SHIT:')
+    Trace('SpeedMod: ' .. SpeedMod)
+    Trace('SpeedModBase: ' .. SpeedModBase)
+
+    local SpeedModExtra = string.gsub(SpeedMod, SpeedModBase .. '.', '')
+
+    Trace('1st SpeedModExtra: ' .. SpeedModExtra)
+
+    SpeedModExtra = string.gsub(SpeedModExtra, 'x', '')
+
+    Trace('2nd SpeedModExtra: ' .. SpeedModExtra)
+
+    if SpeedModExtra ~= nil then return SpeedModExtra else return "0" end
+end
+
+function GetSpeedModType(pn)
+    local SpeedMod = GetSpeedMod(pn)
+
+    if string.find(SpeedMod, ".") ~= nil then return 'x-mod' end
+    if string.find(SpeedMod, "c") ~= nil then return 'c-mod' end
+    if string.find(SpeedMod, "m") ~= nil then return 'm-mod' end
 end
 
 function oitgACoptions()
@@ -456,7 +543,7 @@ function SongModifiers()
 end
 
 function SpeedLines()
-    local type = GetSpeedModType()
+    local type = GetSpeedModRowType()
 
     if type == "pro" then
         return "1,2,3,"
@@ -466,16 +553,16 @@ function SpeedLines()
 end
 
 function SpeedMods(name)
-    local modList = baseSpeed
+    local modList = GetBaseSpeeds()
     local s = "Speed"
 
     if name == "Extra" then
-        modList = extraSpeed
+        modList = GetExtraSpeeds()
         s = "Extra " .. s
     end
 
     if name == "Type" then
-        modList = typeSpeed
+        modList = GetSpeedModTypes()
         s = s .. " Type"
     end
 
@@ -488,7 +575,7 @@ function SpeedMods(name)
         -- now loop through everything else in the list and see if it is set to true
         for i=2, table.getn(modList) do
                 if name == "Base" then
-                    if modList[i] == modBase[pn+1] then
+                    if modList[i] == GetSpeedModBase(pn) then
                         list[i] = true
                         list[1] = false
                     else
@@ -497,7 +584,7 @@ function SpeedMods(name)
                 end
 
                 if name == "Extra" then
-                    if modList[i] == modExtra[pn+1] then
+                    if modList[i] == GetSpeedModExtra(pn) then
                         list[i] = true
                         list[1] = false
                     else
@@ -505,11 +592,8 @@ function SpeedMods(name)
                     end
                 end
 
-                if name == "Type" then
-                    s = modList[i]
-                    s = string.gsub(s, '-Mod','')
-                                       
-                    if s == modType[pn+1] then
+                if name == "Type" then                         
+                    if modList[i] == GetSpeedModType(pn) then
                         list[i] = true
                         list[1] = false
                     else
@@ -520,42 +604,37 @@ function SpeedMods(name)
     end
 
     local function Save(self, list, pn)
+        local SpeedMod = GetSpeedMod(pn)
+        local ModBase = GetSpeedModBase(pn)
+        local ModExtra = GetSpeedModExtra(pn)
+        local ModType = GetSpeedModType(pn)
+
         for i = 1, table.getn(modList) do
             if list[i] then
-                s = modList[i]
+                if name == "Base" then ModBase = modList[i] end
+                if name == "Extra" then ModExtra = modList[i] end
+                if name == "Type" then ModType = modList[i] end
             end
         end
 
-        local p = pn + 1
+        Trace("LEEROY " .. ModBase .. '.' .. ModExtra)
 
-        if name == "Type" then modType[p] = s end
-        if name == "Base" then
-            modBase[p] = s
-            
-            if GetSpeedModType() ~= "pro" then
-                if string.find(modBase[p],"x") then modBase[p] = string.gsub(modBase[p], "x", ""); modType[p] = 'x-mod' end
-                if string.find(modBase[p],"c") then modBase[p] = string.gsub(modBase[p], "c", ""); modType[p] = 'c-mod' end
-                if string.find(modBase[p],"m") then modBase[p] = string.gsub(modBase[p], "m", ""); modType[p] = 'm-mod' end
-            end
-        end
+        SpeedMod = tonumber(ModBase .. '.' .. ModExtra);
 
-        if name == "Extra" then modExtra[p] = s end
-
-        if modType[p] == 'x-mod' then modSpeed[p] = modBase[p] + modExtra[p] .. 'x' end
-        if modType[p] == 'c-mod' then modSpeed[p] = 'c' .. modBase[p]*100 + modExtra[p]*100 end
-        if modType[p] == 'c-mod' and GetSpeedModType() ~= "pro" then modSpeed[p] = 'c' .. modBase[p] end
-        if modType[p] == 'm-mod' then modSpeed[p] = 'm' .. modBase[p]*100 + modExtra[p]*100 end
-        if modType[p] == 'm-mod' and GetSpeedModType() ~= "pro" then modSpeed[p] = 'm' .. modBase[p] end
-        GAMESTATE:ApplyGameCommand('mod,1x',p)
-        ApplySpeedMods()
-        MESSAGEMAN:Broadcast('SpeedModChanged')
+        if ModType == 'c-mod' then SpeedMod = 'c' .. SpeedMod*100 end
+        if ModType == 'm-mod' then SpeedMod = 'm' .. SpeedMod*100 end
+        if ModType == 'x-mod' then SpeedMod = SpeedMod .. 'x' end      
+                    
+        --GAMESTATE:ApplyGameCommand('mod,'..SpeedMod,pn)
+        --ApplySpeedMods()
+        --MESSAGEMAN:Broadcast('SpeedModChanged')
     end
 
     return CreateOptionRow( Params, modList, Load, Save )
 end
 
 function ApplySpeedMods()
-       local modRate = GetRateMod()
+    local modRate = GetRateMod()
 
     for pn=1, 2 do
         if GAMESTATE:IsPlayerEnabled( pn - 1 ) then
@@ -571,10 +650,11 @@ end
 function DisplayBPM(pn, includeRate, includeSpeed) 
         local lowBPM = bpm[1]
         local highBPM = bpm[2]  
-               local rateMod = string.gsub(GetRateMod(),'x','')
+
+        local rateMod = string.gsub(GetRateMod(),'x','')
         rateMod = tonumber(rateMod)
-        local speedMod = modSpeed[pn]
 
+        local speedMod = GetSpeedMod(pn)
         speedMod = string.gsub(speedMod,'x','')
         speedMod = string.gsub(speedMod,'c','')
         speedMod = string.gsub(speedMod,'m','')
@@ -638,7 +718,7 @@ function DisplayBPM(pn, includeRate, includeSpeed)
         can just return the speedMod as that will be the scroll speed regardless
         of the rate/speed mod chosen
         ]]--
-        if includeRate and includeSpeed and (modType[pn] == "m-mod" or modType[pn] == "c-mod") then
+        if includeRate and includeSpeed and (GetSpeedModType(pn) == "m-mod" or GetSpeedModType(pn) == "c-mod") then
             return speedMod
         end
 
index 9b1bed4..458dd03 100644 (file)
@@ -10,7 +10,7 @@ end
 local Names = { "Basic", "Advanced", "Pro" }
 
 function SpeedModTypeRow()
-        local type = GetSpeedModType()
+        local type = GetSpeedModRowType()
 
         local function Load(self, list, pn)
                 -- what we're doing here is checking what we got from profileman against the valid names.
@@ -38,7 +38,7 @@ function SpeedModTypeRow()
         return CreateOptionRow( Params, Names, Load, Save )
 end
 
-function GetSpeedModType()
+function GetSpeedModRowType()
         local type = ProfileTable.SpeedModType
 
         -- as soon as we find a valid name, return it.
index 91f9bf9..76bc97a 100644 (file)
@@ -96,10 +96,7 @@ if GAMESTATE:GetEnv('AngryGrandpa') == 'Turn' then
 if GAMESTATE:GetEnv('Konami') == 'Turn' then
        SCREENMAN:SystemMessage('Konami Code Activated');
        GAMESTATE:SetEnv('Konami','On');
-       end
-       
-InitSpeedMods()
-
+       end     
 end