Compare commits

..

2 Commits

Author SHA1 Message Date
Jay 2dfc1f6dd5 TevX support 2020-04-24 14:14:26 +01:00
Sanjay e5d3561d1a
Refactored Workshop to TevX Format (#71)
* Refactored Workshop to TevX Format

* Refactor .parent change in teverse.construct
2020-04-24 09:05:07 +01:00
10 changed files with 227 additions and 123 deletions

View File

@ -64,5 +64,59 @@ return {
iconAlpha = 0.9,
active = false
})
if teverse.dev.localTevGit then
local workshopBtn = teverse.construct("guiFrame", {
parent = page,
size = guiCoord(1/3, -20, 0, 70),
position = guiCoord(1/3, 10, 0, 0),
backgroundColour = colour.rgb(74, 140, 122),
strokeRadius = 3
})
teverse.guiHelper
.bind(workshopBtn, "xs", {
size = guiCoord(1, -20, 0, 70),
position = guiCoord(0, 10, 0, 140)
})
.bind(workshopBtn, "sm", {
size = guiCoord(1/3, -20, 0, 70),
position = guiCoord(1/3, 10, 0, 60)
})
.bind(workshopBtn, "lg", {
size = guiCoord(1/3, -20, 0, 70),
position = guiCoord(1/3, 10, 0, 60)
})
.hoverColour(workshopBtn, colour.rgb(235, 187, 83))
workshopBtn:on("mouseLeftUp", function()
teverse.apps:loadWorkshop()
end)
teverse.construct("guiTextBox", {
parent = workshopBtn,
size = guiCoord(0.5, -10, 0, 18),
position = guiCoord(0.5, 0, 0.5, -9),
backgroundAlpha = 0,
text = "Workshop",
textSize = 18,
textAlign = "middleLeft",
textColour = colour(1, 1, 1),
active = false
--textFont = "tevurl:fonts/openSansLight.ttf"
})
teverse.construct("guiIcon", {
parent = workshopBtn,
size = guiCoord(0, 40, 0, 40),
position = guiCoord(0.5, -60, 0.5, -20),
iconMax = 40,
iconColour = colour(1, 1, 1),
iconType = "faSolid",
iconId = "tools",
iconAlpha = 0.9,
active = false
})
end
end
}

View File

@ -19,7 +19,7 @@ local boomBtn = engine.construct("guiTextBox", engine.interface, {
fontSize = 18,
backgroundColour = colour(0.2, 0.2, 0.25),
borderRadius = 4,
align = enums.align.middle
textAlign = enums.align.middle
})
boomBtn:on("mouseLeftReleased", function()
boomMode = not boomMode

View File

@ -6,7 +6,7 @@ print("Hello Server!")
require("tevgit:core/server/debug.lua")
require("tevgit:core/server/chat.lua")
workspace:destroyAllChildren()
workspace:destroyChildren()
local mainLight = engine.construct("light", workspace, {
name = "mainLight",

View File

@ -18,7 +18,7 @@ local mainContainer = nil
local workshop = nil
local function runTutorial(module)
mainContainer:destroyAllChildren()
mainContainer:destroyChildren()
local tutorial = require("tevgit:"..module)
local tutorialContainer = engine.construct("guiFrame", mainContainer, {
@ -85,14 +85,14 @@ local function runTutorial(module)
})
for _,page in pairs(tutorial.tutorial) do
instructions:destroyAllChildren()
instructions:destroyChildren()
if type(page) == "string" then
local txt = engine.construct("guiTextBox", instructions, {
size = guiCoord(1,-10,1,-10),
position = guiCoord(0,5,0,5),
backgroundAlpha = 0,
align = enums.align.topLeft,
wrap = true,
textWrap = true,
fontFile = "local:OpenSans-Regular.ttf",
fontSize = 20,
text = page,
@ -200,7 +200,7 @@ local function runTutorial(module)
end
local function createMainInterface()
mainContainer:destroyAllChildren()
mainContainer:destroyChildren()
local sectionYPos = 0
for section, tutorials in pairs(tevEd.tutorials) do

View File

@ -2,21 +2,21 @@
-- Used to share variables between scripts
return {
workshop = nil, -- Holds workshop instance and is set in main.lua
dev = nil, -- Holds workshop instance and is set in main.lua
user = nil, -- Holds user instance and is set in main.lua
developerMode = false, -- Holds the developer_mode boolean and is set in main.lua
sideBarPageDefault = nil, -- Holds the default sidebar page (view) as a string and is set in topbarInterface.lua
sideBarPageActive = nil, -- Holds the current active sidebar page (view) as a string and is set in topbarInterface.lua
defaultColours = { -- Default colors used for theming UI components (~\library\ui\components)
primary = colour:fromRGB(112, 112, 112),
secondary = colour:fromRGB(239, 239, 239),
background = colour:fromRGB(33, 33, 33),
red = colour:fromRGB(255, 82, 82),
green = colour:fromRGB(105, 240, 174),
yellow = colour:fromRGB(255, 215, 64),
blue = colour:fromRGB(68, 138, 255),
orange = colour:fromRGB(255, 171, 64),
purple = colour:fromRGB(124, 77, 255),
white = colour:fromRGB(255, 255, 255)
primary = colour.rgb(112, 112, 112),
secondary = colour.rgb(239, 239, 239),
background = colour.rgb(33, 33, 33),
red = colour.rgb(255, 82, 82),
green = colour.rgb(105, 240, 174),
yellow = colour.rgb(255, 215, 64),
blue = colour.rgb(68, 138, 255),
orange = colour.rgb(255, 171, 64),
purple = colour.rgb(124, 77, 255),
white = colour.rgb(255, 255, 255)
}
}

View File

@ -27,7 +27,8 @@ return {
local positionOverride = args[1] or guiCoord(0, 0, 0, 0) -- If not specified, default to guiCoord(0, 0, 0, 0)
if orientation == "vertical" then -- If orientation is specified to "vertical"
local container = engine.construct("guiFrame", globals.workshop.interface, {
local container = teverse.construct("guiFrame", {
parent = teverse.interface,
size = guiCoord(0.1, 0, 0.1, 0),
position = element.position+guiCoord(-0.02, 0, -0.01, 0),
backgroundColour = globals.defaultColours.red,
@ -36,16 +37,19 @@ return {
backgroundAlpha = 0
})
engine.construct("guiImage", container, {
teverse.construct("guiIcon", {
parent = container,
size = guiCoord(0, 48, 0, 48),
position = guiCoord(0.33, 0, -0.15, 0),
texture = "fa:s-caret-up",
imageColour = globals.defaultColours.secondary,
iconId = "caret-up",
iconType = "faSolid",
iconColour = globals.defaultColours.secondary,
backgroundColour = globals.defaultColours.red,
backgroundAlpha = 0
})
local bodyContainer = engine.construct("guiFrame", container, {
local bodyContainer = teverse.construct("guiFrame", {
parent = container,
size = guiCoord(0.95, 0, 0.4, 0),
position = guiCoord(0.025, 0, 0.23, 0),
backgroundColour = globals.defaultColours.white,
@ -55,30 +59,34 @@ return {
borderColour = globals.defaultColours.secondary
})
engine.construct("guiImage", bodyContainer, {
teverse.construct("guiIcon", {
parent = bodyContainer,
size = guiCoord(0, 16, 0, 16),
position = guiCoord(0.04, 0, 0.25, 0),
texture = "fa:s-info-circle",
imageColour = globals.defaultColours.primary,
iconId = "info-circle",
iconType = "faSolid",
iconColour = globals.defaultColours.primary,
backgroundColour = globals.defaultColours.white,
})
engine.construct("guiTextBox", bodyContainer, {
teverse.construct("guiTextBox", {
parent = bodyContainer,
size = guiCoord(0.82, 0, 1, 0),
position = guiCoord(0.15, 0, 0, 0),
text = text,
fontSize = 16,
textColour = globals.defaultColours.primary,
backgroundColour = globals.defaultColours.white,
align = enums.align.middle,
wrap = true
textAlign = enums.align.middle,
textWrap = true
})
self.display = function() container.visible = true end -- Display tooltip method
self.hide = function() container.visible = false end -- Hide tooltip method
elseif orientation == "horizontal" then -- If orientation is specified to "horizontal"
local container = engine.construct("guiFrame", globals.workshop.interface, {
local container = teverse.construct("guiFrame", {
parent = teverse.interface,
size = guiCoord(0.13, 0, 0.05, 0),
position = (element.position+guiCoord(-0.22, 0, 0.24, 0))+positionOverride, -- Shorthand positioning
backgroundColour = globals.defaultColours.red,
@ -87,16 +95,19 @@ return {
backgroundAlpha = 0
})
engine.construct("guiImage", container, {
teverse.construct("guiIcon", {
parent = container,
size = guiCoord(0, 48, 0, 48),
position = guiCoord(-0.03, 0, -0.06, 0),
texture = "fa:s-caret-left",
imageColour = globals.defaultColours.primary,
iconId = "caret-left",
iconType = "faSolid",
iconColour = globals.defaultColours.primary,
backgroundColour = globals.defaultColours.red,
backgroundAlpha = 0
})
local bodyContainer = engine.construct("guiFrame", container, {
local bodyContainer = teverse.construct("guiFrame", {
parent = container,
size = guiCoord(0.8, 0, 0.9, 0),
position = guiCoord(0.133, 0, 0.05, 0),
backgroundColour = globals.defaultColours.white,
@ -106,23 +117,26 @@ return {
borderColour = globals.defaultColours.primary
})
engine.construct("guiImage", bodyContainer, {
teverse.construct("guiIcon", {
parent = bodyContainer,
size = guiCoord(0, 16, 0, 16),
position = guiCoord(0.05, 0, 0.3, 0),
texture = "fa:s-info-circle",
imageColour = globals.defaultColours.primary,
iconId = "fa:s-info-circle",
iconType = "faSolid",
iconColour = globals.defaultColours.primary,
backgroundColour = globals.defaultColours.white,
})
engine.construct("guiTextBox", bodyContainer, {
teverse.construct("guiTextBox", {
parent = bodyContainer,
size = guiCoord(0.82, 0, 1, 0),
position = guiCoord(0.15, 0, 0, 0),
text = text,
fontSize = 16,
textColour = globals.defaultColours.primary,
backgroundColour = globals.defaultColours.white,
align = enums.align.middle,
wrap = true
textAlign = enums.align.middle,
textWrap = true
})
self.display = function() container.visible = true end -- Display tooltip method

View File

@ -22,57 +22,69 @@ return {
self.id = idValue -- Unique Indentifier
self.pages = {} -- Where we store our pages for sidebar
engine.construct("guiFrame", globals.workshop.interface, {
teverse.construct("guiFrame", {
parent = teverse.interface,
size = guiCoord(0.04, 0, 0.015, 0),
position = guiCoord(0, 0, 0.05, 0),
backgroundColour = globals.defaultColours.secondary,
})
engine.construct("guiFrame", globals.workshop.interface, {
teverse.construct("guiFrame", {
parent = teverse.interface,
size = guiCoord(0.04, 0, 0.015, 0),
position = guiCoord(0, 0, 0.24, 0),
backgroundColour = globals.defaultColours.secondary,
})
local toolsContainer = engine.construct("guiFrame", globals.workshop.interface, {
local toolsContainer = teverse.construct("guiFrame", {
parent = teverse.interface,
size = guiCoord(0.04, 0, 0.18, 0),
position = guiCoord(0, 0, 0.065, 0),
backgroundColour = globals.defaultColours.white,
})
local selectTool = engine.construct("guiImage", toolsContainer, {
local selectTool = teverse.construct("guiIcon", {
parent = toolsContainer,
size = guiCoord(0, 20, 0, 20),
position = guiCoord(0.25, 0, 0.1, 0),
texture = "fa:s-location-arrow",
imageColour = globals.defaultColours.primary,
iconId = "location-arrow",
iconType = "faSolid",
iconColour = globals.defaultColours.primary,
backgroundColour = globals.defaultColours.white,
})
local moveTool = engine.construct("guiImage", toolsContainer, {
local moveTool = teverse.construct("guiIcon", {
parent = toolsContainer,
size = guiCoord(0, 20, 0, 20),
position = guiCoord(0.25, 0, 0.32, 0),
texture = "fa:s-arrows-alt-h",
imageColour = globals.defaultColours.primary,
iconId = "arrows-alt-h",
iconType = "faSolid",
iconColour = globals.defaultColours.primary,
backgroundColour = globals.defaultColours.white,
})
local rotateTool = engine.construct("guiImage", toolsContainer, {
local rotateTool = teverse.construct("guiIcon", {
parent = toolsContainer,
size = guiCoord(0, 20, 0, 20),
position = guiCoord(0.25, 0, 0.54, 0),
texture = "fa:s-sync",
imageColour = globals.defaultColours.primary,
iconId = "sync",
iconType = "faSolid",
iconColour = globals.defaultColours.primary,
backgroundColour = globals.defaultColours.white,
})
local sizeTool = engine.construct("guiImage", toolsContainer, {
local sizeTool = teverse.construct("guiIcon", {
parent = toolsContainer,
size = guiCoord(0, 20, 0, 20),
position = guiCoord(0.25, 0, 0.76, 0),
texture = "fa:s-expand",
imageColour = globals.defaultColours.primary,
iconId = "fa:s-expand",
iconType = "faSolid",
iconColour = globals.defaultColours.primary,
backgroundColour = globals.defaultColours.white,
})
local moreToolsContainer = engine.construct("guiFrame", globals.workshop.interface, {
local moreToolsContainer = teverse.construct("guiFrame", {
parent = teverse.interface,
name = "moreToolsContainer",
size = guiCoord(0.04, 0, 1, 0),
position = guiCoord(0, 0, 0.255, 0),
@ -98,7 +110,8 @@ return {
zIndexRange = 101
end
local iconContainer = engine.construct("guiFrame", moreToolsContainer, {
local iconContainer = teverse.construct("guiFrame", {
parent = moreToolsContainer,
name = pageName,
size = guiCoord(1, 0, 1, 0),
position = guiCoord(0, 0, 0, 0),
@ -129,12 +142,14 @@ return {
local args = {...} -- Holds overrides
local xPositionOverride = args[1] or 0 -- Override if specified, else 0
local positionToolTipOverride = args[2] or guiCoord(0, 0, 0, 0) -- Override if specified, else guiCoord(0, 0, 0, 0)
local iconImage = engine.construct("guiImage", page, {
local iconImage = teverse.construct("guiIcon", {
parent = page,
name = name,
size = guiCoord(0, 20, 0, 20),
position = guiCoord((0.25+xPositionOverride), 0, 0.02+(#page.children*0.04), 0), -- Shorthand positioning w/o a for-loop
texture = icon,
imageColour = globals.defaultColours.primary,
iconId = icon,
iconType = "faSolid",
iconColour = globals.defaultColours.primary,
backgroundColour = globals.defaultColours.white,
})

View File

@ -26,22 +26,26 @@ return {
self.titleIcon = titleIconValue
self.keys = {} -- Where item keys are stored
local container = engine.construct("guiFrame", globals.workshop.interface, {
local container = teverse.construct("guiFrame", {
parent = teverse.interface,
size = guiCoord(1, 0, 0.05, 0),
position = guiCoord(0, 0, 0, 0),
backgroundColour = globals.defaultColours.white,
})
engine.construct("guiImage", container, {
teverse.construct("guiIcon", {
parent = container,
size = guiCoord(0, 28, 0, 28),
position = guiCoord(0.01, 0, 0.1, 0),
texture = titleIconValue,
imageColour = globals.defaultColours.primary,
iconId = titleIconValue,
iconType = "faSolid",
iconColour = globals.defaultColours.primary,
backgroundColour = globals.defaultColours.white,
handleEvents = false,
active = false,
})
engine.construct("guiTextBox", container, {
teverse.construct("guiTextBox", {
parent = container,
size = guiCoord(0.5, 0, 0.1, 0),
position = guiCoord(0.04, 0, 0.05, 0),
text = titleValue,
@ -51,7 +55,8 @@ return {
readOnly = true
})
engine.construct("guiTextBox", container, {
teverse.construct("guiTextBox", {
parent = container,
size = guiCoord(0.48, 0, 0.1, 0),
position = guiCoord(0.86, 0, 0.1, 0),
text = globals.user[2],
@ -60,14 +65,16 @@ return {
readOnly = true
})
local userIcon = engine.construct("guiFrame", container, {
local userIcon = teverse.construct("guiFrame", {
parent = container,
size = guiCoord(0, 32, 0, 32),
position = guiCoord(0.82, 0, 0, 0),
backgroundColour = globals.defaultColours.primary,
borderRadius = 100
})
local statusIcon = engine.construct("guiFrame", container, {
local statusIcon = teverse.construct("guiFrame", {
parent = container,
size = guiCoord(0, 16, 0, 16),
position = guiCoord(0.836, 0, 0.5, 0),
backgroundColour = globals.defaultColours.green,
@ -78,27 +85,33 @@ return {
zIndex = 100
})
local undoButton = engine.construct("guiImage", container, {
local undoButton = teverse.construct("guiIcon", {
parent = container,
size = guiCoord(0, 20, 0, 20),
position = guiCoord(0.92, 0, 0.2, 0),
texture = "fa:s-arrow-left",
imageColour = globals.defaultColours.primary,
iconId = "arrow-left",
iconType = "faSolid",
iconColour = globals.defaultColours.primary,
backgroundColour = globals.defaultColours.white,
})
local redoButton = engine.construct("guiImage", container, {
local redoButton = teverse.construct("guiIcon", {
parent = container,
size = guiCoord(0, 20, 0, 20),
position = guiCoord(0.94, 0, 0.2, 0),
texture = "fa:s-arrow-right",
imageColour = globals.defaultColours.primary,
iconId = "arrow-right",
iconType = "faSolid",
iconColour = globals.defaultColours.primary,
backgroundColour = globals.defaultColours.white,
})
local settingsButton = engine.construct("guiImage", container, {
local settingsButton = teverse.construct("guiIcon", {
parent = container,
size = guiCoord(0, 20, 0, 20),
position = guiCoord(0.97, 0, 0.2, 0),
texture = "fa:s-sliders-h",
imageColour = globals.defaultColours.primary,
iconId = "sliders-h",
iconType = "faSolid",
iconColour = globals.defaultColours.primary,
backgroundColour = globals.defaultColours.white,
})
@ -117,13 +130,14 @@ return {
]]--
table.insert(self.keys, {name})
local button = engine.construct("guiButton", container, {
local button = teverse.construct("guiButton", {
parent = container,
size = guiCoord(0.056, 0, 0.9, 0),
position = guiCoord(0.2+(#self.keys*0.07), 0, 0.05, 0),
text = name,
textColour = globals.defaultColours.primary,
fontSize = 30,
align = enums.align.middle,
textAlign = enums.align.middle,
zIndex = 100
})

View File

@ -2,49 +2,49 @@
-- This script is responsible for creating the workshop interface
local globals = require("tevgit:workshop/library/globals.lua") -- globals; variables or instances that can be shared between files
local prompt = require("tevgit:workshop/library/ui/components/prompt.lua") -- UI Component
--local prompt = require("tevgit:workshop/library/ui/components/prompt.lua") -- UI Component
local topbarInterface = require("tevgit:workshop/library/ui/controllers/topbarInterface.lua") -- UI Controller
local sidebarInterface = require("tevgit:workshop/library/ui/controllers/sidebarInterface.lua") -- UI Controller
local topBar = topbarInterface.construct("horizontalNavbar", "fa:s-cloud", "Test Place 1") -- Create initial topbar instance
local topBar = topbarInterface.construct("horizontalNavbar", "cloud", "Test Place 1") -- Create initial topbar instance
local sideBar = sidebarInterface.construct("verticalNavbar") -- Create initial sidebar instance
local defaultPage = sideBar.registerPage("Default") -- Register default page to sidebar instance
sideBar.registerIcon(defaultPage, "openFolderIcon", "fa:s-folder-open", "Open Folder", nil)
sideBar.registerIcon(defaultPage, "newFileIcon", "fa:s-file", "Create new file", nil)
sideBar.registerIcon(defaultPage, "uploadFileIcon", "fa:s-file-upload", "Upload current file", nil)
sideBar.registerIcon(defaultPage, "downloadFileIcon", "fa:s-file-download", "Download current file", nil)
sideBar.registerIcon(defaultPage, "importFileIcon", "fa:s-file-import", "Import a file", nil, -0.048, guiCoord(0.048, 0, 0, 0))
sideBar.registerIcon(defaultPage, "exportFileIcon", "fa:s-file-export", "Export current file", nil, 0.048, guiCoord(-0.048, 0, 0, 0))
sideBar.registerIcon(defaultPage, "openFolderIcon", "folder-open", "Open Folder", nil)
sideBar.registerIcon(defaultPage, "newFileIcon", "file", "Create new file", nil)
sideBar.registerIcon(defaultPage, "uploadFileIcon", "file-upload", "Upload current file", nil)
sideBar.registerIcon(defaultPage, "downloadFileIcon", "file-download", "Download current file", nil)
sideBar.registerIcon(defaultPage, "importFileIcon", "file-import", "Import a file", nil, -0.048, guiCoord(0.048, 0, 0, 0))
sideBar.registerIcon(defaultPage, "exportFileIcon", "file-export", "Export current file", nil, 0.048, guiCoord(-0.048, 0, 0, 0))
defaultPage.visible = true -- Set default sidebar page to visible
globals.sideBarPageDefault = defaultPage -- Set default sidebar page to default
globals.sideBarPageActive = defaultPage -- Set default sidebar page as active
local designPage = sideBar.registerPage("Design") -- Design default page to sidebar instance
sideBar.registerIcon(designPage, "screenContainerIcon", "fa:s-tv", "Create a container instance", nil)
sideBar.registerIcon(designPage, "guiFrameIcon", "fa:s-square-full", "Create a guiFrame instance", nil)
sideBar.registerIcon(designPage, "guiTextBoxIcon", "fa:s-i-cursor", "Create a guiTextBox instance", nil)
sideBar.registerIcon(designPage, "guiImageIcon", "fa:s-image", "Create a guiImage instance", nil)
sideBar.registerIcon(designPage, "screenContainerIcon", "tv", "Create a container instance", nil)
sideBar.registerIcon(designPage, "guiFrameIcon", "square-full", "Create a guiFrame instance", nil)
sideBar.registerIcon(designPage, "guiTextBoxIcon", "i-cursor", "Create a guiTextBox instance", nil)
sideBar.registerIcon(designPage, "guiImageIcon", "image", "Create a guiImage instance", nil)
local modelPage = sideBar.registerPage("Model") -- Register model page to sidebar instance
sideBar.registerIcon(modelPage, "modelIcon", "fa:s-shapes", "Group instance(s) together", nil)
sideBar.registerIcon(modelPage, "modelIcon", "shapes", "Group instance(s) together", nil)
local insertPage = sideBar.registerPage("Insert") -- Register insert page to sidebar instance
sideBar.registerIcon(insertPage, "blockIcon", "fa:s-cube", "Create a cube instance", nil)
sideBar.registerIcon(insertPage, "circleIcon", "fa:s-circle", "Create a cylinder instance", nil)
--sideBar.registerIcon(designPage, "triangleIcon", "fa:s-i-cursor", nil, nil) -- Triangle / Wedge Icon doesn't exist
sideBar.registerIcon(insertPage, "scriptIcon", "fa:s-code", "Create a script instance", nil)
sideBar.registerIcon(insertPage, "lightIcon", "fa:s-lightbulb", "Create a light instance", nil)
sideBar.registerIcon(insertPage, "blockIcon", "cube", "Create a cube instance", nil)
sideBar.registerIcon(insertPage, "circleIcon", "circle", "Create a cylinder instance", nil)
--sideBar.registerIcon(designPage, "triangleIcon", "i-cursor", nil, nil) -- Triangle / Wedge Icon doesn't exist
sideBar.registerIcon(insertPage, "scriptIcon", "code", "Create a script instance", nil)
sideBar.registerIcon(insertPage, "lightIcon", "lightbulb", "Create a light instance", nil)
local testPage = sideBar.registerPage("Test") -- Register test page to sidebar instance
sideBar.registerIcon(testPage, "consoleIcon", "fa:s-terminal", " Open console window", nil)
sideBar.registerIcon(testPage, "playIcon", "fa:s-play", "Play scene", nil)
sideBar.registerIcon(testPage, "serverIcon", "fa:s-server", "Configure server", nil)
sideBar.registerIcon(testPage, "fullScreenIcon", "fa:s-fullscreen", "Toggle full screen", nil)
sideBar.registerIcon(testPage, "consoleIcon", "terminal", " Open console window", nil)
sideBar.registerIcon(testPage, "playIcon", "play", "Play scene", nil)
sideBar.registerIcon(testPage, "serverIcon", "server", "Configure server", nil)
sideBar.registerIcon(testPage, "fullScreenIcon", "fullscreen", "Toggle full screen", nil)

View File

@ -3,7 +3,7 @@
local globals = require("tevgit:workshop/library/globals.lua") -- globals; variables or instances that can be shared between files
local function init(workshop)
local function init(dev)
--[[
@Description
The initializer method that comes first when a new scene is open.
@ -15,20 +15,22 @@ local function init(workshop)
void, null, nil
]]--
globals.workshop = workshop -- Set workshop instance as a global
globals.user = engine:isAuthenticated() -- Set & Streamline user instance as a global
globals.developerMode = (not globals.workshop.hasLocalTevGit) or (globals.workshop:hasLocalTevGit()) -- Set developmode boolean as a global
globals.dev = dev -- Set teverse.dev (previously workshop) instance as a global
globals.user = teverse.networking.localClient -- Set & Streamline user instance as a global
globals.developerMode = not globals.dev.localTevGit -- Set developmode boolean as a global
local loadingScreen = engine.construct("guiFrame", workshop.interface, {
local loadingScreen = teverse.construct("guiFrame", {
parent = dev.interface,
size = guiCoord(1, 0, 1, 0),
backgroundColour = globals.defaultColours.background,
zIndex = 1000
})
engine.construct("guiTextBox", loadingScreen, {
teverse.construct("guiTextBox", {
parent = loadingScreen,
size = guiCoord(0.5, 0, 0.5, 0),
position = guiCoord(0.25, 0, 0.25, 0),
align = enums.align.middle,
textAlign = enums.align.middle,
backgroundAlpha = 0,
text = "Downloading the latest workshop...\nThis takes longer than a moment during beta."
})
@ -42,7 +44,7 @@ local function init(workshop)
end
end
return function(workshop)
return function(dev)
--[[
@Description
The main method that comes when a new scene is opened.
@ -53,41 +55,46 @@ return function(workshop)
@Returns
function, method
]]--
local success, message = pcall(init, workshop)
dev = teverse.dev
local success, message = pcall(init, dev)
-- If initialize phase fails, prompt to the error screen
if (not success) then
workshop.interface:destroyAllChildren()
local errorScreen = engine.construct("guiFrame", workshop.interface, {
teverse.interface:destroyChildren()
local errorScreen = teverse.construct("guiFrame", {
parent = dev.interface,
size = guiCoord(1, 0, 1, 0),
backgroundColour = globals.defaultColours.background,
backgroundAlpha = 0,
zIndex = 10000
})
engine.construct("guiTextBox", errorScreen, {
teverse.construct("guiTextBox", {
parent = errorScreen,
size = guiCoord(0.8, 0, 0.8, 0),
position = guiCoord(0.1, 0, 0.1, 0),
backgroundColour = globals.defaultColours.background,
backgroundAlpha = 0,
textColour = globals.defaultColours.red,
align = enums.align.topLeft,
textAlign = enums.align.topLeft,
text = "Error loading Workshop\nIf this isn't your fault, please take a screenshot and report this as a bug. \n\n" .. message .." \n\nPlease press 'ENTER' on your keyboard to restart Teverse.",
wrap = true,
textWrap = true,
textFont = "tevurl:fonts/firaCodeMedium.otf"
})
-- Bind the "return" key on the keyboard as temporary fast-reload keybind
engine.input:on("keyPressed", function(keyboard)
if keyboard.key == enums.key["return"] then
workshop:reloadCreate()
teverse.input:on("keyDown", function(key)
if key == "KEY_RETURN" then
teverse.apps:loadWorkshop()
end
end)
end
-- Bind the "f12" key on the keyboard as fast-reload keybind if initialize phase is successful
engine.input:on("keyPressed", function(keyboard)
if keyboard.key == enums.key["f12"] then
workshop:reloadCreate()
teverse.input:on("keyDown", function(key)
if key == "KEY_F12" then
teverse.apps:loadWorkshop()
end
end)
end