Skip to content

Commit

Permalink
Working version
Browse files Browse the repository at this point in the history
  • Loading branch information
LorenzoRogai committed Sep 1, 2024
1 parent d87c985 commit d411719
Show file tree
Hide file tree
Showing 4 changed files with 110 additions and 32 deletions.
4 changes: 3 additions & 1 deletion .pkgmeta
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ package-as: RepHub

externals:
Libs/LibStub: https://repos.wowace.com/wow/libstub/trunk
Libs/LibDataBroker-1.1: https://github.com/tekkub/libdatabroker-1-1
Libs/AceAddon-3.0: https://repos.curseforge.com/wow/ace3/trunk/AceAddon-3.0
Libs/AceDB-3.0: https://repos.curseforge.com/wow/ace3/trunk/AceDB-3.0
Libs/AceGUI-3.0: https://repos.curseforge.com/wow/ace3/trunk/AceGUI-3.0
Libs/LibDBIcon-1.0: https://repos.curseforge.com/wow/libdbicon-1-0/trunk/LibDBIcon-1.0
Libs/LibDataBroker-1.1: https://github.com/tekkub/libdatabroker-1-1
Libs/lib-st: https://repos.wowace.com/wow/lib-st/trunk
2 changes: 2 additions & 0 deletions embeds.xml → Libs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,7 @@
<Script file="Libs\LibDataBroker-1.1\LibDataBroker-1.1.lua"/>
<Include file="Libs\AceAddon-3.0\AceAddon-3.0.xml"/>
<Include file="Libs\AceDB-3.0\AceDB-3.0.xml"/>
<Include file="Libs\AceGUI-3.0\AceGUI-3.0.xml"/>
<Include file="Libs\LibDBIcon-1.0\lib.xml"/>
<Include file="Libs\lib-st\lib-st.xml"/>
</Ui>
132 changes: 103 additions & 29 deletions RepHub.lua
Original file line number Diff line number Diff line change
@@ -1,34 +1,108 @@
local RepHub = LibStub("AceAddon-3.0"):NewAddon("RepHub")
local RepHubLDB = LibStub("LibDataBroker-1.1"):NewDataObject("RepHub", {
type = "data source",
text = "RepHub",
icon = "Interface\\Icons\\Achievement_Reputation_01",
OnTooltipShow = function(tooltip)
tooltip:AddLine("RepHub")

local numFactions = C_Reputation.GetNumFactions()
local factionIndex = 1
while (factionIndex <= numFactions) do
local factionData = C_Reputation.GetFactionDataByIndex(factionIndex)
if factionData.isHeader then
tooltip:AddLine(factionData.name)
else
tooltip:AddLine("-- " .. factionData.name .. " - " .. factionData.currentStanding)
end
factionIndex = factionIndex + 1
end
local RepHub = LibStub("AceAddon-3.0"):NewAddon("RepHub")
local AceGUI = LibStub("AceGUI-3.0")
local RepHubLDB = LibStub("LibDataBroker-1.1"):NewDataObject("RepHub", {
type = "data source",
text = "RepHub",
icon = "Interface\\Icons\\Achievement_Reputation_01",
OnTooltipShow = function(tooltip)
tooltip:AddLine("Click to show RepHub")
end,
OnClick = function()
RepHub:ShowRepHubFrame()
end,
})
local icon = LibStub("LibDBIcon-1.0")
})
local LibDBIcon = LibStub("LibDBIcon-1.0")
local RepHubFrameShown = false

function RepHub:OnInitialize()
-- Assuming you have a ## SavedVariables: RepHubDB line in your TOC
self.db = LibStub("AceDB-3.0"):New("RepHubDB", {
profile = {
minimap = {
hide = false,
},
},
})
icon:Register("RepHub", RepHubLDB, self.db.profile.minimap)
self.db = LibStub("AceDB-3.0"):New("RepHubDB", {
profile = {
minimap = {
hide = false,
},
},
global = {
ReputationList = {},
},
})
LibDBIcon:Register("RepHub", RepHubLDB, self.db.profile.minimap)
RepHub:RefreshReputationGlobalDB()
end

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

local currentGroup = nil

local numFactions = C_Reputation.GetNumFactions()
local factionIndex = 1
while (factionIndex <= numFactions) do
local factionData = C_Reputation.GetFactionDataByIndex(factionIndex)
if factionData.isHeader then
currentGroup = factionData.name

if factionData.isCollapsed then
C_Reputation.ExpandFactionHeader(factionIndex)
numFactions = C_Reputation.GetNumFactions()
end
end
if self.db.global.ReputationList[factionData.factionID] == nil then
self.db.global.ReputationList[factionData.factionID] = factionData
self.db.global.ReputationList[factionData.factionID].currentGroup = currentGroup
self.db.global.ReputationList[factionData.factionID].highestStanding = factionData.currentStanding
self.db.global.ReputationList[factionData.factionID].highestStandingCharacterName = characterName
elseif self.db.global.ReputationList[factionData.factionID].highestStanding < factionData.currentStanding and not factionData.isAccountWide then
self.db.global.ReputationList[factionData.factionID].highestStanding = factionData.currentStanding
self.db.global.ReputationList[factionData.factionID].highestStandingCharacterName = characterName
end
factionIndex = factionIndex + 1
end
end

function RepHub:ShowRepHubFrame()
if RepHubFrameShown then
return
end

local RepHubFrame = AceGUI:Create("Frame")
RepHubFrame:SetTitle("RepHub")
RepHubFrame:SetStatusText("RepHub is a simple account-wide reputation tracker")
RepHubFrame:SetCallback(
"OnClose",
function(widget)
AceGUI:Release(widget)
RepHubFrameShown = false
end
)

local columnsArr = {
{ ["name"] = "Rep Name", ["width"] = 205, },
{ ["name"] = "Group", ["width"] = 205, },
{ ["name"] = "Highest Standing", ["width"] = 205, },
}
local dataArr = {}

local characterName = UnitName("player")

table.foreach(
self.db.global.ReputationList,
function(factionID, factionData)
if not factionData.isHeader then
local highestStandingText = ""
if factionData.isAccountWide then
highestStandingText = "Account-wide"
else
highestStandingText = factionData.highestStanding .. " (" .. factionData.highestStandingCharacterName .. ")"
end
table.insert(dataArr, {factionData.name, factionData.currentGroup, highestStandingText })
end
end
)

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

RepHubFrameShown = true
end
4 changes: 2 additions & 2 deletions RepHub.toc
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
## Interface: 110002
## Title: RepHub
## Description: RepHub is an account-wide reputation tracker for World of Warcraft.
## Description: RepHub is a simple account-wide reputation tracker
## Author: Alwayspizza
## SavedVariables: RepHubDB
## X-Curse-Project-ID: 1094884

embeds.xml
Libs.xml
Rephub.lua

0 comments on commit d411719

Please sign in to comment.