From 8473336737d83e33814eebbda4342b3f1af46f2b Mon Sep 17 00:00:00 2001 From: Flameshadowxeroshin Date: Fri, 7 Oct 2011 01:20:49 +0000 Subject: [PATCH] intelligently load all of the implemented scoring modes for selection --- Themes/_fallback/Scripts/04 Scoring.lua | 29 +++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/Themes/_fallback/Scripts/04 Scoring.lua b/Themes/_fallback/Scripts/04 Scoring.lua index 4ee80e9a1d..a3e6f5d0b4 100644 --- a/Themes/_fallback/Scripts/04 Scoring.lua +++ b/Themes/_fallback/Scripts/04 Scoring.lua @@ -373,3 +373,32 @@ end -- Formulas end here. for v in ivalues(DisabledScoringModes) do r[v] = nil end Scoring = r; + +function UserPrefScoringMode() + local baseChoices = {} + for k,v in pairs(Scoring) do table.insert(baseChoices,k) end + local t = { + Name = "UserPrefScoringMode"; + LayoutType = "ShowAllInRow"; + SelectType = "SelectOne"; + OneChoiceForAllPlayers = true; + ExportOnChange = false; + Choices = baseChoices; + LoadSelections = function(self, list, pn) + if ReadPrefFromFile("UserPrefScoringMode") ~= nil then + local theValue = ReadPrefFromFile("UserPrefScoringMode"); + local success = false; + for k,v in ipairs(baseChoices) do if v == theValue then list[k] = true success = true break end end; + if success == false then list[1] = true end; + else + WritePrefToFile("UserPrefScoringMode", 'DDR Extreme'); + list[1] = true; + end; + end; + SaveSelections = function(self, list, pn) + for k,v in ipairs(list) do if v then WritePrefToFile("UserPrefScoringMode", baseChoices[k]) break end end; + end; + }; + setmetatable( t, t ); + return t; +end