A World of Warcraft Experience Bar addon
worldofwarcraft wow addon midnight
at main 166 lines 4.6 kB view raw
1local _, F = ... 2 3F.Config = { 4 -- Display Options 5 showAtMaxLevel = false, 6 showIncompleteQuestBar = true, 7 questTrackingEnabled = true, 8 showTicks = true, 9 tickOpacity = 0.35, 10 anchorPoint = "TOP", 11 offsetX = 0, 12 offsetY = 100, 13 -- Master visibility toggle (can be flipped with /nxp toggle) 14 enabled = true, 15 16 -- Bar Size 17 barWidth = 600, 18 barHeight = 24, 19 20 -- Textures 21 barTextureMain = "Interface\\Buttons\\WHITE8x8", 22 barTextureRested = "Interface\\Buttons\\WHITE8x8", 23 barTextureQuest = "Interface\\Buttons\\WHITE8x8", 24 barTextureQuestComplete = "Interface\\Buttons\\WHITE8x8", 25 26 -- Font 27 fontPath = "Fonts\\FRIZQT__.TTF", 28 29 -- Bar Colors (RGBA) 30 colorMain = { r = 0.76, g = 0.38, b = 1, a = 1 }, 31 colorRested = { r = 0.34, g = 0.61, b = 0.99, a = 0.8 }, 32 colorQuest = { r = 1, g = 0.64, b = 0.0078, a = 0.25 }, 33 colorQuestComplete = { r = 1, g = 0.64, b = 0.0078, a = 0.8 }, 34 35 -- Text Toggles 36 showLevelText = true, 37 showXPText = true, 38 showPercentText = true, 39 showLevelTimeText = true, 40 showSessionTimeText = true, 41 showXPHourText = true, 42 showLevelingText = true, 43 showQuestRestedText = true, 44 showIncompleteQuestXPText = true, 45 showCompletedQuestXPText = true, 46 showRestedXPText = true, 47 48 -- Logic Settings 49 resetOnReload = true, 50 hideBlizzardXPBar = true, 51 trackedOnly = true, 52} 53 54function F.InitDB() 55 if not NXP_DB then NXP_DB = {} end 56 57 for k, v in pairs(F.Config) do 58 if NXP_DB[k] == nil then 59 NXP_DB[k] = v 60 end 61 end 62 63 F.DB = NXP_DB 64 65 -- Apply the current DB state immediately so visibility is correct on load. 66 if F.UpdateUI then F.UpdateUI() end 67end 68 69-- Slash command to toggle addon visibility. Usage: /nxp toggle | /nxp show | /nxp hide 70SLASH_NIXXNUXXPBAR1 = SLASH_NIXXNUXXPBAR1 or "/nxp" 71SlashCmdList = SlashCmdList or {} 72SlashCmdList["NIXXNUXXPBAR"] = function(msg) 73 msg = msg or "" 74 local cmd, arg1 = msg:match("^(%S+)%s*(.-)$") 75 cmd = cmd and cmd:lower() or "" 76 arg1 = arg1 and arg1:lower() or "" 77 78 local function showHelp() 79 print("NixxnuxXPBar: Commands:") 80 print(" /nxp help") 81 print(" /nxp options") 82 print(" /nxp toggle | /nxp show | /nxp hide") 83 print(" /nxp toggle level | xp | percent | quest | leveling") 84 print(" /nxp toggle incomplete | completed | rested") 85 print(" /nxp tracked (toggle tracked-only quests)") 86 end 87 88 local function toggleLabel(flagKey, label) 89 if F.InitDB then F.InitDB() end 90 F.DB[flagKey] = not F.DB[flagKey] 91 local state = F.DB[flagKey] and "On" or "Off" 92 print("NixxnuxXPBar: " .. label .. " " .. state) 93 if F.UpdateUI then F.UpdateUI() end 94 end 95 96 if cmd == "toggle" and arg1 == "" then 97 if F.InitDB then F.InitDB() end 98 F.DB.enabled = not F.DB.enabled 99 100 if F.DB.enabled then 101 print("NixxnuxXPBar: Visible") 102 if F.UpdateUI then F.UpdateUI() end 103 else 104 print("NixxnuxXPBar: Hidden") 105 if F.Frame and F.Frame.Hide then F.Frame:Hide() end 106 end 107 return 108 end 109 110 if cmd == "toggle" then 111 local map = { 112 level = { key = "showLevelText", label = "Level Text" }, 113 xp = { key = "showXPText", label = "XP Text" }, 114 percent = { key = "showPercentText", label = "Percent Text" }, 115 quest = { key = "showQuestRestedText", label = "Quest/Rested Percent Text" }, 116 leveling = { key = "showLevelingText", label = "Leveling Text" }, 117 incomplete = { key = "showIncompleteQuestXPText", label = "Uncompleted Quest XP Text" }, 118 completed = { key = "showCompletedQuestXPText", label = "Completed Quest XP Text" }, 119 rested = { key = "showRestedXPText", label = "Rested XP Text" }, 120 } 121 122 local entry = map[arg1] 123 if entry then 124 toggleLabel(entry.key, entry.label) 125 else 126 showHelp() 127 end 128 return 129 end 130 131 if cmd == "show" then 132 if F.InitDB then F.InitDB() end 133 F.DB.enabled = true 134 print("NixxnuxXPBar: Visible") 135 if F.UpdateUI then F.UpdateUI() end 136 return 137 end 138 139 if cmd == "options" then 140 if F.Options and F.Options.Open then 141 F.Options.Open() 142 else 143 print("NixxnuxXPBar: Options not available yet") 144 end 145 return 146 end 147 148 if cmd == "tracked" then 149 if F.InitDB then F.InitDB() end 150 F.DB.trackedOnly = not F.DB.trackedOnly 151 local state = F.DB.trackedOnly and "On" or "Off" 152 print("NixxnuxXPBar: Tracked-only " .. state) 153 if F.UpdateUI then F.UpdateUI() end 154 return 155 end 156 157 if cmd == "hide" then 158 if F.InitDB then F.InitDB() end 159 F.DB.enabled = false 160 print("NixxnuxXPBar: Hidden") 161 if F.Frame and F.Frame.Hide then F.Frame:Hide() end 162 return 163 end 164 165 showHelp() 166end