Skip to content

Commit

Permalink
optimizations && structure changes
Browse files Browse the repository at this point in the history
optimization of preload (preload so long, but gif not glitching)
  • Loading branch information
Egor00f committed Feb 17, 2025
1 parent 4f68437 commit 7d99ab8
Show file tree
Hide file tree
Showing 5 changed files with 210 additions and 95 deletions.
26 changes: 14 additions & 12 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"tasks": [
{
"type": "shell",
"label": "Build tests",
"label": "Build",
"detail": "Build tests place",
"command": "rojo build tests.project.json --output tests.rbxl && exit",
"group": {
Expand All @@ -15,8 +15,8 @@
},
{
"type": "shell",
"label": "Generate sourcemap for tests",
"detail": "Generate sourcemap for tests",
"label": "Generate sourcemap",
"detail": "Generate sourcemap",
"command": "rojo sourcemap tests.project.json --output sourcemap.json && exit",
"group": {
"kind": "none"
Expand Down Expand Up @@ -57,22 +57,24 @@
},
{
"type": "shell",
"label": "publish",
"detail": "publish it as wally package",
"label": "Publish",
"detail": "Publish this as wally package",
"command": "wally publish && exit",
"group": {
"kind": "none"
},
"problemMatcher": []
},
],
"options": {
"shell": {
"executable": "cmd",
"args": [
"/k"
]
}
"windows": {
"options": {
"shell": {
"executable": "cmd",
"args": [
"/k"
]
}
},
},
"version": "2.0.0"
}
92 changes: 92 additions & 0 deletions src/gifFrame.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
local ContentProvider = game:GetService("ContentProvider")
local Players = game:GetService("Players")

--[[
Gif frame class
]]
local gifFrame = {}

local function CreateGui(name: string)
local a = Players.LocalPlayer.PlayerGui:FindFirstChild(name)

if not a then
a = Instance.new("ScreenGui", Players.LocalPlayer.PlayerGui)
a.Name = name
end

return a
end

local Gui = CreateGui("GifPreloadGui")

--[[
gifFrame struct
]]
export type GifFrame = {

--[[
Label with image
]]
Image: ImageLabel,

--[[
delay on this image
]]
Time: number,
}

--[[
Preload frame
]]
function gifFrame.Preload(self: GifFrame)
ContentProvider:PreloadAsync(self.Image.Image)
end

--[[
Wait image loading
]]
function gifFrame.WaitLoading(self: GifFrame)
while not self.Image.IsLoaded do
task.wait()
end
end

--[[
Destroy gif frame
]]
function gifFrame.Destroy(self: GifFrame)
self.Image:Destroy()
end

function gifFrame.Show(self: GifFrame, parent: Frame)
self.Image.Position = UDim2.fromScale(0, 0)
self.Image.Parent = parent
end

function gifFrame.Hide(self: GifFrame)
self.Image.Position = UDim2.fromScale(1, 1)
self.Image.Parent = Gui
end

--[[
Gif frame constructor
]]
function gifFrame.new(id: string, t: number): GifFrame

if (not id:find("http://www.roblox.com/asset/?id=")) or (not id:find("rbxassetid://")) then
id = "rbxassetid://" .. id
end

local img: GifFrame = {
Image = Instance.new("ImageLabel"),
Time = t
}

img.Image.Image = id
img.Image.Size = UDim2.fromScale(1, 1)
img.Image.Position = UDim2.fromScale(1, 1)

return img
end

return gifFrame
Loading

0 comments on commit 7d99ab8

Please sign in to comment.