Skip to content

Commit

Permalink
fix plugin issues
Browse files Browse the repository at this point in the history
  • Loading branch information
James committed Sep 28, 2023
1 parent c3b06fa commit 6db080b
Show file tree
Hide file tree
Showing 4 changed files with 108 additions and 156 deletions.
80 changes: 42 additions & 38 deletions plugin/src/lua/plugin/PluginRunner.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

local RunService = game:GetService("RunService")

if not plugin or RunService:IsRunMode() then
if not plugin or not RunService:IsEdit() then
return
end

Expand All @@ -23,37 +23,44 @@ local CanaryStudioPluginButton = CanaryStudioPluginToolbar:CreateButton("Canary
local PluginFinishedLoading = false
local IsTesting = false

local OverrideValues = {
ReleaseLatest = {
published_at = "2007-01-14T20:34:22+00:00",
body = "This is a test!",
tag_name = "0.0.0",
target_commitish = "main"
},

LibrariesList = {
Roblox = '"TestPackage": {"$className": "ModuleScript"}',
Is = '"TestPackage": {"$className": "ModuleScript"}',
Cool = '"TestPackage": {"$className": "ModuleScript"}',
["B)"] = '"TestPackage": {"$className": "ModuleScript"}',
},

ExternalSettings = {
Files = 14,
CanaryStudioChangelog = "We've made some large changes since the last update to the plugin and have fixed lots of bugs!\n\nInstalling has been revamped - The process is now a lot quicker and more performant\nRedesigned Home Page - The home page now has a menu bar and shows this changelog\nInternal code rework - It's now a lot easier to fix issues and add new features"
},
}

local HttpCache = require(Vendor.Core.HttpCache)
Fetch.SetHttpCacheTable(Vendor.Core.HttpCache)

if IsTesting then
local HttpCache = require(Vendor.Core.HttpCache)
PluginFinishedLoading = true

for cacheName in GitHubRequests do
if cacheName == "ReleaseLatest" then
HttpCache[cacheName] = {
published_at = "2007-01-14T20:34:22+00:00",
body = "This is a test!",
tag_name = "0.0.0",
target_commitish = "main"
}
elseif cacheName == "LibrariesList" then
HttpCache[cacheName] = {
Roblox = '"TestPackage": {"$className": "ModuleScript"}',
Is = '"TestPackage": {"$className": "ModuleScript"}',
Cool = '"TestPackage": {"$className": "ModuleScript"}',
["B)"] = '"TestPackage": {"$className": "ModuleScript"}',
}
elseif cacheName == "ExternalSettings" then
HttpCache[cacheName] = {
Files = 11,
CanaryStudioChangelog = "We've made some large changes since the last update to the plugin and have fixed lots of bugs!\n\nInstalling has been revamped - The process is now a lot quicker and more performant\nRedesigned Home Page - The home page now has a menu bar and shows this changelog\nInternal code rework - It's now a lot easier to fix issues and add new features"
}
end
HttpCache[cacheName] = OverrideValues[cacheName]
end

PluginFinishedLoading = true
else
for cacheName, URL in GitHubRequests do
Fetch.FetchAsync(URL, true, 3, cacheName)
local Result = Fetch.FetchAsync(URL, true, 3, cacheName)

if not Result then
warn("[CanaryStudio]: Could not fetch valid URL, getting local values. It is recommended to re-enter the place as most vital features will not work offline.")
HttpCache[cacheName] = OverrideValues[cacheName]
end
end
end

Expand All @@ -62,30 +69,27 @@ local WindowController = require(Vendor.Core.WindowController)(PluginGui)

CanaryStudioPluginButton.Click:Connect(function()
if not PluginFinishedLoading then
warn("CanaryStudio has not finished loading yet.")
warn("[CanaryStudio]: Canary Studio has not finished loading yet.")
return
end

WindowController.SetWindow("HomeWindow")
end)

if IsTesting then
for scriptType, templateTable in CanaryStudioSettings.CanaryStudioInstanceTemplates do
for context, templateURL in templateTable do
for scriptType, templateTable in CanaryStudioSettings.CanaryStudioInstanceTemplates do
for context, templateURL in templateTable do
if IsTesting then
CanaryStudioSettings.CanaryStudioInstanceTemplates[scriptType][context] = "-- this is testing!"
continue
end
end
else
for scriptType, templateTable in CanaryStudioSettings.CanaryStudioInstanceTemplates do
for context, templateURL in templateTable do
local TemplateContents = Fetch.FetchAsync(templateURL, false)

if not TemplateContents then
CanaryStudioSettings.CanaryStudioInstanceTemplates[scriptType][context] = "-- could not get source"
end
local TemplateContents = Fetch.FetchAsync(templateURL, false)

CanaryStudioSettings.CanaryStudioInstanceTemplates[scriptType][context] = TemplateContents
if not TemplateContents then
CanaryStudioSettings.CanaryStudioInstanceTemplates[scriptType][context] = "-- could not get source"
end

CanaryStudioSettings.CanaryStudioInstanceTemplates[scriptType][context] = TemplateContents
end
end

Expand Down
16 changes: 10 additions & 6 deletions plugin/src/lua/plugin/Vendor/Core/PluginGui.lua
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ if not AlreadyRan then
local TotalFiles = Iris.State(1)
local TitleMessage = Iris.State("Updating ")
local BelowMessage = Iris.State("Updating framework to latest version")
local FileType = Iris.State("files")

Iris.UpdateGlobalConfig(Iris.TemplateConfig.sizeClear)
Iris.UpdateGlobalConfig(Iris.TemplateConfig[`color{StudioSettings.Theme.Name}`])
Expand Down Expand Up @@ -136,23 +137,25 @@ if not AlreadyRan then
end Iris.End()

WindowList.ReleaseNotesWindow = Iris.Window(`Release Notes for {HttpCache.ReleaseLatest.tag_name}`, {isOpened = false}) do
Iris.Text(HttpCache.ReleaseLatest.body, true)
Iris.Text({HttpCache.ReleaseLatest.body, true})
Iris.Separator()
Iris.Text(`Commit Branch: {HttpCache.ReleaseLatest.target_commitish}`)
Iris.Text(`Published At: {FormattedPublishDate}`)
end Iris.End()

WindowList.UpdateStatusWindow = Iris.Window({`{TitleMessage:get()}({math.floor((FinishedFiles:get() / TotalFiles:get()) * 100)}%)`, [Iris.Args.Window.NoClose] = true, [Iris.Args.Window.NoResize] = true}, {isOpened = false, size = Vector2.new(334, 109)}) do
Iris.Text(BelowMessage:get())
Iris.Text(`{FinishedFiles:get()} of {HttpCache.ExternalSettings.Files} files`)
Iris.Text(`{FinishedFiles:get()} of {TotalFiles:get()} files`)
end Iris.End()

WindowList.PackageManagerWindow = Iris.Window("Canary Studio - Package Manager", {isOpened = false}) do

for libraryName in HttpCache.LibrariesList do
Settings.CanaryStudioInstallerPackages[libraryName] = Iris.Checkbox(libraryName).state.isChecked:get()
end
end Iris.End()

WindowList.ConfirmWindow = Iris.Window({"Confirm", [Iris.Args.Window.NoClose] = true, [Iris.Args.Window.NoTitleBar] = true}, {isOpened = false, size = Vector2.new(432, 122)}) do
Iris.Text(PluginGuiContents.ConfirmWindow.MessageText, true)
Iris.Text({PluginGuiContents.ConfirmWindow.MessageText, true})
Iris.SameLine() do
if Iris.Button("OK").clicked() then
PluginGuiContents.ConfirmWindow.ConfirmFunction()
Expand All @@ -166,7 +169,7 @@ if not AlreadyRan then
end Iris.End()

WindowList.MessageWindow = Iris.Window({"Message", [Iris.Args.Window.NoClose] = true, [Iris.Args.Window.NoTitleBar] = true}, {isOpened = false, size = Vector2.new(432, 122)}) do
Iris.Text(PluginGuiContents.MessageWindow.MessageText, true, PluginGuiContents.MessageWindow.TextColor)
Iris.Text({PluginGuiContents.MessageWindow.MessageText, true, PluginGuiContents.MessageWindow.TextColor})

if Iris.Button("OK").clicked() then
WindowController.SetWindow("MessageWindow", false)
Expand All @@ -178,11 +181,12 @@ if not AlreadyRan then
WindowController = require(Vendor.Core.WindowController)(WindowList)
VersionController = require(Vendor.Core.VersionController)

VersionController.DataUpdated:Connect(function(files, totalfiles, title, body)
VersionController.DataUpdated:Connect(function(files, totalfiles, title, body, filetype)
FinishedFiles:set(files)
TotalFiles:set(totalfiles)
TitleMessage:set(title)
BelowMessage:set(body)
FileType:set(filetype)
end)

return WindowList
Expand Down
30 changes: 18 additions & 12 deletions plugin/src/lua/plugin/Vendor/Core/VersionController.lua
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ function VersionController.GetDirectoryFromStructureJSON(json: {any}, parent: In

if not isPackage then
FinishedFiles += 1
VersionController.DataUpdated:Fire(FinishedFiles, HttpCache.ExternalSettings.Files, "Updating ", "Updating framework to latest version")
VersionController.DataUpdated:Fire(FinishedFiles, HttpCache.ExternalSettings.Files, "Updating ", "Updating framework to latest version", "files")
end

InstanceFromClass[propertyName] = Source
Expand Down Expand Up @@ -194,9 +194,17 @@ function VersionController.UpdateFramework()
CanaryEngineStructure.Parent = ReplicatedStorage
end

if CurrentInstance.ReplicatedFirst then
CurrentInstance.ReplicatedFirst.Framework:Destroy()
EngineLoaderStructure.Parent = CurrentInstance.ReplicatedFirst
if CurrentInstance.ReplicatedFirst then
if CurrentInstance.ReplicatedFirst.Framework or CurrentInstance.ReplicatedFirst.Internal then
local EngineItem = CurrentInstance.ReplicatedFirst.Framework

if not EngineItem then
EngineItem = CurrentInstance.ReplicatedFirst.Internal
end

EngineItem:Destroy()
EngineLoaderStructure.Parent = CurrentInstance.ReplicatedFirst
end
end

if not ReplicatedFirst:GetAttribute("EngineLoaderEnabled") then
Expand All @@ -209,7 +217,7 @@ function VersionController.UpdateFramework()
task.wait(UPDATE_COOLDOWN_SECONDS)
UpdateDebounce = false
FinishedFiles = 0
VersionController.DataUpdated:Fire(FinishedFiles, 1, "nil", "nil")
VersionController.DataUpdated:Fire(FinishedFiles, 1, "nil", "nil", "nil")
end)
end

Expand Down Expand Up @@ -263,11 +271,9 @@ function VersionController.InstallFramework()

FinishedFiles = 0

if not TableKit.IsEmpty(HttpCache.LibrariesList) then
for _, value in CanaryStudioSettings.CanaryStudioInstallerPackages do
if value then
TotalPackageFiles += 1
end
for _, value in CanaryStudioSettings.CanaryStudioInstallerPackages do
if value then
TotalPackageFiles += 1
end
end

Expand All @@ -283,7 +289,7 @@ function VersionController.InstallFramework()
PackageInstallCache:FindFirstChild(libraryName):Clone().Parent = NewInstance[libraryJSON["$parent"] or "Replicated"].Packages

FinishedFiles += 1
VersionController.DataUpdated:Fire(FinishedFiles, TotalPackageFiles, "Installing ", "Installing latest version of packages")
VersionController.DataUpdated:Fire(FinishedFiles, TotalPackageFiles, "Installing ", "Installing latest version of packages", "packages")
end

FinishedFiles = 0
Expand All @@ -292,7 +298,7 @@ function VersionController.InstallFramework()
WindowController.SetWindow("UpdateStatusWindow", false)
WindowController.SetMessageWindow("Framework installed successfully!", Color3.fromRGB(205, 255, 151))

VersionController.DataUpdated:Fire(FinishedFiles, 1, "nil", "nil")
VersionController.DataUpdated:Fire(FinishedFiles, 1, "nil", "nil", "nil")
task.wait(UPDATE_COOLDOWN_SECONDS)
UpdateDebounce = false
end)
Expand Down
Loading

0 comments on commit 6db080b

Please sign in to comment.