diff --git a/HideCoA.lua b/HideCoA.lua index f6cc7a7..ebc86fb 100644 --- a/HideCoA.lua +++ b/HideCoA.lua @@ -125,6 +125,24 @@ f:SetScript("OnEvent", function(self, event, arg1) end + if not HideCoADB.profiles then + HideCoADB.profiles = {} + end + + if not HideCoADB.profiles["Default"] then + HideCoADB.profiles["Default"] = {} + end + + local realmCharProfile = GetRealmName() .. " - " .. UnitName("player") + + if not HideCoADB.profiles[realmCharProfile] then + HideCoADB.profiles[realmCharProfile] = {} + end + + if not HideCoADB.selectedProfile then + HideCoADB.selectedProfile = "Default" + end + elseif event == "PLAYER_LOGIN" then ApplySetting() diff --git a/Options.lua b/Options.lua index 941d26f..63a03df 100644 --- a/Options.lua +++ b/Options.lua @@ -24,8 +24,13 @@ local content = CreateFrame("Frame", nil, panel) content:SetPoint("TOPLEFT", sidebar, "TOPRIGHT", 16, 0) content:SetPoint("BOTTOMRIGHT", panel, "BOTTOMRIGHT", -16, 16) -local classTitle = content:CreateFontString(nil, "ARTWORK", "GameFontNormalLarge") -classTitle:SetPoint("TOPLEFT", content, "TOPLEFT", 0, 0) +local classContent = CreateFrame("Frame", nil, content) +classContent:SetAllPoints(content) + +local profileContent + +local classTitle = classContent:CreateFontString(nil, "ARTWORK", "GameFontNormalLarge") +classTitle:SetPoint("TOPLEFT", classContent, "TOPLEFT", 0, 0) local titleFont, titleSize = classTitle:GetFont() classTitle:SetFont(titleFont, titleSize + 4, "OUTLINE") @@ -38,7 +43,7 @@ local previousSpacing = -12 for _, frameName in ipairs(HideCoA.FRAMES) do - local check = CreateFrame("CheckButton", "HideCoAClassCheck" .. frameName, content, "InterfaceOptionsCheckButtonTemplate") + local check = CreateFrame("CheckButton", "HideCoAClassCheck" .. frameName, classContent, "InterfaceOptionsCheckButtonTemplate") check:SetPoint("TOPLEFT", previousAnchor, "BOTTOMLEFT", 0, previousSpacing) _G[check:GetName() .. "Text"]:SetText("Hide " .. frameName) @@ -68,11 +73,16 @@ end local TAB_HEIGHT = 18 local tabButtons = {} +local profileTabButton local function SelectClass(class) selectedClass = class + classContent:Show() + profileContent:Hide() + profileTabButton.selectedTexture:Hide() + local displayName = (LOCALIZED_CLASS_NAMES_MALE and LOCALIZED_CLASS_NAMES_MALE[class]) or class classTitle:SetText(displayName) @@ -130,6 +140,99 @@ for index, class in ipairs(HideCoA.CUSTOM_CLASSES) do end +profileContent = CreateFrame("Frame", nil, content) +profileContent:SetAllPoints(content) +profileContent:Hide() + +local profileTitle = profileContent:CreateFontString(nil, "ARTWORK", "GameFontNormalLarge") +profileTitle:SetPoint("TOPLEFT", profileContent, "TOPLEFT", 0, 0) +profileTitle:SetFont(titleFont, titleSize + 4, "OUTLINE") +profileTitle:SetText("Profile") + +local function GetProfileNames() + + local names = {} + + for name in pairs(HideCoADB.profiles) do + if name ~= "Default" then + table.insert(names, name) + end + end + + table.sort(names) + table.insert(names, 1, "Default") + + return names + +end + +local profileDropDown = CreateFrame("Frame", "HideCoAProfileDropDown", profileContent, "UIDropDownMenuTemplate") +profileDropDown:SetPoint("TOPLEFT", profileTitle, "BOTTOMLEFT", -16, -12) + +local function ProfileDropDown_OnClick(self) + HideCoADB.selectedProfile = self.value + UIDropDownMenu_SetText(profileDropDown, self.value) +end + +UIDropDownMenu_Initialize(profileDropDown, function(self, level) + + for _, name in ipairs(GetProfileNames()) do + + local info = UIDropDownMenu_CreateInfo() + info.text = name + info.value = name + info.func = ProfileDropDown_OnClick + info.checked = (HideCoADB.selectedProfile == name) + + UIDropDownMenu_AddButton(info, level) + + end + +end) + +UIDropDownMenu_SetWidth(profileDropDown, 140) + +local divider = sidebar:CreateTexture(nil, "ARTWORK") +divider:SetHeight(1) +divider:SetTexture(1, 1, 1, 0.3) + +profileTabButton = CreateFrame("Button", "HideCoAProfileTab", sidebar) +profileTabButton:SetHeight(TAB_HEIGHT) +profileTabButton:SetPoint("BOTTOMLEFT", sidebar, "BOTTOMLEFT", 0, 0) +profileTabButton:SetPoint("RIGHT", sidebar, "RIGHT", 0, 0) + +divider:SetPoint("BOTTOMLEFT", profileTabButton, "TOPLEFT", 0, 4) +divider:SetPoint("BOTTOMRIGHT", profileTabButton, "TOPRIGHT", 0, 4) + +local profileSelectedTexture = profileTabButton:CreateTexture(nil, "BACKGROUND") +profileSelectedTexture:SetAllPoints() +profileSelectedTexture:SetTexture(1, 1, 1, 0.2) +profileSelectedTexture:Hide() +profileTabButton.selectedTexture = profileSelectedTexture + +profileTabButton:SetHighlightTexture("Interface\\QuestFrame\\UI-QuestTitleHighlight", "ADD") + +local profileTabText = profileTabButton:CreateFontString(nil, "OVERLAY", "GameFontHighlightSmall") +profileTabText:SetPoint("LEFT", 4, 0) +profileTabText:SetText("Profile") + +local function SelectProfileTab() + + classContent:Hide() + profileContent:Show() + + for _, button in pairs(tabButtons) do + button.selectedTexture:Hide() + end + + profileTabButton.selectedTexture:Show() + + UIDropDownMenu_SetText(profileDropDown, HideCoADB.selectedProfile or "Default") + +end + +profileTabButton:SetScript("OnClick", SelectProfileTab) + panel:SetScript("OnShow", function() SelectClass(selectedClass or HideCoA.CUSTOM_CLASSES[1]) end)