From 7148a9a5fa0496efa6a6895bca9fef0b459ab5fe Mon Sep 17 00:00:00 2001 From: Road-block Date: Tue, 6 Feb 2018 00:21:10 +0200 Subject: [PATCH] Remove some settings from member addon menu that do not affect addon operation. Add more groupings to standings tablet: - 'by armor type' and 'by role' (no spec information in vanilla so this one is messy) --- alts.lua | 2 +- bids.lua | 2 +- localization.lua | 24 +++++++ logs.lua | 2 +- loot.lua | 2 +- migrations.lua | 2 +- prices.lua | 2 +- reserves.lua | 2 +- shootyepgp.lua | 4 +- shootyepgp.toc | 4 +- standings.lua | 169 +++++++++++++++++++++++++++++++++++++++++++---- 11 files changed, 193 insertions(+), 22 deletions(-) diff --git a/alts.lua b/alts.lua index 189cddc..5d0a17f 100644 --- a/alts.lua +++ b/alts.lua @@ -114,5 +114,5 @@ function sepgp_alts:OnTooltipUpdate() end end --- GLOBALS: sepgp_saychannel,sepgp_groupbyclass,sepgp_raidonly,sepgp_decay,sepgp_reservechannel,sepgp_main,sepgp_progress,sepgp_discount,sepgp_log,sepgp_dbver,sepgp_looted +-- GLOBALS: sepgp_saychannel,sepgp_groupbyclass,sepgp_groupbyarmor,sepgp_groupbyrole,sepgp_raidonly,sepgp_decay,sepgp_reservechannel,sepgp_main,sepgp_progress,sepgp_discount,sepgp_log,sepgp_dbver,sepgp_looted -- GLOBALS: sepgp,sepgp_prices,sepgp_standings,sepgp_bids,sepgp_loot,sepgp_reserves,sepgp_alts,sepgp_logs diff --git a/bids.lua b/bids.lua index 88a2ee1..d798a36 100644 --- a/bids.lua +++ b/bids.lua @@ -228,5 +228,5 @@ function sepgp_bids:OnTooltipUpdate() end end --- GLOBALS: sepgp_saychannel,sepgp_groupbyclass,sepgp_raidonly,sepgp_decay,sepgp_reservechannel,sepgp_main,sepgp_progress,sepgp_discount,sepgp_log,sepgp_dbver,sepgp_looted +-- GLOBALS: sepgp_saychannel,sepgp_groupbyclass,sepgp_groupbyarmor,sepgp_groupbyrole,sepgp_raidonly,sepgp_decay,sepgp_reservechannel,sepgp_main,sepgp_progress,sepgp_discount,sepgp_log,sepgp_dbver,sepgp_looted -- GLOBALS: sepgp,sepgp_prices,sepgp_standings,sepgp_bids,sepgp_loot,sepgp_reserves,sepgp_alts,sepgp_logs diff --git a/localization.lua b/localization.lua index e30da73..958f53f 100644 --- a/localization.lua +++ b/localization.lua @@ -54,6 +54,18 @@ Import overwrites all existing EPGP values. Paste all the csv data here replacing this text, then hit Import. Results will print here when done.]], + ["Group by armor"] = true, + ["Group members by armor."] = true, + ["Group by roles"] = true, + ["Group members by roles."] = true, + ["CLOTH"] = true, + ["LEATHER"] = true, + ["MAIL"] = true, + ["PLATE"] = true, + ["TANK"] = true, + ["HEALER"] = true, + ["CASTER"] = true, + ["PHYS DPS"] = true, -- shootyepgp ["{shootyepgp}Type \"+\" if on main, or \"+\" (without quotes) if on alt within %dsec."] = true, ["|cffFF3333|Hshootybid:1:$ML|h[Mainspec/NEED]|h|r"] = true, @@ -245,6 +257,18 @@ L:RegisterTranslations("zhCN", function() return { 粘贴这里的所有CSV数据替换文本, 然后再导入. 完成后打印结果.]], + ["Group by armor"] = "Group by armor", + ["Group members by armor."] = "Group members by armor.", + ["Group by roles"] = "Group by roles", + ["Group members by roles."] = "Group members by roles.", + ["CLOTH"] = "CLOTH", + ["LEATHER"] = "LEATHER", + ["MAIL"] = "MAIL", + ["PLATE"] = "PLATE", + ["TANK"] = "TANK", + ["HEALER"] = "HEALER", + ["CASTER"] = "CASTER", + ["PHYS DPS"] = "PHYS DPS", -- shootyepgp ["{shootyepgp}Type \"+\" if on main, or \"+\" (without quotes) if on alt within %dsec."] = "{shootyepgp}使用 \"+\" 如果你在大号上, 或者 \"+\" (没有引号) 如果在小号 %d秒.", ["|cffFF3333|Hshootybid:1:$ML|h[Mainspec/NEED]|h|r"] = "|cffFF3333|Hshootybid:1:$ML|h[主天赋/需求]|h|r", diff --git a/logs.lua b/logs.lua index cfd8354..c208bfb 100644 --- a/logs.lua +++ b/logs.lua @@ -121,5 +121,5 @@ function sepgp_logs:OnTooltipUpdate() end end --- GLOBALS: sepgp_saychannel,sepgp_groupbyclass,sepgp_raidonly,sepgp_decay,sepgp_reservechannel,sepgp_main,sepgp_progress,sepgp_discount,sepgp_log,sepgp_dbver,sepgp_looted +-- GLOBALS: sepgp_saychannel,sepgp_groupbyclass,sepgp_groupbyarmor,sepgp_groupbyrole,sepgp_raidonly,sepgp_decay,sepgp_reservechannel,sepgp_main,sepgp_progress,sepgp_discount,sepgp_log,sepgp_dbver,sepgp_looted -- GLOBALS: sepgp,sepgp_prices,sepgp_standings,sepgp_bids,sepgp_loot,sepgp_reserves,sepgp_alts,sepgp_logs diff --git a/loot.lua b/loot.lua index a53ef2e..5ba5014 100644 --- a/loot.lua +++ b/loot.lua @@ -121,5 +121,5 @@ function sepgp_loot:OnTooltipUpdate() end end --- GLOBALS: sepgp_saychannel,sepgp_groupbyclass,sepgp_raidonly,sepgp_decay,sepgp_reservechannel,sepgp_main,sepgp_progress,sepgp_discount,sepgp_log,sepgp_dbver,sepgp_looted +-- GLOBALS: sepgp_saychannel,sepgp_groupbyclass,sepgp_groupbyarmor,sepgp_groupbyrole,sepgp_raidonly,sepgp_decay,sepgp_reservechannel,sepgp_main,sepgp_progress,sepgp_discount,sepgp_log,sepgp_dbver,sepgp_looted -- GLOBALS: sepgp,sepgp_prices,sepgp_standings,sepgp_bids,sepgp_loot,sepgp_reserves,sepgp_alts,sepgp_logs diff --git a/migrations.lua b/migrations.lua index c113ad4..52c3ac1 100644 --- a/migrations.lua +++ b/migrations.lua @@ -19,5 +19,5 @@ function sepgp:v2tov3() sepgp_dbver = 3 end --- GLOBALS: sepgp_saychannel,sepgp_groupbyclass,sepgp_raidonly,sepgp_decay,sepgp_reservechannel,sepgp_main,sepgp_progress,sepgp_discount,sepgp_log,sepgp_dbver,sepgp_looted +-- GLOBALS: sepgp_saychannel,sepgp_groupbyclass,sepgp_groupbyarmor,sepgp_groupbyrole,sepgp_raidonly,sepgp_decay,sepgp_reservechannel,sepgp_main,sepgp_progress,sepgp_discount,sepgp_log,sepgp_dbver,sepgp_looted -- GLOBALS: sepgp,sepgp_prices,sepgp_standings,sepgp_bids,sepgp_loot,sepgp_reserves,sepgp_alts,sepgp_logs diff --git a/prices.lua b/prices.lua index c577a06..8ba821e 100644 --- a/prices.lua +++ b/prices.lua @@ -812,5 +812,5 @@ function sepgp_prices:GetPrice(item,progress) return price end --- GLOBALS: sepgp_saychannel,sepgp_groupbyclass,sepgp_raidonly,sepgp_decay,sepgp_reservechannel,sepgp_main,sepgp_progress,sepgp_discount,sepgp_log,sepgp_dbver,sepgp_looted +-- GLOBALS: sepgp_saychannel,sepgp_groupbyclass,sepgp_groupbyarmor,sepgp_groupbyrole,sepgp_raidonly,sepgp_decay,sepgp_reservechannel,sepgp_main,sepgp_progress,sepgp_discount,sepgp_log,sepgp_dbver,sepgp_looted -- GLOBALS: sepgp,sepgp_prices,sepgp_standings,sepgp_bids,sepgp_loot,sepgp_reserves,sepgp_alts,sepgp_logs \ No newline at end of file diff --git a/reserves.lua b/reserves.lua index be9eb6e..f88aed7 100644 --- a/reserves.lua +++ b/reserves.lua @@ -120,5 +120,5 @@ function sepgp_reserves:OnTooltipUpdate() end end --- GLOBALS: sepgp_saychannel,sepgp_groupbyclass,sepgp_raidonly,sepgp_decay,sepgp_reservechannel,sepgp_main,sepgp_progress,sepgp_discount,sepgp_log,sepgp_dbver,sepgp_looted +-- GLOBALS: sepgp_saychannel,sepgp_groupbyclass,sepgp_groupbyarmor,sepgp_groupbyrole,sepgp_raidonly,sepgp_decay,sepgp_reservechannel,sepgp_main,sepgp_progress,sepgp_discount,sepgp_log,sepgp_dbver,sepgp_looted -- GLOBALS: sepgp,sepgp_prices,sepgp_standings,sepgp_bids,sepgp_loot,sepgp_reserves,sepgp_alts,sepgp_logs diff --git a/shootyepgp.lua b/shootyepgp.lua index 48d7c8b..aafd714 100644 --- a/shootyepgp.lua +++ b/shootyepgp.lua @@ -1355,6 +1355,7 @@ function sepgp:buildMenu() name = L["Raid Progress"], desc = L["Highest Tier the Guild is raiding.\nUsed to adjust GP Prices.\nUsed for suggested EP awards."], order = 90, + hidden = function() return not (admin()) end, get = function() return sepgp_progress end, set = function(v) sepgp_progress = v @@ -1409,6 +1410,7 @@ function sepgp:buildMenu() name = L["Offspec Price %"], desc = L["Set Offspec Items GP Percent."], order = 115, + hidden = function() return not (admin()) end, get = function() return sepgp_discount end, set = function(v) sepgp_discount = v @@ -2250,5 +2252,5 @@ function sepgp:EasyMenu_Initialize(level, menuList) end end --- GLOBALS: sepgp_saychannel,sepgp_groupbyclass,sepgp_raidonly,sepgp_decay,sepgp_reservechannel,sepgp_main,sepgp_progress,sepgp_discount,sepgp_altspool,sepgp_altpercent,sepgp_log,sepgp_dbver,sepgp_looted,sepgp_debug +-- GLOBALS: sepgp_saychannel,sepgp_groupbyclass,sepgp_groupbyarmor,sepgp_groupbyrole,sepgp_raidonly,sepgp_decay,sepgp_reservechannel,sepgp_main,sepgp_progress,sepgp_discount,sepgp_altspool,sepgp_altpercent,sepgp_log,sepgp_dbver,sepgp_looted,sepgp_debug -- GLOBALS: sepgp,sepgp_prices,sepgp_standings,sepgp_bids,sepgp_loot,sepgp_reserves,sepgp_alts,sepgp_logs diff --git a/shootyepgp.toc b/shootyepgp.toc index cc9744f..f0bfcd3 100644 --- a/shootyepgp.toc +++ b/shootyepgp.toc @@ -7,10 +7,10 @@ ## X-Website: https://github.com/Road-block/shootyepgp/releases/latest ## X-Category: Guild ## X-Credits: shooty, Qcat(zhCN) -## Version: 3.40 +## Version: 3.40.1 ## X-Alpha: ## OptionalDeps: Ace2 -## SavedVariables: sepgp_saychannel, sepgp_groupbyclass, sepgp_raidonly, sepgp_dbver, sepgp_debug +## SavedVariables: sepgp_saychannel, sepgp_groupbyclass, sepgp_groupbyarmor, sepgp_groupbyrole, sepgp_raidonly, sepgp_dbver, sepgp_debug ## SavedVariablesPerCharacter: sepgp_main, sepgp_log, sepgp_looted, sepgp_decay, sepgp_reservechannel, sepgp_progress, sepgp_discount, sepgp_altspool, sepgp_altpercent Libs\AceLibrary\AceLibrary.lua diff --git a/standings.lua b/standings.lua index d582c0b..6468012 100644 --- a/standings.lua +++ b/standings.lua @@ -4,8 +4,50 @@ local C = AceLibrary("Crayon-2.0") local BC = AceLibrary("Babble-Class-2.2") local L = AceLibrary("AceLocale-2.2"):new("shootyepgp") +local _G = getfenv(0) sepgp_standings = sepgp:NewModule("sepgp_standings", "AceDB-2.0") +local groupings = { + "sepgp_groupbyclass", + "sepgp_groupbyarmor", + "sepgp_groupbyrole", +} +local PLATE, MAIL, LEATHER, CLOTH = 4,3,2,1 +local DPS, CASTER, HEALER, TANK = 4,3,2,1 +local class_to_armor = { + PALADIN = PLATE, + WARRIOR = PLATE, + HUNTER = MAIL, + SHAMAN = MAIL, + DRUID = LEATHER, + ROGUE = LEATHER, + MAGE = CLOTH, + PRIEST = CLOTH, + WARLOCK = CLOTH, +} +local armor_text = { + [CLOTH] = L["CLOTH"], + [LEATHER] = L["LEATHER"], + [MAIL] = L["MAIL"], + [PLATE] = L["PLATE"], +} +local class_to_role = { + PALADIN = {HEALER,DPS,TANK,CASTER}, + PRIEST = {HEALER,CASTER}, + DRUID = {HEALER,TANK,DPS,CASTER}, + SHAMAN = {HEALER,DPS,CASTER}, + MAGE = {CASTER}, + WARLOCK = {CASTER}, + ROGUE = {DPS}, + HUNTER = {DPS}, + WARRIOR = {TANK,DPS}, +} +local role_text = { + [TANK] = L["TANK"], + [HEALER] = L["HEALER"], + [CASTER] = L["CASTER"], + [DPS] = L["PHYS DPS"], +} local shooty_export = CreateFrame("Frame", "shooty_exportframe", UIParent) shooty_export:SetWidth(250) shooty_export:SetHeight(150) @@ -63,7 +105,7 @@ shooty_export.scroll = CreateFrame("ScrollFrame", "shooty_exportscroll", shooty_ shooty_export.scroll:SetPoint('TOPLEFT', shooty_export, 'TOPLEFT', 8, -30) shooty_export.scroll:SetPoint('BOTTOMRIGHT', shooty_export, 'BOTTOMRIGHT', -30, 8) shooty_export.scroll:SetScrollChild(shooty_export.edit) -table.insert(UISpecialFrames,"shooty_exportframe") +sepgp:make_escable("shooty_exportframe","add") function sepgp_standings:Export() shooty_export.action:Hide() @@ -132,6 +174,46 @@ function sepgp_standings.import() end end +local class_cache = setmetatable({},{__index = function(t,k) + local class + if BC:HasReverseTranslation(k) then + class = string.upper(BC:GetReverseTranslation(k)) + else + class = string.upper(k) + end + if (class) then + rawset(t,k,class) + return class + end + return k +end}) +function sepgp_standings:getArmorClass(class) + class = class_cache[class] + return class_to_armor[class] or 0 +end + +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 class = class_cache[lclass] + local roles = class_to_role[class] + if not (roles) then + player[3]=0 + else + for i,role in ipairs(roles) do + if i==1 then + player[3]=role + else + table.insert(roster,{player[1],player[2],role,player[4],player[5],player[6]}) + end + end + end + end + return roster +end + function sepgp_standings:OnEnable() if not T:IsRegistered("sepgp_standings") then T:Register("sepgp_standings", @@ -153,7 +235,19 @@ function sepgp_standings:OnEnable() "text", L["Group by class"], "tooltipText", L["Group members by class."], "checked", sepgp_groupbyclass, - "func", function() sepgp_standings:ToggleGroupByClass() end + "func", function() sepgp_standings:ToggleGroupBy("sepgp_groupbyclass") end + ) + D:AddLine( + "text", L["Group by armor"], + "tooltipText", L["Group members by armor."], + "checked", sepgp_groupbyarmor, + "func", function() sepgp_standings:ToggleGroupBy("sepgp_groupbyarmor") end + ) + D:AddLine( + "text", L["Group by roles"], + "tooltipText", L["Group members by roles."], + "checked", sepgp_groupbyrole, + "func", function() sepgp_standings:ToggleGroupBy("sepgp_groupbyrole") end ) D:AddLine( "text", L["Refresh"], @@ -230,8 +324,14 @@ function sepgp_standings:Toggle(forceShow) end end -function sepgp_standings:ToggleGroupByClass() - sepgp_groupbyclass = not sepgp_groupbyclass +function sepgp_standings:ToggleGroupBy(setting) + for _,value in ipairs(groupings) do + if value ~= setting then + _G[value] = false + end + end + _G[setting] = not _G[setting] + self:Top() self:Refresh() end @@ -242,7 +342,7 @@ function sepgp_standings:ToggleRaidOnly() end -- Builds a standings table with record: --- name, class, EP, GP, PR +-- name, class, armor_class, roles, EP, GP, PR -- and sorted by PR function sepgp_standings:BuildStandingsTable() local t = { } @@ -269,25 +369,37 @@ function sepgp_standings:BuildStandingsTable() main = C:Colorize(BC:GetHexColor(main_class), main) sepgp.alts[main] = sepgp.alts[main] or {} sepgp.alts[main][name] = class - end + end + local armor_class = self:getArmorClass(class) if ep > 0 then if (sepgp_raidonly) and next(r) then if r[name] then - table.insert(t,{name,class,ep,gp,ep/gp}) + table.insert(t,{name,class,armor_class,ep,gp,ep/gp}) end else - table.insert(t,{name,class,ep,gp,ep/gp}) + table.insert(t,{name,class,armor_class,ep,gp,ep/gp}) end end end if (sepgp_groupbyclass) then table.sort(t, function(a,b) if (a[2] ~= b[2]) then return a[2] > b[2] - else return a[5] > b[5] end + else return a[6] > b[6] 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 a[6] > b[6] end + end) + elseif (sepgp_groupbyrole) then + t = self:getRolesClass(t) -- we are subbing role into armor_class to avoid extra table creation + table.sort(t, function(a,b) + if (a[3] ~= b[3]) then return a[3] > b[3] + else return a[6] > b[6] end + end) else table.sort(t, function(a,b) - return a[5] > b[5] + return a[6] > b[6] end) end return t @@ -302,8 +414,41 @@ function sepgp_standings:OnTooltipUpdate() "text4", C:Orange(L["pr"]), "child_text4R", 1, "child_text4G", 1, "child_text4B", 0, "child_justify4", "RIGHT" ) local t = self:BuildStandingsTable() + local separator for i = 1, table.getn(t) do - local name, class, ep, gp, pr = unpack(t[i]) + local name, class, armor_class, ep, gp, pr = unpack(t[i]) + if (sepgp_groupbyarmor) or (sepgp_groupbyrole) then + if not (separator) then + if (sepgp_groupbyarmor) then + separator = armor_text[armor_class] + elseif (sepgp_groupbyrole) then + separator = role_text[armor_class] + end + if (separator) then + cat:AddLine( + "text", C:Green(separator), + "text2", "", + "text3", "", + "text4", "" + ) + end + else + local last_separator = separator + if (sepgp_groupbyarmor) then + separator = armor_text[armor_class] + elseif (sepgp_groupbyrole) then + separator = role_text[armor_class] + end + if (separator) and (separator ~= last_separator) then + cat:AddLine( + "text", C:Green(separator), + "text2", "", + "text3", "", + "text4", "" + ) + end + end + end local text = C:Colorize(BC:GetHexColor(class), name) local text2 = string.format("%.4g", ep) local text3 = string.format("%.4g", gp) @@ -324,5 +469,5 @@ function sepgp_standings:OnTooltipUpdate() end end --- GLOBALS: sepgp_saychannel,sepgp_groupbyclass,sepgp_raidonly,sepgp_decay,sepgp_reservechannel,sepgp_main,sepgp_progress,sepgp_discount,sepgp_log,sepgp_dbver,sepgp_looted +-- GLOBALS: sepgp_saychannel,sepgp_groupbyclass,sepgp_groupbyarmor,sepgp_groupbyrole,sepgp_raidonly,sepgp_decay,sepgp_reservechannel,sepgp_main,sepgp_progress,sepgp_discount,sepgp_log,sepgp_dbver,sepgp_looted -- GLOBALS: sepgp,sepgp_prices,sepgp_standings,sepgp_bids,sepgp_loot,sepgp_reserves,sepgp_alts,sepgp_logs