-
Notifications
You must be signed in to change notification settings - Fork 0
/
FarmPvPFunctions.lua
259 lines (212 loc) · 7.32 KB
/
FarmPvPFunctions.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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
local _G = _G
local _, FP = ...
function FP:GetHighestWeeklyRating()
-- 2v2 is 1, 3v3 is 2, 5v5 is 3 (doesn't exist in retail), rbg is 4.
local _, _, weeklyBest2v2 = GetPersonalRatedInfo(1)
local _, _, weeklyBest3v3 = GetPersonalRatedInfo(2)
local _, _, weeklyBestRBG = GetPersonalRatedInfo(4)
return math.max(weeklyBest2v2, weeklyBest3v3, weeklyBestRBG)
end
function FP:GetHighestWeeklyRank(highestRating)
for i = 1, #(FP.RanksRatingIntervals), 1 do
if highestRating >= FP.RanksRatingIntervals[i] and FP.RanksRatingIntervals[i + 1] ~= nil and highestRating < FP.RanksRatingIntervals[i + 1] then
return i
end
end
end
function FP:SetSectionText(target, textureTarget, value)
if value <= 0 then
target:SetText("-")
if textureTarget then
textureTarget:Hide()
end
else
target:SetText(string.commavalue(value))
if textureTarget and FP.Settings.Mode == 'default' then
textureTarget:Show()
end
end
end
function FP:SetPlayerFactionTexture()
local playerFaction, _ = UnitFactionGroup("player")
_G.FarmPvPFrame_Faction:SetTexture(self.FactionTextures[playerFaction])
end
function FP:SetHighestWeeklyRankTexture()
local highestWeeklyRating = self:GetHighestWeeklyRating()
local highestWeeklyRank = self:GetHighestWeeklyRank(highestWeeklyRating)
_G.FarmPvPFrame_honorWeeklyTotalRankTexture:SetTexture(self.RanksIconMapping[highestWeeklyRank])
end
function FP:SetTitle(title)
_G.FarmPvPFrame_Title:SetText(title)
end
function FP:SetVersion(version)
_G.FarmPvPFrame_Version:SetText(version)
end
function FP:ShowHideSections()
local playerLevel = UnitLevel("player")
if playerLevel ~= 60 then
_G.FarmPvPFrame_conquest:Hide()
_G.FarmPvPFrame_conquestTexture:Hide()
_G.FarmPvPFrame_conquestRankTexture:Hide()
_G.FarmPvPFrame_conquestRank:Hide()
_G.FarmPvPFrame_honorWeeklyTotal:Hide()
_G.FarmPvPFrame_honorWeeklyTotalTexture:Hide()
_G.FarmPvPFrame_honorWeeklyTotalRankTexture:Hide()
_G.FarmPvPFrame_honorWeeklyTotalRank:Hide()
_G.FarmPvPFrame_honorTotal:Hide()
_G.FarmPvPFrame_honorTotalTexture:Hide()
_G.FarmPvPFrame_honorTotalRankTexture:Hide()
_G.FarmPvPFrame_honorTotalRank:Hide()
_G.FarmPvPFrame_Remaining:Hide()
_G.FarmPvPFrame_LevelPrefixText:Show()
_G.FarmPvPFrame_LevelSuffixText:Show()
_G.FarmPvPFrame_numberSix:Show()
_G.FarmPvPFrame_numberZero:Show()
else
_G.FarmPvPFrame_conquest:Show()
_G.FarmPvPFrame_conquestTexture:Show()
_G.FarmPvPFrame_conquestRankTexture:Show()
_G.FarmPvPFrame_conquestRank:Show()
_G.FarmPvPFrame_honorWeeklyTotal:Show()
_G.FarmPvPFrame_honorWeeklyTotalTexture:Show()
_G.FarmPvPFrame_honorWeeklyTotalRankTexture:Show()
_G.FarmPvPFrame_honorWeeklyTotalRank:Show()
_G.FarmPvPFrame_honorTotal:Show()
_G.FarmPvPFrame_honorTotalTexture:Show()
_G.FarmPvPFrame_honorTotalRankTexture:Show()
_G.FarmPvPFrame_honorTotalRank:Show()
_G.FarmPvPFrame_Remaining:Show()
_G.FarmPvPFrame_LevelPrefixText:Hide()
_G.FarmPvPFrame_LevelSuffixText:Hide()
_G.FarmPvPFrame_numberSix:Hide()
_G.FarmPvPFrame_numberZero:Hide()
end
end
function FP:HookButtons()
_G.FarmPvPFrame_CloseButton:SetAlpha(0)
_G.FarmPvPFrame_MaximizeMinimizeButton:SetAlpha(0)
_G.FarmPvPFrame:HookScript("OnEnter", function ()
_G.FarmPvPFrame_CloseButton:SetAlpha(1)
_G.FarmPvPFrame_MaximizeMinimizeButton:SetAlpha(1)
end)
_G.FarmPvPFrame:HookScript("OnLeave", function (self)
if _G.FarmPvPFrame_CloseButton:IsMouseOver() == false and _G.FarmPvPFrame_MaximizeMinimizeButton:IsMouseOver() == false then
_G.FarmPvPFrame_CloseButton:SetAlpha(0)
_G.FarmPvPFrame_MaximizeMinimizeButton:SetAlpha(0)
end
end)
_G.FarmPvPFrame_CloseButton:SetScript("OnLeave", function (self)
self:SetAlpha(0)
_G.FarmPvPFrame_MaximizeMinimizeButton:SetAlpha(0)
end)
_G.FarmPvPFrame_CloseButton:SetScript("OnEnter", function (self)
self:SetAlpha(1)
_G.FarmPvPFrame_MaximizeMinimizeButton:SetAlpha(1)
end)
_G.FarmPvPFrame_MaximizeMinimizeButton:HookScript("OnLeave", function (self)
self:SetAlpha(0)
_G.FarmPvPFrame_CloseButton:SetAlpha(0)
end)
_G.FarmPvPFrame_MaximizeMinimizeButton:HookScript("OnEnter", function (self)
self:SetAlpha(1)
_G.FarmPvPFrame_CloseButton:SetAlpha(1)
end)
end
function FP:Minimize()
-- Start by making the main frame smaller.
_G.FarmPvPFrame:SetHeight(50)
-- Hide unimportant frames.
_G.FarmPvPFrame_Header:Hide()
_G.FarmPvPFrame_Title:Hide()
_G.FarmPvPFrame_Faction:Hide()
_G.FarmPvPFrame_Version:Hide()
_G.FarmPvPFrame_Remaining:Hide()
-- Make sure pre-60 frames are hidden in compact mode.
_G.FarmPvPFrame_LevelPrefixText:Hide()
_G.FarmPvPFrame_LevelSuffixText:Hide()
_G.FarmPvPFrame_numberSix:Hide()
_G.FarmPvPFrame_numberZero:Hide()
-- Reposition and alter sections.
FP:RepositionSection('conquest', {"LEFT", 45, 0})
FP:RepositionSection('honorWeeklyTotal', {"CENTER"})
FP:RepositionSection('honorTotal', {"RIGHT", -45, 0})
end
function FP:Maximize()
-- Start by making the main frame bigger.
_G.FarmPvPFrame:SetHeight(275)
_G.FarmPvPFrame_Header:Show()
_G.FarmPvPFrame_Title:Show()
_G.FarmPvPFrame_Faction:Show()
_G.FarmPvPFrame_Version:Show()
_G.FarmPvPFrame_Remaining:Show()
_G.FarmPvPFrame_CloseButton:Show()
_G.FarmPvPFrame_MaximizeMinimizeButton:Show()
-- Reposition and alter sections.
FP:RepositionSection('conquest', {"LEFT", 45, 90})
FP:RepositionSection('honorWeeklyTotal', {"LEFT", 45, -25})
FP:RepositionSection('honorTotal', {"BOTTOMLEFT", 45, 85})
end
function FP:RepositionSection(id, position)
local rankTexture = _G["FarmPvPFrame_" .. id .. "RankTexture"]
rankTexture:ClearAllPoints()
rankTexture:SetPoint(unpack(position))
local main = _G["FarmPvPFrame_" .. id]
main:ClearAllPoints()
if FP.Settings.Mode == "compact" then
rankTexture:SetAlpha(0.5)
main:SetPoint("CENTER", rankTexture)
if main:GetText() == '-' then
main:Hide()
end
_G["FarmPvPFrame_" .. id .. "Texture"]:Hide()
_G["FarmPvPFrame_" .. id .. "Rank"]:Hide()
else
-- We want to reset the position.
rankTexture:SetAlpha(1)
main:SetPoint("BOTTOMLEFT", rankTexture, 45, 0)
main:Show()
if main:GetText() ~= '-' then
_G["FarmPvPFrame_" .. id .. "Texture"]:Show()
end
_G["FarmPvPFrame_" .. id .. "Rank"]:Show()
end
end
function FP:HideSection(id)
_G["FarmPvPFrame_" .. id]:Hide()
_G["FarmPvPFrame_" .. id .. "Texture"]:Hide()
_G["FarmPvPFrame_" .. id .. "Rank"]:Hide()
_G["FarmPvPFrame_" .. id .. "RankTexture"]:Hide()
end
function FP:ShowSection(id)
_G["FarmPvPFrame_" .. id]:Show()
_G["FarmPvPFrame_" .. id .. "RankTexture"]:Show()
if FP.Settings.Mode ~= 'compact' then
_G["FarmPvPFrame_" .. id .. "Texture"]:Show()
_G["FarmPvPFrame_" .. id .. "Rank"]:Show()
end
end
function FP:ShowCompleteSection()
FP:HideSection("conquest")
FP:HideSection("honorWeeklyTotal")
FP:HideSection("honorTotal")
_G.FarmPvPFrame_Remaining:Hide()
_G.FarmPvPFrame_CompleteText:Show()
end
function FP:HideCompleteSection()
FP:ShowSection("conquest")
FP:ShowSection("honorWeeklyTotal")
FP:ShowSection("honorTotal")
if FP.Settings.Mode ~= 'compact' then
_G.FarmPvPFrame_Remaining:Show()
end
_G.FarmPvPFrame_CompleteText:Hide()
end
function FP:SetLocation()
if FP.Settings.Location ~= nil then
_G.FarmPvPFrame:SetPoint(unpack(FP.Settings.Location))
end
_G.FarmPvPFrame:HookScript("OnDragStop", function (self)
local point, relativeTo, relativePoint, xOfs, yOfs = self:GetPoint()
FP.Settings.Location = {point, relativeTo, relativePoint, xOfs, yOfs}
end)
end