@quenty/genericscreenguiprovider 8.1.0 → 8.1.2-canary.433.80025dc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,22 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [8.1.2-canary.433.80025dc.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/genericscreenguiprovider@8.1.1...@quenty/genericscreenguiprovider@8.1.2-canary.433.80025dc.0) (2023-12-14)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @quenty/genericscreenguiprovider
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
## [8.1.1](https://github.com/Quenty/NevermoreEngine/compare/@quenty/genericscreenguiprovider@8.1.0...@quenty/genericscreenguiprovider@8.1.1) (2023-10-28)
|
|
15
|
+
|
|
16
|
+
**Note:** Version bump only for package @quenty/genericscreenguiprovider
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
6
22
|
# [8.1.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/genericscreenguiprovider@8.0.0...@quenty/genericscreenguiprovider@8.1.0) (2023-10-18)
|
|
7
23
|
|
|
8
24
|
**Note:** Version bump only for package @quenty/genericscreenguiprovider
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quenty/genericscreenguiprovider",
|
|
3
|
-
"version": "8.1.0",
|
|
3
|
+
"version": "8.1.2-canary.433.80025dc.0",
|
|
4
4
|
"description": "Providers screenGuis with a given display order for easy use",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Roblox",
|
|
@@ -24,13 +24,16 @@
|
|
|
24
24
|
"Quenty"
|
|
25
25
|
],
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@quenty/blend": "
|
|
28
|
-
"@quenty/loader": "
|
|
29
|
-
"@quenty/
|
|
30
|
-
"@quenty/
|
|
27
|
+
"@quenty/blend": "7.1.2-canary.433.80025dc.0",
|
|
28
|
+
"@quenty/loader": "7.0.1-canary.433.80025dc.0",
|
|
29
|
+
"@quenty/maid": "2.6.0",
|
|
30
|
+
"@quenty/servicebag": "7.0.1-canary.433.80025dc.0",
|
|
31
|
+
"@quenty/string": "3.1.0",
|
|
32
|
+
"@quenty/uiobjectutils": "3.4.1-canary.433.80025dc.0",
|
|
33
|
+
"@quenty/valueobject": "8.1.2-canary.433.80025dc.0"
|
|
31
34
|
},
|
|
32
35
|
"publishConfig": {
|
|
33
36
|
"access": "public"
|
|
34
37
|
},
|
|
35
|
-
"gitHead": "
|
|
38
|
+
"gitHead": "80025dcd926765b502d322bb84e013b973409d8c"
|
|
36
39
|
}
|
|
@@ -25,12 +25,13 @@
|
|
|
25
25
|
|
|
26
26
|
local require = require(script.Parent.loader).load(script)
|
|
27
27
|
|
|
28
|
-
local Players = game:GetService("Players")
|
|
29
28
|
local RunService = game:GetService("RunService")
|
|
30
29
|
|
|
31
30
|
local String = require("String")
|
|
32
|
-
local PlayerGuiUtils = require("PlayerGuiUtils")
|
|
33
31
|
local Blend = require("Blend")
|
|
32
|
+
local Maid = require("Maid")
|
|
33
|
+
local ScreenGuiService = require("ScreenGuiService")
|
|
34
|
+
local ServiceBag = require("ServiceBag")
|
|
34
35
|
|
|
35
36
|
local GenericScreenGuiProvider = {}
|
|
36
37
|
GenericScreenGuiProvider.ClassName = GenericScreenGuiProvider
|
|
@@ -50,16 +51,37 @@ function GenericScreenGuiProvider.new(orders)
|
|
|
50
51
|
return self
|
|
51
52
|
end
|
|
52
53
|
|
|
54
|
+
function GenericScreenGuiProvider:Init(serviceBag)
|
|
55
|
+
self._serviceBag = assert(serviceBag, "No serviceBag")
|
|
56
|
+
self._maid = Maid.new()
|
|
57
|
+
|
|
58
|
+
self._screenGuiService = self._serviceBag:GetService(ScreenGuiService)
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
function GenericScreenGuiProvider:Start()
|
|
62
|
+
|
|
63
|
+
end
|
|
64
|
+
|
|
53
65
|
function GenericScreenGuiProvider:__index(index)
|
|
54
66
|
if GenericScreenGuiProvider[index] then
|
|
55
67
|
return GenericScreenGuiProvider[index]
|
|
68
|
+
elseif index == "_screenGuiService"
|
|
69
|
+
or index == "_serviceBag"
|
|
70
|
+
or index == "_maid" then
|
|
71
|
+
return rawget(self, index)
|
|
72
|
+
else
|
|
73
|
+
error(string.format("Bad index %q", tostring(index)), 2)
|
|
56
74
|
end
|
|
57
|
-
|
|
58
|
-
error(("Bad index %q"):format(tostring(index)), 2)
|
|
59
75
|
end
|
|
60
76
|
|
|
61
|
-
function GenericScreenGuiProvider:__newindex(index,
|
|
62
|
-
|
|
77
|
+
function GenericScreenGuiProvider:__newindex(index, value)
|
|
78
|
+
if index == "_screenGuiService"
|
|
79
|
+
or index == "_serviceBag"
|
|
80
|
+
or index == "_maid" then
|
|
81
|
+
rawset(self, index, value)
|
|
82
|
+
else
|
|
83
|
+
error(string.format("Bad index %q", tostring(index)), 2)
|
|
84
|
+
end
|
|
63
85
|
end
|
|
64
86
|
|
|
65
87
|
--[=[
|
|
@@ -68,8 +90,16 @@ end
|
|
|
68
90
|
@return Observable<Instance>
|
|
69
91
|
]=]
|
|
70
92
|
function GenericScreenGuiProvider:ObserveScreenGui(orderName)
|
|
93
|
+
assert(type(orderName) == "string", "Bad orderName")
|
|
94
|
+
|
|
71
95
|
if not RunService:IsRunning() then
|
|
72
|
-
return
|
|
96
|
+
return Blend.New "Frame" {
|
|
97
|
+
Name = String.toCamelCase(orderName);
|
|
98
|
+
Archivable = false;
|
|
99
|
+
Size = UDim2.fromScale(1, 1);
|
|
100
|
+
BackgroundTransparency = 1;
|
|
101
|
+
Parent = self:_getScreenGuiService():ObservePlayerGui();
|
|
102
|
+
}
|
|
73
103
|
end
|
|
74
104
|
|
|
75
105
|
return Blend.New "ScreenGui" {
|
|
@@ -77,7 +107,7 @@ function GenericScreenGuiProvider:ObserveScreenGui(orderName)
|
|
|
77
107
|
ResetOnSpawn = false;
|
|
78
108
|
AutoLocalize = false;
|
|
79
109
|
DisplayOrder = self:GetDisplayOrder(orderName);
|
|
80
|
-
Parent =
|
|
110
|
+
Parent = self:_getScreenGuiService():ObservePlayerGui();
|
|
81
111
|
ZIndexBehavior = Enum.ZIndexBehavior.Sibling;
|
|
82
112
|
}
|
|
83
113
|
end
|
|
@@ -88,21 +118,27 @@ end
|
|
|
88
118
|
@return ScreenGui
|
|
89
119
|
]=]
|
|
90
120
|
function GenericScreenGuiProvider:Get(orderName)
|
|
91
|
-
|
|
92
|
-
return self:_mockScreenGui(orderName)
|
|
93
|
-
end
|
|
121
|
+
assert(type(orderName) == "string", "Bad orderName")
|
|
94
122
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
123
|
+
if not RunService:IsRunning() then
|
|
124
|
+
local frame = Instance.new("Frame")
|
|
125
|
+
frame.Name = String.toCamelCase(orderName)
|
|
126
|
+
frame.Archivable = false
|
|
127
|
+
frame.Size = UDim2.fromScale(1, 1)
|
|
128
|
+
frame.BorderSizePixel = 0
|
|
129
|
+
frame.BackgroundTransparency = 1
|
|
130
|
+
frame.BackgroundColor3 = Color3.new(1, 1, 1)
|
|
131
|
+
frame.Parent = self:_getScreenGuiService():GetPlayerGui()
|
|
132
|
+
return frame
|
|
98
133
|
end
|
|
99
134
|
|
|
100
135
|
local screenGui = Instance.new("ScreenGui")
|
|
101
136
|
screenGui.Name = String.toCamelCase(orderName)
|
|
102
137
|
screenGui.ResetOnSpawn = false
|
|
103
138
|
screenGui.AutoLocalize = false
|
|
139
|
+
screenGui.Archivable = false
|
|
104
140
|
screenGui.DisplayOrder = self:GetDisplayOrder(orderName)
|
|
105
|
-
screenGui.Parent =
|
|
141
|
+
screenGui.Parent = self:_getScreenGuiService():GetPlayerGui()
|
|
106
142
|
screenGui.ZIndexBehavior = Enum.ZIndexBehavior.Sibling
|
|
107
143
|
|
|
108
144
|
return screenGui
|
|
@@ -120,53 +156,24 @@ function GenericScreenGuiProvider:GetDisplayOrder(orderName)
|
|
|
120
156
|
return self._order[orderName]
|
|
121
157
|
end
|
|
122
158
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
@return function -- Cleanup function to reset mock parent
|
|
127
|
-
]=]
|
|
128
|
-
function GenericScreenGuiProvider:SetupMockParent(target)
|
|
129
|
-
assert(not RunService:IsRunning(), "Bad target")
|
|
130
|
-
assert(target, "Bad target")
|
|
131
|
-
|
|
132
|
-
rawset(self, "_mockParent", target)
|
|
133
|
-
|
|
134
|
-
return function()
|
|
135
|
-
if rawget(self, "_mockParent") == target then
|
|
136
|
-
rawset(self, "_mockParent", nil)
|
|
137
|
-
end
|
|
159
|
+
function GenericScreenGuiProvider:_getScreenGuiService()
|
|
160
|
+
if self._screenGuiService then
|
|
161
|
+
return self._screenGuiService
|
|
138
162
|
end
|
|
139
|
-
end
|
|
140
|
-
|
|
141
|
-
function GenericScreenGuiProvider:_mockScreenGui(orderName)
|
|
142
|
-
assert(type(orderName) == "string", "Bad orderName")
|
|
143
|
-
assert(rawget(self, "_mockParent"), "No _mockParent set")
|
|
144
|
-
|
|
145
|
-
local displayOrder = self:GetDisplayOrder(orderName)
|
|
146
163
|
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
164
|
+
-- Hack!
|
|
165
|
+
-- TODO: Don't do this? But what's the alternative..
|
|
166
|
+
if not RunService:IsRunning() then
|
|
167
|
+
local serviceBag = ServiceBag.new()
|
|
168
|
+
self._screenGuiService = serviceBag:GetService(require("ScreenGuiService"))
|
|
169
|
+
return self._screenGuiService
|
|
170
|
+
end
|
|
152
171
|
|
|
153
|
-
|
|
172
|
+
error("Not initialized")
|
|
154
173
|
end
|
|
155
174
|
|
|
156
|
-
function GenericScreenGuiProvider:
|
|
157
|
-
|
|
158
|
-
assert(rawget(self, "_mockParent"), "No _mockParent set")
|
|
159
|
-
|
|
160
|
-
local displayOrder = self:GetDisplayOrder(orderName)
|
|
161
|
-
|
|
162
|
-
return Blend.New "Frame" {
|
|
163
|
-
Size = UDim2.new(1, 0, 1, 0);
|
|
164
|
-
BackgroundTransparency = 1;
|
|
165
|
-
ZIndex = displayOrder;
|
|
166
|
-
Parent = rawget(self, "_mockParent");
|
|
167
|
-
};
|
|
175
|
+
function GenericScreenGuiProvider:Destroy()
|
|
176
|
+
self._maid:DoCleaning()
|
|
168
177
|
end
|
|
169
178
|
|
|
170
|
-
|
|
171
|
-
|
|
172
179
|
return GenericScreenGuiProvider
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
--[=[
|
|
2
|
+
@class ScreenGuiService
|
|
3
|
+
]=]
|
|
4
|
+
|
|
5
|
+
local require = require(script.Parent.loader).load(script)
|
|
6
|
+
|
|
7
|
+
local RunService = game:GetService("RunService")
|
|
8
|
+
|
|
9
|
+
local Maid = require("Maid")
|
|
10
|
+
local ValueObject = require("ValueObject")
|
|
11
|
+
local PlayerGuiUtils = require("PlayerGuiUtils")
|
|
12
|
+
|
|
13
|
+
local ScreenGuiService = {}
|
|
14
|
+
ScreenGuiService.ServiceName = "ScreenGuiService"
|
|
15
|
+
|
|
16
|
+
function ScreenGuiService:Init(serviceBag)
|
|
17
|
+
assert(not self._serviceBag, "Already initialized")
|
|
18
|
+
self._serviceBag = assert(serviceBag, "No serviceBag")
|
|
19
|
+
|
|
20
|
+
self:_ensureInit()
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
function ScreenGuiService:GetPlayerGui()
|
|
24
|
+
self:_ensureInit()
|
|
25
|
+
|
|
26
|
+
return self._playerGui.Value
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
function ScreenGuiService:SetGuiParent(playerGui)
|
|
30
|
+
self:_ensureInit()
|
|
31
|
+
|
|
32
|
+
self._playerGui.Value = playerGui
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
function ScreenGuiService:ObservePlayerGui()
|
|
36
|
+
self:_ensureInit()
|
|
37
|
+
|
|
38
|
+
return self._playerGui:Observe()
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
function ScreenGuiService:_ensureInit()
|
|
42
|
+
assert(self ~= ScreenGuiService, "Cannot call directly, use serviceBag")
|
|
43
|
+
|
|
44
|
+
if not self._maid then
|
|
45
|
+
self._maid = Maid.new()
|
|
46
|
+
self._playerGui = self._maid:Add(ValueObject.new(PlayerGuiUtils.findPlayerGui()))
|
|
47
|
+
|
|
48
|
+
-- TODO: Don't do this? But what's the alternative..
|
|
49
|
+
if not RunService:IsRunning() then
|
|
50
|
+
if ScreenGuiService._hackPlayerGui then
|
|
51
|
+
self._playerGui:Mount(ScreenGuiService._hackPlayerGui:Observe())
|
|
52
|
+
else
|
|
53
|
+
ScreenGuiService._hackPlayerGui = self._playerGui
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
function ScreenGuiService:Destroy()
|
|
60
|
+
self._maid:DoCleaning()
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
return ScreenGuiService
|