Skip to content

Commit

Permalink
Merge pull request #190 from Slivo-fr/bugfix/gui-honor-values
Browse files Browse the repository at this point in the history
Fix GUI honor values
  • Loading branch information
kakysha authored Mar 14, 2022
2 parents 00fd15b + c96f206 commit 5352f25
Show file tree
Hide file tree
Showing 4 changed files with 103 additions and 42 deletions.
79 changes: 55 additions & 24 deletions GUI.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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();
Expand All @@ -127,7 +130,7 @@ function GUI:UpdateTableView()
button.Background:SetTexture("Interface/Glues/CharacterCreate/CharacterCreateMetalFrameHorizontal")
button.Highlight:SetTexture()
button:Show();

elseif (itemIndex <= #rows) then
local name, class, thisWeekHonor, estHonor, lastWeekHonor, standing, RP, rank, last_checked = unpack(rows[itemIndex])
local last_seen, last_seen_human = (GetServerTime() - last_checked), ""
Expand All @@ -146,16 +149,37 @@ function GUI:UpdateTableView()
button.Name:SetWordWrap(false)
if tonumber(thisWeekHonor) == 1 then thisWeekHonor = 0 end
button.Honor:SetText(colorize(thisWeekHonor, class));
if HonorSpy.db.factionrealm.estHonorCol.show then
button.EstHonor:SetText(colorize(estHonor, class));
button.EstHonor:SetWidth(80);
button.EstWeekHonor:SetText(colorize((tonumber(estHonor) or 0) + (tonumber(thisWeekHonor) or 0), class));
button.EstWeekHonor:SetWidth(80);
else
if HonorSpy.db.factionrealm.estHonorCol.show then
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
end
button.EstWeekHonor:SetText(colorize(estHonor, class));
else
button.EstWeekHonor:SetText();
end
else
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);
button.EstWeekHonor:SetText();
button.EstWeekHonor:SetWidth(0);
end
button.LstWkHonor:SetText(colorize(lastWeekHonor, class));
button.Standing:SetText(colorize(standing, class));
Expand Down Expand Up @@ -190,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)

Expand Down Expand Up @@ -228,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
Expand Down
4 changes: 2 additions & 2 deletions HybridScrollFrame.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@
</Anchors>
</FontString>
<FontString parentKey="EstHonor" inherits="GameFontHighlightSmall" justifyH="LEFT">
<Size x="80"/>
<Size x="100"/>
<Anchors>
<Anchor point="TOPLEFT" relativePoint="TOPRIGHT" relativeKey="$parent.Honor"/>
</Anchors>
</FontString>
<FontString parentKey="EstWeekHonor" inherits="GameFontHighlightSmall" justifyH="LEFT">
<Size x="80"/>
<Size x="100"/>
<Anchors>
<Anchor point="TOPLEFT" relativePoint="TOPRIGHT" relativeKey="$parent.EstHonor"/>
</Anchors>
Expand Down
31 changes: 26 additions & 5 deletions honorspy.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -935,6 +955,7 @@ function HonorSpy:OnInitialize()
last_reset = 0,
minimapButton = {hide = false},
estHonorCol = {show = false},
estTodayHonorCol = {show = false},
actualCommPrefix = "",
fakePlayers = {},
goodPlayers = {},
Expand Down
31 changes: 20 additions & 11 deletions settings.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
Expand All @@ -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"],
Expand All @@ -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."],
Expand All @@ -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"],
Expand All @@ -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")

0 comments on commit 5352f25

Please sign in to comment.