mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-04-20 20:55:50 +00:00
85 lines
2.1 KiB
Lua
85 lines
2.1 KiB
Lua
if not plugin then
|
|
return
|
|
end
|
|
|
|
local Plugin = require(script.Parent.Plugin)
|
|
local Config = require(script.Parent.Config)
|
|
local Version = require(script.Parent.Version)
|
|
|
|
--[[
|
|
Check if the user is using a newer version of Rojo than last time. If they
|
|
are, show them a reminder to make sure they check their server version.
|
|
]]
|
|
local function checkUpgrade()
|
|
-- When developing Rojo, there's no use in doing version checks
|
|
if Config.dev then
|
|
return
|
|
end
|
|
|
|
local lastVersion = plugin:GetSetting("LastRojoVersion")
|
|
|
|
if lastVersion then
|
|
local wasUpgraded = Version.compare(Config.version, lastVersion) == 1
|
|
|
|
if wasUpgraded then
|
|
local message = (
|
|
"\nRojo detected an upgrade from version %s to version %s." ..
|
|
"\nMake sure you have also upgraded your server!" ..
|
|
"\n\nRojo version %s is intended for use with server version %s.\n"
|
|
):format(
|
|
Version.display(lastVersion), Version.display(Config.version),
|
|
Version.display(Config.version), Config.expectedServerVersionString
|
|
)
|
|
|
|
print(message)
|
|
end
|
|
end
|
|
|
|
plugin:SetSetting("LastRojoVersion", Config.version)
|
|
end
|
|
|
|
local function main()
|
|
local pluginInstance = Plugin.new()
|
|
|
|
local displayedVersion = Config.dev and "DEV" or Version.display(Config.version)
|
|
|
|
local toolbar = plugin:CreateToolbar("Rojo Plugin " .. displayedVersion)
|
|
|
|
toolbar:CreateButton("Test Connection", "Connect to Rojo Server", Config.icons.testConnection)
|
|
.Click:Connect(function()
|
|
checkUpgrade()
|
|
|
|
pluginInstance:connect()
|
|
:catch(function(err)
|
|
warn(err)
|
|
end)
|
|
end)
|
|
|
|
local function syncIn()
|
|
checkUpgrade()
|
|
|
|
pluginInstance:syncIn()
|
|
:catch(function(err)
|
|
warn(err)
|
|
end)
|
|
end
|
|
|
|
local shortDescription = "Sync In"
|
|
local longDescription = "Sync into Roblox Studio"
|
|
|
|
toolbar:CreateButton(shortDescription, longDescription, Config.icons.syncIn).Click:Connect(syncIn)
|
|
plugin:CreatePluginAction("RojoSyncIn", shortDescription, longDescription).Triggered:Connect(syncIn)
|
|
|
|
toolbar:CreateButton("Toggle Polling", "Poll server for changes", Config.icons.togglePolling)
|
|
.Click:Connect(function()
|
|
checkUpgrade()
|
|
|
|
pluginInstance:togglePolling()
|
|
:catch(function(err)
|
|
warn(err)
|
|
end)
|
|
end)
|
|
end
|
|
|
|
main()
|