Advertisement
Jousway

USW2 03 ThemePrefs.lua

Feb 11th, 2012
225
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.89 KB | None | 0 0
  1. ThemePrefs.InitAll(Prefs)
  2.  
  3. function InitUserPrefs()
  4.     local Prefs = {
  5.         USWUseDefaultColour = true,
  6.         USWNoteskin4thRed = '255'
  7.     }
  8.     for k, v in pairs(Prefs) do
  9.         -- kind of xxx
  10.         local GetPref = type(v) == "boolean" and GetUserPrefB or GetUserPref
  11.         if GetPref(k) == nil then
  12.             SetUserPref(k, v)
  13.         end
  14.     end
  15. end;
  16.  
  17. local tChoices = {};
  18. for i=1,256 do tChoices[i] = i; end;
  19.  
  20. -- what the fuck am I doing - Jousway
  21. function USWUseDefaultColour()
  22.     local t = {
  23.         Name = "USWUseDefaultColour";
  24.         LayoutType = "ShowAllInRow";
  25.         SelectType = "SelectOne";
  26.         OneChoiceForAllPlayers = true;
  27.         ExportOnChange = false;
  28.         Choices = { 'True','False' };
  29.         LoadSelections = function(self, list, pn)
  30.             if ReadPrefFromFile("USWUseDefaultColour") ~= nil then
  31.                 if GetUserPrefB("USWUseDefaultColour") then
  32.                     list[2] = true;
  33.                 else
  34.                     list[1] = true;
  35.                 end;
  36.             else
  37.                 WritePrefToFile("USWUseDefaultColour",false);
  38.                 list[1] = true;
  39.             end;
  40.         end;
  41.         SaveSelections = function(self, list, pn)
  42.             local val;
  43.             if list[2] then
  44.                 val = true;
  45.             else
  46.                 val = false;
  47.             end;
  48.             WritePrefToFile("USWUseDefaultColour",val);
  49.             MESSAGEMAN:Broadcast("PreferenceSet", { Message == "Set Preference" } );
  50.             THEME:ReloadMetrics();
  51.         end;
  52.     };
  53.     setmetatable( t, t );
  54.     return t;
  55. end;
  56.  
  57.  
  58. -- I dont even... *flips table*
  59. function USWNoteskin4thRed()
  60.     local t = {
  61.         Name = "USWNoteskin4thRed";
  62.         LayoutType = "ShowAllInRow";
  63.         SelectType = "SelectOne";
  64.         OneChoiceForAllPlayers = true;
  65.         ExportOnChange = true;
  66.         Choices = tChoices;
  67.         LoadSelections = function(self, list, pn)
  68.             if ReadPrefFromFile("USWNoteskin4thRed") ~= nil then
  69.                 if GetUserPrefB("USWNoteskin4thRed") then
  70.                     list = val
  71.                 end;
  72.             end;
  73.         end;
  74.         SaveSelections = function(self, list, pn)
  75.             local val = list;
  76.             WritePrefToFile("USWNoteskin4thRed",val);
  77.         end;
  78.     };
  79.     setmetatable(t, t);
  80.     return t;
  81. end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement