From 1f85d99874bf9d7456da1a955666ef57e68c136e Mon Sep 17 00:00:00 2001 From: Horyoshi <42314202+Cinecom@users.noreply.github.com> Date: Thu, 9 Oct 2025 17:42:03 +0200 Subject: [PATCH] Update --- extra_features.lua | 28 +-------- shootyepgp.lua | 16 ++++- shootyepgp.toc | 2 +- standings.lua | 142 +++++++++++++++++++++++++++++++++++++++++---- 4 files changed, 150 insertions(+), 38 deletions(-) diff --git a/extra_features.lua b/extra_features.lua index ee946bf..f22b6f5 100644 --- a/extra_features.lua +++ b/extra_features.lua @@ -140,29 +140,7 @@ end --- Turn loot sounds on/off +-- Initialize loot sounds setting (default: enabled) if sepgp_sound == nil then - sepgp_sound = 1 -end - --- Slash command handler function -local function HandleLootSoundCommand(msg) - local command - if msg then - command = string.lower(msg) - else - command = "" - end - - if command == "on" then - sepgp_sound = 1 - DEFAULT_CHAT_FRAME:AddMessage("Loot sounds |cFF00FF00enabled|r") - elseif command == "off" then - sepgp_sound = 0 - DEFAULT_CHAT_FRAME:AddMessage("Loot sounds |cFFFF0000disabled|r (" .. UnitName("player") .. ", you're boring)") - end -end - --- Register the slash commands -SLASH_LOOTSOUND1 = "/lootsound" -SlashCmdList["LOOTSOUND"] = HandleLootSoundCommand \ No newline at end of file + sepgp_sound = 1 +end \ No newline at end of file diff --git a/shootyepgp.lua b/shootyepgp.lua index 5840be2..35060a2 100644 --- a/shootyepgp.lua +++ b/shootyepgp.lua @@ -306,11 +306,25 @@ function sepgp:buildMenu() desc = L["Only show members in raid."], order = 80, get = function() return not not sepgp_raidonly end, - set = function(v) + set = function(v) sepgp_raidonly = not sepgp_raidonly sepgp:SetRefresh(true) end, } + options.args["loot_sounds"] = { + type = "toggle", + name = "Loot sounds", + desc = "Enable or disable loot sounds.", + order = 82, + get = function() return sepgp_sound == 1 end, + set = function(v) + if sepgp_sound == 1 then + sepgp_sound = 0 + else + sepgp_sound = 1 + end + end, + } options.args["progress_tier_header"] = { type = "header", name = string.format(L["Progress Setting: %s"],sepgp_progress), diff --git a/shootyepgp.toc b/shootyepgp.toc index ea87cb5..cc8086f 100644 --- a/shootyepgp.toc +++ b/shootyepgp.toc @@ -7,7 +7,7 @@ ## X-Website: https://github.com/cinecom/shootyepgp/ ## X-Category: Guild ## X-Credits: shooty, Qcat(zhCN) -## Version: 10.10 +## Version: 10.11 ## X-Alpha: ## OptionalDeps: Ace2 ## SavedVariables: sepgp_saychannel, sepgp_groupbyclass, sepgp_groupbyarmor, sepgp_groupbyrole, sepgp_raidonly, sepgp_dbver, sepgp_debug, sepgp_fubar, sepgp_sound diff --git a/standings.lua b/standings.lua index 7442ccb..ee82775 100644 --- a/standings.lua +++ b/standings.lua @@ -12,6 +12,9 @@ local groupings = { "sepgp_groupbyarmor", "sepgp_groupbyrole", } +-- Column sorting state +local sort_column = "pr" -- default sort by PR +local sort_direction = "desc" -- default descending local PLATE, MAIL, LEATHER, CLOTH = 4,3,2,1 local DPS, CASTER, HEALER, TANK = 4,3,2,1 local class_to_armor = { @@ -195,7 +198,7 @@ function sepgp_standings:getRolesClass(roster) local roster_num = table.getn(roster) for i=1,roster_num do local player = roster[i] - local name, lclass, armor_class, ep, gp, pr = unpack(player) + local name, lclass, armor_class, ep, gp, pr, rankName = unpack(player) local class = class_cache[lclass] local roles = class_to_role[class] if not (roles) then @@ -205,9 +208,9 @@ function sepgp_standings:getRolesClass(roster) if i==1 then player[3]=role else - table.insert(roster,{player[1],player[2],role,player[4],player[5],player[6]}) + table.insert(roster,{player[1],player[2],role,player[4],player[5],player[6],player[7]}) end - end + end end end return roster @@ -224,12 +227,31 @@ function sepgp_standings:OnEnable() "showHintWhenDetached", true, "cantAttach", true, "menu", function() + D:AddLine( + "text", "Sort by EP", + "tooltipText", "Sort standings by EP.", + "checked", sort_column == "ep", + "func", function() sepgp_standings:SetColumnSort("ep") end + ) + D:AddLine( + "text", "Sort by GP", + "tooltipText", "Sort standings by GP.", + "checked", sort_column == "gp", + "func", function() sepgp_standings:SetColumnSort("gp") end + ) + D:AddLine( + "text", "Sort by PR", + "tooltipText", "Sort standings by PR.", + "checked", sort_column == "pr", + "func", function() sepgp_standings:SetColumnSort("pr") end + ) + D:AddLine() D:AddLine( "text", L["Raid Only"], "tooltipText", L["Only show members in raid."], "checked", sepgp_raidonly, "func", function() sepgp_standings:ToggleRaidOnly() end - ) + ) D:AddLine( "text", L["Group by class"], "tooltipText", L["Group members by class."], @@ -248,6 +270,7 @@ function sepgp_standings:OnEnable() "checked", sepgp_groupbyrole, "func", function() sepgp_standings:ToggleGroupBy("sepgp_groupbyrole") end ) + D:AddLine() D:AddLine( "text", L["Refresh"], "tooltipText", L["Refresh window"], @@ -365,6 +388,62 @@ local pr_sorter_standings = function(a,b) end end +-- Column sorting functions +local function sort_by_ep(a, b) + if sort_direction == "desc" then + return tonumber(a[4]) > tonumber(b[4]) + else + return tonumber(a[4]) < tonumber(b[4]) + end +end + +local function sort_by_gp(a, b) + if sort_direction == "desc" then + return tonumber(a[5]) > tonumber(b[5]) + else + return tonumber(a[5]) < tonumber(b[5]) + end +end + +local function sort_by_pr(a, b) + if sort_direction == "desc" then + return tonumber(a[6]) > tonumber(b[6]) + else + return tonumber(a[6]) < tonumber(b[6]) + end +end + +-- Toggle column sort +function sepgp_standings:SetColumnSort(column) + if sort_column == column then + -- Toggle direction if clicking same column + if sort_direction == "desc" then + sort_direction = "asc" + else + sort_direction = "desc" + end + else + -- New column, default to descending + sort_column = column + sort_direction = "desc" + end + self:Top() + self:Refresh() +end + +-- Sort functions for Tablet callbacks +function sepgp_standings:SortByEP() + self:SetColumnSort("ep") +end + +function sepgp_standings:SortByGP() + self:SetColumnSort("gp") +end + +function sepgp_standings:SortByPR() + self:SetColumnSort("pr") +end + function sepgp_standings:BuildStandingsTable() local t = { } local r = { } @@ -402,35 +481,76 @@ function sepgp_standings:BuildStandingsTable() end end end + -- Determine which sort function to use based on selected column + local sort_func + if sort_column == "ep" then + sort_func = sort_by_ep + elseif sort_column == "gp" then + sort_func = sort_by_gp + elseif sort_column == "pr" then + sort_func = sort_by_pr + else + sort_func = pr_sorter_standings + end + if (sepgp_groupbyclass) then table.sort(t, function(a,b) if (a[2] ~= b[2]) then return a[2] > b[2] - else return pr_sorter_standings(a,b) end + else return sort_func(a,b) end end) elseif (sepgp_groupbyarmor) then table.sort(t, function(a,b) if (a[3] ~= b[3]) then return a[3] > b[3] - else return pr_sorter_standings(a,b) end + else return sort_func(a,b) end end) elseif (sepgp_groupbyrole) then t = self:getRolesClass(t) table.sort(t, function(a,b) if (a[3] ~= b[3]) then return a[3] > b[3] - else return pr_sorter_standings(a,b) end + else return sort_func(a,b) end end) else - table.sort(t, pr_sorter_standings) + table.sort(t, sort_func) end return t end function sepgp_standings:OnTooltipUpdate() + -- Build column headers with sort indicators + local ep_indicator = "" + local gp_indicator = "" + local pr_indicator = "" + + if sort_column == "ep" then + if sort_direction == "desc" then + ep_indicator = " \226\150\188" -- down arrow + else + ep_indicator = " \226\150\178" -- up arrow + end + end + + if sort_column == "gp" then + if sort_direction == "desc" then + gp_indicator = " \226\150\188" + else + gp_indicator = " \226\150\178" -- up arrow + end + end + + if sort_column == "pr" then + if sort_direction == "desc" then + pr_indicator = " \226\150\188" + else + pr_indicator = " \226\150\178" -- up arrow + end + end + local cat = T:AddCategory( "columns", 4, "text", C:Orange(L["Name"]), "child_textR", 1, "child_textG", 1, "child_textB", 1, "child_justify", "LEFT", - "text2", C:Orange(L["ep"]), "child_text2R", 1, "child_text2G", 1, "child_text2B", 1, "child_justify2", "RIGHT", - "text3", C:Orange(L["gp"]), "child_text3R", 1, "child_text3G", 1, "child_text3B", 1, "child_justify3", "RIGHT", - "text4", C:Orange(L["pr"]), "child_text4R", 1, "child_text4G", 1, "child_text4B", 0, "child_justify4", "RIGHT" + "text2", C:Orange(L["ep"] .. ep_indicator), "child_text2R", 1, "child_text2G", 1, "child_text2B", 1, "child_justify2", "RIGHT", + "text3", C:Orange(L["gp"] .. gp_indicator), "child_text3R", 1, "child_text3G", 1, "child_text3B", 1, "child_justify3", "RIGHT", + "text4", C:Orange(L["pr"] .. pr_indicator), "child_text4R", 1, "child_text4G", 1, "child_text4B", 0, "child_justify4", "RIGHT" ) local t = self:BuildStandingsTable() local separator