-
Notifications
You must be signed in to change notification settings - Fork 7
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
bc2264c
commit 2189f65
Showing
77 changed files
with
15,501 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,3 +39,6 @@ luac.out | |
*.x86_64 | ||
*.hex | ||
|
||
# Auto-formatter config | ||
.luaconfig | ||
|
Large diffs are not rendered by default.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
## Interface: 20502 | ||
## Title: ArenaStats - TBC | ||
## Notes: Arena history and statistics with csv export | ||
## Author: Kallias-Sulfuron | ||
## Version: 1 | ||
## SavedVariables: ArenaStats | ||
|
||
embeds.xml | ||
locales.xml | ||
|
||
ArenaStats.lua | ||
GUI.lua | ||
HybridScrollFrame.xml | ||
options.lua |
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 |
---|---|---|
@@ -0,0 +1,235 @@ | ||
local addonName = "ArenaStats" | ||
local addonTitle = select(2, _G.GetAddOnInfo(addonName)) | ||
local ArenaStats = _G.LibStub("AceAddon-3.0"):GetAddon(addonName) | ||
local L = _G.LibStub("AceLocale-3.0"):GetLocale(addonName, true) | ||
local AceGUI = _G.LibStub("AceGUI-3.0") | ||
local f, scrollFrame, rows, stats | ||
local exportFrame, exportEditBox | ||
|
||
function ArenaStats:CreateGUI() | ||
f = AceGUI:Create("Frame") | ||
f:Hide() | ||
f:SetWidth(699) | ||
f:EnableResize(false) | ||
|
||
f:SetTitle(addonTitle) | ||
local frameName = addonName .."_MainFrame" | ||
_G[frameName] = f | ||
table.insert(_G.UISpecialFrames, frameName) | ||
f:SetStatusText("Status Bar") | ||
f:SetLayout("Flow") | ||
|
||
|
||
local exportButton = AceGUI:Create("Button") | ||
exportButton:SetWidth(100) | ||
exportButton:SetText(string.format(" %s ", L["Export"])) | ||
f:AddChild(exportButton) | ||
exportButton:SetCallback("OnClick", function() ArenaStats:ExportCSV() end) | ||
|
||
-- TABLE HEADER | ||
local tableHeader = AceGUI:Create("SimpleGroup") | ||
tableHeader:SetFullWidth(true) | ||
tableHeader:SetLayout("Flow") | ||
f:AddChild(tableHeader) | ||
|
||
local margin = AceGUI:Create("Label") | ||
margin:SetWidth(4) | ||
tableHeader:AddChild(margin) | ||
|
||
ArenaStats:CreateScoreButton(tableHeader, 145, "Date") | ||
ArenaStats:CreateScoreButton(tableHeader, 40, "Map") | ||
ArenaStats:CreateScoreButton(tableHeader, 94, "Duration") | ||
ArenaStats:CreateScoreButton(tableHeader, 100, "Team") | ||
ArenaStats:CreateScoreButton(tableHeader, 40, "Rating") | ||
ArenaStats:CreateScoreButton(tableHeader, 100, "Enemy Team") | ||
ArenaStats:CreateScoreButton(tableHeader, 80, "Enemy Faction") | ||
|
||
|
||
-- TABLE | ||
local scrollContainer = AceGUI:Create("SimpleGroup") | ||
scrollContainer:SetFullWidth(true) | ||
scrollContainer:SetFullHeight(true) | ||
scrollContainer:SetLayout("Fill") | ||
f:AddChild(scrollContainer) | ||
|
||
scrollFrame = _G.CreateFrame("ScrollFrame", nil, scrollContainer.frame, "ArenaStatsHybridScrollFrame") | ||
_G.HybridScrollFrame_CreateButtons(scrollFrame, "ArenaStatsHybridScrollListItemTemplate") | ||
scrollFrame.update = function() ArenaStats:UpdateTableView() end | ||
|
||
|
||
-- Export frame | ||
|
||
exportFrame = AceGUI:Create("Frame") | ||
exportFrame:SetWidth(550) | ||
exportFrame.sizer_se:Hide() | ||
exportFrame:SetStatusText("") | ||
exportFrame:SetLayout("Flow") | ||
exportFrame:SetTitle(L["Export"]) | ||
exportFrame:Hide() | ||
exportEditBox = AceGUI:Create("MultiLineEditBox") | ||
exportEditBox:SetLabel('ExportString') | ||
exportEditBox:SetNumLines(29) | ||
exportEditBox:SetText("") | ||
exportEditBox:SetWidth(500) | ||
exportEditBox.button:Hide() | ||
exportEditBox.frame:SetClipsChildren(true) | ||
exportFrame:AddChild(exportEditBox) | ||
exportFrame.eb = exportEditBox | ||
end | ||
|
||
function ArenaStats:UpdateTableView() | ||
self:RefreshLayout() | ||
end | ||
|
||
function ArenaStats:CreateScoreButton(tableHeader, width, localeStr) | ||
btn = AceGUI:Create("Label") | ||
btn:SetWidth(width) | ||
btn:SetText(string.format(" %s ", L[localeStr])) | ||
btn:SetJustifyH("LEFT") | ||
tableHeader:AddChild(btn) | ||
margin = AceGUI:Create("Label") | ||
margin:SetWidth(4) | ||
tableHeader:AddChild(margin) | ||
end | ||
|
||
function ArenaStats:RefreshLayout() | ||
local buttons = _G.HybridScrollFrame_GetButtons(scrollFrame) | ||
local offset = _G.HybridScrollFrame_GetOffset(scrollFrame) | ||
|
||
f:SetStatusText(string.format(L["Recorded %i arenas"], #rows)) | ||
|
||
for buttonIndex = 1, #buttons do | ||
local button = buttons[buttonIndex] | ||
local itemIndex = buttonIndex + offset | ||
local row = rows[itemIndex] | ||
|
||
if (itemIndex <= #rows) then | ||
button:SetID(itemIndex) | ||
button.Date:SetText(_G.date(L["%F %T"], row["endTime"])) | ||
button.Map:SetText(self:ZoneNameShort(row["zoneId"])) | ||
button.Duration:SetText(self:HumanDuration(row["duration"])) | ||
|
||
button.IconTeamPlayerClass1:SetTexture(self:ClassIconId(row["teamPlayerClass1"])) | ||
button.IconTeamPlayerClass2:SetTexture(self:ClassIconId(row["teamPlayerClass2"])) | ||
button.IconTeamPlayerClass3:SetTexture(self:ClassIconId(row["teamPlayerClass3"])) | ||
button.IconTeamPlayerClass4:SetTexture(self:ClassIconId(row["teamPlayerClass4"])) | ||
button.IconTeamPlayerClass5:SetTexture(self:ClassIconId(row["teamPlayerClass5"])) | ||
button.Rating:SetText(row["diffRating"]) | ||
button.Rating:SetTextColor(self:ColorForRating(row["diffRating"])) | ||
button.IconEnemyPlayer1:SetTexture(self:ClassIconId(row["enemyPlayerClass1"])) | ||
button.IconEnemyPlayer2:SetTexture(self:ClassIconId(row["enemyPlayerClass2"])) | ||
button.IconEnemyPlayer3:SetTexture(self:ClassIconId(row["enemyPlayerClass3"])) | ||
button.IconEnemyPlayer4:SetTexture(self:ClassIconId(row["enemyPlayerClass4"])) | ||
button.IconEnemyPlayer5:SetTexture(self:ClassIconId(row["enemyPlayerClass5"])) | ||
button.IconEnemyPlayer5:SetTexture(self:ClassIconId(row["enemyPlayerClass5"])) | ||
button.EnemyFaction:SetTexture(self:FactionIconId(row["enemyFaction"])) | ||
|
||
|
||
button:SetWidth(scrollFrame.scrollChild:GetWidth()) | ||
button:Show() | ||
else | ||
button:Hide() | ||
end | ||
end | ||
|
||
local buttonHeight = scrollFrame.buttonHeight | ||
local totalHeight = #rows * buttonHeight | ||
local shownHeight = #buttons * buttonHeight | ||
|
||
_G.HybridScrollFrame_Update(scrollFrame, totalHeight, shownHeight) | ||
end | ||
|
||
function ArenaStats:Show() | ||
if not f then | ||
self:CreateGUI() | ||
end | ||
|
||
rows = ArenaStats:BuildTable() | ||
|
||
f:Show() | ||
self:RefreshLayout() | ||
end | ||
|
||
function ArenaStats:Hide() | ||
f:Hide() | ||
end | ||
|
||
function ArenaStats:Toggle() | ||
if f and f:IsShown() then | ||
self:Hide() | ||
else | ||
self:Show() | ||
end | ||
end | ||
|
||
function ArenaStats:HumanDuration(seconds) | ||
if seconds < 60 then | ||
return string.format(L["%is"], seconds) | ||
end | ||
local minutes = math.floor(seconds / 60) | ||
if minutes < 60 then | ||
return string.format(L["%im %is"], minutes, (seconds - minutes * 60)) | ||
end | ||
local hours = math.floor(minutes / 60) | ||
return string.format(L["%ih %im"], hours, (minutes - hours * 60)) | ||
end | ||
|
||
function ArenaStats:ClassIconId(className) | ||
|
||
if not className then | ||
return 0 | ||
end | ||
|
||
if className == "MAGE" then | ||
return 626001 | ||
elseif className == "PRIEST" then | ||
return 626004 | ||
elseif className == "DRUID" then | ||
return 625999 | ||
elseif className == "SHAMAN" then | ||
return 626006 | ||
elseif className == "PALADIN" then | ||
return 626003 | ||
elseif className == "WARLOCK" then | ||
return 626007 | ||
elseif className == "WARRIOR" then | ||
return 626008 | ||
elseif className == "HUNTER" then | ||
return 626000 | ||
elseif className == "ROGUE" then | ||
return 626005 | ||
end | ||
end | ||
|
||
function ArenaStats:FactionIconId(factionId) | ||
|
||
if not factionId then | ||
return 0 | ||
end | ||
|
||
if factionId == 0 then | ||
return 132485 | ||
else | ||
return 132486 | ||
end | ||
end | ||
|
||
function ArenaStats:ColorForRating(rating) | ||
|
||
if not rating or rating == 0 then | ||
return 255, 255, 255, 1 | ||
end | ||
|
||
if rating < 0 then | ||
return 255, 0, 0, 1 | ||
else | ||
return 0, 255, 0, 1 | ||
end | ||
end | ||
|
||
function ArenaStats:ExportFrame() | ||
return exportFrame | ||
end | ||
function ArenaStats:ExportEditBox() | ||
return exportEditBox | ||
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 |
---|---|---|
@@ -0,0 +1,133 @@ | ||
<Ui xmlns="http://www.blizzard.com/wow/ui/" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://www.blizzard.com/wow/ui/..\FrameXML\UI.xsd"> | ||
|
||
<Frame name="ArenaStatsHybridScrollListItemTemplate" virtual="true"> | ||
<Size x="0" y="24"/> | ||
<Layers> | ||
<Layer level="BACKGROUND"> | ||
<Texture parentKey="Background" setAllPoints="true"> | ||
<Color r="0" g="0" b="0" a="0.2"/> | ||
</Texture> | ||
</Layer> | ||
<Layer level="ARTWORK"> | ||
<FontString parentKey="Date" inherits="GameFontHighlightSmall" justifyH="LEFT"> | ||
<Size x="150"/> | ||
<Anchors> | ||
<Anchor point="LEFT" x="4" y="0"/> | ||
</Anchors> | ||
</FontString> | ||
<FontString parentKey="Map" inherits="GameFontHighlightSmall" justifyH="LEFT"> | ||
<Size x="40"/> | ||
<Anchors> | ||
<Anchor point="LEFT" relativePoint="RIGHT" relativeKey="$parent.Date" x="4"/> | ||
</Anchors> | ||
</FontString> | ||
<FontString parentKey="Duration" inherits="GameFontHighlightSmall" justifyH="LEFT"> | ||
<Size x="98"/> | ||
<Anchors> | ||
<Anchor point="LEFT" relativePoint="RIGHT" relativeKey="$parent.Map"/> | ||
</Anchors> | ||
</FontString> | ||
|
||
|
||
<Texture parentKey="IconTeamPlayerClass1"> | ||
<Size x="20" y="20"/> | ||
<Anchors> | ||
<Anchor point="LEFT" relativePoint="RIGHT" relativeKey="$parent.Duration"/> | ||
</Anchors> | ||
</Texture> | ||
<Texture parentKey="IconTeamPlayerClass2"> | ||
<Size x="20" y="20"/> | ||
<Anchors> | ||
<Anchor point="LEFT" relativePoint="RIGHT" relativeKey="$parent.IconTeamPlayerClass1"/> | ||
</Anchors> | ||
</Texture> | ||
<Texture parentKey="IconTeamPlayerClass3"> | ||
<Size x="20" y="20"/> | ||
<Anchors> | ||
<Anchor point="LEFT" relativePoint="RIGHT" relativeKey="$parent.IconTeamPlayerClass2"/> | ||
</Anchors> | ||
</Texture> | ||
<Texture parentKey="IconTeamPlayerClass4"> | ||
<Size x="20" y="20"/> | ||
<Anchors> | ||
<Anchor point="LEFT" relativePoint="RIGHT" relativeKey="$parent.IconTeamPlayerClass3"/> | ||
</Anchors> | ||
</Texture> | ||
<Texture parentKey="IconTeamPlayerClass5"> | ||
<Size x="20" y="20"/> | ||
<Anchors> | ||
<Anchor point="LEFT" relativePoint="RIGHT" relativeKey="$parent.IconTeamPlayerClass4"/> | ||
</Anchors> | ||
</Texture> | ||
|
||
<FontString parentKey="Rating" inherits="GameFontHighlightSmall" justifyH="CENTER"> | ||
<Size x="36"/> | ||
<Anchors> | ||
<Anchor point="LEFT" relativePoint="RIGHT" relativeKey="$parent.IconTeamPlayerClass5" x="4"/> | ||
</Anchors> | ||
</FontString> | ||
|
||
<Texture parentKey="IconEnemyPlayer1"> | ||
<Size x="20" y="20"/> | ||
<Anchors> | ||
<Anchor point="LEFT" relativePoint="RIGHT" relativeKey="$parent.Rating" x="8"/> | ||
</Anchors> | ||
</Texture> | ||
<Texture parentKey="IconEnemyPlayer2"> | ||
<Size x="20" y="20"/> | ||
<Anchors> | ||
<Anchor point="LEFT" relativePoint="RIGHT" relativeKey="$parent.IconEnemyPlayer1"/> | ||
</Anchors> | ||
</Texture> | ||
<Texture parentKey="IconEnemyPlayer3"> | ||
<Size x="20" y="20"/> | ||
<Anchors> | ||
<Anchor point="LEFT" relativePoint="RIGHT" relativeKey="$parent.IconEnemyPlayer2"/> | ||
</Anchors> | ||
</Texture> | ||
<Texture parentKey="IconEnemyPlayer4"> | ||
<Size x="20" y="20"/> | ||
<Anchors> | ||
<Anchor point="LEFT" relativePoint="RIGHT" relativeKey="$parent.IconEnemyPlayer3"/> | ||
</Anchors> | ||
</Texture> | ||
<Texture parentKey="IconEnemyPlayer5"> | ||
<Size x="20" y="20"/> | ||
<Anchors> | ||
<Anchor point="LEFT" relativePoint="RIGHT" relativeKey="$parent.IconEnemyPlayer4"/> | ||
</Anchors> | ||
</Texture> | ||
<Texture parentKey="EnemyFaction"> | ||
<Size x="20" y="20"/> | ||
<Anchors> | ||
<Anchor point="LEFT" relativePoint="RIGHT" relativeKey="$parent.IconEnemyPlayer5" x="25"/> | ||
</Anchors> | ||
</Texture> | ||
|
||
|
||
</Layer> | ||
<Layer level="HIGHLIGHT"> | ||
<Texture parentKey="Highlight" setAllPoints="true" alphaMode="ADD"> | ||
<Color r="1" g="0.75" b="0" a="0.2"/> | ||
</Texture> | ||
</Layer> | ||
</Layers> | ||
</Frame> | ||
|
||
<Frame name="ArenaStatsHybridScrollFrame" inherits="HybridScrollFrameTemplate" virtual="true"> | ||
<Anchors> | ||
<Anchor point="TOPLEFT" x="2" y="-2"/> | ||
<Anchor point="BOTTOMRIGHT" x="-25" y="7"/> | ||
</Anchors> | ||
<Frames> | ||
<Slider parentKey="scrollBar" inherits="HybridScrollBarTemplate"> | ||
<Anchors> | ||
<Anchor point="TOPLEFT" relativePoint="TOPRIGHT" x="1" y="-16"/> | ||
<Anchor point="BOTTOMLEFT" relativePoint="BOTTOMRIGHT" x="1" y="12"/> | ||
</Anchors> | ||
</Slider> | ||
</Frames> | ||
</Frame> | ||
</Ui> |
Oops, something went wrong.