diff --git a/GUI.lua b/GUI.lua index a2cb523..f7505cf 100755 --- a/GUI.lua +++ b/GUI.lua @@ -85,7 +85,7 @@ function GUI:Toggle() if (mainFrame and mainFrame:IsShown()) then GUI:Hide() else - GUI:Show(false, L["EstHonor"]) + GUI:Show(false, L["ThisWeekHonor"]) end end @@ -113,12 +113,15 @@ function GUI:UpdateTableView() button.EstHonor:SetText(); button.EstWeekHonor:SetText(); if HonorSpy.db.factionrealm.estHonorCol.show then - button.EstHonor:SetWidth(80); button.EstWeekHonor:SetWidth(80); else - button.EstHonor:SetWidth(0); button.EstWeekHonor:SetWidth(0); end + if HonorSpy.db.factionrealm.estTodayHonorCol.show then + button.EstHonor:SetWidth(80); + else + button.EstHonor:SetWidth(0); + end button.LstWkHonor:SetText(); button.Standing:SetText(); button.RP:SetText(); @@ -147,27 +150,37 @@ function GUI:UpdateTableView() if tonumber(thisWeekHonor) == 1 then thisWeekHonor = 0 end button.Honor:SetText(colorize(thisWeekHonor, class)); if HonorSpy.db.factionrealm.estHonorCol.show then - button.EstHonor:SetWidth(80); - button.EstWeekHonor:SetWidth(80); + button.EstWeekHonor:SetWidth(100); if (tonumber(estHonor) ~= nil) then local estTodayHonor = estHonor - thisWeekHonor -- This may happen when blizz value is up to date but estimation is not if (estTodayHonor < 0) then - estHonor = thisWeekHonor - estTodayHonor = 0 - end - button.EstHonor:SetText(colorize(estTodayHonor, class)); + estHonor = thisWeekHonor + end button.EstWeekHonor:SetText(colorize(estHonor, class)); else - button.EstHonor:SetText(); button.EstWeekHonor:SetText(); end else - button.EstHonor:SetText(); - button.EstHonor:SetWidth(0); button.EstWeekHonor:SetText(); button.EstWeekHonor:SetWidth(0); end + if HonorSpy.db.factionrealm.estTodayHonorCol.show then + button.EstHonor:SetWidth(100); + if (tonumber(estHonor) ~= nil) then + local estTodayHonor = estHonor - thisWeekHonor + -- This may happen when blizz value is up to date but estimation is not + if (estTodayHonor < 0) then + estTodayHonor = 0 + end + button.EstHonor:SetText(colorize(estTodayHonor, class)); + else + button.EstHonor:SetText(); + end + else + button.EstHonor:SetText(); + button.EstHonor:SetWidth(0); + end button.LstWkHonor:SetText(colorize(lastWeekHonor, class)); button.Standing:SetText(colorize(standing, class)); button.RP:SetText(colorize(RP, class)); @@ -201,7 +214,10 @@ function GUI:PrepareGUI() _G["HonorSpyGUI_MainFrame"] = mainFrame tinsert(UISpecialFrames, "HonorSpyGUI_MainFrame") -- allow ESC close mainFrame:SetTitle(L["HonorSpy Standings"]) - if HonorSpy.db.factionrealm.estHonorCol.show then mainFrame:SetWidth(760) else mainFrame:SetWidth(600) end + local pixels = 600 + if HonorSpy.db.factionrealm.estHonorCol.show then pixels = 700 end + if HonorSpy.db.factionrealm.estTodayHonorCol.show then pixels = pixels + 100 end + mainFrame:SetWidth(pixels) mainFrame:SetLayout("List") mainFrame:EnableResize(false) @@ -239,33 +255,37 @@ function GUI:PrepareGUI() btn:SetText(colorize(L["Name"], "ORANGE")) tableHeader:AddChild(btn) - btn = AceGUI:Create("InteractiveLabel") - btn:SetCallback("OnClick", function() + local knownHonorbtn = AceGUI:Create("InteractiveLabel") + knownHonorbtn:SetCallback("OnClick", function() GUI:Show(false, L["Honor"]) end) - btn.highlight:SetColorTexture(0.3, 0.3, 0.3, 0.5) - btn:SetWidth(80) - btn:SetText(colorize(L["Honor"], "ORANGE")) - tableHeader:AddChild(btn) - - if HonorSpy.db.factionrealm.estHonorCol.show then - btn:SetText(colorize(L["KnownHonor"], "ORANGE")) + knownHonorbtn.highlight:SetColorTexture(0.3, 0.3, 0.3, 0.5) + knownHonorbtn:SetWidth(80) + knownHonorbtn:SetText(colorize(L["Honor"], "ORANGE")) + tableHeader:AddChild(knownHonorbtn) + + if HonorSpy.db.factionrealm.estTodayHonorCol.show then + knownHonorbtn:SetText(colorize(L["KnownHonor"], "ORANGE")) btn = AceGUI:Create("InteractiveLabel") btn:SetCallback("OnClick", function() GUI:Show(false, L["EstHonor"]) end) btn.highlight:SetColorTexture(0.3, 0.3, 0.3, 0.5) - btn:SetWidth(80) + btn:SetWidth(100) btn:SetText(colorize(L["EstHonor"], "ORANGE")) tableHeader:AddChild(btn) + end + + if HonorSpy.db.factionrealm.estHonorCol.show then + knownHonorbtn:SetText(colorize(L["KnownHonor"], "ORANGE")) btn = AceGUI:Create("InteractiveLabel") btn:SetCallback("OnClick", function() GUI:Show(false, L["ThisWeekHonor"]) end) btn.highlight:SetColorTexture(0.3, 0.3, 0.3, 0.5) - btn:SetWidth(80) + btn:SetWidth(100) btn:SetText(colorize(L["ThisWeekHonor"], "ORANGE")) tableHeader:AddChild(btn) end diff --git a/HybridScrollFrame.xml b/HybridScrollFrame.xml index 0b4115c..8d7a7a8 100755 --- a/HybridScrollFrame.xml +++ b/HybridScrollFrame.xml @@ -21,13 +21,13 @@ - + - + diff --git a/honorspy.lua b/honorspy.lua index 524cad5..46d1c18 100755 --- a/honorspy.lua +++ b/honorspy.lua @@ -366,19 +366,39 @@ LibStub("AceConfig-3.0"):RegisterOptionsTable("HonorSpy", options, {"honorspy", function HonorSpy:BuildStandingsTable(sort_by) local t = { } for playerName, player in pairs(HonorSpy.db.factionrealm.currentStandings) do - table.insert(t, {playerName, player.class, player.thisWeekHonor or 0, player.estHonor or "", player.lastWeekHonor or 0, player.standing or 0, player.RP or 0, player.rank or 0, player.last_checked or 0}) + table.insert(t, {playerName, player.class, tonumber(player.thisWeekHonor) or 0, tonumber(player.estHonor) or 0, tonumber(player.lastWeekHonor) or 0, tonumber(player.standing) or 0, player.RP or 0, player.rank or 0, player.last_checked or 0}) end - local sort_column = 3; -- ThisWeekHonor + local sort_column = 3; -- KnownHonor if (sort_by == L["EstHonor"]) then sort_column = 4; end if (sort_by == L["ThisWeekHonor"]) then sort_column = -1; end if (sort_by == L["Standing"]) then sort_column = 5; end - if (sort_by == L["Rank"]) then sort_column = 7; end + if (sort_by == L["Rank"]) then sort_column = 8; end if (sort_by == L["Name"]) then sort_column = 1; end local sort_func = function(a,b) if sort_column == 1 then return a[1] < b[1] end - if sort_column == 4 then return math.max(a[3],tonumber(a[4]) or 0) > math.max(b[3],tonumber(b[4]) or 0) end - if sort_column == -1 then return (a[3] + (tonumber(a[4]) or 0)) > (b[3] + (tonumber(b[4]) or 0)) end + if sort_column == 4 then + local c = a[4]-a[3] + if c < 0 then c = 0 end + local d = b[4]-b[3] + if d < 0 then d = 0 end + return c > d + end + if sort_column == -1 then + local c = a[4]-a[3] + if c < 0 then + c = a[3] + else + c = a[4] + end + local d = b[4]-b[3] + if d < 0 then + d = b[3] + else + d = b[4] + end + return c > d + end if sort_column == 5 then if a[5] == b[5] then return a[6] < b[6] @@ -935,6 +955,7 @@ function HonorSpy:OnInitialize() last_reset = 0, minimapButton = {hide = false}, estHonorCol = {show = false}, + estTodayHonorCol = {show = false}, actualCommPrefix = "", fakePlayers = {}, goodPlayers = {}, diff --git a/settings.lua b/settings.lua index 4c996ed..8e182bd 100755 --- a/settings.lua +++ b/settings.lua @@ -35,20 +35,29 @@ options.args["estHonorCol"] = { set = function(info, v) HonorSpy.db.factionrealm.estHonorCol.show = v; HonorSpyGUI:PrepareGUI() end, } +options.args["estTodayHonorCol"] = { + order = 4, + type = "toggle", + name = "Show Estimated Todays Honor", + desc = "Shows the Estimated Todays Honor column in the table. This data will only be populated by other people with HonorSpy.", + get = function() return HonorSpy.db.factionrealm.estTodayHonorCol.show end, + set = function(info, v) HonorSpy.db.factionrealm.estTodayHonorCol.show = v; HonorSpyGUI:PrepareGUI() end, +} + options.args["estHonorColDesc"] = { - order = 4, + order = 5, type = "description", name = L["Shows the Estimated Honor column in the table. This data will only be populated by other people with HonorSpy."] .. '\n\n' } options.args["sep1"] = { - order = 5, + order = 6, type = "description", name = "\n" } options.args["poolBoost"] = { - order = 6, + order = 7, type = "range", name = L["Pool Booster Count"], desc = L["Number of characters to add to Pool"], @@ -61,7 +70,7 @@ options.args["poolBoost"] = { } options.args["spreadPoolBoostOverWeek"] = { - order = 7, + order = 8, type = "toggle", name = L["Spread the poolboost count over the week"], desc = L["As final pool boost should be only achieved at the end of the week"], @@ -70,19 +79,19 @@ options.args["spreadPoolBoostOverWeek"] = { } options.args["sep2"] = { - order = 8, + order = 9, type = "description", name = L["This is how big the discrepancy is at the end of PvP week between HonorSpy pool size and real server pool size. Pool size will slowly be growing during the week reaching the final value of 'gathered number of players' + 'pool boost size'."] .. "\n\n" } options.args["sep3"] = { - order = 9, + order = 10, type = "description", name = "\n" } options.args["som_realm"] = { - order = 10, + order = 11, type = "toggle", name = L["Season of Mastery"], desc = L["Implements the ranking changes applied to Season of Mastery."], @@ -91,20 +100,20 @@ options.args["som_realm"] = { } options.args["sep4"] = { - order = 11, + order = 12, type = "description", name = L["Enables Season of Mastery ranking changes."] .. '\n\n' } options.args["export"] = { - order = 12, + order = 13, type = "execute", name = L["Export to CSV"], desc = L["Show window with current data in CSV format"], func = function() HonorSpy:ExportCSV() end, } options.args["purge_data"] = { - order = 13, + order = 14, type = "execute", name = L["Purge all data"], desc = L["Delete all collected data"], @@ -114,4 +123,4 @@ options.args["purge_data"] = { } LibStub("AceConfig-3.0"):RegisterOptionsTable("HonorSpy-options", options) -LibStub("AceConfigDialog-3.0"):AddToBlizOptions("HonorSpy-options", "HonorSpy") +LibStub("AceConfigDialog-3.0"):AddToBlizOptions("HonorSpy-options", "HonorSpy") \ No newline at end of file