Something went wrong. Try again.
World of Warcraft: Forever addon that adds profession tracking.
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193local function MakeCheckButton(parent, text) local checkButton = CreateFrame("CheckButton", nil, parent, "SettingsCheckBoxTemplate") checkButton.text = checkButton:CreateFontString(nil, "ARTWORK", "GameFontNormal") checkButton.text:SetText(text) checkButton.text:SetPoint("LEFT", checkButton, "RIGHT", 4, 0) checkButton:SetSize(21, 20) checkButton:SetHitRectInsets(0, -200, 0, 0) checkButton.HoverBackground = nil return checkButtonend
local function HasDropdownTemplate() return C_XMLUtil and C_XMLUtil.GetTemplateInfo and C_XMLUtil.GetTemplateInfo("WowStyle1DropdownTemplate")end
local function CreateColorSwatch(parent) local button = CreateFrame("Button", nil, parent) button:SetSize(20, 20) button.border = button:CreateTexture(nil, "BACKGROUND") button.border:SetAllPoints() button.border:SetColorTexture(0.15, 0.15, 0.15, 1) button.color = button:CreateTexture(nil, "OVERLAY") button.color:SetPoint("TOPLEFT", 2, -2) button.color:SetPoint("BOTTOMRIGHT", -2, 2) function button:SetColor(r, g, b) self.color:SetColorTexture(r, g, b, 1) end return buttonend
local function OpenBarColorPicker() local r, g, b = Professor:GetBarColor()
local function Apply(nr, ng, nb) if not nr then return end Professor:SetBarColor(nr, ng, nb) end
if ColorPickerFrame and ColorPickerFrame.SetupColorPickerAndShow then ColorPickerFrame:SetupColorPickerAndShow({ r = r, g = g, b = b, hasOpacity = false, swatchFunc = function() Apply(ColorPickerFrame:GetColorRGB()) end, cancelFunc = function(previous) if previous then Apply(previous.r, previous.g, previous.b) else Apply(ColorPickerFrame:GetPreviousValues()) end end, }) return end
if not ColorPickerFrame then return end ColorPickerFrame.func = function() Apply(ColorPickerFrame:GetColorRGB()) end ColorPickerFrame.swatchFunc = ColorPickerFrame.func ColorPickerFrame.cancelFunc = function(previous) if previous then Apply(previous.r, previous.g, previous.b) end end ColorPickerFrame.hasOpacity = false if ColorPickerFrame.SetColorRGB then ColorPickerFrame:SetColorRGB(r, g, b) end ColorPickerFrame:Show()end
function Professor:CreateProfessionDropdown(parent) local dropdown = CreateFrame("DropdownButton", "ProfessorProfessionDropdown", parent, "WowStyle1DropdownTemplate") dropdown:SetWidth(220) dropdown:SetDefaultText("None") dropdown:SetupMenu(function(_, rootDescription) rootDescription:CreateRadio("None", function() return Professor:GetSelectedKey() == nil end, function() Professor:SetSelected(nil) end) for _, prof in ipairs(Professor:GetKnownProfessions()) do local key = prof.slot rootDescription:CreateRadio(prof.name, function() return Professor:GetSelectedKey() == key end, function() Professor:SetSelected(key) end) end end) return dropdownend
function Professor:CreateSettings() if self.CategoryID then return end
local optionsFrame = CreateFrame("Frame", nil, nil, "VerticalLayoutFrame") optionsFrame.spacing = 8
local category = Settings.RegisterCanvasLayoutCategory(optionsFrame, "Professor") self.CategoryID = category:GetID() self.SettingsCategory = category Settings.RegisterAddOnCategory(category)
local layoutIndex = 0 local function NextIndex() layoutIndex = layoutIndex + 1 return layoutIndex end
local header = CreateFrame("Frame", nil, optionsFrame) header:SetSize(150, 50) local headerText = header:CreateFontString(nil, "ARTWORK", "GameFontHighlightHuge") headerText:SetPoint("TOPLEFT", 7, -22) headerText:SetText("Professor") local divider = header:CreateTexture(nil, "ARTWORK") divider:SetAtlas("Options_HorizontalDivider", true) divider:SetPoint("BOTTOMLEFT", -50) header.layoutIndex = NextIndex() header.bottomPadding = 10
local professionRow = CreateFrame("Frame", nil, optionsFrame) professionRow:SetSize(420, 32) professionRow.layoutIndex = NextIndex()
local professionLabel = professionRow:CreateFontString(nil, "ARTWORK", "GameFontNormal") professionLabel:SetPoint("LEFT", 7, 0) professionLabel:SetText("Profession")
if HasDropdownTemplate() then self.settingsDropdown = self:CreateProfessionDropdown(professionRow) self.settingsDropdown:SetPoint("LEFT", professionLabel, "RIGHT", 16, 0) else local fallback = professionRow:CreateFontString(nil, "ARTWORK", "GameFontHighlight") fallback:SetPoint("LEFT", professionLabel, "RIGHT", 16, 0) fallback:SetText("Use /professor cycle or a keybind to choose a profession.") self.settingsDropdownLabel = fallback end
local colorRow = CreateFrame("Frame", nil, optionsFrame) colorRow:SetSize(420, 28) colorRow.layoutIndex = NextIndex()
local colorLabel = colorRow:CreateFontString(nil, "ARTWORK", "GameFontNormal") colorLabel:SetPoint("LEFT", 7, 0) colorLabel:SetText("Bar color")
self.settingsColorSwatch = CreateColorSwatch(colorRow) self.settingsColorSwatch:SetPoint("LEFT", colorLabel, "RIGHT", 16, 0) self.settingsColorSwatch:SetScript("OnClick", OpenBarColorPicker)
local alwaysText = MakeCheckButton(optionsFrame, "Always show text") alwaysText.layoutIndex = NextIndex() alwaysText:SetScript("OnClick", function(button) ProfessorDB.alwaysShowText = button:GetChecked() and true or false Professor:Refresh() end) self.settingsAlwaysText = alwaysText
optionsFrame:Layout() self:UpdateSettingsControls()end
function Professor:UpdateSettingsControls() if self.settingsAlwaysText then self.settingsAlwaysText:SetChecked(ProfessorDB.alwaysShowText) end if self.settingsColorSwatch then self.settingsColorSwatch:SetColor(self:GetBarColor()) end if self.settingsDropdown then if self.settingsDropdown.GenerateMenu then self.settingsDropdown:GenerateMenu() end if self.settingsDropdown.SetDefaultText then self.settingsDropdown:SetDefaultText(self:GetSelectedLabel()) end end if self.settingsDropdownLabel then self.settingsDropdownLabel:SetText(self:GetSelectedLabel()) endend