self.clickable:RegisterForClicks("LeftButtonUp") if self:GetChecked() then SortedConfigCategorySubfilters.SetFilterOptionValue(self.key1, self.key2, true) else SortedConfigCategorySubfilters.SetFilterOptionValue(self.key1, self.key2, nil) end SortedSubcategoryFrame_Update() Sorted_UpdateBagContents() Sorted_FilterItems() self:SetAutoFocus(false) self:SetNumeric(true) self:SetMaxLetters(6) if self:GetNumber() > 0 then SortedConfigCategorySubfilters.SetFilterOptionValue(self:GetParent().key1, self:GetParent().key2, self:GetNumber(), "min") else SortedConfigCategorySubfilters.SetFilterOptionValue(self:GetParent().key1, self:GetParent().key2, nil, "min") end SortedSubcategoryFrame_Update() Sorted_UpdateBagContents() Sorted_FilterItems() self:SetAutoFocus(false) self:SetNumeric(true) self:SetMaxLetters(6) if self:GetNumber() > 0 then SortedConfigCategorySubfilters.SetFilterOptionValue(self:GetParent().key1, self:GetParent().key2, self:GetNumber(), "max") else SortedConfigCategorySubfilters.SetFilterOptionValue(self:GetParent().key1, self:GetParent().key2, nil, "max") end SortedSubcategoryFrame_Update() Sorted_UpdateBagContents() Sorted_FilterItems() function self:Update(byName, userInput) local id, name if byName then name = self.editBoxName:GetText() local link = select(2, GetItemInfo(name)) if link then id = string.match(link, ".-item:(%d+):.*") self.editBoxID:SetText(id) id = tonumber(id) else self.editBoxID:SetText("") end else id = self.editBoxID:GetNumber() if id > 0 then name = select(1, GetItemInfo(id)) if name then self.editBoxName:SetText(name) else self.editBoxName:SetText("") end end end if userInput then if (not id or 1 > id) and (not name or name == "") then table.remove(SortedConfigCategoryGroups:GetData().filters[SortedConfigCategoryFilters.selected].values[self.key1], self.key2) Sorted_CleanTable(SortedConfigCategoryGroups:GetData()) self.editBoxID:ClearFocus() self.editBoxName:ClearFocus() SortedConfigCategoryFilters:Update() SortedConfigCategorySubfilters:Update() return else SortedConfigCategorySubfilters.SetFilterOptionValue(self.key1, self.key2, id, "id") SortedConfigCategorySubfilters.SetFilterOptionValue(self.key1, self.key2, name, "name") end end if id and id > 0 then local _, _, rarity, _, _, _, _, _, _, icon = GetItemInfo(self.editBoxID:GetNumber()) if rarity then self.icon:SetTexture(icon) local r,g,b = Sorted_GetItemQualityColor(rarity) self.editBoxName:SetTextColor(r, g, b) else self.icon:SetTexture("") self.editBoxName:SetTextColor(1,1,1) end else self.icon:SetTexture("") self.editBoxName:SetTextColor(1,1,1) end if userInput then SortedConfigCategorySubfilters:Update() end end self:GetParent().textID:SetText(Sorted.Localize("SUBFILTER_SPECIFIC_ITEMS_ID")) self:SetAutoFocus(false) self:SetNumeric(true) self:SetMaxLetters(7) if userInput then self:GetParent():Update(false, true) SortedSubcategoryFrame_Update() Sorted_UpdateBagContents() Sorted_FilterItems() end self:GetParent().textName:SetText(Sorted.Localize("SUBFILTER_SPECIFIC_ITEMS_NAME")) self:SetAutoFocus(false) if userInput then self:GetParent():Update(true, true) SortedSubcategoryFrame_Update() Sorted_UpdateBagContents() Sorted_FilterItems() end self:SetAutoFocus(false) if userInput then if self:GetText() ~= "" then SortedConfigCategorySubfilters.SetFilterOptionValue(self.key1, self.key2, self:GetText()) SortedConfigCategorySubfilters:Update(true) else table.remove(SortedConfigCategoryGroups:GetData().filters[SortedConfigCategoryFilters.selected].values[self.key1], self.key2) Sorted_CleanTable(SortedConfigCategoryGroups:GetData()) SortedConfigCategoryFilters:Update() SortedConfigCategorySubfilters:Update(false) end SortedSubcategoryFrame_Update() Sorted_UpdateBagContents() Sorted_FilterItems() end self:SetScale(1.1) self.backdrop = self:CreateTexture() self.backdrop:SetAllPoints() Sorted.RegisterBackdrop(self.backdrop) function self:OnUpdateFunc(elapsed) if self.animating then self.animElapsed = self.animElapsed + elapsed * 4 if self.animElapsed > 1 then self.animElapsed = 1 self.animating = false end local smooth = math.sin(self.animElapsed * math.pi / 2) self:SetAlpha(smooth) self:SetSize(384 * smooth, 256 * smooth) else self:SetScript("OnUpdate", nil) end end self:ClearAllPoints() self:SetPoint("CENTER") self.animating = true self.animElapsed = 0 self:SetScript("OnUpdate", self.OnUpdateFunc) if button == "LeftButton" and not self:GetParent().isMoving then self:GetParent():StartMoving() self:GetParent().isMoving = true end if button == "LeftButton" and self:GetParent().isMoving then self:GetParent():StopMovingOrSizing(); self:GetParent().isMoving = false; end if (self:GetParent().isMoving) then self:GetParent():StopMovingOrSizing() self:GetParent().isMoving = false end self.text1:SetScale(1.4) self.text1:SetText(Sorted.Localize("PROFILE_SELECTION_HEADER", UnitName("player"))) self.title:SetText(Sorted.Localize("PROFILE_SELECTION_CREATE_NEW")) self:SetAutoFocus(false) function self:Update() self.editBox:SetText(UnitName("player").." ("..GetRealmName()..")") end if not Sorted_IsClassic() then self:RegisterEvent("GLOBAL_MOUSE_DOWN") end self.editBox:SetScript("OnEnterPressed", function(self) self:ClearFocus() end) self:Update() if event == "GLOBAL_MOUSE_DOWN" and self:IsShown() then if not self:IsMouseOver() then self.editBox:ClearFocus() end end self.Bg = self:CreateTexture() self.Bg:SetPoint("TOPLEFT") self.Bg:SetPoint("BOTTOMRIGHT") Sorted.RegisterBackdrop(self.Bg) function self:OnUpdateFunc(elapsed) if self.animating then self.animElapsed = self.animElapsed + elapsed * 4 if self.animElapsed > 1 or Sorted_GetSetting("animations") == 1 then self.animElapsed = 1 self.animating = false if self.animation == "Hide" then self:Hide() end end if self.animation == "Show" then local smooth = math.sin(self.animElapsed * math.pi / 2) self:SetAlpha(smooth) self:SetSize(640 * smooth, 520 * smooth) self.dropShadowFrame:Show() elseif self.animation == "Hide" then local smooth = math.sin((1 - self.animElapsed) * math.pi / 2) self:SetAlpha(smooth) self.dropShadowFrame:Hide() end else self:SetScript("OnUpdate", nil) end end function self:Animate(animation) self.animating = true self.animation = animation self.animElapsed = 0 self:SetScript("OnUpdate", self.OnUpdateFunc) if animation == "Show" then PlaySound(SOUNDKIT.IG_MAINMENU_OPEN) elseif animation == "Hide" then PlaySound(SOUNDKIT.IG_MAINMENU_CLOSE) end end if Sorted_IsDemo() then self:SetFrameStrata("FULLSCREEN_DIALOG") end self:SetScale(Sorted_GetSetting("scale")) self:ClearAllPoints() self:SetPoint("CENTER") self:SetFrameLevel(3985) self:Animate("Show") if button == "LeftButton" and not self:GetParent().isMoving then self:GetParent():StartMoving() self:GetParent().isMoving = true end if button == "LeftButton" and self:GetParent().isMoving then self:GetParent():StopMovingOrSizing(); self:GetParent().isMoving = false; end if (self:GetParent().isMoving) then self:GetParent():StopMovingOrSizing() self:GetParent().isMoving = false end self.bg:SetColorTexture(0, 0, 0) self.bg:SetAlpha(0.5) SortedConfigFrame.tabs = { _G[self:GetName().."1"], _G[self:GetName().."2"] , --_G[self:GetName().."3"] , _G[self:GetName().."4"] , _G[self:GetName().."5"] } local function SelectTab(tab) tab.selected = true _G[tab:GetName().."Left"]:Hide() _G[tab:GetName().."Middle"]:Hide() _G[tab:GetName().."Right"]:Hide() _G[tab:GetName().."LeftDisabled"]:Show() _G[tab:GetName().."MiddleDisabled"]:Show() _G[tab:GetName().."RightDisabled"]:Show() _G["SortedConfigFrameContents"..tab.content]:Show() PlaySound(SOUNDKIT.IG_MAINMENU_OPTION_CHECKBOX_ON) end local function DeselectTab(tab) tab.selected = false _G[tab:GetName().."Left"]:Show() _G[tab:GetName().."Middle"]:Show() _G[tab:GetName().."Right"]:Show() _G[tab:GetName().."LeftDisabled"]:Hide() _G[tab:GetName().."MiddleDisabled"]:Hide() _G[tab:GetName().."RightDisabled"]:Hide() _G["SortedConfigFrameContents"..tab.content]:Hide() end function SortedConfigFrame_ToggleTab(tab) if not tab.selected then for _, tab2 in pairs(SortedConfigFrame.tabs) do DeselectTab(tab2) end SelectTab(tab) end end function SortedConfigFrame_UpdateTabWidths() for _, tab in pairs(SortedConfigFrame.tabs) do PanelTemplates_TabResize(tab, 0, nil, tab.minWidth) end end SortedConfigFrame_ToggleTab(SortedConfigFrame.tabs[1]) if Sorted_IsShadowlands() or Sorted_IsTBC() then BackdropTemplateMixin.OnBackdropLoaded(self) end self.timeSinceLastUpdate = 0 self:SetMinMaxValues(0.5, 2) _G[self:GetName().."High"]:SetText("") _G[self:GetName().."Low"]:SetText("") _G[self:GetName().."Text"]:SetText(Sorted.Localize("CONFIG_APPEARANCE_SCALE")) _G[self:GetName().."Text"]:SetFontObject("SortedTitleFont") self.timeSinceLastUpdate = self.timeSinceLastUpdate + elapsed if self.timeSinceLastUpdate > 0.1 then Sorted_SetScale(self:GetValue()) self.timeSinceLastUpdate = 0 end self:SetValue(Sorted_GetSetting("scale")) self.valueString:SetText(math.floor(self:GetValue() * 100 + 0.5) / 100) if self:GetValue() > 0.98 and 1.02 > self:GetValue() then self:SetValue(1) end Sorted_SetSetting("scale", self:GetValue()) self.valueString:SetText(math.floor(self:GetValue() * 100 + 0.5) / 100) Sorted_SetScale(self:GetValue()) if Sorted_IsShadowlands() or Sorted_IsTBC() then BackdropTemplateMixin.OnBackdropLoaded(self) end self:SetMinMaxValues(18, 32) _G[self:GetName().."High"]:SetText("") _G[self:GetName().."Low"]:SetText("") _G[self:GetName().."Text"]:SetText(Sorted.Localize("CONFIG_APPEARANCE_ICON_SIZE")) _G[self:GetName().."Text"]:SetFontObject("SortedTitleFont") self:SetValue(Sorted_GetSetting("iconSize")) self.valueString:SetText(math.floor(self:GetValue() * 10) / 10) --self:SetValue(math.floor(self:GetValue())) Sorted_SetSetting("iconSize", self:GetValue()) self.valueString:SetText(math.floor(self:GetValue() * 10) / 10) Sorted_PositionItemButtons() Sorted_GetSortButton(SORTED_SORTBUTTON_ICON).width = Sorted_GetSetting("iconSize") * 1.1 Sorted_GetSortButton(SORTED_SORTBUTTON_FAVORITES).width = Sorted_GetSetting("iconSize") * 1.1 Sorted_UpdateSortButtons() Sorted_UpdateItemButtons() Sorted_FilterItems() if Sorted_IsShadowlands() or Sorted_IsTBC() then BackdropTemplateMixin.OnBackdropLoaded(self) end local function OnClick(self, button) if self:GetChecked() then Sorted_SetSetting("iconBorders", 2) else Sorted_SetSetting("iconBorders", 1) end Sorted_UpdateIconBorders() end self:RegisterForClicks("LeftButtonDown") self:HookScript("OnClick", OnClick) self.text:SetText(Sorted.Localize("CONFIG_APPEARANCE_ICON_BORDERS")) self.text:SetFontObject(Sorted13Font) self.text:SetTextColor(1,1,1) self.clickable:SetPoint("RIGHT", self:GetParent(), -16, 0) if Sorted_GetSetting("iconBorders") == 2 then self:SetChecked(true) else self:SetChecked(false) end if Sorted_IsShadowlands() or Sorted_IsTBC() then BackdropTemplateMixin.OnBackdropLoaded(self) end self:SetMinMaxValues(0, 8) _G[self:GetName().."High"]:SetText("") _G[self:GetName().."Low"]:SetText("") _G[self:GetName().."Text"]:SetText(Sorted.Localize("CONFIG_APPEARANCE_ICON_BORDER_THICKNESS")) _G[self:GetName().."Text"]:SetFontObject("SortedTitleFont") self:SetValue(Sorted_GetSetting("iconBorderThickness")) self.valueString:SetText(math.floor(self:GetValue() * 10) / 10) Sorted_SetSetting("iconBorderThickness", self:GetValue()) self.valueString:SetText(math.floor(self:GetValue() * 100) / 100) Sorted_PositionItemButtons() if Sorted_IsShadowlands() or Sorted_IsTBC() then BackdropTemplateMixin.OnBackdropLoaded(self) end self:SetMinMaxValues(0, 16) _G[self:GetName().."High"]:SetText("") _G[self:GetName().."Low"]:SetText("") _G[self:GetName().."Text"]:SetText(Sorted.Localize("CONFIG_APPEARANCE_SPACING")) _G[self:GetName().."Text"]:SetFontObject("SortedTitleFont") self:SetValue(Sorted_GetSetting("padding")) self.valueString:SetText(math.floor(self:GetValue() * 10) / 10) Sorted_SetSetting("padding", self:GetValue()) self.valueString:SetText(math.floor(self:GetValue() * 10) / 10) Sorted_PositionItemButtons() Sorted_UpdateItemButtons() Sorted_PositionItemButtons() local function OnClick(self, button) if self:GetChecked() then Sorted_SetSetting("animations", 2) else Sorted_SetSetting("animations", 1) end end self:RegisterForClicks("LeftButtonDown") self:HookScript("OnClick", OnClick) self.text:SetText(Sorted.Localize("CONFIG_BEHAVIOR_ANIMATIONS")) self.text:SetFontObject(Sorted13Font) self.text:SetTextColor(1,1,1) self.clickable:SetPoint("RIGHT", self:GetParent(), "RIGHT", -16, 0) self.text:ClearAllPoints() self.text:SetPoint("LEFT", 28, 0) if Sorted_GetSetting("animations") == 2 then self:SetChecked(true) else self:SetChecked(false) end self.text:SetText(Sorted.Localize("CONFIG_APPEARANCE_FONT_SIZE")) if Sorted_IsShadowlands() or Sorted_IsTBC() then BackdropTemplateMixin.OnBackdropLoaded(self) end self.values = { [-2] = Sorted.Localize("CONFIG_APPEARANCE_FONT_SIZE_1"), [-1] = Sorted.Localize("CONFIG_APPEARANCE_FONT_SIZE_2"), [0] = Sorted.Localize("CONFIG_APPEARANCE_FONT_SIZE_3"), [1] = Sorted.Localize("CONFIG_APPEARANCE_FONT_SIZE_4"), [2] = Sorted.Localize("CONFIG_APPEARANCE_FONT_SIZE_5") } function self:UpdateText() local value = math.floor(self:GetValue() + 0.5) self.valueString:SetText(self.values[value]) end self:SetMinMaxValues(-2, 2) _G[self:GetName().."High"]:SetText("") _G[self:GetName().."Low"]:SetText("") _G[self:GetName().."Text"]:SetText("") self:SetValue(Sorted_GetSetting("fontSize")) self:UpdateText() self:SetValue(math.floor(self:GetValue())) Sorted_SetSetting("fontSize", self:GetValue()) self:UpdateText() Sorted_UpdateFonts() SortedConfigFrame_UpdateTabWidths() SortedMoneyText:UpdateMoneyText() --Sorted_PositionItemButtons() self.text:SetText(Sorted.Localize("CONFIG_APPEARANCE_FONT_OUTLINE")) if Sorted_IsShadowlands() or Sorted_IsTBC() then BackdropTemplateMixin.OnBackdropLoaded(self) end self.values = { [0] = Sorted.Localize("CONFIG_APPEARANCE_FONT_OUTLINE_1"), [1] = Sorted.Localize("CONFIG_APPEARANCE_FONT_OUTLINE_2"), [2] = Sorted.Localize("CONFIG_APPEARANCE_FONT_OUTLINE_3") } function self:UpdateText() local value = math.floor(self:GetValue() + 0.5) self.valueString:SetText(self.values[value]) end self:SetMinMaxValues(0, 2) _G[self:GetName().."High"]:SetText("") _G[self:GetName().."Low"]:SetText("") _G[self:GetName().."Text"]:SetText("") self:SetValue(Sorted_GetSetting("fontOutline")) self:UpdateText() self:SetValue(math.floor(self:GetValue())) Sorted_SetSetting("fontOutline", self:GetValue()) self:UpdateText() Sorted_UpdateFonts() SortedConfigFrame_UpdateTabWidths() SortedMoneyText:UpdateMoneyText() SortedSortButtons_Update() --Sorted_PositionItemButtons() if Sorted_IsShadowlands() or Sorted_IsTBC() then BackdropTemplateMixin.OnBackdropLoaded(self) end self:SetMinMaxValues(60, 200) _G[self:GetName().."High"]:SetText("") _G[self:GetName().."Low"]:SetText("") _G[self:GetName().."Text"]:SetText(Sorted.Localize("CONFIG_APPEARANCE_SIDE_PANE_WIDTH")) _G[self:GetName().."Text"]:SetFontObject("SortedTitleFont") self:SetValue(Sorted_GetSetting("categoriesWidth")) self.valueString:SetText(math.floor(self:GetValue())) Sorted_SetSetting("categoriesWidth", self:GetValue()) self.valueString:SetText(math.floor(self:GetValue())) SortedFrame_UpdateMinSize() local function OnClick(self, button) if self:GetChecked() then Sorted_SetSetting("categoriesUseIcons", 2) else Sorted_SetSetting("categoriesUseIcons", 1) end Sorted_ReloadAllSettings() end self:RegisterForClicks("LeftButtonDown") self:HookScript("OnClick", OnClick) self.text:SetText(Sorted.Localize("CONFIG_APPEARANCE_ALWAYS_USE_ICONS")) self.text:SetFontObject(Sorted13Font) self.text:SetTextColor(1,1,1) self.clickable:SetPoint("RIGHT", self:GetParent(), -16, 0) self.clickable:HookScript("OnEnter", function(self) SortedTooltip.CreateLocalized(self, "ANCHOR_LEFT", "TOOLTIP_CONFIG_ALWAYS_USE_ICONS") end) self.clickable:HookScript("OnLeave", function(self) SortedTooltip.Cancel() end) if Sorted_GetSetting("categoriesUseIcons") == 2 then self:SetChecked(true) else self:SetChecked(false) end local function OnClick(self, button) if self:GetChecked() then Sorted_SetSetting("skinning", 2) else Sorted_SetSetting("skinning", 1) end end self:RegisterForClicks("LeftButtonDown") self:HookScript("OnClick", OnClick) self.text:SetText(Sorted.Localize("CONFIG_APPEARANCE_ELVUI_SKIN")) self.text:SetFontObject(Sorted13Font) self.text:SetTextColor(1,1,1) self.clickable:SetPoint("RIGHT", self:GetParent(), -16, 0) self.clickable:HookScript("OnEnter", function(self) SortedTooltip.CreateLocalized(self, "ANCHOR_LEFT", "TOOLTIP_CONFIG_ELVUI_SKIN") end) self.clickable:HookScript("OnLeave", function(self) SortedTooltip.Cancel() end) if Sorted_GetSetting("skinning") == 2 then self:SetChecked(true) else self:SetChecked(false) end if not (--[[ElvUI and ]]AddOnSkins) then self:Disable() end local function OnClick(self, button) if self:GetChecked() then Sorted_SetSetting("combineStacks", 2) else Sorted_SetSetting("combineStacks", 1) end Sorted_UpdateItemButtons() Sorted_FilterItems() end self:RegisterForClicks("LeftButtonDown") self:HookScript("OnClick", OnClick) self.text:SetText(Sorted.Localize("CONFIG_BEHAVIOR_COMBINE_STACKS")) self.text:SetFontObject(Sorted13Font) self.text:SetTextColor(1,1,1) self.text:ClearAllPoints() self.text:SetPoint("LEFT", 28, 0) self.clickable:SetPoint("RIGHT", self:GetParent(), "RIGHT", -16, 0) self.clickable:HookScript("OnEnter", function(self) SortedTooltip.CreateLocalized(self, "ANCHOR_LEFT", "TOOLTIP_CONFIG_COMBINE_STACKS") end) self.clickable:HookScript("OnLeave", function(self) SortedTooltip.Cancel() end) if Sorted_GetSetting("combineStacks") == 2 then self:SetChecked(true) else self:SetChecked(false) end self.text:SetText(Sorted.Localize("CONFIG_BEHAVIOR_NEW_ITEMS_HEADER")) local function OnClick(self, button) if self:GetChecked() then Sorted_SetSetting("newOnTop", 2) else Sorted_SetSetting("newOnTop", 1) end Sorted_UpdateItemButtons() Sorted_FilterItems() end self:RegisterForClicks("LeftButtonDown") self:HookScript("OnClick", OnClick) self.text:SetText(Sorted.Localize("CONFIG_BEHAVIOR_PIN_NEW")) self.text:SetFontObject(Sorted13Font) self.text:SetTextColor(1,1,1) self.text:ClearAllPoints() self.text:SetPoint("LEFT", 28, 0) self.clickable:SetPoint("RIGHT", self:GetParent(), "RIGHT", -16, 0) if Sorted_GetSetting("newOnTop") == 2 then self:SetChecked(true) else self:SetChecked(false) end local function OnClick(self, button) if self:GetChecked() then Sorted_SetSetting("newItemIndicators", 2) else Sorted_SetSetting("newItemIndicators", 1) end Sorted_UpdateNewItemsPerCategory() end self:RegisterForClicks("LeftButtonDown") self:HookScript("OnClick", OnClick) self.text:SetText(Sorted.Localize("CONFIG_BEHAVIOR_NEW_INDICATORS")) self.text:SetFontObject(Sorted13Font) self.text:SetTextColor(1,1,1) self.text:ClearAllPoints() self.text:SetPoint("LEFT", 28, 0) self.clickable:SetPoint("RIGHT", self:GetParent(), "RIGHT", -16, 0) if Sorted_GetSetting("newItemIndicators") == 2 then self:SetChecked(true) else self:SetChecked(false) end self.text:SetText(Sorted.Localize("CONFIG_BEHAVIOR_SCROLLING_HEADER")) self.text:SetText(Sorted.Localize("CONFIG_BEHAVIOR_SCROLL_WHEEL_SPEED")) if Sorted_IsShadowlands() or Sorted_IsTBC() then BackdropTemplateMixin.OnBackdropLoaded(self) end function self:UpdateText() self.valueString:SetText(math.floor(self:GetValue())) end self:SetMinMaxValues(1, 10) _G[self:GetName().."High"]:SetText("") _G[self:GetName().."Low"]:SetText("") _G[self:GetName().."Text"]:SetText("") self:HookScript("OnEnter", function(self) SortedTooltip.CreateLocalized(self, "ANCHOR_LEFT", "TOOLTIP_CONFIG_SCROLL_WHEEL_SPEED") end) self:HookScript("OnLeave", function(self) SortedTooltip.Cancel() end) self:SetValue(Sorted_GetSetting("scrollSpeed")) self:UpdateText() Sorted_SetSetting("scrollSpeed", self:GetValue()) self:UpdateText() self.text:SetText(Sorted.Localize("CONFIG_BEHAVIOR_SMOOTH_SCROLLING_POWER")) if Sorted_IsShadowlands() or Sorted_IsTBC() then BackdropTemplateMixin.OnBackdropLoaded(self) end function self:UpdateText() if self:GetValue() == 0 then self.valueString:SetText("Disabled") else self.valueString:SetText(math.floor(self:GetValue() * 100) / 50) end end self:SetMinMaxValues(0, 0.5) _G[self:GetName().."High"]:SetText("") _G[self:GetName().."Low"]:SetText("") _G[self:GetName().."Text"]:SetText("") self:HookScript("OnEnter", function(self) SortedTooltip.CreateLocalized(self, "ANCHOR_LEFT", "TOOLTIP_CONFIG_SMOOTH_SCROLLING") end) self:HookScript("OnLeave", function(self) SortedTooltip.Cancel() end) self:SetValue(Sorted_GetSetting("smoothingAmount")) self:UpdateText() if 0.01 > self:GetValue() then self:SetValue(0) end Sorted_SetSetting("smoothingAmount", self:GetValue()) if self:GetValue() > 0 then Sorted_SetSetting("smoothScrolling", 2) else Sorted_SetSetting("smoothScrolling", 1) end self:UpdateText() self.text:SetText(Sorted.Localize("CONFIG_BEHAVIOR_TOOLTIP_HEADER")) self.text:SetText(Sorted.Localize("CONFIG_BEHAVIOR_TOOLTIP_DELAY")) if Sorted_IsShadowlands() or Sorted_IsTBC() then BackdropTemplateMixin.OnBackdropLoaded(self) end function self:UpdateText() if self:GetValue() == 1 then self.valueString:SetText("1 "..Sorted.Localize("SUBFILTER_TIME_SECOND_SHORT")) else self.valueString:SetText((math.floor(self:GetValue() * self:GetValue() * 100) / 100).." "..Sorted.Localize("SUBFILTER_TIME_SECONDS_SHORT")) end end self:SetMinMaxValues(0.1, 1) _G[self:GetName().."High"]:SetText("") _G[self:GetName().."Low"]:SetText("") _G[self:GetName().."Text"]:SetText("") self:SetValue(Sorted_GetSetting("tooltipDelay") ^ 0.5) self:UpdateText() Sorted_SetSetting("tooltipDelay", self:GetValue() * self:GetValue()) self:UpdateText() local function OnClick(self, button) if self:GetChecked() then Sorted_SetSetting("tooltipInfo", 2) else Sorted_SetSetting("tooltipInfo", 1) end end self:RegisterForClicks("LeftButtonDown") self:HookScript("OnClick", OnClick) self.text:SetText(Sorted.Localize("CONFIG_BEHAVIOR_TOOLTIP_INFO")) self.text:SetFontObject(Sorted13Font) self.text:SetTextColor(1,1,1) self.text:ClearAllPoints() self.text:SetPoint("LEFT", 28, 0) self.clickable:SetPoint("RIGHT", self.text, "RIGHT", 8, 0) if Sorted_GetSetting("tooltipInfo") == 2 then self:SetChecked(true) else self:SetChecked(false) end if Sorted_IsShadowlands() or Sorted_IsTBC() then BackdropTemplateMixin.OnBackdropLoaded(self) end self.text:SetText(Sorted.Localize("CONFIG_BEHAVIOR_AUTO")) self.open:SetText(Sorted.Localize("CONFIG_BEHAVIOR_AUTO_OPEN")) self.close:SetText(Sorted.Localize("CONFIG_BEHAVIOR_AUTO_CLOSE")) local t = {"merchant", "auction", "bank", "mail"} local function OnClick(self) local autoOpenClose = Sorted_GetSetting("autoOpenClose") if self:GetChecked() then autoOpenClose = bit.bor(autoOpenClose, self:GetID()) elseif (bit.band(autoOpenClose, self:GetID())) ~= 0 then autoOpenClose = autoOpenClose - self:GetID() end Sorted_SetSetting("autoOpenClose", autoOpenClose) end local function OnShow(self) self:SetChecked(bit.band(Sorted_GetSetting("autoOpenClose"), self:GetID()) ~= 0) end for i, v in pairs(t) do self[v.."Text"] = self:CreateFontString(nil, "OVERLAY", "Sorted12Font") self[v.."Text"]:SetText(Sorted.Localize("CONFIG_BEHAVIOR_AUTO_"..string.upper(v))) self[v.."Text"]:SetPoint("RIGHT", self, "TOPRIGHT", -144, -16 - i * 24) self[v.."Open"] = CreateFrame("CheckButton", nil, self, "UICheckButtonTemplate") self[v.."Open"]:SetSize(24, 25) self[v.."Open"]:SetPoint("CENTER", self, "TOPRIGHT", -104, -16 - i * 24) self[v.."Open"]:SetID(2^(i - 1)) self[v.."Open"]:SetScript("OnClick", OnClick) self[v.."Open"]:SetScript("OnShow", OnShow) self[v.."Close"] = CreateFrame("CheckButton", nil, self, "UICheckButtonTemplate") self[v.."Close"]:SetSize(24, 25) self[v.."Close"]:SetPoint("CENTER", self, "TOPRIGHT", -48, -16 - i * 24) self[v.."Close"]:SetID(2^(i + 3)) self[v.."Close"]:SetScript("OnClick", OnClick) self[v.."Close"]:SetScript("OnShow", OnShow) end self.text:SetText(Sorted.Localize("CONFIG_BEHAVIOR_ON_OPEN_HEADER")) self.text:SetScale(1.2) self.text:SetText(Sorted.Localize("CONFIG_BEHAVIOR_ON_OPEN_SORTING_HEADER")) local function OnClick(self, button) if self:GetChecked() then Sorted_SetSetting("onOpenSortKeepPrev", 2) SortedConfigOnOpenSortSpecific:SetChecked(false) UIDropDownMenu_DisableDropDown(SortedConfigOnOpenSortSpecificDropdown) UIDropDownMenu_DisableDropDown(SortedConfigOnOpenSortAscendingDropdown) end self:SetChecked(true) end self:RegisterForClicks("LeftButtonDown") self:HookScript("OnClick", OnClick) self.text:SetText(Sorted.Localize("CONFIG_BEHAVIOR_ON_OPEN_USE_PREVIOUS")) self.text:SetFontObject(Sorted13Font) self.text:SetTextColor(1,1,1) self.text:ClearAllPoints() self.text:SetPoint("LEFT", 28, 0) self.clickable:SetPoint("RIGHT", self:GetParent(), "RIGHT", -16, 0) if Sorted_GetSetting("onOpenSortKeepPrev") == 2 then self:SetChecked(true) else self:SetChecked(false) end self.clickable:SetWidth(self.text:GetWidth() + 48) local function OnClick(self, button) if self:GetChecked() then Sorted_SetSetting("onOpenSortKeepPrev", 1) SortedConfigOnOpenSortPrev:SetChecked(false) UIDropDownMenu_EnableDropDown(SortedConfigOnOpenSortSpecificDropdown) UIDropDownMenu_EnableDropDown(SortedConfigOnOpenSortAscendingDropdown) end self:SetChecked(true) end self:RegisterForClicks("LeftButtonDown") self:HookScript("OnClick", OnClick) self.text:SetText(Sorted.Localize("CONFIG_BEHAVIOR_ON_OPEN_USE_SPECIFIC")) self.text:SetFontObject(Sorted13Font) self.text:SetTextColor(1,1,1) self.text:ClearAllPoints() self.text:SetPoint("LEFT", 28, 0) self.clickable:SetPoint("RIGHT", self:GetParent(), "RIGHT", -16, 0) if Sorted_GetSetting("onOpenSortKeepPrev") == 1 then self:SetChecked(true) UIDropDownMenu_EnableDropDown(SortedConfigOnOpenSortSpecificDropdown) UIDropDownMenu_EnableDropDown(SortedConfigOnOpenSortAscendingDropdown) else self:SetChecked(false) UIDropDownMenu_DisableDropDown(SortedConfigOnOpenSortSpecificDropdown) UIDropDownMenu_DisableDropDown(SortedConfigOnOpenSortAscendingDropdown) end self.clickable:SetWidth(self.text:GetWidth() + 48) function self:Update() local value = Sorted_GetSetting("onOpenSortMethod") UIDropDownMenu_SetSelectedValue(SortedConfigOnOpenSortSpecificDropdown, value) local sortButton = Sorted_GetSortButton(math.floor(value / 10)) local sortMethod = sortButton.sortMethods[value % 10] if sortMethod.title ~= "" then UIDropDownMenu_SetText(SortedConfigOnOpenSortSpecificDropdown, sortButton.name.." ("..sortMethod.title..")") else UIDropDownMenu_SetText(SortedConfigOnOpenSortSpecificDropdown, sortButton.name) end end local function SortSpecificDropdown_OnClick(self) UIDropDownMenu_SetSelectedValue(SortedConfigOnOpenSortSpecificDropdown, self.value) Sorted_SetSetting("onOpenSortMethod", self.value) SortedConfigOnOpenSortSpecificDropdown:Update() end local function SortSpecificDropdown_Init() for i,v in ipairs(Sorted_sortButtons) do if v:Enabled() and v.sortMethods then for methodIndex, method in ipairs(v.sortMethods) do local info = UIDropDownMenu_CreateInfo() info.func = SortSpecificDropdown_OnClick if method.title ~= "" then info.text = v.name.." ("..method.title..")" else info.text = v.name end info.value = v.uniqueID * 10 + methodIndex UIDropDownMenu_AddButton(info) end end end end self.type = CONTROLTYPE_DROPDOWN UIDropDownMenu_SetWidth(self, 160) UIDropDownMenu_Initialize(self, SortSpecificDropdown_Init) self:Update() function self:Update() local value = Sorted_GetSetting("onOpenSortAscending") UIDropDownMenu_SetSelectedValue(SortedConfigOnOpenSortAscendingDropdown, value) if value == 1 then UIDropDownMenu_SetText(SortedConfigOnOpenSortAscendingDropdown, Sorted.Localize("CONFIG_BEHAVIOR_ON_OPEN_SORT_DESCENDING")) else UIDropDownMenu_SetText(SortedConfigOnOpenSortAscendingDropdown, Sorted.Localize("CONFIG_BEHAVIOR_ON_OPEN_SORT_ASCENDING")) end end local function Dropdown_OnClick(self) UIDropDownMenu_SetSelectedValue(SortedConfigOnOpenSortAscendingDropdown, self.value) Sorted_SetSetting("onOpenSortAscending", self.value) SortedConfigOnOpenSortAscendingDropdown:Update() end local function Dropdown_Init() local info = UIDropDownMenu_CreateInfo() info.func = Dropdown_OnClick info.text = Sorted.Localize("CONFIG_BEHAVIOR_ON_OPEN_SORT_ASCENDING") info.value = 2 UIDropDownMenu_AddButton(info) local info = UIDropDownMenu_CreateInfo() info.func = Dropdown_OnClick info.text = Sorted.Localize("CONFIG_BEHAVIOR_ON_OPEN_SORT_DESCENDING") info.value = 1 UIDropDownMenu_AddButton(info) end self.type = CONTROLTYPE_DROPDOWN UIDropDownMenu_SetWidth(self, 128) UIDropDownMenu_Initialize(self, Dropdown_Init) self:Update() self.text:SetText(Sorted.Localize("CONFIG_BEHAVIOR_ON_OPEN_FILTERING_HEADER")) local function OnClick(self, button) if self:GetChecked() then Sorted_SetSetting("onOpenFilterKeepPrev", 0) SortedConfigOnOpenFilterSpecific:SetChecked(false) SortedConfigOnOpenFilterPrev:SetChecked(false) UIDropDownMenu_DisableDropDown(SortedConfigOnOpenFilterSpecificDropdown) end self:SetChecked(true) end self:RegisterForClicks("LeftButtonDown") self:HookScript("OnClick", OnClick) self.text:SetText(Sorted.Localize("CONFIG_BEHAVIOR_ON_OPEN_NONE")) self.text:SetFontObject(Sorted13Font) self.text:SetTextColor(1,1,1) self.text:ClearAllPoints() self.text:SetPoint("LEFT", 28, 0) self.clickable:SetPoint("RIGHT", self:GetParent(), "RIGHT", -16, 0) if Sorted_GetSetting("onOpenFilterKeepPrev") == 0 then self:SetChecked(true) else self:SetChecked(false) end self.clickable:SetWidth(self.text:GetWidth() + 48) local function OnClick(self, button) if self:GetChecked() then Sorted_SetSetting("onOpenFilterKeepPrev", 2) SortedConfigOnOpenFilterSpecific:SetChecked(false) SortedConfigOnOpenFilterNone:SetChecked(false) UIDropDownMenu_DisableDropDown(SortedConfigOnOpenFilterSpecificDropdown) end self:SetChecked(true) end self:RegisterForClicks("LeftButtonDown") self:HookScript("OnClick", OnClick) self.text:SetText(Sorted.Localize("CONFIG_BEHAVIOR_ON_OPEN_USE_PREVIOUS")) self.text:SetFontObject(Sorted13Font) self.text:SetTextColor(1,1,1) self.text:ClearAllPoints() self.text:SetPoint("LEFT", 28, 0) self.clickable:SetPoint("RIGHT", self:GetParent(), "RIGHT", -16, 0) if Sorted_GetSetting("onOpenFilterKeepPrev") == 2 then self:SetChecked(true) else self:SetChecked(false) end self.clickable:SetWidth(self.text:GetWidth() + 48) local function OnClick(self, button) if self:GetChecked() then Sorted_SetSetting("onOpenFilterKeepPrev", 1) SortedConfigOnOpenFilterPrev:SetChecked(false) SortedConfigOnOpenFilterNone:SetChecked(false) UIDropDownMenu_EnableDropDown(SortedConfigOnOpenFilterSpecificDropdown) end self:SetChecked(true) end self:RegisterForClicks("LeftButtonDown") self:HookScript("OnClick", OnClick) self.text:SetText(Sorted.Localize("CONFIG_BEHAVIOR_ON_OPEN_USE_SPECIFIC")) self.text:SetFontObject(Sorted13Font) self.text:SetTextColor(1,1,1) self.text:ClearAllPoints() self.text:SetPoint("LEFT", 28, 0) self.clickable:SetPoint("RIGHT", self:GetParent(), "RIGHT", -16, 0) if Sorted_GetSetting("onOpenFilterKeepPrev") == 1 then self:SetChecked(true) UIDropDownMenu_EnableDropDown(SortedConfigOnOpenFilterSpecificDropdown) else self:SetChecked(false) UIDropDownMenu_DisableDropDown(SortedConfigOnOpenFilterSpecificDropdown) end self.clickable:SetWidth(self.text:GetWidth() + 48) function self:Update() local value = Sorted_GetSetting("onOpenFilterCategory") UIDropDownMenu_SetSelectedValue(SortedConfigOnOpenFilterSpecificDropdown, value) if Sorted_GetSetting("categories")[value] then UIDropDownMenu_SetText(SortedConfigOnOpenFilterSpecificDropdown, Sorted_GetSetting("categories")[value].name) end end local function Dropdown_OnClick(self) UIDropDownMenu_SetSelectedValue(SortedConfigOnOpenFilterSpecificDropdown, self.value) Sorted_SetSetting("onOpenFilterCategory", self.value) SortedConfigOnOpenFilterSpecificDropdown:Update() end local function Dropdown_Init() local categories = Sorted_GetSetting("categories") if categories then for i,v in ipairs(categories) do local info = UIDropDownMenu_CreateInfo() info.func = Dropdown_OnClick info.value = i info.text = v.name UIDropDownMenu_AddButton(info) end end end self.type = CONTROLTYPE_DROPDOWN UIDropDownMenu_SetWidth(self, 160) UIDropDownMenu_Initialize(self, Dropdown_Init) self:Update() local function OnClick(self, button) if self:GetChecked() then Sorted_SetSetting("onOpenKeepSearch", 2) else Sorted_SetSetting("onOpenKeepSearch", 1) end end self:RegisterForClicks("LeftButtonDown") self:HookScript("OnClick", OnClick) self.text:SetText(Sorted.Localize("CONFIG_BEHAVIOR_ON_OPEN_KEEP_SEARCH")) self.text:SetFontObject(Sorted13Font) self.text:SetTextColor(1,1,1) self.text:ClearAllPoints() self.text:SetPoint("LEFT", 28, 0) self.clickable:SetPoint("RIGHT", self.text, "RIGHT", 8, 0) if Sorted_GetSetting("onOpenKeepSearch") == 2 then self:SetChecked(true) else self:SetChecked(false) end local function OnClick(self, button) if self:GetChecked() then Sorted_SetSetting("onOpenPinFavorites", 2) else Sorted_SetSetting("onOpenPinFavorites", 1) end end self:RegisterForClicks("LeftButtonDown") self:HookScript("OnClick", OnClick) self.text:SetText(Sorted.Localize("CONFIG_BEHAVIOR_ON_OPEN_PIN_FAVORITES")) self.text:SetFontObject(Sorted13Font) self.text:SetTextColor(1,1,1) self.text:ClearAllPoints() self.text:SetPoint("LEFT", 28, 0) self.clickable:SetPoint("RIGHT", self.text, "RIGHT", 8, 0) if Sorted_GetSetting("onOpenPinFavorites") == 2 then self:SetChecked(true) else self:SetChecked(false) end self.selected = nil function self:GetData() if self.selected then return Sorted_GetSetting("categories")[self.selected] end end function self:UpdateButtons() local categories = Sorted_GetSetting("categories") local dragging, hovering = self.dragging, nil if dragging then for i, button in ipairs(self.buttons) do if i~=dragging and button.invisibleButton:IsMouseOver() then hovering = i end end end for i, button in ipairs(self.buttons) do if categories[i] then button:Show() button:ClearAllPoints() if hovering then if button.dragging then button:SetPoint("TOPLEFT", 4, 12 - hovering * 21) elseif dragging > i and i >= hovering then button:SetPoint("TOPLEFT", 4, 12 - i * 21 - 21) elseif i > dragging and hovering >= i then button:SetPoint("TOPLEFT", 4, 12 - i * 21 + 21) else button:SetPoint("TOPLEFT", 4, 12 - i * 21) end else button:SetPoint("TOPLEFT", 4, 12 - i * 21) end button:SetSize(124, 21) button.invisibleButton:Show() button.invisibleButton:ClearAllPoints() button.invisibleButton:SetPoint("TOPLEFT", 4, 12 - i * 21) button.invisibleButton:SetSize(124, 21) button.text:SetText(categories[i].name) if self.selected == i then button.selectedTexture:Show() else button.selectedTexture:Hide() end else button:Hide() button.invisibleButton:Hide() end end if #self.buttons > #categories then self.addButton:SetPoint("TOPLEFT", 12, -6 - #categories * 21) self.addButton:Show() else self.addButton:Hide() end end function self:SelectButton(index) if index == self.selected then self.buttons[index].selectedTexture:Hide() self.selected = nil _G[self:GetParent():GetName().."Left"]:Hide() return end for i, button in ipairs(self.buttons) do if index == i then button.selectedTexture:Show() else button.selectedTexture:Hide() end end self.selected = index local category = Sorted_GetSetting("categories")[index] SortedConfigCategoryName.editBox:SetText(category.name) if category.icon then SortedConfigCategoryIcon:SetNormalTexture("Interface\\Icons\\"..category.icon) else SortedConfigCategoryIcon:SetNormalTexture("Interface\\Icons\\inv_misc_questionmark") end SortedConfigCategoryFilters:Update() SortedConfigCategorySubfilters:Update() --SortedConfigCategoryFilters:Deselect() _G[self:GetParent():GetName().."Left"]:Show() end function self:PerformButtonDrag(i1) local i2 local categories = Sorted_GetSetting("categories") for i, v in pairs(self.buttons) do if i ~= i1 and v.invisibleButton:IsMouseOver() then i2 = i end end if self.selected then categories[self.selected].selected = true end if not i2 then return false end local data = categories[i1] local temp = {} Sorted_CopyTable(data, temp) table.remove(categories, i1) table.insert(categories, i2, temp) if self.selected then for k,v in pairs(categories) do if v.selected then v.selected = nil self.selected = k end end local category = Sorted_GetSetting("categories")[self.selected] SortedConfigCategoryName.editBox:SetText(category.name) if category.icon then SortedConfigCategoryIcon:SetNormalTexture("Interface\\Icons\\"..category.icon) else SortedConfigCategoryIcon:SetNormalTexture("Interface\\Icons\\inv_misc_questionmark") end SortedConfigCategoryFilters:Update() SortedConfigCategorySubfilters:Update() end Sorted_ReloadAllSettings() self:UpdateButtons() end self.buttons = {} for i = 1, 22 do local b = CreateFrame("Button", self:GetName()..i, self, "SortedButtonTemplate") b:SetID(i) b:SetMovable(true) b:RegisterForDrag("LeftButton") b:SetScript("OnClick", function(self) self:GetParent():SelectButton(self:GetID()) PlaySound(SOUNDKIT.IG_CHAT_EMOTE_BUTTON ) end) b:SetScript("OnDragStart", function(self) self.dragging = true SortedConfigCategories.dragging = self:GetID() --self:StartMoving() self:SetFrameStrata("FULLSCREEN") --self:SetAlpha(0.7) --self.deleteButton:Hide() end) b:SetScript("OnDragStop", function(self) self.dragging = false SortedConfigCategories.dragging = nil SortedConfigCategories:PerformButtonDrag(self:GetID()) self:StopMovingOrSizing() self:SetFrameStrata("DIALOG") SortedConfigCategories:UpdateButtons() --self:SetAlpha(1) self.deleteButton:Show() end) b:SetScript("OnHide", function(self, button) self.dragging = false SortedConfigCategories.dragging = nil self:StopMovingOrSizing() --self:SetAlpha(1) self.deleteButton:Show() end) b:SetScript("OnUpdate", function(self, button) if self.dragging then SortedConfigCategories:UpdateButtons() end end) local db = CreateFrame("Button", b:GetName().."DeleteButton", b, "SortedDeleteButtonTemplate") db:SetPoint("LEFT", b, "RIGHT", -3, 0) db:SetScript("OnClick", function(self) SortedTooltip.Cancel() local data = Sorted_GetSetting("categories") table.remove(data, self:GetParent():GetID()) if self:GetParent():GetID() == SortedConfigCategories.selected then SortedConfigCategories:SelectButton(self:GetParent():GetID()) end SortedConfigCategories:UpdateButtons() Sorted_SelectCategoryButton(nil) SortedFilterButtons_Update(SortedFrameFilterButtons) SortedSubcategoryFrame_Update() local category = SortedConfigCategories:GetData() if category then SortedConfigCategoryName.editBox:SetText(category.name) if category.icon then SortedConfigCategoryIcon:SetNormalTexture("Interface\\Icons\\"..category.icon) else SortedConfigCategoryIcon:SetNormalTexture("Interface\\Icons\\inv_misc_questionmark") end SortedConfigCategoryFilters:Update() SortedConfigCategorySubfilters:Update() else _G[SortedConfigCategories:GetParent():GetName().."Left"]:Hide() end end) db:SetScript("OnEnter", function(self) SortedTooltip.CreateLocalized(self, "ANCHOR_LEFT", "TOOLTIP_CONFIG_REMOVE_CATEGORY", Sorted_GetSetting("categories")[self:GetParent():GetID()].name) end) db:SetScript("OnLeave", function(self) SortedTooltip.Cancel() end) -- Create an invisible button that never moves for IsMouseOver checks local ib = CreateFrame("Button", self:GetName()..i.."InvisibleButton", self) ib:SetID(i) self.buttons[i] = b b.deleteButton = db b.invisibleButton = ib end self.addButton = CreateFrame("Button", self:GetName().."AddButton", self, "SortedPlusButtonTemplate") self.addText = self.addButton:CreateFontString(self:GetName().."AddText", "OVERLAY", "SortedButtonFont") self.addText:SetPoint("LEFT", self.addButton, "RIGHT") self.addText:SetText(Sorted.Localize("CONFIG_CATEGORIES_ADD")) self.addButton:SetScript("OnClick", function(self) local data = Sorted_GetSetting("categories") table.insert(data, { ["name"] = Sorted.Localize("CONFIG_CATEGORIES_DEFAULT_NAME"), ["filterGroups"] = {} }) self:GetParent():UpdateButtons() self:GetParent():SelectButton(#data) SortedConfigCategoryName.editBox:SetFocus() SortedFilterButtons_Update(SortedFrameFilterButtons) Sorted_UpdateNewItemsPerCategory() end) self.selected = nil self.selected = nil self:UpdateButtons() _G[self:GetParent():GetName().."Left"]:Hide() self.title:SetText(Sorted.Localize("CONFIG_CATEGORIES_NAME")) if not Sorted_IsClassic() then self:RegisterEvent("GLOBAL_MOUSE_DOWN") end self.editBox:SetScript("OnTextChanged", function(self) local category = Sorted_GetSetting("categories")[SortedConfigCategories.selected] category.name = self:GetText() SortedConfigCategories:UpdateButtons() SortedFilterButtons_Update(SortedFrameFilterButtons) end) self.editBox:SetScript("OnEnterPressed", function(self) self:ClearFocus() end) if event == "GLOBAL_MOUSE_DOWN" and self:IsShown() then if not self:IsMouseOver() then self.editBox:ClearFocus() end end self.value = 1 function self:GetData() local data = SortedConfigCategories:GetData() if data then if not data.filterGroups then data.filterGroups = {} end if not data.filterGroups[self.value] then data.filterGroups[self.value] = {} end return data.filterGroups[self.value] end end function self:GetEntries() local t = SortedConfigCategories:GetData() if t then return t.filterGroups else return nil end end function self:Update() local entries = self:GetEntries() if entries then if 1 >= #self:GetEntries() then self.removeButton:Disable() else self.removeButton:Enable() end _G[self:GetName().."Text"]:SetText("Group "..self.value) end end local function Sorted_CategoryGroupsDropdown_OnClick(self) UIDropDownMenu_SetSelectedValue(SortedConfigCategoryGroups, self.value) SortedConfigCategoryGroups.value = self.value SortedConfigCategoryFilters:Update() end local function Sorted_CategoryGroupsDropdown_Init() local entries = self:GetEntries() if entries then for i, v in ipairs(entries) do local info = {} info.text = "Group "..i info.value = i info.func = Sorted_CategoryGroupsDropdown_OnClick UIDropDownMenu_AddButton(info) end end end self.type = CONTROLTYPE_DROPDOWN UIDropDownMenu_SetWidth(self, 96) UIDropDownMenu_Initialize(self, Sorted_CategoryGroupsDropdown_Init) self.addButton = CreateFrame("Button", self:GetName().."AddButton", self, "SortedSmallPlusButtonTemplate") self.addButton:SetPoint("TOPLEFT", self, "TOPRIGHT", -16, 1) self.removeButton = CreateFrame("Button", self:GetName().."AddButton", self, "SortedSmallMinusButtonTemplate") self.removeButton:SetPoint("BOTTOMLEFT", self, "BOTTOMRIGHT", -16, 2) UIDropDownMenu_SetSelectedValue(SortedConfigCategoryGroups, 1) self:Update() self.title:SetText(Sorted.Localize("CONFIG_CATEGORIES_FILTERS")) self.selected = nil function self:Update() --local filters = SortedConfigCategoryGroups:GetData() local filters = Sorted_filters table.sort(self.buttons, function(a,b) return b:GetID() > a:GetID() end) for i, v in pairs(self.buttons) do self.buttons[i]:SetPoint("TOPLEFT", 2, -5 - 24 * (i - 1)) self.buttons[i]:SetPoint("BOTTOMRIGHT", self, "TOPRIGHT", -2, -3 - 24 * i) if SortedConfigCategories.selected and Sorted_GetFilterModified(SortedConfigCategories.selected, SortedConfigCategoryGroups.value, v:GetID()) then self.buttons[i].text:SetText("• "..filters[v:GetID()].name) else self.buttons[i].text:SetText(filters[v:GetID()].name) end self.buttons[i]:Show() end --SortedConfigCategorySubfilters:Update() end function self:Deselect() if self.selected then self:SelectButton(self.selected) end end function self:SelectButton(filterID) local buttonID for i, v in pairs(self.buttons) do if v:GetID() == filterID then buttonID = i end end if filterID == self.selected then self.buttons[buttonID].selectedTexture:Hide() self.buttons[buttonID].text:SetTextColor(0.85, 0.8, 0.75) SortedConfigCategorySubfiltersScrollFrame:GetParent():Hide() self.selected = nil return end for i, button in ipairs(self.buttons) do if buttonID == i then button.selectedTexture:Show() button.text:SetTextColor(1, 1, 1) else button.selectedTexture:Hide() button.text:SetTextColor(0.85, 0.8, 0.75) end end self.selected = filterID SortedConfigCategorySubfiltersScrollFrame:GetParent():Show() SortedConfigCategorySubfilters:Update() end self.buttons = {} for i, filter in pairs(Sorted_filters) do local b = CreateFrame("Button", self:GetName()..i, self) b:SetHighlightTexture("Interface\\WorldMap\\UI-QuestPoi-HighlightBar") b:GetHighlightTexture():SetBlendMode("ADD") b:SetPushedTexture("Interface\\WorldMap\\UI-QuestPoi-HighlightBar") b:GetPushedTexture():SetBlendMode("ADD") b:GetPushedTexture():SetAlpha(0.6) b.selectedTexture = b:CreateTexture(self:GetName().."SelectedTexture", "OVERLAY") b.selectedTexture:SetTexture("Interface\\WorldMap\\UI-QuestPoi-HighlightBar") b.selectedTexture:SetBlendMode("ADD") b.selectedTexture:SetAllPoints() b.selectedTexture:Hide() local fs = b:CreateFontString(b:GetName().."Text", "OVERLAY", "SortedButtonFont") fs:SetPoint("LEFT", 4, 0) fs:SetTextColor(0.85, 0.8, 0.75) b.text = fs b:SetID(i) b:SetScript("OnEnter", function(self) self.text:SetTextColor(1, 1, 1) end) b:SetScript("OnLeave", function(self) if self:GetID() ~= SortedConfigCategoryFilters.selected then self.text:SetTextColor(0.85, 0.8, 0.75) end end) b:SetScript("OnClick", function(self) self:GetParent():SelectButton(self:GetID()) end) b:Hide() table.insert(self.buttons, b) end self:Deselect() self.SetFilterOptionValue = function(optionGroup, option, value, key) -- Since the table gets cleaned up, reconstruct anything that's missing local data = SortedConfigCategoryGroups:GetData() if not data.filters then data.filters = {} end if not data.filters[SortedConfigCategoryFilters.selected] then data.filters[SortedConfigCategoryFilters.selected] = {} end if not data.filters[SortedConfigCategoryFilters.selected].values then data.filters[SortedConfigCategoryFilters.selected].values = {} end -- Set the value local values = data.filters[SortedConfigCategoryFilters.selected].values if not values[optionGroup] then values[optionGroup] = {} end if key then if not values[optionGroup][option] then values[optionGroup][option] = {} end values[optionGroup][option][key] = value else values[optionGroup][option] = value end Sorted_CleanTable(SortedConfigCategoryGroups:GetData()) SortedConfigCategoryFilters:Update() end self.checkButtons = {} self.numberRanges = {} self.specificItems = {} self.fontStrings = {} self.editBoxes = {} self.allItems = {} function self:GetItem(row, type) local y = -13 - (row - 1) * 22 if type == "CheckButton" then if not self.checkButtons[row] then local cb = CreateFrame("CheckButton", self:GetName().."CheckButton"..row, self, "SortedFilterOptionCheckBox") cb:SetPoint("TOPLEFT", 4, y + 11) cb.clickable:SetPoint("RIGHT", self) self.checkButtons[row] = cb table.insert(self.allItems, cb) end return self.checkButtons[row] elseif type == "Range" then if not self.numberRanges[row] then local nr = CreateFrame("Frame", self:GetName().."NumberRange"..row, self, "SortedFilterOptionRange") nr:SetPoint("TOPLEFT", 6, y + 11) nr:SetPoint("BOTTOMRIGHT", self, "TOPRIGHT", 0, y - 11) self.numberRanges[row] = nr table.insert(self.allItems, nr) end return self.numberRanges[row] elseif type == "Item" then if not self.specificItems[row] then local si = CreateFrame("Frame", self:GetName().."SpecificItem"..row, self, "SortedFilterOptionItem") si:SetPoint("TOPLEFT", 6, y + 11) si:SetPoint("BOTTOMRIGHT", self, "TOPRIGHT", 0, y - 11) self.specificItems[row] = si table.insert(self.allItems, si) --si.editBoxID:HookScript("OnTextChanged", ItemIDOnTextChanged) --si.editBoxName:HookScript("OnTextChanged", ItemNameOnTextChanged) end return self.specificItems[row] elseif type == "Text" then if not self.editBoxes[row] then local eb = CreateFrame("EditBox", self:GetName().."EditBox"..row, self, "SortedFilterOptionText") eb:SetPoint("TOPLEFT", 8, y + 11) eb:SetPoint("BOTTOMRIGHT", self, "TOPRIGHT", -4, y - 11) self.editBoxes[row] = eb table.insert(self.allItems, eb) end return self.editBoxes[row] elseif type == "Header" then if not self.fontStrings[row] then self.fontStrings[row] = self:CreateFontString(self:GetName().."FontString"..row, "OVERLAY", "SortedButtonFont") self.fontStrings[row]:SetPoint("LEFT", self, "TOPLEFT", 6, y) table.insert(self.allItems, self.fontStrings[row]) end return self.fontStrings[row] end end function self:Update() for _, v in pairs(self.allItems) do v.toHide = true end if SortedConfigCategoryFilters.selected then local filterID = SortedConfigCategoryFilters.selected local data = SortedConfigCategoryGroups:GetData() local options = Sorted_filters[SortedConfigCategoryFilters.selected] local row = 1 for optionGroupID, optionGroup in ipairs(options.optionGroups) do local head = self:GetItem(row, "Header") head:SetText(optionGroup.name) head.toHide = false head:Show() if Sorted_GetSubfilterGroupEnabled(SortedConfigCategories.selected, SortedConfigCategoryGroups.value, filterID, optionGroupID) then self:GetItem(row, "Header"):SetTextColor(1, 0.82, 0) row = row + 1 if optionGroup.type == "LIST" then local i = 1 local v = Sorted_GetSubfilterValue(SortedConfigCategories.selected, SortedConfigCategoryGroups.value, filterID, optionGroupID, i) while v do local eb = self:GetItem(row, "Text") eb.toHide = false eb:Show() eb:SetText(v) eb.key1 = optionGroupID eb.key2 = i row = row + 1 i = i + 1 v = Sorted_GetSubfilterValue(SortedConfigCategories.selected, SortedConfigCategoryGroups.value, filterID, optionGroupID, i) end local eb = self:GetItem(row, "Text") eb.toHide = false eb:Show() eb:SetText("") eb.key1 = optionGroupID eb.key2 = i row = row + 1 elseif optionGroup.type == "IDLIST" then local i = 1 local v = Sorted_GetSubfilterValue(SortedConfigCategories.selected, SortedConfigCategoryGroups.value, filterID, optionGroupID, i) while v do local si = self:GetItem(row, "Item") si.toHide = false si:Show() if v.id then si.editBoxID:SetText(v.id) else si.editBoxID:SetText("") end if v.name then si.editBoxName:SetText(v.name) else si.editBoxName:SetText("") end si.key1 = optionGroupID si.key2 = i si:Update() row = row + 3 i = i + 1 v = Sorted_GetSubfilterValue(SortedConfigCategories.selected, SortedConfigCategoryGroups.value, filterID, optionGroupID, i) end local si = self:GetItem(row, "Item") si.toHide = false si:Show() si.editBoxID:SetText("") si.editBoxName:SetText("") si.key1 = optionGroupID si.key2 = i si:Update() row = row + 3 else for optionID, option in ipairs(optionGroup.options) do if option.type == "RANGE" then local nr = self:GetItem(row, "Range") nr.text:SetText(option.name) local value = Sorted_GetSubfilterValue(SortedConfigCategories.selected, SortedConfigCategoryGroups.value, filterID, optionGroupID, optionID) if value then if value.min and value.min > 0 then nr.min:SetNumber(value.min) else nr.min:SetText("") end if value.max and value.max > 0 then nr.max:SetNumber(value.max) else nr.max:SetText("") end else nr.min:SetText("") nr.max:SetText("") end nr.toHide = false nr:Show() nr.key1 = optionGroupID nr.key2 = optionID else local cb = self:GetItem(row, "CheckButton") cb.text:SetText(option.name) cb.toHide = false cb:Show() if Sorted_GetSubfilterValue(SortedConfigCategories.selected, SortedConfigCategoryGroups.value, filterID, optionGroupID, optionID) then cb:SetChecked(true) else cb:SetChecked(false) end cb.key1 = optionGroupID cb.key2 = optionID end row = row + 1 end end else self:GetItem(row, "Header"):SetTextColor(0.5, 0.5, 0.5) row = row + 1 end end self:SetHeight(row * 22 - 12) self:UpdateScrollBar() end for _, v in pairs(self.allItems) do if v.toHide then v:Hide() end end end function self:UpdateScrollBar() local max = SortedConfigCategorySubfilters:GetHeight() - SortedConfigCategorySubfiltersScrollFrame:GetHeight() if max > 0 then self:GetParent().scrollBar:SetMinMaxValues(0, max) else self:GetParent().scrollBar:SetMinMaxValues(0, 0) end end self:Update() self:UpdateScrollBar() self.scrollBar = CreateFrame("Slider", self:GetName().."ScrollBar", self, "MinimalScrollBarTemplate") self.scrollBar.trackBG:Hide() self.scrollBar:SetPoint("TOPRIGHT", 1, -18) self.scrollBar:SetPoint("BOTTOM", 0, 16) self.scrollBar:SetMinMaxValues(1, 1) self.scrollBar:SetValueStep(1) self.scrollBar.scrollStep = 16 self.scrollBar:SetValue(0) self:SetScrollChild(_G["SortedConfigCategorySubfilters"]) self:EnableMouseWheel(1) self:SetScript("OnMouseWheel", function(self, delta) self.scrollBar:SetValue(self.scrollBar:GetValue() - delta * 30) end) self.title:SetText(Sorted.Localize("CONFIG_PROFILES_NAME")) function self:Update() self.editBox:SetText(Sorted_GetSetting("profileName")) end if not Sorted_IsClassic() then self:RegisterEvent("GLOBAL_MOUSE_DOWN") end self.editBox:SetScript("OnTextChanged", function(self) Sorted_SetSetting("profileName", self:GetText()) SortedConfigProfileDropdown:ValueFunc() end) self.editBox:SetScript("OnEnterPressed", function(self) self:ClearFocus() end) self:Update() if event == "GLOBAL_MOUSE_DOWN" and self:IsShown() then if not self:IsMouseOver() then self.editBox:ClearFocus() end end