A World of Warcraft Experience Bar addon
worldofwarcraft wow addon midnight

add options panel and open command

bdbch dd06af32 8e8e59a4

+118
+10
Config.lua
··· 53 53 local function showHelp() 54 54 print("NixxnuxXPBar: Commands:") 55 55 print(" /nxp help") 56 + print(" /nxp options") 56 57 print(" /nxp toggle | /nxp show | /nxp hide") 57 58 print(" /nxp toggle level | xp | percent | quest | leveling") 58 59 print(" /nxp toggle incomplete | completed | rested") ··· 107 108 F.DB.enabled = true 108 109 print("NixxnuxXPBar: Visible") 109 110 if F.UpdateUI then F.UpdateUI() end 111 + return 112 + end 113 + 114 + if cmd == "options" then 115 + if F.Options and F.Options.Open then 116 + F.Options.Open() 117 + else 118 + print("NixxnuxXPBar: Options not available yet") 119 + end 110 120 return 111 121 end 112 122
+1
NixxnuxXPBar.toc
··· 18 18 19 19 Init.lua 20 20 Config.lua 21 + Options.lua 21 22 Utils.lua 22 23 UI.lua 23 24 State.lua
+107
Options.lua
··· 1 + local _, F = ... 2 + 3 + F.Options = F.Options or {} 4 + 5 + local panel 6 + local controls = {} 7 + 8 + local function SetOption(key, value) 9 + if F.InitDB then F.InitDB() end 10 + if not F.DB then return end 11 + 12 + F.DB[key] = value and true or false 13 + 14 + if key == "enabled" then 15 + if value then 16 + if F.UpdateUI then F.UpdateUI() end 17 + else 18 + if F.Frame and F.Frame.Hide then F.Frame:Hide() end 19 + end 20 + return 21 + end 22 + 23 + if key == "hideBlizzardXPBar" and F.UI and F.UI.HideBlizzardBars then 24 + F.UI.HideBlizzardBars() 25 + end 26 + 27 + if F.UpdateUI then F.UpdateUI() end 28 + end 29 + 30 + local function CreateHeader(parent, text, y) 31 + local fs = parent:CreateFontString(nil, "ARTWORK", "GameFontNormal") 32 + fs:SetPoint("TOPLEFT", parent, "TOPLEFT", 16, y) 33 + fs:SetText(text) 34 + return y - 20 35 + end 36 + 37 + local function CreateCheckbox(parent, key, label, y) 38 + local cb = CreateFrame("CheckButton", nil, parent, "InterfaceOptionsCheckButtonTemplate") 39 + cb.Text:SetText(label) 40 + cb:SetPoint("TOPLEFT", parent, "TOPLEFT", 16, y) 41 + cb:SetScript("OnClick", function(self) 42 + SetOption(key, self:GetChecked()) 43 + end) 44 + 45 + controls[key] = cb 46 + return y - 28 47 + end 48 + 49 + function F.Options.Refresh() 50 + if F.InitDB then F.InitDB() end 51 + if not F.DB then return end 52 + 53 + for key, cb in pairs(controls) do 54 + cb:SetChecked(F.DB[key] and true or false) 55 + end 56 + end 57 + 58 + function F.Options.Open() 59 + if not panel then return end 60 + 61 + if Settings and Settings.OpenToCategory then 62 + Settings.OpenToCategory(panel.name) 63 + elseif InterfaceOptionsFrame_OpenToCategory then 64 + InterfaceOptionsFrame_OpenToCategory(panel) 65 + InterfaceOptionsFrame_OpenToCategory(panel) 66 + end 67 + end 68 + 69 + function F.Options.Create() 70 + if panel then return end 71 + 72 + panel = CreateFrame("Frame", "NXP_OptionsPanel", UIParent) 73 + panel.name = "NixxnuxXPBar" 74 + 75 + local title = panel:CreateFontString(nil, "ARTWORK", "GameFontNormalLarge") 76 + title:SetPoint("TOPLEFT", panel, "TOPLEFT", 16, -16) 77 + title:SetText("NixxnuxXPBar") 78 + 79 + local y = -48 80 + y = CreateHeader(panel, "General", y) 81 + y = CreateCheckbox(panel, "enabled", "Enable addon", y) 82 + y = CreateCheckbox(panel, "trackedOnly", "Count tracked (pinned) quests only", y) 83 + 84 + y = y - 10 85 + y = CreateHeader(panel, "Text Labels", y) 86 + y = CreateCheckbox(panel, "showLevelText", "Level text", y) 87 + y = CreateCheckbox(panel, "showXPText", "XP text", y) 88 + y = CreateCheckbox(panel, "showPercentText", "Percent text", y) 89 + y = CreateCheckbox(panel, "showQuestRestedText", "Quest/rested percent text", y) 90 + y = CreateCheckbox(panel, "showLevelingText", "Leveling info text", y) 91 + y = CreateCheckbox(panel, "showIncompleteQuestXPText", "Uncompleted quest XP text", y) 92 + y = CreateCheckbox(panel, "showCompletedQuestXPText", "Completed quest XP text", y) 93 + y = CreateCheckbox(panel, "showRestedXPText", "Rested XP text", y) 94 + 95 + panel:SetScript("OnShow", function() 96 + F.Options.Refresh() 97 + end) 98 + 99 + if Settings and Settings.RegisterCanvasLayoutCategory then 100 + local category = Settings.RegisterCanvasLayoutCategory(panel, panel.name) 101 + Settings.RegisterAddOnCategory(category) 102 + elseif InterfaceOptions_AddCategory then 103 + InterfaceOptions_AddCategory(panel) 104 + end 105 + end 106 + 107 + F.Options.Create()