A World of Warcraft Experience Bar addon
worldofwarcraft wow addon midnight

add label toggles and quest xp text

bdbch ef6c37de fd0cf0a9

+112 -14
+58 -7
Config.lua
··· 8 8 enabled = true, 9 9 10 10 -- Text Toggles 11 + showLevelText = true, 12 + showXPText = true, 13 + showPercentText = true, 11 14 showLevelTimeText = true, 12 15 showSessionTimeText = true, 13 16 showXPHourText = true, 17 + showLevelingText = true, 14 18 showQuestRestedText = true, 19 + showIncompleteQuestXPText = true, 20 + showCompletedQuestXPText = true, 21 + showRestedXPText = true, 15 22 16 23 -- Logic Settings 17 24 resetOnReload = true, ··· 38 45 SlashCmdList = SlashCmdList or {} 39 46 SlashCmdList["NIXXNUXXPBAR"] = function(msg) 40 47 msg = msg or "" 41 - local cmd = msg:match("^(%S+)") 48 + local cmd, arg1 = msg:match("^(%S+)%s*(.-)$") 42 49 cmd = cmd and cmd:lower() or "" 50 + arg1 = arg1 and arg1:lower() or "" 43 51 44 - if cmd == "toggle" then 45 - -- Ensure DB is initialized, then flip the flag 52 + local function showHelp() 53 + print("NixxnuxXPBar: Commands:") 54 + print(" /nxp help") 55 + print(" /nxp toggle | /nxp show | /nxp hide") 56 + print(" /nxp toggle level | xp | percent | quest | leveling") 57 + print(" /nxp toggle incomplete | completed | rested") 58 + end 59 + 60 + local function toggleLabel(flagKey, label) 61 + if F.InitDB then F.InitDB() end 62 + F.DB[flagKey] = not F.DB[flagKey] 63 + local state = F.DB[flagKey] and "On" or "Off" 64 + print("NixxnuxXPBar: " .. label .. " " .. state) 65 + if F.UpdateUI then F.UpdateUI() end 66 + end 67 + 68 + if cmd == "toggle" and arg1 == "" then 46 69 if F.InitDB then F.InitDB() end 47 70 F.DB.enabled = not F.DB.enabled 48 71 ··· 53 76 print("NixxnuxXPBar: Hidden") 54 77 if F.Frame and F.Frame.Hide then F.Frame:Hide() end 55 78 end 56 - elseif cmd == "show" then 79 + return 80 + end 81 + 82 + if cmd == "toggle" then 83 + local map = { 84 + level = { key = "showLevelText", label = "Level Text" }, 85 + xp = { key = "showXPText", label = "XP Text" }, 86 + percent = { key = "showPercentText", label = "Percent Text" }, 87 + quest = { key = "showQuestRestedText", label = "Quest/Rested Percent Text" }, 88 + leveling = { key = "showLevelingText", label = "Leveling Text" }, 89 + incomplete = { key = "showIncompleteQuestXPText", label = "Uncompleted Quest XP Text" }, 90 + completed = { key = "showCompletedQuestXPText", label = "Completed Quest XP Text" }, 91 + rested = { key = "showRestedXPText", label = "Rested XP Text" }, 92 + } 93 + 94 + local entry = map[arg1] 95 + if entry then 96 + toggleLabel(entry.key, entry.label) 97 + else 98 + showHelp() 99 + end 100 + return 101 + end 102 + 103 + if cmd == "show" then 57 104 if F.InitDB then F.InitDB() end 58 105 F.DB.enabled = true 59 106 print("NixxnuxXPBar: Visible") 60 107 if F.UpdateUI then F.UpdateUI() end 61 - elseif cmd == "hide" then 108 + return 109 + end 110 + 111 + if cmd == "hide" then 62 112 if F.InitDB then F.InitDB() end 63 113 F.DB.enabled = false 64 114 print("NixxnuxXPBar: Hidden") 65 115 if F.Frame and F.Frame.Hide then F.Frame:Hide() end 66 - else 67 - print("NixxnuxXPBar: Commands: /nxp toggle | /nxp show | /nxp hide") 116 + return 68 117 end 118 + 119 + showHelp() 69 120 end
+54 -7
UI.lua
··· 165 165 F.InfoText:SetDrawLayer("OVERLAY", 2) 166 166 F.InfoText:SetTextColor(1, 1, 1, 1) 167 167 168 + -- quest/rested XP amounts 169 + F.QuestXPText = overlay:CreateFontString(nil, "OVERLAY") 170 + F.QuestXPText:SetFont(CFG.font, CFG.fontSize - 2, "OUTLINE") 171 + F.QuestXPText:SetPoint("TOP", overlay, "BOTTOM", 0, -22) 172 + F.QuestXPText:SetJustifyH("CENTER") 173 + F.QuestXPText:SetDrawLayer("OVERLAY", 2) 174 + F.QuestXPText:SetTextColor(1, 1, 1, 1) 175 + 168 176 -- Leveling info 169 177 F.LevelingText = overlay:CreateFontString(nil, "OVERLAY") 170 178 F.LevelingText:SetFont(CFG.font, CFG.fontSize - 2, "OUTLINE") ··· 260 268 local percentXP = (s.maxXP > 0) and (s.currentXP / s.maxXP * 100) or 0 261 269 local percentRested = (s.maxXP > 0) and (s.restedXP / s.maxXP * 100) or 0 262 270 263 - F.LevelText:SetText("Level " .. s.level) 271 + if db.showLevelText then 272 + F.LevelText:SetText("Level " .. s.level) 273 + F.LevelText:Show() 274 + else 275 + F.LevelText:SetText("") 276 + F.LevelText:Hide() 277 + end 264 278 265 - if s.isMaxLevel then 266 - F.TextCenter:SetText("Level " .. s.level .. " (Max)") 279 + if db.showXPText then 280 + if s.isMaxLevel then 281 + F.TextCenter:SetText("Level " .. s.level .. " (Max)") 282 + else 283 + F.TextCenter:SetText(string.format("%s / %s", FormatLargeNumber(s.currentXP), FormatLargeNumber(s.maxXP))) 284 + end 285 + F.TextCenter:Show() 267 286 else 268 - F.TextCenter:SetText(string.format("%s / %s", FormatLargeNumber(s.currentXP), FormatLargeNumber(s.maxXP))) 287 + F.TextCenter:SetText("") 288 + F.TextCenter:Hide() 269 289 end 270 290 271 291 local percentStr = "" ··· 284 304 end 285 305 end 286 306 287 - if percentStr ~= "" and s.maxXP > 0 then 307 + if db.showPercentText and percentStr ~= "" and s.maxXP > 0 then 288 308 F.TextRight:SetText(percentStr) 309 + F.TextRight:Show() 289 310 else 290 311 F.TextRight:SetText("") 312 + F.TextRight:Hide() 291 313 end 292 314 293 315 do ··· 309 331 levelingStr = string.format("Leveling in: %s (%s XP/Hr)", timerText, xpRateText) 310 332 end 311 333 312 - if #infoParts > 0 then 334 + if db.showQuestRestedText and #infoParts > 0 then 313 335 F.InfoText:SetText(table.concat(infoParts, " - ")) 336 + F.InfoText:Show() 314 337 else 315 338 F.InfoText:SetText("") 339 + F.InfoText:Hide() 316 340 end 317 341 318 - if levelingStr ~= "" then 342 + if db.showLevelingText and levelingStr ~= "" then 319 343 F.LevelingText:SetText(levelingStr) 344 + F.LevelingText:Show() 320 345 else 321 346 F.LevelingText:SetText("") 347 + F.LevelingText:Hide() 348 + end 349 + end 350 + 351 + do 352 + local xpParts = {} 353 + if db.showIncompleteQuestXPText and (s.incompleteXP or 0) > 0 then 354 + table.insert(xpParts, string.format("Uncompleted Quest XP: %s", FormatLargeNumber(s.incompleteXP or 0))) 355 + end 356 + if db.showCompletedQuestXPText and (s.completeXP or 0) > 0 then 357 + table.insert(xpParts, string.format("Completed Quest XP: %s", FormatLargeNumber(s.completeXP or 0))) 358 + end 359 + if db.showRestedXPText and (s.restedXP or 0) > 0 then 360 + table.insert(xpParts, string.format("Rested XP: %s", FormatLargeNumber(s.restedXP or 0))) 361 + end 362 + 363 + if #xpParts > 0 then 364 + F.QuestXPText:SetText(table.concat(xpParts, " - ")) 365 + F.QuestXPText:Show() 366 + else 367 + F.QuestXPText:SetText("") 368 + F.QuestXPText:Hide() 322 369 end 323 370 end 324 371 end