diff --git a/Config.lua b/Config.lua index 8a51ed9..a148697 100644 --- a/Config.lua +++ b/Config.lua @@ -14,6 +14,15 @@ F.Config = { barWidth = 600, barHeight = 24, + -- Textures + barTextureMain = "Interface\\Buttons\\WHITE8x8", + barTextureRested = "Interface\\Buttons\\WHITE8x8", + barTextureQuest = "Interface\\Buttons\\WHITE8x8", + barTextureQuestComplete = "Interface\\Buttons\\WHITE8x8", + + -- Font + fontPath = "Fonts\\FRIZQT__.TTF", + -- Bar Colors (RGBA) colorMain = { r = 0.76, g = 0.38, b = 1, a = 1 }, colorRested = { r = 0.34, g = 0.61, b = 0.99, a = 0.8 }, diff --git a/Options.lua b/Options.lua index 55ef106..087f9df 100644 --- a/Options.lua +++ b/Options.lua @@ -13,9 +13,20 @@ local questRelatedKeys = { showIncompleteQuestBar = true, colorQuest = true, colorQuestComplete = true, + barTextureQuest = true, + barTextureQuestComplete = true, } local TICK_OPACITY_KEY = "tickOpacity" +local DEFAULT_STATUSBAR = "Interface\\Buttons\\WHITE8x8" +local DEFAULT_FONT = "Fonts\\FRIZQT__.TTF" + +local function GetLibSharedMedia() + if LibStub then + return LibStub("LibSharedMedia-3.0", true) + end + return nil +end local function SetOption(key, value) if F.InitDB then F.InitDB() end @@ -66,6 +77,13 @@ local function SetNumericOption(key, value) if F.UpdateUI then F.UpdateUI() end end +local function SetStringOption(key, value) + if F.InitDB then F.InitDB() end + if not F.DB then return end + F.DB[key] = value + if F.UpdateUI then F.UpdateUI() end +end + local function SetColorOption(key, r, g, b, a) if F.InitDB then F.InitDB() end if not F.DB then return end @@ -138,6 +156,58 @@ local function CreateSlider(parent, key, label, y, minValue, maxValue, step) return y - 52 end +local function BuildMediaList(kind, defaultLabel, defaultValue) + local list = {} + local order = {} + + list[defaultValue] = defaultLabel + table.insert(order, defaultValue) + + local LSM = GetLibSharedMedia() + if LSM and LSM.HashTable then + local entries = {} + for name, path in pairs(LSM:HashTable(kind) or {}) do + if type(path) == "string" and path ~= "" then + table.insert(entries, { name = tostring(name), path = path }) + end + end + table.sort(entries, function(a, b) return a.name < b.name end) + for _, entry in ipairs(entries) do + list[entry.path] = entry.name + table.insert(order, entry.path) + end + end + + return list, order +end + +local function CreateDropdown(parent, key, label, y, list, order, width) + local name = "NXP_Options_" .. key .. "Dropdown" + local dropdown = CreateFrame("Frame", name, parent, "UIDropDownMenuTemplate") + dropdown:SetPoint("TOPLEFT", parent, "TOPLEFT", -6, y) + + local labelText = dropdown:CreateFontString(nil, "ARTWORK", "GameFontHighlight") + labelText:SetPoint("TOPLEFT", dropdown, "TOPLEFT", 16, 14) + labelText:SetText(label) + + UIDropDownMenu_SetWidth(dropdown, width or 220) + UIDropDownMenu_Initialize(dropdown, function(self) + for _, value in ipairs(order or {}) do + local info = UIDropDownMenu_CreateInfo() + info.text = list[value] or value + info.value = value + info.func = function() + UIDropDownMenu_SetSelectedValue(dropdown, value) + SetStringOption(key, value) + end + UIDropDownMenu_AddButton(info) + end + end) + + controls[key] = { type = "dropdown", widget = dropdown, list = list, label = labelText } + return y - 50 +end + local function CreateColorPicker(parent, key, label, y, fallback) local labelText = parent:CreateFontString(nil, "ARTWORK", "GameFontHighlight") labelText:SetPoint("TOPLEFT", parent, "TOPLEFT", 16, y) @@ -236,6 +306,12 @@ function F.Options.Refresh() local r, g, b, a = GetColorOption(key, control.fallback) local tex = control.widget:GetNormalTexture() if tex then tex:SetColorTexture(r, g, b, a) end + elseif control.type == "dropdown" then + local defaults = F.Config or {} + local value = F.DB[key] + if value == nil then value = defaults[key] end + UIDropDownMenu_SetSelectedValue(control.widget, value) + UIDropDownMenu_SetText(control.widget, control.list and control.list[value] or value or "") end end @@ -298,6 +374,7 @@ function F.Options.Create() y = CreateCheckbox(content, "trackedOnly", "Count tracked (pinned) quests only", y) y = CreateCheckbox(content, "showIncompleteQuestBar", "Show uncompleted quest XP bar", y) y = CreateCheckbox(content, "showTicks", "Show XP ticks", y) + y = y - 6 y = CreateSlider(content, "tickOpacity", "Tick opacity", y, 10, 100, 1) y = y - 10 @@ -313,6 +390,21 @@ function F.Options.Create() y = CreateColorPicker(content, "colorQuest", "Uncompleted Quest XP", y, { 1, 0.64, 0.0078, 0.25 }) y = CreateColorPicker(content, "colorQuestComplete", "Completed Quest XP", y, { 1, 0.64, 0.0078, 0.8 }) + y = y - 6 + y = CreateHeader(content, "Textures", y) + y = y - 6 + local statusbarList, statusbarOrder = BuildMediaList("statusbar", "Default (Solid)", DEFAULT_STATUSBAR) + y = CreateDropdown(content, "barTextureMain", "Normal XP texture", y, statusbarList, statusbarOrder) + y = CreateDropdown(content, "barTextureRested", "Rested XP texture", y, statusbarList, statusbarOrder) + y = CreateDropdown(content, "barTextureQuest", "Uncompleted quest XP texture", y, statusbarList, statusbarOrder) + y = CreateDropdown(content, "barTextureQuestComplete", "Completed quest XP texture", y, statusbarList, statusbarOrder) + + y = y - 6 + y = CreateHeader(content, "Font", y) + y = y - 6 + local fontList, fontOrder = BuildMediaList("font", "Default", DEFAULT_FONT) + y = CreateDropdown(content, "fontPath", "Font", y, fontList, fontOrder) + y = y - 10 y = CreateHeader(content, "Text Labels", y) y = CreateCheckbox(content, "showLevelText", "Level text", y) diff --git a/UI.lua b/UI.lua index c58c1c7..b766e84 100644 --- a/UI.lua +++ b/UI.lua @@ -283,6 +283,25 @@ function F.UI.Update() end if db then + local fontPath = db.fontPath or CFG.font + F.LevelText:SetFont(fontPath, CFG.barFontSize, "OUTLINE") + F.TextCenter:SetFont(fontPath, CFG.barFontSize, "OUTLINE") + F.TextRight:SetFont(fontPath, CFG.barFontSize, "OUTLINE") + F.InfoText:SetFont(fontPath, CFG.fontSize - 2, "OUTLINE") + F.LevelingText:SetFont(fontPath, CFG.fontSize - 2, "OUTLINE") + if F.QuestXPText then + F.QuestXPText:SetFont(fontPath, CFG.fontSize - 2, "OUTLINE") + end + + local mainTexture = db.barTextureMain or CFG.texture + local restedTexture = db.barTextureRested or CFG.texture + local questTexture = db.barTextureQuest or CFG.texture + local questCompleteTexture = db.barTextureQuestComplete or CFG.texture + F.BarMain:SetStatusBarTexture(mainTexture) + F.BarRested:SetStatusBarTexture(restedTexture) + F.BarQuest:SetStatusBarTexture(questTexture) + F.BarQuestComplete:SetStatusBarTexture(questCompleteTexture) + F.BarMain:SetStatusBarColor(resolveColor(db.colorMain, CFG.colorMain)) F.BarRested:SetStatusBarColor(resolveColor(db.colorRested, CFG.colorRested)) F.BarQuest:SetStatusBarColor(resolveColor(db.colorQuest, CFG.colorQuest))