Serious progress on #30. Stuff in the service menu not working correctly yet though.
authorCameron Ball <c.ball1729@gmail.com>
Thu, 19 Dec 2013 09:25:52 +0000 (17:25 +0800)
committerCameron Ball <c.ball1729@gmail.com>
Thu, 19 Dec 2013 09:25:52 +0000 (17:25 +0800)
Themes/GrooveNights/Languages/english.ini
Themes/GrooveNights/Scripts/01 ProfileRows.lua
Themes/GrooveNights/Scripts/02 SpeedMods.lua
Themes/GrooveNights/Scripts/05 CustomMods.lua [new file with mode: 0644]
Themes/GrooveNights/Scripts/Other.lua
Themes/GrooveNights/Scripts/gnSystem.lua
Themes/GrooveNights/metrics.ini

index 84e0e8b..096f5c1 100644 (file)
@@ -364,6 +364,7 @@ JudgeDifficulty=Judge Diff.
 DefaultFailType=Fail Type
 Theme=Swap Theme
 SpeedModType=Speed Mods
+CustomMods=Custom Mods
 GoodLuckCameron=Good Luck Cameron
 
 
index 34436c8..fbca9fb 100644 (file)
@@ -44,7 +44,7 @@ if PROFILEMAN ~= nil then
     ProfileTable = PROFILEMAN:GetMachineProfile():GetSaved()
 end
 
--- This function originally written by Marc Cannon ("Vyhd")
+-- This function written by Marc Cannon ("Vyhd")
 function CreateOptionRow( Params, Names, LoadFctn, SaveFctn )
         if not Params.Name then return nil end
 
@@ -77,46 +77,47 @@ function CreateOptionRow( Params, Names, LoadFctn, SaveFctn )
         return t
 end
 
--- creates a row list given a list of names and values
-function CreateProfileRow( Params, Values )
-        local pref = ProfileTable[Params.Name]
+function CreateGenericOptionRow( Params, Choices, Values )
+        local function Load(self, list, pn)                
+            for i=1,table.getn(Choices) do
+                list[i] = Params.LoadCallback(list[i], Values[i], pn)
 
-        local function Load(self, list, pn)
-                -- what we're doing here is checking what we got from profileman against the valid names.
-                for i=1,table.getn(Values) do
-                        if pref == Values[i] then list[i] = true return end
-                end
+                if Params.SelectType ~= "SelectMultiple" and list[i] then return end
+            end
 
-                if Params.Default then list[Params.Default] = true else list[1] = true end
+            if Params.Default then list[Params.Default] = true else list[1] = true SCREENMAN:SystemMessage("here") end
         end
 
         local function Save(self, list, pn)
-                -- go through each item in the list and save the first one that is set to true
-                for i=1,table.getn(Values) do
-                        if list[i] then
-                                ProfileTable[Params.Name] = Values[i]
-                                PROFILEMAN:SaveMachineProfile()
-                                return
-                        end
+                for i=1,table.getn(Choices) do
+                    Params.SaveCallback(list[i], Values[i], pn)
                 end
         end
 
-        return CreateOptionRow( Params, Values, Load, Save )
+        return CreateOptionRow( Params, Choices, Load, Save )
+end
+
+-- creates a row list given a list of names and values
+function CreateProfileRow( Params, Choices, Values )
+        local pref = ProfileTable[Params.Name]
+        
+        Params.LoadCallback = function(List, Value) if Params.SekectType ~= "SelectMultiple" then return Value == pref else return pref[Value] end end
+        Params.SaveCallback = function(List, Value)
+                                if Params.SelectType ~= "SelectMultiple" and List then ProfileTable[Params.Name] = Value PROFILEMAN:SaveMachineProfile() return end
+                                if Params.SelectType == "SelectMultiple" then
+                                    if type(ProfileTable[Params.Name]) ~= "table" then ProfileTable[Params.Name] = {} end
+                                    ProfileTable[Params.Name][Value] = List
+                                    PROFILEMAN:SaveMachineProfile()
+                                end
+                              end
+
+        return CreateGenericOptionRow( Params, Choices, Values )
 end
 
 function CreateProfileRowBool( Params )
-    local choices = {"OFF", "ON"}
-
-    local function Load(self, list, pn)
-        if ProfileTable[Params.Name] then list[2] = true else list[1] = true end
-    end
-
-    local function Save(self, list, pn)
-        if list[1] then ProfileTable[Params.Name] = false else ProfileTable[Params.Name] = true end
-        PROFILEMAN:SaveMachineProfile()
-        return
-    end
-    return CreateOptionRow( Params, choices, Load, Save )
+    local Choices = {"OFF", "ON"}
+    local Values = {false, true}
+    return CreateProfileRow( Params, Choices, Values )
 end
 
 function GetProfilePref(Name)
index ce4cb77..44111b6 100644 (file)
@@ -15,7 +15,7 @@ All I ask is that you keep this notice intact and don't redistribute in bytecode
 local Names = { "Basic", "Advanced", "Pro" }\r
 \r
 function SpeedModTypeRow()\r
-        return CreateProfileRow( { Name = "SpeedModType", Default = 3 }, Names )\r
+        return CreateProfileRow( { Name = "SpeedModType", Default = 3 }, Names, Names )\r
 end\r
 \r
 function GetSpeedModRowType()\r
diff --git a/Themes/GrooveNights/Scripts/05 CustomMods.lua b/Themes/GrooveNights/Scripts/05 CustomMods.lua
new file mode 100644 (file)
index 0000000..fc47976
--- /dev/null
@@ -0,0 +1,65 @@
+-- For tracking applied mods
+local AppliedModsTable = {}
+
+-- For resetting mods
+local WasInOptions = {PLAYER_1 = false, PLAYER_2 = false}
+
+-- Holds the mods
+local ModsTable = {}
+
+function RegisterCustomMod(Name, fn, Params, Choices)
+    assert(ModsTable[Name] == nil, "Cannot re-register custom mod" .. Name)
+    Params.Name = Name
+    ModsTable[Name] = { ["Params"] = Params, ["Choices"] = Choices, Callback = fn }
+
+    if not AppliedModsTable[PLAYER_1] then AppliedModsTable[PLAYER_1] = {} end
+    if not AppliedModsTable[PLAYER_2] then AppliedModsTable[PLAYER_2] = {} end
+    
+    AppliedModsTable[PLAYER_1][Name] = false
+    AppliedModsTable[PLAYER_2][Name] = false
+end
+
+function CustomModOptionRow(Name)
+    local Choices = ModsTable[Name].Choices 
+    local Params = ModsTable[Name].Params
+
+    Params.LoadCallback = function(List, Value, pn)
+                            WasInOptions[pn] = true
+
+                            -- If this is the first round, reset the skin as it may still be set from earlier
+                            --if GetStageText() == "1" then AppliedModsTable[pn][Name] = nil end
+                           if AppliedModsTable[pn][Name] then Trace("MODSTABLE IS " ..AppliedModsTable[pn][Name]) end
+                            return AppliedModsTable[pn][Name] == Value
+                          end
+
+    Params.SaveCallback = function(List, Value, pn) if List then AppliedModsTable[pn][Name] = Value end end
+
+    return CreateGenericOptionRow( Params, Choices, Choices )
+end
+
+function DoCustomMod(Name, pn, Params)
+    --if this is the first stage and the user was NOT in the options, reset the mod to default
+    if GetStageText() == "1" and not WasInOptions[pn] then AppliedModsTable[pn][Name] = nil end
+
+    if AppliedModsTable[pn][Name] ~= nil then Params.Value = AppliedModsTable[pn][Name] return ModsTable[Name].Callback(Params) end
+
+    WasInOptions[pn] = false
+end
+
+function CustomModsServiceOptionRow()
+    local Choices = {}
+    local Params = { Name = "CustomMods", SelectType = "SelectMultiple"  }
+
+    for ModName,ModValue in pairs(ModsTable) do
+        table.insert(Choices, ModName)
+    end
+
+    return CreateProfileRow(Params, Choices, Choices)
+end
+
+function CustomModLines()
+
+end
+
+
+
index 1f22fdc..432d934 100644 (file)
@@ -429,16 +429,16 @@ function GetModifierNames( num )
 end
 
 function oitgACoptions()
-    local OptionLines = "1,2,3,4,5,6,7,8,9,10,11,12"
+    local OptionLines = "1,2,3,4,5,6,7,8,9,10,11,12,13"
     
-    if EasterEggsEnabled() then OptionLines = OptionLines .. ",13" end
+    if EasterEggsEnabled() then OptionLines = OptionLines .. ",14" end
 
     return OptionLines
 end
 
 function SongModifiers()
     -- this is very basic right now, but it can be modified to take in to account OITG specific stuff
-    return SpeedLines() .. "4,5,25,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24"
+    return SpeedLines() .. "4,5,25,26,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24"
 end
 
 function SpeedLines()
index 4a9518b..000981f 100644 (file)
@@ -416,6 +416,18 @@ RegisterGlobalCallback("LowBPM", LowBPM)
 RegisterGlobalCallback("TotalTimeMinutes", TotalTimeMinutes)
 RegisterGlobalCallback("TotalTimeSeconds", TotalTimeSeconds)
 
+-- custom mods
+local function LoadJudgeSkin(Params)
+    Params.Actor:Load( THEME:GetPath( EC_GRAPHICS, '', '_Judgements/' .. Params.Value ))
+end
+
+local function DummyCallback(Params)
+    return true
+end
+
+RegisterCustomMod( "JudgeSkin", LoadJudgeSkin, { OneChoiceForAllPlayers = false, LineNumber = 25 }, { "GrooveNights", "Love", "Tactics", "Chromatic", "Deco", "FP", "ITG2" } )
+RegisterCustomMod( "DummyMod", DummyCallback, { OneChoiceForAllPlayers = false, LineNumber = 26 }, { "Yolo", "Swag", "Young", "Money", "Cash", "Money" } )
+
 --actor setters
 
 function SetFromDisplayScrollSpeed( Actor, pn )
@@ -432,8 +444,3 @@ function GoodLuckCameronOptionsRow()
     local Params = { Name = "GoodLuckCameron" }
     return CreateProfileRowBool( Params )
 end
-
-function gnJudgementSkinsOptionRow()
-    local Names = { "GrooveNights", "Love", "Tactics", "Chromatic", "Deco", "FP", "ITG2" }
-    return JudgeSkinOptionsRow(Names, "GrooveNights")
-end
\ No newline at end of file
index 81d5e6b..fd3c033 100644 (file)
@@ -2560,8 +2560,8 @@ CombinedLifeX=SCREEN_CENTER_X
 CombinedLifeY=SCREEN_TOP+54
 CombinedLifeOnCommand=addy,-100;addy,+100
 CombinedLifeOffCommand=
-PlayerP1OnCommand=%function(self) LoadSkin(self:GetChild('Judgment'):GetChild(''), PLAYER_1) end
-PlayerP2OnCommand=%function(self) LoadSkin(self:GetChild('Judgment'):GetChild(''), PLAYER_2) end
+PlayerP1OnCommand=%function(self) DoCustomMod("JudgeSkin", PLAYER_1, { Actor = self:GetChild('Judgment'):GetChild('') } )end
+PlayerP2OnCommand=%function(self) DoCustomMod("JudgeSkin", PLAYER_2, { Actor = self:GetChild('Judgment'):GetChild('') } )end
 
 [ScreenGameplayTraining]
 Fallback=ScreenGameplay
@@ -3970,7 +3970,8 @@ Line9=conf,DefaultFailType
 Line10=conf,Theme
 Line11=lua,SpeedModTypeRow()
 Line12=lua,EasterEggsOptionsRow()
-Line13=lua,GoodLuckCameronOptionsRow()
+Line13=lua,CustomModsServiceOptionRow()
+Line14=lua,GoodLuckCameronOptionsRow()
 
 [ScreenGraphicOptions]
 Fallback=ScreenOptionsSubmenu
@@ -4048,7 +4049,8 @@ Line2=lua,SpeedMods('Extra')
 Line3=lua,SpeedMods('Type')
 Line4=list,Persp
 Line5=lua,RateMods()
-Line25=lua,gnJudgementSkinsOptionRow()
+Line25=lua,CustomModOptionRow('JudgeSkin')
+Line26=lua,CustomModOptionRow('DummyMod')
 Line6=list,NoteSkins2
 Line7=list,Accel
 Line8=list,Mini