-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathOutfitterAbout.lua
275 lines (208 loc) · 7.83 KB
/
OutfitterAbout.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
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
----------------------------------------
-- Outfitter Copyright 2009-2018 John Stephen
-- All rights reserved, unauthorized redistribution is prohibited
----------------------------------------
----------------------------------------
Outfitter._AboutView = {}
----------------------------------------
function Outfitter._AboutView:New(pParent)
return OutfitterAboutFrame
end
function Outfitter._AboutView:Construct(pParent)
self.Title = self:CreateFontString(nil, "OVERLAY", "GameFontNormalLarge")
self.Title:SetPoint("TOP", self, "TOP", -4, -36)
self.Title:SetWidth(230)
self.Title:SetText(Outfitter.cAboutTitle:format(Outfitter.cVersion))
self.AuthorText = self:CreateFontString(nil, "OVERLAY", "GameFontNormal")
self.AuthorText:SetPoint("TOP", self.Title, "BOTTOM", 0, -13)
self.AuthorText:SetWidth(230)
self.AuthorText:SetJustifyH("CENTER")
self.AuthorText:SetText(Outfitter.cAboutAuthor)
self.AuthorText = self:CreateFontString(nil, "OVERLAY", "GameFontGreen")
self.AuthorText:SetPoint("TOP", self.Title, "BOTTOM", 0, -27)
self.AuthorText:SetWidth(250)
self.AuthorText:SetJustifyH("CENTER")
self.AuthorText:SetText("Ported to Classic by Restoshaman/Miv of <Onslaught> on Skeram")
self.ThanksText = self:CreateFontString(nil, "OVERLAY", "GameFontNormal")
self.ThanksText:SetPoint("TOP", self.Title, "BOTTOM", 0, -58)
self.ThanksText:SetWidth(230)
self.ThanksText:SetJustifyH("CENTER")
self.ThanksText:SetText(Outfitter.cAboutThanks)
self.Credits = Outfitter:New(Outfitter._Credits, self)
self.Credits:SetPoint("TOP", self.ThanksText, "BOTTOM", 0, -10)
self.Credits:SetWidth(230)
self.Credits:SetHeight(200)
self.CopyrightText = self:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
self.CopyrightText:SetPoint("TOP", self.ThanksText, "BOTTOM", 0, -200)
self.CopyrightText:SetWidth(230)
self.CopyrightText:SetJustifyH("CENTER")
self.CopyrightText:SetText(Outfitter.cAboutCopyright)
--self.TestTexture = self.Credits:CreateTexture(nil, "OVERLAY")
--self.TestTexture:SetAllPoints()
--self.TestTexture:SetTexture(1, 0, 0, 0.5)
end
----------------------------------------
Outfitter._Credits = {}
----------------------------------------
function Outfitter._Credits:New(pParent)
return CreateFrame("Frame", nil, pParent)
end
function Outfitter._Credits:Construct(pParent)
self.CreditFrames = {}
self.AvailableCreditFrames = {}
self:SetScript("OnShow", self.OnShow)
self:SetScript("OnHide", self.OnHide)
self:SetScript("OnUpdate", self.OnUpdate)
-- Compile the list
-- Add everything except the current realm
self.Players = {}
for vRealm, vRealmPlayers in pairs(Outfitter.CreditPlayersByRealm) do
if vRealm ~= Outfitter.RealmName then
for vPlayerName, vPlayerInfo in pairs(vRealmPlayers) do
if type(vPlayerInfo) == "number" then
table.insert(self.Players,
{
Name = vPlayerName,
Realm = vRealm,
Level = vPlayerInfo
})
end
end
end
end -- for
-- Add the current realm
local vRealmPlayers = Outfitter.CreditPlayersByRealm[Outfitter.RealmName]
if vRealmPlayers then
-- Calculate how many players there are in the current realm
local vNumRealmPlayers = 0
for vPlayerName, vPlayerInfo in pairs(vRealmPlayers) do
vNumRealmPlayers = vNumRealmPlayers + 1
end
-- Calculate the desired percentage of players from this realm. This
-- ensures that donors and other contributors will show up more often
-- to themselves and other players on their realms
local vLocalPercentage = 0.02 * vNumRealmPlayers
if vLocalPercentage > 0.5 then
vLocalPercentage = 0.5
end
-- Calculate the minimum number of players to add and repeatedly add the
-- realm until that minimum is met
local vMinRealmPlayers = #self.Players * vLocalPercentage / (1 - vLocalPercentage)
repeat
for vPlayerName, vPlayerInfo in pairs(vRealmPlayers) do
if type(vPlayerInfo) == "number" then
table.insert(self.Players,
{
Name = vPlayerName,
Realm = Outfitter.RealmName,
Level = vPlayerInfo
})
end
vMinRealmPlayers = vMinRealmPlayers - 1
end
until vMinRealmPlayers <= 0
end
self:Shuffle()
self.PlayerIndex = 1
self.NextPlayerTime = 0
end
function Outfitter._Credits:Shuffle()
for _, vPlayerInfo in ipairs(self.Players) do
vPlayerInfo.SortValue = math.random()
end
table.sort(self.Players, function (pInfo1, pInfo2)
return pInfo1.SortValue < pInfo2.SortValue
end)
end
function Outfitter._Credits:OnShow()
while next(self.AvailableCreditFrames) do
table.remove(self.AvailableCreditFrames)
end
for _, vCreditFrame in ipairs(self.CreditFrames) do
table.insert(self.AvailableCreditFrames, vCreditFrame)
end
end
function Outfitter._Credits:OnHide()
end
function Outfitter._Credits:OnUpdate(pElapsed)
self.NextPlayerTime = self.NextPlayerTime - pElapsed
if self.NextPlayerTime > 0 then
return
end
self.NextPlayerTime = 1.2
local vCreditFrame = table.remove(self.AvailableCreditFrames)
if not vCreditFrame then
vCreditFrame = Outfitter:New(Outfitter._CreditFrame, self)
table.insert(self.CreditFrames, vCreditFrame)
end
vCreditFrame:SetPlayer(self.Players[self.PlayerIndex])
vCreditFrame:Animate("DROPLET")
self.PlayerIndex = self.PlayerIndex + 1
if self.PlayerIndex > #self.Players then
self:Shuffle()
self.PlayerIndex = 1
end
end
function Outfitter._Credits:ReleaseCreditFrame(pCreditFrame)
table.insert(self.AvailableCreditFrames, pCreditFrame)
end
----------------------------------------
Outfitter._CreditFrame = {}
----------------------------------------
function Outfitter._CreditFrame:New(pParent)
return CreateFrame("Frame", nil, pParent)
end
function Outfitter._CreditFrame:Construct(pParent)
self.Width = 130
self.Height = 30
self.Line1 = self:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
self.Line1:SetPoint("TOP", self, "TOP")
self.Line1:SetWidth(self.Width)
self.Line2 = self:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall")
self.Line2:SetPoint("TOP", self.Line1, "BOTTOM")
self.Line2:SetWidth(self.Width)
self:SetWidth(self.Width)
self:SetHeight(self.Height)
--self.TestTexture = self:CreateTexture(nil, "OVERLAY")
--self.TestTexture:SetAllPoints()
--self.TestTexture:SetTexture(1, 0, 0, 0.5)
self.DestWidth = self:GetParent():GetWidth() - self.Width
self.DestHeight = self:GetParent():GetHeight() - self.Height - 30
self:SetScript("OnUpdate", self.OnUpdate)
end
function Outfitter._CreditFrame:SetPlayer(pPlayerInfo)
self.Line1:SetText(pPlayerInfo.Name)
self.Line2:SetText(pPlayerInfo.Realm)
end
function Outfitter._CreditFrame:Animate(pStyle)
self.AnimationStyle = pStyle
self.AnimationElapsed = 0
if self.AnimationStyle == "DROPLET" then
self.HorizPos = math.random() * self.DestWidth - 0.5 * self.DestWidth
self.VertPos = 0
self:SetPoint("TOP", self:GetParent(), "TOP", self.HorizPos, self.VertPos)
self:SetAlpha(0)
self.FadeInTime = 0.8
self.VertVelocity = 0
self.VertAccel = 0
end
end
function Outfitter._CreditFrame:OnUpdate(pElapsed)
if self.AnimationStyle == "DROPLET" then
self.AnimationElapsed = self.AnimationElapsed + pElapsed
if self.AnimationElapsed > self.FadeInTime then
self:SetAlpha(1)
self.VertAccel = -50
self.VertVelocity = self.VertVelocity + self.VertAccel * pElapsed
self.VertPos = self.VertPos + self.VertVelocity * pElapsed
self:SetPoint("TOP", self:GetParent(), "TOP", self.HorizPos, self.VertPos)
if self.VertPos < -self.DestHeight then
self.AnimationStyle = nil
self:SetAlpha(0)
self:GetParent():ReleaseCreditFrame(self)
end
else
self:SetAlpha(self.AnimationElapsed / self.FadeInTime)
end
end
end