-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Renown.lua
133 lines (109 loc) · 6.35 KB
/
Renown.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
local EventFrame = nil
local AZPRenownVersion = 23
local FactionIDs =
{
[2503] = {Position = 2, Name = "Maruuk Centaur",},
[2507] = {Position = 1, Name = "Dragonscale Expedition",},
[2510] = {Position = 4, Name = "Valdrakken Accord",},
[2511] = {Position = 3, Name = "Iskaara Tuskarr",},
}
function AZPRenownOnLoad()
EventFrame = CreateFrame("FRAME", nil)
EventFrame:RegisterEvent("VARIABLES_LOADED")
EventFrame:RegisterEvent("MAJOR_FACTION_RENOWN_LEVEL_CHANGED")
EventFrame:RegisterEvent("CURRENCY_DISPLAY_UPDATE")
EventFrame:SetScript("OnEvent", function(...) AZPRenownOnEvent(...) end)
ColorPickerOkayButton:HookScript("OnClick", function() AZPRenownColorSave() end)
end
function AZPRenownOnEvent(_, event, ...)
if event == "MAJOR_FACTION_RENOWN_LEVEL_CHANGED" then
-- elseif event == "CURRENCY_DISPLAY_UPDATE" then
-- if ... == 1813 then AZPRenownFrameUpdateValues() end
elseif event == "VARIABLES_LOADED" then
if AZPRenownLevels == nil then AZPRenownLevels = {} end
if AZPRenownLevels.MaxValues == nil then AZPRenownLevels.MaxValues = {} end
C_Timer.After(1, function() AZPRenownGetFactionLevels() AZPCreateFramesOnExpansionPage() end)
end
end
function AZPCreateFramesOnExpansionPage()
local ExpackTest = {ExpansionLandingPage.Overlay:GetChildren()}
local FactionListFrame = ExpackTest[1].MajorFactionList
ExpansionLandingPage.AZPRenownFrame = CreateFrame("Frame", nil, ExpansionLandingPage)
ExpansionLandingPage.AZPRenownFrame:SetSize(60, 450)
ExpansionLandingPage.AZPRenownFrame:SetPoint("TOPLEFT", FactionListFrame, "TOPRIGHT", -20, 60)
ExpansionLandingPage.AZPRenownFrame:SetFrameStrata("HIGH")
ExpansionLandingPage.AZPRenownFrame.HeaderFrame = CreateFrame("Frame", nil, ExpansionLandingPage.AZPRenownFrame)
ExpansionLandingPage.AZPRenownFrame.HeaderFrame:SetSize(60, 50)
ExpansionLandingPage.AZPRenownFrame.HeaderFrame:SetPoint("TOP", ExpansionLandingPage.AZPRenownFrame, "TOP", 0, 0)
ExpansionLandingPage.AZPRenownFrame.HeaderFrame:SetFrameLevel(100)
ExpansionLandingPage.AZPRenownFrame.HeaderFrame.AccountMax = ExpansionLandingPage.AZPRenownFrame.HeaderFrame:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall")
ExpansionLandingPage.AZPRenownFrame.HeaderFrame.AccountMax:SetPoint("TOP", ExpansionLandingPage.AZPRenownFrame.HeaderFrame, "TOP", 0, -5)
ExpansionLandingPage.AZPRenownFrame.HeaderFrame.AccountMax:SetText("Max Level")
ExpansionLandingPage.AZPRenownFrame.HeaderFrame.Percentage = ExpansionLandingPage.AZPRenownFrame.HeaderFrame:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall")
ExpansionLandingPage.AZPRenownFrame.HeaderFrame.Percentage:SetPoint("TOP", ExpansionLandingPage.AZPRenownFrame.HeaderFrame.AccountMax, "BOTTOM", 0, -5)
ExpansionLandingPage.AZPRenownFrame.HeaderFrame.Percentage:SetText("Rep Rate")
-- ExpansionLandingPage.AZPRenownFrame.HeaderFrame.Percentage = ExpansionLandingPage.AZPRenownFrame.HeaderFrame:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall")
-- ExpansionLandingPage.AZPRenownFrame.HeaderFrame.Percentage:SetPoint("TOP", ExpansionLandingPage.AZPRenownFrame.HeaderFrame.Percentage, "BOTTOM", 0, -5)
-- ExpansionLandingPage.AZPRenownFrame.HeaderFrame.Percentage:SetText("Inventory")
ExpansionLandingPage.AZPRenownFrame.FactionList = {}
for i = 1, 4 do
ExpansionLandingPage.AZPRenownFrame.FactionList[i] = CreateFrame("Frame", nil, ExpansionLandingPage.AZPRenownFrame)
local curFrame = ExpansionLandingPage.AZPRenownFrame.FactionList[i]
curFrame:SetSize(60, 88)
if i == 1 then
curFrame:SetPoint("TOP", ExpansionLandingPage.AZPRenownFrame.HeaderFrame, "BOTTOM", 0, -12)
else
curFrame:SetPoint("TOP", ExpansionLandingPage.AZPRenownFrame.FactionList[i-1], "BOTTOM", 0, -12)
end
curFrame:SetFrameLevel(100)
curFrame.AccountMax = curFrame:CreateFontString(nil, "OVERLAY", "GameFontNormalLarge")
curFrame.AccountMax:SetPoint("TOP", curFrame, "TOP", 0, -20)
curFrame.AccountMax:SetText("Max Level")
curFrame.Percentage = curFrame:CreateFontString(nil, "OVERLAY", "GameFontNormalLarge")
curFrame.Percentage:SetPoint("TOP", curFrame.AccountMax, "BOTTOM", 0, -10)
curFrame.Percentage:SetText("Rep Rate")
-- curFrame.Inventory = curFrame:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall")
-- curFrame.Inventory:SetPoint("TOP", curFrame.Percentage, "BOTTOM", 0, -10)
-- curFrame.Inventory:SetText("Inventory")
end
AZPRenownAddDataToFrame()
end
function AZPRenownGetFactionLevels()
local curGUID = UnitGUID("PLAYER")
AZPRenownLevels[curGUID] =
{
[2503] = tonumber(C_MajorFactions.GetMajorFactionData(2503).renownLevel),
[2507] = tonumber(C_MajorFactions.GetMajorFactionData(2507).renownLevel),
[2510] = tonumber(C_MajorFactions.GetMajorFactionData(2510).renownLevel),
[2511] = tonumber(C_MajorFactions.GetMajorFactionData(2511).renownLevel),
}
end
function AZPRenownGetMaxValues()
for PlayerGUID, PlayerData in pairs(AZPRenownLevels) do
if PlayerGUID ~= "MaxValues" then
for FactionID, FactionLevel in pairs(PlayerData) do
if AZPRenownLevels.MaxValues[FactionID] == nil then AZPRenownLevels.MaxValues[FactionID] = FactionLevel
elseif FactionLevel > tonumber(AZPRenownLevels.MaxValues[FactionID]) then
AZPRenownLevels.MaxValues[FactionID] = FactionLevel
end
end
end
end
end
function AZPRenownAddDataToFrame()
local curGUID = UnitGUID("PLAYER")
AZPRenownGetMaxValues()
for FactionID, FactionData in pairs(FactionIDs) do
local maxLevel = AZPRenownLevels.MaxValues[FactionID]
local curPercentage = 100
if maxLevel >= 20 then
if AZPRenownLevels[curGUID][FactionID] < 10 then curPercentage = 300
elseif AZPRenownLevels[curGUID][FactionID] < 20 then curPercentage = 200 end
elseif maxLevel >= 10 then
if AZPRenownLevels[curGUID][FactionID] < 10 then curPercentage = 200 end
end
ExpansionLandingPage.AZPRenownFrame.FactionList[FactionData.Position].AccountMax:SetText(maxLevel)
ExpansionLandingPage.AZPRenownFrame.FactionList[FactionData.Position].Percentage:SetText(string.format("%d%%", curPercentage))
end
end
AZPRenownOnLoad()