-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d87c985
commit d411719
Showing
4 changed files
with
110 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |