mirror of
https://github.com/unixtensor/Roblox-Elevator-Game.git
synced 2026-02-03 21:36:49 +00:00
big commit
This commit is contained in:
121
src/load/intro/IntroGui.lua
Normal file
121
src/load/intro/IntroGui.lua
Normal file
@@ -0,0 +1,121 @@
|
||||
--Not a good idea to call modules from other services here
|
||||
|
||||
--Who said UI on here cant look like a web design lole,
|
||||
|
||||
local RS = game:GetService("RunService")
|
||||
local Storage = game:GetService("ReplicatedStorage")
|
||||
|
||||
local LoadingFun = true
|
||||
|
||||
local function GuiDependencies(IntroGui: ScreenGui): typeof(GuiDependencies)
|
||||
IntroGui.Enabled = true
|
||||
|
||||
local Frame = IntroGui:WaitForChild("Frame")
|
||||
local Viewport = Frame:WaitForChild("ViewportFrame")
|
||||
|
||||
local FrameGradient = Frame:WaitForChild("UIGradient")
|
||||
local TextShadow = Frame:WaitForChild("TextShadow")
|
||||
local FrameworkText = Frame:WaitForChild("Framework")
|
||||
local SandboxText = Frame:WaitForChild("Sandbox")
|
||||
local DeveloperText = Frame:WaitForChild("Developer")
|
||||
local ShadowGradient = TextShadow:WaitForChild("UIGradient")
|
||||
|
||||
local ViewportCamera = Instance.new("Camera")
|
||||
ViewportCamera.FieldOfView = 50
|
||||
ViewportCamera.Parent = Viewport
|
||||
Viewport.CurrentCamera = ViewportCamera
|
||||
|
||||
local GL_Cube = Viewport:WaitForChild("GL_Cube")
|
||||
|
||||
return {
|
||||
IntroGui = IntroGui,
|
||||
Frame = Frame,
|
||||
Viewport = Viewport,
|
||||
ViewportCamera = ViewportCamera,
|
||||
GL_Cube = GL_Cube,
|
||||
FrameGradient = FrameGradient,
|
||||
TextShadow = TextShadow,
|
||||
ShadowGradient = ShadowGradient,
|
||||
FrameworkText = FrameworkText,
|
||||
SandboxText = SandboxText,
|
||||
DeveloperText = DeveloperText
|
||||
}
|
||||
end
|
||||
|
||||
type GUIs = typeof(GuiDependencies)
|
||||
type Stepped = RBXScriptConnection
|
||||
|
||||
local function GUI_LoadFinish(Stepped: Stepped, Gui: GUIs) --We can now access the framework
|
||||
--Image if we had HTML and CSS...
|
||||
local Tween = require(Storage:WaitForChild("Tween"))
|
||||
|
||||
local EaseStyle = Enum.EasingStyle.Linear
|
||||
|
||||
local FrameTween_Constructor = Tween.constructor(TweenInfo.new(1, EaseStyle), Gui.Frame, {
|
||||
BackgroundTransparency = 1
|
||||
})
|
||||
local DeveloperTween_Constructor = Tween.constructor(TweenInfo.new(1, EaseStyle), Gui.DeveloperText, {
|
||||
TextTransparency = 1
|
||||
})
|
||||
local ViewportFrame_Constructor = Tween.constructor(TweenInfo.new(3, EaseStyle), Gui.Viewport, {
|
||||
Position = UDim2.fromScale(0.5, 2) --Guaranteed off screen
|
||||
})
|
||||
|
||||
FrameTween_Constructor:Start()
|
||||
DeveloperTween_Constructor:Start()
|
||||
local ViewportTween = ViewportFrame_Constructor:Start() --The longest tween
|
||||
|
||||
--Text deleting effect
|
||||
task.spawn(function()
|
||||
local sandbox_text_len = #Gui.SandboxText.Text
|
||||
|
||||
for i = sandbox_text_len, 1, -1 do --"A sandbox experience" has the longest text
|
||||
local rhpid_text_len = #Gui.FrameworkText.Text
|
||||
|
||||
Gui.SandboxText.Text = Gui.SandboxText.Text:sub(1,i-1)
|
||||
if rhpid_text_len ~= 0 then
|
||||
Gui.FrameworkText.Text = Gui.FrameworkText.Text:sub(1,i-1)
|
||||
Gui.TextShadow.Text = Gui.FrameworkText.Text --heh hack
|
||||
end
|
||||
task.wait(.05)
|
||||
end
|
||||
end)
|
||||
|
||||
ViewportTween.Completed:Wait()
|
||||
Stepped:Disconnect()
|
||||
Gui.IntroGui:Destroy() --We dont need the intro gui anymore
|
||||
end
|
||||
|
||||
type GL_Cube = BasePart
|
||||
type GL_Side = BasePart
|
||||
type LoadFinishedSignal = RBXScriptSignal
|
||||
|
||||
return function(IntroGui: ScreenGui, load_elapse_start: number): LoadFinishedSignal
|
||||
local Gui = GuiDependencies(IntroGui)
|
||||
|
||||
Gui.ViewportCamera.CFrame = CFrame.lookAt(Gui.GL_Cube.Position-Vector3.new(3,-2.5,5), Gui.GL_Cube.Position)
|
||||
|
||||
local Cube_CF = Gui.GL_Cube.CFrame
|
||||
local Stepped = RS.Stepped:Connect(function(delta, dt)
|
||||
--Magic number heaven
|
||||
local d2 = delta*10
|
||||
Gui.FrameGradient.Rotation=d2
|
||||
Gui.ShadowGradient.Rotation=d2*4
|
||||
|
||||
Gui.GL_Cube.CFrame = Cube_CF*CFrame.Angles(math.rad(100*math.cos(delta/8)), 0, delta/2)
|
||||
end)
|
||||
|
||||
task.spawn(function()
|
||||
if not game:IsLoaded() then
|
||||
game.Loaded:Wait()
|
||||
end
|
||||
|
||||
local load_elapse = os.clock()-load_elapse_start
|
||||
if LoadingFun then
|
||||
task.wait(math.max(0, 3-load_elapse)) --Only if you take longer than or exactly 3 seconds to load
|
||||
end
|
||||
|
||||
print(load_elapse)
|
||||
GUI_LoadFinish(Stepped, Gui)
|
||||
end)
|
||||
end
|
||||
47
src/load/intro/init.client.lua
Normal file
47
src/load/intro/init.client.lua
Normal file
@@ -0,0 +1,47 @@
|
||||
local load_elapse_start = os.clock()
|
||||
|
||||
local ReplicatedFirst = game:GetService("ReplicatedFirst")
|
||||
local Players = game:GetService("Players")
|
||||
local Storage = game:GetService("ReplicatedStorage")
|
||||
|
||||
local DisabledInStudio = game:GetService("RunService"):IsStudio()
|
||||
local IntroGui = nil
|
||||
|
||||
local function LoadedBind()
|
||||
local Bind_Completed = Instance.new("BindableFunction")
|
||||
Bind_Completed.Name = "LoadingComplete"
|
||||
Bind_Completed.Parent = Storage:WaitForChild("Client")
|
||||
Bind_Completed.OnInvoke = function()
|
||||
return game:IsLoaded()
|
||||
end
|
||||
end
|
||||
|
||||
local function LoadingIntroGUI()
|
||||
local RunIntroGui = require(script:WaitForChild("IntroGui"))
|
||||
|
||||
local Player = Players.LocalPlayer
|
||||
if not Player then
|
||||
repeat
|
||||
Player = Players.LocalPlayer
|
||||
task.wait()
|
||||
until Player
|
||||
end
|
||||
|
||||
local PlayerGui = Player:WaitForChild("PlayerGui")
|
||||
IntroGui = PlayerGui:WaitForChild("rhpidframework_intro", 10)
|
||||
|
||||
if IntroGui then
|
||||
--Let the magic begin
|
||||
RunIntroGui(IntroGui, load_elapse_start)
|
||||
else
|
||||
warn("Waited 10 seconds for the intro gui without success")
|
||||
end
|
||||
end
|
||||
|
||||
if not DisabledInStudio then
|
||||
LoadingIntroGUI()
|
||||
end
|
||||
|
||||
LoadedBind()
|
||||
|
||||
ReplicatedFirst:RemoveDefaultLoadingScreen()
|
||||
Reference in New Issue
Block a user