-
Notifications
You must be signed in to change notification settings - Fork 223
Expand file tree
/
Copy pathContainer.lua
More file actions
215 lines (195 loc) · 7.28 KB
/
Copy pathContainer.lua
File metadata and controls
215 lines (195 loc) · 7.28 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
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
local hasBecomeOldTheme = false
local previousInsetHeight = 0
return function(Icon)
-- Has to be included for the time being due to this bug mentioned here:
-- https://devforum.roblox.com/t/bug/2973508/7
local GuiService = game:GetService("GuiService")
local Players = game:GetService("Players")
local UserInputService = game:GetService("UserInputService")
local container = {}
local Signal = require(script.Parent.Parent.Packages.GoodSignal)
local insetChanged = Signal.new()
local guiInset = GuiService:GetGuiInset()
local startInset = 0
local yDownOffset = 0
local ySizeOffset = 0
local checkCount = 0
local isConsoleScreen = false
local isUsingVR = false
local function checkInset(status)
local currentHeight = GuiService.TopbarInset.Height
local isOldTopbar = currentHeight <= 36
-- These additional checks are needed to ensure *it is actually* the old topbar
-- and not a client which takes a really long time to load
-- There's unfortunately no APIs to do this a prettier way
isConsoleScreen = GuiService:IsTenFootInterface()
isUsingVR = UserInputService.VREnabled
Icon.isOldTopbar = isOldTopbar
checkCount += 1
if currentHeight == 0 and status == nil then
task.defer(function()
task.wait(8)
checkInset("ForceConvertToOld")
end)
elseif checkCount == 1 then
task.delay(5, function()
local localPlayer = Players.LocalPlayer
localPlayer:WaitForChild("PlayerGui")
if checkCount == 1 then
checkInset()
end
end)
end
-- Conver to old theme if verified
if Icon.isOldTopbar and not isConsoleScreen and not isUsingVR and hasBecomeOldTheme == false and (currentHeight ~= 0 or status == "ForceConvertToOld") then
hasBecomeOldTheme = true
task.defer(function()
-- If oldtopbar, apply the Classic theme
local themes = script.Parent.Parent.Features.Themes
local Classic = require(themes.Classic)
Icon.modifyBaseTheme(Classic)
-- Also configure the oldtopbar correctly
local function decideToHideTopbar()
if GuiService.MenuIsOpen then
Icon.setTopbarEnabled(false, true)
else
Icon.setTopbarEnabled()
end
end
GuiService:GetPropertyChangedSignal("MenuIsOpen"):Connect(decideToHideTopbar)
decideToHideTopbar()
end)
end
-- Modify the offsets slightly depending on device type
guiInset = GuiService:GetGuiInset()
startInset = if isOldTopbar then 12 else guiInset.Y - 50
yDownOffset = if isOldTopbar then 2 else 0 --if isOldTopbar then 2 else 0
ySizeOffset = -2
if isConsoleScreen then
startInset = 10
yDownOffset = 0 ---9
end
if GuiService.TopbarInset.Height == 0 and not hasBecomeOldTheme then
yDownOffset += 13
ySizeOffset = 50
end
-- Now inform other areas of the change
insetChanged:Fire(guiInset)
local insetHeight = guiInset.Y
if insetHeight ~= previousInsetHeight then
previousInsetHeight = insetHeight
task.defer(function()
Icon.insetHeightChanged:Fire(insetHeight)
end)
end
end
GuiService:GetPropertyChangedSignal("TopbarInset"):Connect(checkInset)
checkInset("FirstTime")
local screenGui = Instance.new("ScreenGui")
insetChanged:Connect(function()
screenGui:SetAttribute("StartInset", startInset)
end)
screenGui.Name = "TopbarStandard"
screenGui.Enabled = true
screenGui.DisplayOrder = Icon.baseDisplayOrder
screenGui.ZIndexBehavior = Enum.ZIndexBehavior.Sibling
screenGui.IgnoreGuiInset = true
screenGui.ResetOnSpawn = false
screenGui.ScreenInsets = Enum.ScreenInsets.TopbarSafeInsets
container[screenGui.Name] = screenGui
Icon.baseDisplayOrderChanged:Connect(function()
screenGui.DisplayOrder = Icon.baseDisplayOrder
end)
local holders = Instance.new("Frame")
holders.Name = "Holders"
holders.BackgroundTransparency = 1
insetChanged:Connect(function()
local holderY = if isUsingVR then 36 else 56
local holderSize = if isConsoleScreen then UDim2.new(1, 0, 0, holderY) else UDim2.new(1, 0, 1, ySizeOffset)
holders.Position = UDim2.new(0, 0, 0, yDownOffset)
holders.Size = holderSize
end)
holders.Visible = true
holders.ZIndex = 1
holders.Parent = screenGui
local screenGuiCenter = screenGui:Clone()
local holdersCenter = screenGuiCenter.Holders
local function updateCenteredHoldersHeight()
holdersCenter.Size = UDim2.new(1, 0, 0, GuiService.TopbarInset.Height+ySizeOffset)
end
screenGuiCenter.Name = "TopbarCentered"
screenGuiCenter.DisplayOrder = Icon.baseDisplayOrder
screenGuiCenter.ScreenInsets = Enum.ScreenInsets.TopbarSafeInsets
Icon.baseDisplayOrderChanged:Connect(function()
screenGuiCenter.DisplayOrder = Icon.baseDisplayOrder
end)
container[screenGuiCenter.Name] = screenGuiCenter
insetChanged:Connect(updateCenteredHoldersHeight)
updateCenteredHoldersHeight()
local screenGuiClipped = screenGui:Clone()
screenGuiClipped.Name = screenGuiClipped.Name.."Clipped"
screenGuiClipped.DisplayOrder = (Icon.baseDisplayOrder + 1)
Icon.baseDisplayOrderChanged:Connect(function()
screenGuiClipped.DisplayOrder = (Icon.baseDisplayOrder + 1)
end)
container[screenGuiClipped.Name] = screenGuiClipped
local screenGuiCenterClipped = screenGuiCenter:Clone()
screenGuiCenterClipped.Name = screenGuiCenterClipped.Name.."Clipped"
screenGuiCenterClipped.DisplayOrder = (Icon.baseDisplayOrder + 1)
Icon.baseDisplayOrderChanged:Connect(function()
screenGuiCenterClipped.DisplayOrder = (Icon.baseDisplayOrder + 1)
end)
container[screenGuiCenterClipped.Name] = screenGuiCenterClipped
local holderReduction = -24
local left = Instance.new("ScrollingFrame")
left:SetAttribute("IsAHolder", true)
left.Name = "Left"
insetChanged:Connect(function()
left.Position = UDim2.fromOffset(startInset, 0)
end)
left.Size = UDim2.new(1, holderReduction, 1, 0)
left.BackgroundTransparency = 1
left.Visible = true
left.ZIndex = 1
left.Active = false
left.ClipsDescendants = true
left.HorizontalScrollBarInset = Enum.ScrollBarInset.None
left.CanvasSize = UDim2.new(0, 0, 1, -1) -- This -1 prevents a dropdown scrolling appearance bug
left.AutomaticCanvasSize = Enum.AutomaticSize.X
left.ScrollingDirection = Enum.ScrollingDirection.X
left.ScrollBarThickness = 0
left.BorderSizePixel = 0
left.Selectable = false
left.ScrollingEnabled = false--true
left.ElasticBehavior = Enum.ElasticBehavior.Never
left.Parent = holders
local UIListLayout = Instance.new("UIListLayout")
insetChanged:Connect(function()
UIListLayout.Padding = UDim.new(0, startInset)
end)
UIListLayout.FillDirection = Enum.FillDirection.Horizontal
UIListLayout.SortOrder = Enum.SortOrder.LayoutOrder
UIListLayout.VerticalAlignment = Enum.VerticalAlignment.Bottom
UIListLayout.HorizontalAlignment = Enum.HorizontalAlignment.Left
UIListLayout.Parent = left
local center = left:Clone()
insetChanged:Connect(function()
center.UIListLayout.Padding = UDim.new(0, startInset)
end)
center.ScrollingEnabled = false
center.UIListLayout.HorizontalAlignment = Enum.HorizontalAlignment.Center
center.Name = "Center"
center.Parent = holdersCenter
local right = left:Clone()
insetChanged:Connect(function()
right.UIListLayout.Padding = UDim.new(0, startInset)
end)
right.UIListLayout.HorizontalAlignment = Enum.HorizontalAlignment.Right
right.Name = "Right"
right.AnchorPoint = Vector2.new(1, 0)
right.Position = UDim2.new(1, -12, 0, 0)
right.Parent = holders
-- This is important so that all elements update instantly
insetChanged:Fire(guiInset)
return container
end