You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
186 lines
726 KiB
186 lines
726 KiB
|
5 years ago
|
local buttonSize = 40
|
||
|
|
local padding = 3
|
||
|
|
local rows = 10
|
||
|
|
local cols = 12
|
||
|
|
local scrollStep = 2
|
||
|
|
|
||
|
|
CreateFrame("Frame", "SortedIconPicker", UIParent, "SortedShadowedFrame")
|
||
|
|
SortedIconPicker:SetFrameStrata("FULLSCREEN_DIALOG")
|
||
|
|
SortedIconPicker:SetFrameLevel(10)
|
||
|
|
SortedIconPicker:SetSize(cols * (buttonSize + padding) + 40, rows * (buttonSize + padding) + 16 + 40)
|
||
|
|
SortedIconPicker.backdrop = SortedIconPicker:CreateTexture()
|
||
|
|
SortedIconPicker.backdrop:SetDrawLayer("BACKGROUND")
|
||
|
|
SortedIconPicker.backdrop:SetAllPoints()
|
||
|
|
Sorted.RegisterBackdrop(SortedIconPicker.backdrop)
|
||
|
|
CreateFrame("Frame", "SortedIconPickerDropShadow", SortedIconPicker, "SortedDropShadowTemplate")
|
||
|
|
SortedIconPickerDropShadow:SetFrameLevel(5)
|
||
|
|
SortedIconPicker:EnableMouse(true)
|
||
|
|
SortedIconPicker:Hide()
|
||
|
|
if not Sorted_IsClassic() then
|
||
|
|
SortedIconPicker:RegisterEvent("GLOBAL_MOUSE_DOWN")
|
||
|
|
SortedIconPicker:SetScript("OnEvent", function(self, event)
|
||
|
|
if event == "GLOBAL_MOUSE_DOWN" then
|
||
|
|
if not self:IsMouseOver() then
|
||
|
|
self:Hide()
|
||
|
|
end
|
||
|
|
end
|
||
|
|
end)
|
||
|
|
end
|
||
|
|
CreateFrame("Frame", "SortedIconPickerInner", SortedIconPicker)
|
||
|
|
SortedIconPickerInner:SetPoint("TOPLEFT", 8, -8)
|
||
|
|
SortedIconPickerInner:SetPoint("BOTTOMRIGHT", -8, 8)
|
||
|
|
|
||
|
|
local f = SortedIconPickerInner
|
||
|
|
f.buttons = {}
|
||
|
|
for y = 1, rows do
|
||
|
|
f.buttons[y] = {}
|
||
|
|
for x = 1, cols do
|
||
|
|
local b = CreateFrame("Button", "SortedIconPickerButton_"..x.."_"..y, SortedIconPickerInner)
|
||
|
|
b:SetSize(buttonSize, buttonSize)
|
||
|
|
b:SetPoint("CENTER", f, "TOPLEFT", padding / 2 + (x - 1) * (buttonSize + padding) + buttonSize / 2, -40 - padding / 2 - (y - 1) * (buttonSize + padding) - buttonSize / 2)
|
||
|
|
|
||
|
|
b.iconShadow = b:CreateTexture(b:GetName().."IconGlowTexture", "ARTWORK")
|
||
|
|
b.iconShadow:SetTexture("Interface\\Addons\\Sorted\\Textures\\Item_Shadow")
|
||
|
|
b.iconShadow:SetPoint("TOPLEFT", -40, 40)
|
||
|
|
b.iconShadow:SetPoint("BOTTOMRIGHT", 40, -40)
|
||
|
|
--b.iconGlow:SetBlendMode("ADD")
|
||
|
|
b.iconShadow:Hide()
|
||
|
|
|
||
|
|
b:SetScript("OnClick", function(self, button)
|
||
|
|
SortedIconPicker.func(self.icon)
|
||
|
|
SortedIconPicker:Hide()
|
||
|
|
end)
|
||
|
|
b:SetScript("OnEnter", function(self, button)
|
||
|
|
self:SetSize(buttonSize * 1.45, buttonSize * 1.45)
|
||
|
|
self.iconShadow:Show()
|
||
|
|
self.iconShadow:SetDrawLayer("BACKGROUND")
|
||
|
|
self:SetFrameStrata("TOOLTIP")
|
||
|
|
self:GetNormalTexture():SetVertexColor(1, 1, 1, 1)
|
||
|
|
self:GetNormalTexture():SetTexCoord(0,1,0,1)
|
||
|
|
SortedTooltip.Schedule(function()
|
||
|
|
GameTooltip:SetOwner(self, "ANCHOR_LEFT")
|
||
|
|
GameTooltip:ClearLines()
|
||
|
|
GameTooltip:AddLine("|cffffffff"..self.icon)
|
||
|
|
GameTooltip:Show()
|
||
|
|
end)
|
||
|
|
end)
|
||
|
|
b:SetScript("OnLeave", function(self, button)
|
||
|
|
self:SetSize(buttonSize, buttonSize)
|
||
|
|
self.iconShadow:Hide()
|
||
|
|
self:SetFrameStrata("FULLSCREEN_DIALOG")
|
||
|
|
self:GetNormalTexture():SetVertexColor(0.9, 0.9, 0.9, 1)
|
||
|
|
self:GetNormalTexture():SetTexCoord(0.1,0.9,0.1,0.9)
|
||
|
|
SortedTooltip.Cancel()
|
||
|
|
end)
|
||
|
|
b:HookScript("OnMouseDown", function(self, button)
|
||
|
|
if button == "LeftButton" then
|
||
|
|
self:SetSize(buttonSize * 1.3, buttonSize * 1.3)
|
||
|
|
end
|
||
|
|
end)
|
||
|
|
|
||
|
|
f.buttons[y][x] = b
|
||
|
|
end
|
||
|
|
end
|
||
|
|
|
||
|
|
f:SetScript("OnHide", function(self)
|
||
|
|
self.icons = nil
|
||
|
|
self.filteredIcons = nil
|
||
|
|
end)
|
||
|
|
|
||
|
|
function SortedIconPickerInner:FilterIcons()
|
||
|
|
self.filteredIcons = {}
|
||
|
|
self.count = 0
|
||
|
|
if self.icons then
|
||
|
|
local text = self.searchBox.editBox:GetText()
|
||
|
|
local s2 = text:lower():gsub("%s+", ""):gsub("%p+", "")
|
||
|
|
for k, v in pairs(self.icons) do
|
||
|
|
local s1 = v:lower():gsub("%s+", ""):gsub("%p+", "")
|
||
|
|
if text == "" or s1:find(s2) then
|
||
|
|
table.insert(self.filteredIcons, k)
|
||
|
|
self.count = self.count + 1
|
||
|
|
end
|
||
|
|
end
|
||
|
|
local max = math.ceil(self.count / (cols * scrollStep) - math.floor(rows / scrollStep) + 1)
|
||
|
|
if max < 1 then max = 1 end
|
||
|
|
self.scrollBar:SetMinMaxValues(1, max)
|
||
|
|
self:UpdateButtons()
|
||
|
|
end
|
||
|
|
end
|
||
|
|
|
||
|
|
function SortedIconPickerInner:UpdateButtons()
|
||
|
|
if self.count then
|
||
|
|
local index = self.scrollBar:GetValue() * cols * scrollStep - cols * scrollStep
|
||
|
|
index = self.count - index
|
||
|
|
for y = 1, rows do
|
||
|
|
for x = 1, cols do
|
||
|
|
local b = self.buttons[y][x]
|
||
|
|
if self.filteredIcons[index] then
|
||
|
|
b.icon = self.icons[self.filteredIcons[index]]
|
||
|
|
b:SetNormalTexture("Interface\\Icons\\"..b.icon)
|
||
|
|
b:Show()
|
||
|
|
if b:IsMouseOver() then
|
||
|
|
GameTooltip:SetOwner(b, "ANCHOR_LEFT")
|
||
|
|
GameTooltip:ClearLines()
|
||
|
|
GameTooltip:AddLine("|cffffffff"..b.icon)
|
||
|
|
GameTooltip:Show()
|
||
|
|
b:GetNormalTexture():SetVertexColor(1, 1, 1, 1)
|
||
|
|
b:GetNormalTexture():SetTexCoord(0,1,0,1)
|
||
|
|
else
|
||
|
|
b:GetNormalTexture():SetVertexColor(0.9, 0.9, 0.9, 1)
|
||
|
|
b:GetNormalTexture():SetTexCoord(0.1,0.9,0.1,0.9)
|
||
|
|
end
|
||
|
|
else
|
||
|
|
b:Hide()
|
||
|
|
end
|
||
|
|
index = index - 1
|
||
|
|
end
|
||
|
|
end
|
||
|
|
end
|
||
|
|
end
|
||
|
|
|
||
|
|
f.scrollBar = CreateFrame("Slider", "SortedIconPickerScrollBar", SortedIconPicker, "MinimalScrollBarTemplate")
|
||
|
|
f.scrollBar.trackBG:Hide()
|
||
|
|
f.scrollBar:SetPoint("TOPRIGHT", -8, -64)
|
||
|
|
f.scrollBar:SetPoint("BOTTOM", 0, 24)
|
||
|
|
f.scrollBar:SetValueStep(1)
|
||
|
|
f.scrollBar.ScrollUpButton:SetScript("OnClick", function(self, button)
|
||
|
|
end)
|
||
|
|
f.scrollBar.ScrollDownButton:SetScript("OnClick", function(self, button)
|
||
|
|
end)
|
||
|
|
f.scrollBar:SetScript("OnValueChanged", function(self)
|
||
|
|
self:SetValue(math.floor(self:GetValue()))
|
||
|
|
SortedIconPickerInner:UpdateButtons()
|
||
|
|
end)
|
||
|
|
f.scrollBar:SetMinMaxValues(1, 1)
|
||
|
|
f.scrollBar:SetValue(1)
|
||
|
|
|
||
|
|
f:EnableMouseWheel(1)
|
||
|
|
f:SetScript("OnMouseWheel", function(self, delta)
|
||
|
|
self.scrollBar:SetValue(self.scrollBar:GetValue() - delta)
|
||
|
|
end)
|
||
|
|
|
||
|
|
f.searchBox = CreateFrame("Frame", "SortedIconPickerSearchBox", SortedIconPickerInner, "SortedLargeInputBoxTemplate")
|
||
|
|
f.searchBox:SetPoint("TOPLEFT", 2, -4)
|
||
|
|
f.searchBox:SetWidth(384)
|
||
|
|
f.searchBox.editBox:SetScript("OnTextChanged", function(self, userInput)
|
||
|
|
SortedIconPickerInner:FilterIcons()
|
||
|
|
end)
|
||
|
|
f.searchBox.editBox:SetAutoFocus(true)
|
||
|
|
|
||
|
|
f.closeButton = CreateFrame("Button", "SortedIconPickerCloseButton", SortedIconPicker, "UIPanelCloseButton")
|
||
|
|
f.closeButton:SetPoint("TOPRIGHT", -4, -4)
|
||
|
|
|
||
|
|
function Sorted_PickIcon(parent, func)
|
||
|
|
if Sorted_IsClassic() then
|
||
|
|
SortedIconPickerInner.icons = {"Ability_Ambush","Ability_BackStab","Ability_BullRush","Ability_CheapShot","Ability_Creature_Cursed_01","Ability_Creature_Cursed_02","Ability_Creature_Cursed_03","Ability_Creature_Cursed_04","Ability_Creature_Cursed_05","Ability_Creature_Disease_01","Ability_Creature_Disease_02","Ability_Creature_Disease_03","Ability_Creature_Disease_04","Ability_Creature_Disease_05","Ability_Creature_Poison_01","Ability_Creature_Poison_02","Ability_Creature_Poison_03","Ability_Creature_Poison_04","Ability_Creature_Poison_05","Ability_Creature_Poison_06","Ability_CriticalStrike","Ability_Defend","Ability_Devour","Ability_Druid_AquaticForm","Ability_Druid_Bash","Ability_Druid_CatForm","Ability_Druid_CatFormAttack","Ability_Druid_ChallangingRoar","Ability_Druid_Cower","Ability_Druid_Dash","Ability_Druid_DemoralizingRoar","Ability_Druid_Disembowel","Ability_Druid_Enrage","Ability_Druid_FerociousBite","Ability_Druid_Mangle","Ability_Druid_Mangle.tga","Ability_Druid_Maul","Ability_Druid_Rake","Ability_Druid_Ravage","Ability_Druid_SupriseAttack","Ability_Druid_Swipe","Ability_Druid_TravelForm","Ability_DualWield","Ability_Ensnare","Ability_EyeOfTheOwl","Ability_FiegnDead","Ability_GhoulFrenzy","Ability_GolemStormBolt","Ability_GolemThunderClap","Ability_Gouge","Ability_Hibernation","Ability_Hunter_AimedShot","Ability_Hunter_AspectOfTheMonkey","Ability_Hunter_BeastCall","Ability_Hunter_BeastCall02","Ability_Hunter_BeastSoothe","Ability_Hunter_BeastTaming","Ability_Hunter_BeastTraining","Ability_Hunter_CriticalShot","Ability_Hunter_EagleEye","Ability_Hunter_Harass","Ability_Hunter_MendPet","Ability_Hunter_Pathfinding","Ability_Hunter_Pet_Bat","Ability_Hunter_Pet_Bear","Ability_Hunter_Pet_Boar","Ability_Hunter_Pet_Cat","Ability_Hunter_Pet_Crab","Ability_Hunter_Pet_Crocolisk","Ability_Hunter_Pet_Gorilla","Ability_Hunter_Pet_Hyena","Ability_Hunter_Pet_Owl","Ability_Hunter_Pet_Raptor","Ability_Hunter_Pet_Scorpid","Ability_Hunter_Pet_Spider","Ability_Hunter_Pet_TallStrider","Ability_Hunter_Pet_Turtle","Ability_Hunter_Pet_Vulture","Ability_Hunter_Pet_WindSerpent","Ability_Hunter_Pet_Wolf","Ability_Hunter_Quickshot","Ability_Hunter_RunningShot","Ability_Hunter_SniperShot","Ability_Hunter_SwiftStrike","Ability_ImpalingBolt","Ability_Kick","Ability_Marksmanship","Ability_MeleeDamage","Ability_Mount_BlackDireWolf","Ability_Mount_BlackPanther","Ability_Mount_Charger","Ability_Mount_Dreadsteed","Ability_Mount_JungleTiger","Ability_Mount_Kodo_01","Ability_Mount_Kodo_02","Ability_Mount_Kodo_03","Ability_Mount_MechaStrider","Ability_Mount_MountainRam","Ability_Mount_NightmareHorse","Ability_Mount_PinkTiger","Ability_Mount_Raptor","Ability_Mount_RidingHorse","Ability_Mount_Undeadhorse","Ability_Mount_WhiteDireWolf","Ability_Mount_WhiteTiger","Ability_Parry","Ability_Physical_Taunt","Ability_PierceDamage","Ability_PoisonArrow","Ability_Poisons","Ability_PoisonSting","Ability_Racial_Avatar","Ability_Racial_BearForm","Ability_Racial_BloodRage","Ability_Racial_Cannibalize","Ability_Racial_ShadowMeld","Ability_Racial_Ultravision","Ability_Repair","Ability_Rogue_Ambush","Ability_Rogue_Disguise","Ability_Rogue_Distract","Ability_Rogue_DualWeild","Ability_Rogue_Eviscerate","Ability_Rogue_FeignDeath","Ability_Rogue_Feint","Ability_Rogue_Garrote","Ability_Rogue_KidneyShot","Ability_Rogue_Rupture","Ability_Rogue_SliceDice","Ability_Rogue_Sprint","Ability_Rogue_Trip","Ability_Sap","Ability_Seal","Ability_SearingArrow","Ability_ShockWave","Ability_ShootWand","Ability_Smash","Ability_Spy","Ability_Stealth","Ability_SteelMelee","Ability_Suffocate","Ability_TheBlackArrow","Ability_Throw","Ability_ThunderBolt","Ability_ThunderClap","Ability_TownWatch","Ability_Tracking","Ability_TrueShot","Ability_UpgradeMoonGlaive","Ability_Vanish","Ability_Warrior_BattleShout","Ability_Warrior_Challange","Ability_Warrior_Charge","Ability_Warrior_Cleave","Ability_Warrior_DecisiveStrike","Ability_Warrior_DefensiveStance","Ability_Warrior_Disarm","Ability_Warrior_InnerRage","Ability_Warrior_OffensiveStance","Ability_Warrior_PunishingBlow","Ability_Warrior_Reveng
|
||
|
|
else
|
||
|
|
SortedIconPickerInner.icons = {"inv_wingedlion2mount_silver","inv_wingedlion2mount_dark","inv_giantbeastmount2_orange","inv_giantbeastmount2_green","inv_giantbeastmount2_blue","inv_giantbeastmount_orange","inv_giantbeastmount_green","inv_giantbeastmount_blue","inv_darkhoundmount_draka_orange","inv_darkhoundmount_draka_green","inv_darkhoundmount_draka_blue","inv_maldraxxusflyermount_red","inv_maldraxxusflyermount_green","inv_maldraxxusflyermount_blue","inv_maldraxxusflyermount_black","spell_arcane_teleportoribos","spell_arcane_portaloribos","inv_dragonwhelpoutland2_light","inv_devourermediummount","inv_ore_shadestone","inv_ore_porousstone","inv_tradeskill_cooking_shadowlandsfeast_small01","inv_tradeskill_cooking_shadowlandsfeast_large01","runesmith_icon","inv_jewelcrafting_90_maxlvlring_yellow","inv_jewelcrafting_90_maxlvlneck_yellow","inv_jewelcrafting_90_maxlvlneck_orange","inv_jewelcrafting_90_lvlupring_yellow","inv_jewelcrafting_90_lvlupneck_yellow","inv_jewelcrafting_90_lvlupneck_orange","item_revendreth_paragonchest_03","item_revendreth_paragonchest_02","item_maldraxxus_paragonchest_03","item_maldraxxus_paragonchest_02","item_bastion_paragonchest_03","item_bastion_paragonchest_02","item_ardenweald_paragonchest_03","item_ardenweald_paragonchest_02","item_revendreth_paragonchest_01","item_maldraxxus_paragonchest_01","item_bastion_paragonchest_01","item_ardenweald_paragonchest_01","9xp_sigil_maldraxxus01","9xp_sigil_ardenweald01","inv_misc_token_boost_shadowlands","ui_embercourt-emoji-veryhappy","ui_embercourt-emoji-uncomfortable","ui_embercourt-emoji-miserable","ui_embercourt-emoji-happy","ui_embercourt-emoji-elated","inv_ore_elethium_nugget","inv_ore_elethium","inv_squirrelardenweald_yellow","inv_squirrelardenweald_red","inv_squirrelardenweald_dark","inv_squirrelardenweald_blue","inv_ardenwealdpod","inv_fox2_white","inv_fox2_teal","inv_fox2_red","inv_fox2_purple","inv_fox2_orange","inv_fox2_green","inv_fox2_gold","inv_fox2_darkred","inv_fox2_blue","inv_fox2_black","inv_treepetred","inv_treepetpurple","inv_treepetorange","inv_jewelcrafting_90_maxlvlneck_red","inv_jewelcrafting_90_maxlvlneck_purple","inv_jewelcrafting_90_maxlvlneck_green","inv_jewelcrafting_90_maxlvlneck_blue","inv_stygia","inv_soulash","inv_phantasma","inv_jewelcrafting_90_reagent_red","inv_jewelcrafting_90_reagent_purple","inv_jewelcrafting_90_reagent_green","inv_jewelcrafting_90_reagent_blue","inv_jewelcrafting_90_rarecut_yellow","inv_jewelcrafting_90_rarecut_red","inv_jewelcrafting_90_rarecut_purple","inv_jewelcrafting_90_rarecut_orange","inv_jewelcrafting_90_rarecut_green","inv_jewelcrafting_90_rarecut_blue","inv_jewelcrafting_90_maxlvlring_red","inv_jewelcrafting_90_maxlvlring_purple","inv_jewelcrafting_90_maxlvlring_orange","inv_jewelcrafting_90_maxlvlring_blue","inv_jewelcrafting_90_lvlupring_red","inv_jewelcrafting_90_lvlupring_purple","inv_jewelcrafting_90_lvlupring_orange","inv_jewelcrafting_90_lvlupring_blue","inv_jewelcrafting_90_lvlupneck_red","inv_jewelcrafting_90_lvlupneck_purple","inv_jewelcrafting_90_lvlupneck_green","inv_jewelcrafting_90_lvlupneck_blue","inv_jewelcrafting_90_laestritesetting","inv_jewelcrafting_90_gem_yellow","inv_jewelcrafting_90_gem_red","inv_jewelcrafting_90_gem_purple","inv_jewelcrafting_90_gem_orange","inv_jewelcrafting_90_gem_green","inv_jewelcrafting_90_gem_blue","inv_jewelcrafting_90_elethiumsetting","inv_jewelcrafting_90_cutuncommon_yellow","inv_jewelcrafting_90_cutuncommon_red","inv_jewelcrafting_90_cutuncommon_purple","inv_jewelcrafting_90_cutuncommon_orange","inv_jewelcrafting_90_cutuncommon_green","inv_jewelcrafting_90_cutuncommon_blue","inv_sword_1h_maldraxxusruneblade_d_02","inv_sword_1h_maldraxxusruneblade_d_01","inv_bow_1h_newplayer_a_01","inv_staff_2h_newplayer_a_02","inv_staff_2h_newplayer_a_01","inv_glaive_1h_newplayer_a_01","inv_mace_1h_newplayer_a_01","inv_mace_2h_newplayer_a_01","inv_knife_1h_newplayer_a_02","inv_knife_1h_newplayer_a_01","inv_sword_2h_newplayer_a_02","inv_sword_2h_newplayer_a_01","inv_sword_1h_newplayer_a_03","inv_sword_1h_newplayer_a_02","inv_sword_1h_newplayer_a_01","inv_s
|
||
|
|
end
|
||
|
|
|
||
|
|
SortedIconPicker.func = func
|
||
|
|
SortedIconPicker:SetPoint("TOPLEFT", parent, "BOTTOMRIGHT")
|
||
|
|
SortedIconPicker:Show()
|
||
|
|
|
||
|
|
SortedIconPickerInner.filteredIcons = {}
|
||
|
|
SortedIconPickerInner:FilterIcons()
|
||
|
|
end
|