-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPlayerlist.lua
More file actions
183 lines (154 loc) · 4.65 KB
/
Playerlist.lua
File metadata and controls
183 lines (154 loc) · 4.65 KB
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
-- THIS MAY BECOME A MODULE FOR MULTIPLE UIS INSTEAD OF THE PLAYERLIST. IT WILL BE DELELTED
--// Services
local CoreGui = game:GetService("CoreGui")
local Players = game:GetService("Players")
--// Unpack Playerlist UI
local Playerlist = CoreGui.PlayerList
local Children = Playerlist.Children
local Container = Children:FindFirstChild("SizeOffsetFrame", true)
local TitleBar = Container.TitleBar
local ScrollingFrame = Container.ScrollingFrameContainer
local Entries = ScrollingFrame:FindFirstChild("OffsetUndoFrame", true)
--// Module
local Bindings = {
Playerlist = Container,
Container = ScrollingFrame,
TitleBar = TitleBar,
TitleTags = TitleBar.ChildrenFrame,
Entries = Entries
}
local Types = {
Team = "t_",
Player = "p_"
}
function CollectStats(Parent, Split)
local Found = {}
for _, Child in next, Parent:GetChildren() do
local Name = Child.Name
if Name:match(Split) then
local Stat = Name:split(Split)[2]
Found[Stat] = Child
end
end
return Found
end
function ResolvePlayer(Entry: Frame)
local PlayerName = Entry:FindFirstChild("PlayerName", true)
if not PlayerName then return end
PlayerName = PlayerName:FindFirstChildOfClass("TextLabel") or PlayerName
local ChildrenFrame = Entry.ChildrenFrame
local PlayerIcon = ChildrenFrame:FindFirstChild("PlayerIcon", true)
local BackgroundExtender = ChildrenFrame.BackgroundExtender -- Dumb
local NameFrame = ChildrenFrame.NameFrame
local BGFrame = NameFrame.BGFrame
local self = {
Stats = CollectStats(ChildrenFrame, "GameStat_"),
Entry = Entry,
ChildrenFrame = ChildrenFrame,
PlayerIcon = PlayerIcon,
PlayerName = PlayerName,
NameFrame = NameFrame,
CleanName = PlayerName.Text
}
function self:GetStat(Name: string)
return self.Stats[Name]
end
function self:SetPlayerName(Text: string)
PlayerName.Text = Text
end
function self:SetPlayerIcon(Image: string)
PlayerIcon.Image = Image
end
function self:SetPlayerIconProperty(Key: string, Value)
PlayerIcon[Key] = Value
end
function self:SetPlayerNameProperty(Key: string, Value)
PlayerName[Key] = Value
end
function self:SetBackgroundProperty(Key: string, Value)
local Stats = self.Stats
local Backs = {
BackgroundExtender,
BGFrame
}
for _, Background in next, Backs do
Background[Key] = Value
end
for _, Stat in next, Stats do
Stat[Key] = Value
end
end
return self
end
function ResolveTeam(Tag: Frame)
local TeamName = Tag:FindFirstChild("TeamName", true)
if not TeamName then return end
local BackgroundExtender = Tag.BackgroundExtender -- Dumb
local NameFrame = Tag.NameFrame
local BGFrame = NameFrame.BGFrame
local self = {
Stats = CollectStats(Tag, "gameStat_"),
Tag = Tag,
TeamName = TeamName,
NameFrame = NameFrame,
CleanName = TeamName.Text
}
function self:GetStat(Name: string)
return self.Stats[Name]
end
function self:SetTeamText(Text: string)
TeamName.Text = Text
end
function self:GetTeamText(Text: string): string
return TeamName.Text
end
function self:SetTextProperty(Key: string, Value)
TeamName[Key] = Value
end
function self:SetBackgroundProperty(Key: string, Value)
local Stats = self.Stats
local Backs = {
BackgroundExtender,
BGFrame
}
for _, Background in next, Backs do
Background[Key] = Value
end
for _, Stat in next, Stats do
Stat[Key] = Value
end
end
return self
end
function Bindings:GetEntriesByType(Match: string)
local Matched = {}
local Resolves = {
[Types.Player] = ResolvePlayer,
[Types.Team] = ResolveTeam,
}
for _, Entry in next, Entries:GetChildren() do
local Name = Entry.Name
if Name:match(Match) then
local Resolve = Resolves[Match]
local Resolved = Resolve(Entry)
local CleanName = Resolved.CleanName
Matched[CleanName] = Resolved
end
end
return Matched
end
function Bindings:GetTeams()
return self:GetEntriesByType(Types.Team)
end
function Bindings:GetPlayers()
return self:GetEntriesByType(Types.Player)
end
function Bindings:GetTeam(Match)
local Tags = self:GetTeams()
return Tags[Match]
end
function Bindings:GetPlayer(Target: Player)
local Entries = self:GetPlayers()
return Entries[Target.Name]
end
return Bindings