Advertisement
Guest User

Untitled

a guest
Oct 24th, 2014
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.85 KB | None | 0 0
  1. local frame = CreateFrame("FRAME", "FooAddonFrame");
  2. frame:RegisterEvent("PLAYER_LOGIN");
  3. frame:RegisterEvent("PLAYER_LOGOUT");
  4. local function eventHandler(self, event, ...)
  5.     -- If the player is logging off, turn on the new models
  6.     if event == "PLAYER_LOGOUT" then
  7.         SetCVar("hdPlayerModels", 1);
  8.     -- If the player is logging on, turn off the new models
  9.     elseif event == "PLAYER_LOGIN" then
  10.         SetCVar("hdPlayerModels", 0)
  11.     end
  12. end
  13. frame:SetScript("OnEvent", eventHandler);
  14.  
  15. local db; -- File-global handle to the Database
  16. local defaults = {
  17.     profile = {
  18.     LDBIconStorage = {}, -- LibDBIcon storage
  19.     },
  20. };
  21.  
  22. local ldbObject = {
  23.     type = "launcher",
  24.     icon = "Interface\\ICONS\\INV_MISC_FILM_01",
  25.     --This is the icon used. Any .blp or .tga file is a valid icon.
  26.     --This path is ALWAYS relative to the World of Warcraft
  27.     --root (ie, "C:\Program Files\World of Warcraft" for
  28.     --Windows and "/Applications/World of Warcraft" for Mac)
  29.     label = "CharModFix",
  30.     OnClick = function(self, button)
  31.     -- Add a click handler here
  32.         SetCVar("hdPlayerModels",1-GetCVar("hdPlayerModels"))
  33.     end,
  34.     OnTooltipShow = function(tooltip)
  35.     tooltip:AddLine("Toggle Character Model");
  36.     --Add text here. The first line is ALWAYS a "header" type.
  37.     --It will appear slightly larger than subsequent lines of text
  38.  end,
  39. };
  40.  
  41. function updateDB(self, event, database)
  42.     db = database.profile;
  43.     LibStub("LibDBIcon-1.0"):Refresh("AddonLDBObjectName", db.LDBIconStorage);
  44. end
  45.  
  46. local vars = LibStub("AceDB-3.0"):New("AddonSavedVarStorage", defaults);
  47. vars:RegisterCallback("OnProfileChanged", updateDB);
  48. vars:RegisterCallback("OnProfileCopied", updateDB);
  49. vars:RegisterCallback("OnProfileReset", updateDB);
  50. db = vars.profile;
  51.  
  52. LibStub("LibDataBroker-1.1"):NewDataObject("AddonLDBObjectName", ldbObject);
  53. LibStub("LibDBIcon-1.0"):Register("AddonLDBObjectName", ldbObject, db.LDBIconStorage);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement