Skip to content

Commit

Permalink
Filter and Statistics
Browse files Browse the repository at this point in the history
  • Loading branch information
LorenzoRogai committed Sep 4, 2024
1 parent 4507a86 commit 9956864
Showing 1 changed file with 42 additions and 3 deletions.
45 changes: 42 additions & 3 deletions RepHub.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ local LibDataBroker = LibStub("LibDataBroker-1.1"):NewDataObject("RepHub", {
end,
})
local LibDBIcon = LibStub("LibDBIcon-1.0")
local RepHubFrame = nil
local RepHubFrameShown = false
local RepHubFrameShown, RepHubFrame, RepHubTable, filterValue = false, nil, nil, nil

function RepHub:OnInitialize()
self.db = LibStub("AceDB-3.0"):New("RepHubDB", {
Expand All @@ -23,6 +22,7 @@ function RepHub:OnInitialize()
},
},
global = {
characterNames = {},
ReputationList = {},
},
})
Expand Down Expand Up @@ -63,9 +63,24 @@ function RepHub:FindHighestStanding(standingsTable)
return highestStanding, highestStandingCharacterName
end

function RepHub:FilterFunction(row)
local showRow = false
for rowKey, rowValue in pairs(row) do
if string.find(string.lower(rowValue), string.lower(filterValue)) then
showRow = true
break
end
end
return showRow
end

function RepHub:RefreshReputationGlobalDB()
local characterName = UnitName("player")

if not tContains(self.db.global.characterNames, characterName) then
table.insert(self.db.global.characterNames, characterName)
end

local currentGroup = nil

C_Reputation.ExpandAllFactionHeaders()
Expand Down Expand Up @@ -108,6 +123,23 @@ function RepHub:CreateRepHubFrame()
RepHub:HideRepHubFrame()
end
)

local StatsLabel = AceGUI:Create("Label")
StatsLabel:SetFullWidth(true)
StatsLabel:SetText("Total reputations: " .. RepHub:GetStandingsCount(self.db.global.ReputationList) .. " | Total characters: " .. #self.db.global.characterNames)
RepHubFrame:AddChild(StatsLabel)

local SearchBox = AceGUI:Create("EditBox")
SearchBox:SetFullWidth(true)
SearchBox:SetLabel("Search:")
SearchBox:SetCallback(
"OnEnterPressed",
function(widget, event, text)
filterValue = text
RepHubTable:SetFilter(RepHub.FilterFunction)
end
)
RepHubFrame:AddChild(SearchBox)

local columnsArr = {
{ ["name"] = "Reputation Name", ["width"] = 155, },
Expand Down Expand Up @@ -137,10 +169,17 @@ function RepHub:CreateRepHubFrame()
end
)

local RepHubTableGroup = AceGUI:Create("SimpleGroup")
RepHubTableGroup:SetFullWidth(true)
RepHubTableGroup:SetHeight(390)
RepHubTableGroup:SetLayout("Fill")

local ScrollingTable = LibStub("ScrollingTable")
local RepHubTable = ScrollingTable:CreateST(columnsArr, 27, nil, nil, RepHubFrame.frame)
RepHubTable = ScrollingTable:CreateST(columnsArr, 23, nil, nil, RepHubTableGroup.frame)
RepHubTable:SetData(dataArr, true)

RepHubFrame:AddChild(RepHubTableGroup)

RepHubFrame.frame:Hide()
end

Expand Down

0 comments on commit 9956864

Please sign in to comment.