Compare commits

...

11 Commits

Author SHA1 Message Date
Sanjay Bhadra 7ffb2dfe47 Refactored Workshop to TevX Format 2020-04-20 15:25:54 -04:00
Jay 2753406be2 App publish workflow (prototype, needs work) 2020-04-19 21:57:28 +01:00
Jay 10176d4f66 New core UIs 2020-04-19 19:47:42 +01:00
Jay 20b70ad8a7 Console.lua 2020-04-17 22:09:32 +01:00
Jay 7cf19da3ae added main ui 2020-04-16 22:46:50 +01:00
Jay d86d0a712f Tevgit reset 2020-04-16 21:28:23 +01:00
Jay 9d2cca67eb Merge branch 'master' of https://github.com/teverse/teverse 2020-04-15 20:26:40 +01:00
Jay beb35bbc8f Develop and app dashboard 2020-04-15 20:26:38 +01:00
Sanjay 28ed81c357
Merge pull request #70 from teverse/rewrite-tevx
Workshop Overhaul (rewrite)
2020-04-14 18:41:19 -04:00
Jay afd690f598 added ability to post on feed 2020-04-13 14:57:48 +01:00
Jay f6020eed89 http test, homepage additions 2020-04-12 11:53:02 +01:00
16 changed files with 823 additions and 226 deletions

184
core/apps/editor.lua Normal file
View File

@ -0,0 +1,184 @@
-- This script is ran when the user is running a local app/sandbox
local share = teverse.construct("guiTextBox", {
parent = teverse.coreInterface,
size = guiCoord(0, 60, 0, 16),
position = guiCoord(0.5, -65, 1, -20),
strokeRadius = 4,
text = "Share",
textAlign = "middle",
textSize = 12
})
local reload = teverse.construct("guiTextBox", {
parent = teverse.coreInterface,
size = guiCoord(0, 60, 0, 16),
position = guiCoord(0.5, 5, 1, -20),
strokeRadius = 4,
text = "Reload",
textAlign = "middle",
textSize = 12
})
reload:on("mouseLeftUp", function()
teverse.apps:reload()
end)
share:on("mouseLeftUp", function()
share.visible = false
local dialog = teverse.construct("guiFrame", {
parent = teverse.coreInterface,
size = guiCoord(0, 300, 0, 200),
position = guiCoord(0.5, -150, 0.5, -100),
strokeRadius = 4,
strokeAlpha = 0.3
})
local appsContainer = teverse.construct("guiFrame", {
parent = dialog,
size = guiCoord(1.0, -10, 1, -30),
position = guiCoord(0, 5, 0, 5),
backgroundAlpha = 0
})
teverse.guiHelper
.gridConstraint(appsContainer, {
cellSize = guiCoord(0, 130, 0, 24),
cellMargin = guiCoord(0, 10, 0, 15)
})
teverse.http:get("https://teverse.com/api/users/" .. teverse.networking.localClient.id .. "/apps", {
["Authorization"] = "BEARER " .. teverse.userToken
}, function(code, body)
if code == 200 then
local apps = teverse.json:decode(body)
for _,app in pairs(apps) do
local appGui = teverse.construct("guiFrame", {
parent = appsContainer,
strokeAlpha = 0.1,
strokeRadius = 4
})
teverse.guiHelper.hoverColour(appGui, colour.rgb(247, 247, 247))
teverse.construct("guiTextBox", {
parent = appGui,
size = guiCoord(1.0, -20, 1, -10),
position = guiCoord(0, 10, 0, 5),
backgroundAlpha = 0,
text = app.name,
textSize = 16,
textAlign = "middleLeft",
textFont = "tevurl:fonts/openSansBold.ttf",
active = false
})
appGui:on("mouseLeftUp", function()
dialog:destroyChildren()
local msg = teverse.construct("guiTextBox", {
parent = dialog,
size = guiCoord(1.0, -20, 1, -10),
position = guiCoord(0, 10, 0, 5),
backgroundAlpha = 0,
text = "We're updating your app.",
textSize = 16,
textAlign = "topLeft",
textWrap = true
})
local code, body = teverse.http:put("https://teverse.com/api/apps/" .. app.id .. "/script",
teverse.json:encode(teverse.apps:getSource()),
{
["Authorization"] = "BEARER " .. teverse.userToken,
["Content-Type"] = "application/json"
})
if code == 200 then
msg.text = "Your app was updated! Please note apps may be subject to moderation before becoming public."
else
msg.text = "Something went wrong."
end
end)
end
local nameBox = teverse.construct("guiTextBox", {
parent = dialog,
size = guiCoord(1, -105, 0, 20),
position = guiCoord(0, 5, 1, -25),
textSize = 16,
textAlign = "middleLeft",
text = "Name",
backgroundColour = colour.rgb(240, 240, 240),
strokeRadius = 2,
textEditable = true
})
nameBox:on("mouseLeftUp", function()
nameBox.text = ""
end)
local createNew = teverse.construct("guiTextBox", {
parent = dialog,
size = guiCoord(0, 100, 0, 20),
position = guiCoord(1, -105, 1, -25),
backgroundColour = colour.rgb(216, 100, 89),
textSize = 18,
textAlign = "middle",
textFont = "tevurl:fonts/openSansBold.ttf",
text = "Create New",
textColour = colour(1, 1, 1),
strokeRadius = 2,
zIndex = 2
})
createNew:on("mouseLeftUp", function()
local newApp = {
name = nameBox.text
}
dialog:destroyChildren()
local msg = teverse.construct("guiTextBox", {
parent = dialog,
size = guiCoord(1.0, -20, 1, -10),
position = guiCoord(0, 10, 0, 5),
backgroundAlpha = 0,
text = "We're creating your new app.",
textSize = 16,
textAlign = "topLeft",
textWrap = true
})
teverse.http:post("https://teverse.com/api/apps/", teverse.json:encode(newApp), {
["Authorization"] = "BEARER " .. teverse.userToken,
["Content-Type"] = "application/json"
}, function(code, body)
if code == 201 then
local app = teverse.json:decode(body)
msg.text = "Deploying script to your new app (" .. app.id .. ")..."
local code, body = teverse.http:put("https://teverse.com/api/apps/" .. app.id .. "/script",
teverse.json:encode(teverse.apps:getSource()),
{
["Authorization"] = "BEARER " .. teverse.userToken,
["Content-Type"] = "application/json"
})
msg.text = "Your new app has been published; please note apps may be subject to moderation before becoming public."
else
msg.text = "Something went wrong (" .. code .. ")"
end
end)
end)
else
teverse.construct("guiTextBox", {
parent = appsContainer,
size = guiCoord(1.0, -20, 1, -10),
position = guiCoord(0, 10, 0, 5),
backgroundAlpha = 0,
text = "Something went wrong",
textSize = 16,
textAlign = "topLeft"
})
end
end)
end)

13
core/apps/running.lua Normal file
View File

@ -0,0 +1,13 @@
-- This script is ran when the user is running a shared app
local appsContainer = teverse.construct("guiTextBox", {
parent = teverse.coreInterface,
size = guiCoord(1, 0, 0, 15),
position = guiCoord(0, 0, 1, -15),
backgroundAlpha = 0,
text = "You are running user generated code",
textShadowSize = 4,
textSize = 12,
textColour = colour(1, 1, 1),
textAlign = "middle"
})

View File

@ -3,6 +3,125 @@ return {
iconId = "shapes",
iconType = "faSolid",
setup = function(page)
local loading = teverse.construct("guiTextBox", {
parent = page,
size = guiCoord(1.0, 100, 1.0, 100),
position = guiCoord(0, -50, 0, -50),
backgroundAlpha = 0.4,
backgroundColour = colour(0, 0, 0),
text = "Working...",
textColour = colour(0,0,0),
textAlign = "middle",
visible = false,
zIndex = 10000
})
teverse.construct("guiTextBox", {
parent = page,
size = guiCoord(1.0, -20, 0, 48),
position = guiCoord(0, 10, 0, 10),
backgroundAlpha = 0,
text = "Apps",
textSize = 48,
textAlign = "middleLeft"
})
local subtitle = teverse.construct("guiTextBox", {
parent = page,
size = guiCoord(1.0, -20, 0, 18),
position = guiCoord(0, 10, 0, 58),
backgroundAlpha = 0,
text = "Loading Apps",
textSize = 18,
textAlign = "middleLeft"
})
local appsContainer = teverse.construct("guiFrame", {
parent = page,
size = guiCoord(1.0, -20, 1, -100),
position = guiCoord(0, 10, 0, 90),
backgroundAlpha = 0
})
teverse.guiHelper
.gridConstraint(appsContainer, {
cellSize = guiCoord(0, 150, 0, 80),
cellMargin = guiCoord(0, 15, 0, 25)
})
teverse.http:get("https://teverse.com/api/apps", {
["Authorization"] = "BEARER " .. teverse.userToken
}, function(code, body)
if code == 200 then
local apps = teverse.json:decode(body)
subtitle.text = "Found " .. #apps .. " public apps."
for _,app in pairs(apps) do
local appGui = teverse.construct("guiFrame", {
parent = appsContainer,
strokeAlpha = 0.1,
strokeRadius = 4
})
teverse.guiHelper.hoverColour(appGui, colour.rgb(247, 247, 247))
appGui:on("mouseLeftUp", function()
if not loading.visible then
loading.text = "Working..."
loading.visible = true
teverse.http:get("https://teverse.com/api/apps/" .. app.id .. "/script", {
["Authorization"] = "BEARER " .. teverse.userToken
}, function(code, body)
if code == 200 then
loading.visible = false
teverse.apps:loadString(body)
else
loading.text = "Unable to load app."
sleep(1.5)
loading.visible = false
end
end)
end
end)
teverse.construct("guiTextBox", {
parent = appGui,
size = guiCoord(1.0, -20, 0, 22),
position = guiCoord(0, 10, 0, 5),
backgroundAlpha = 0,
text = app.name,
textSize = 22,
textAlign = "middleLeft",
textFont = "tevurl:fonts/openSansBold.ttf",
active = false
})
teverse.construct("guiTextBox", {
parent = appGui,
size = guiCoord(1.0, -20, 0, 16),
position = guiCoord(0, 10, 0, 24),
backgroundAlpha = 0,
textAlpha = 0.5,
text = "by " .. app.owner.username,
textSize = 16,
active = false
})
teverse.construct("guiIcon", {
parent = appGui,
size = guiCoord(1, 0, 1, -45),
position = guiCoord(0, 0, 0, 45),
iconMax = 20,
iconColour = colour(1, 1, 1),
iconType = "faSolid",
iconId = "code",
iconAlpha = 0.9,
backgroundAlpha = 1.0,
backgroundColour = colour.rgb(216, 100, 89),
active = false
})
end
else
subtitle.text = "Server error."
end
end)
end
}

View File

@ -3,6 +3,66 @@ return {
iconId = "layer-group",
iconType = "faSolid",
setup = function(page)
teverse.construct("guiTextBox", {
parent = page,
size = guiCoord(1.0, -20, 0, 48),
position = guiCoord(0, 10, 0, 10),
backgroundAlpha = 0,
text = "Develop",
textSize = 48,
textAlign = "middleLeft"
})
local newSandboxBtn = teverse.construct("guiFrame", {
parent = page,
size = guiCoord(1/3, -20, 0, 70),
position = guiCoord(0, 10, 0, 60),
backgroundColour = colour.rgb(74, 140, 122),
strokeRadius = 3
})
teverse.guiHelper
.bind(newSandboxBtn, "xs", {
size = guiCoord(1, -20, 0, 70),
position = guiCoord(0, 10, 0, 60)
})
.bind(newSandboxBtn, "sm", {
size = guiCoord(1/3, -20, 0, 70),
position = guiCoord(0, 10, 0, 60)
})
.bind(newSandboxBtn, "lg", {
size = guiCoord(1/3, -20, 0, 70),
position = guiCoord(0, 10, 0, 60)
})
.hoverColour(newSandboxBtn, colour.rgb(235, 187, 83))
newSandboxBtn:on("mouseLeftUp", function()
teverse.apps:prompt()
end)
teverse.construct("guiTextBox", {
parent = newSandboxBtn,
size = guiCoord(0.5, -10, 0, 18),
position = guiCoord(0.5, 0, 0.5, -9),
backgroundAlpha = 0,
text = "Run Script",
textSize = 18,
textAlign = "middleLeft",
textColour = colour(1, 1, 1),
active = false
--textFont = "tevurl:fonts/openSansLight.ttf"
})
teverse.construct("guiIcon", {
parent = newSandboxBtn,
size = guiCoord(0, 40, 0, 40),
position = guiCoord(0.5, -60, 0.5, -20),
iconMax = 40,
iconColour = colour(1, 1, 1),
iconType = "faSolid",
iconId = "code",
iconAlpha = 0.9,
active = false
})
end
}

View File

@ -1,8 +1,9 @@
local function newFeedItem(pfp, name, date, body)
local item = teverse.construct("guiFrame", {
size = guiCoord(1, -20, 0, 48),
position = guiCoord(0, 10, 0, 26),
backgroundAlpha = 1
position = guiCoord(0, 10, 0, 40),
backgroundAlpha = 0,
name = "feedItem"
})
teverse.construct("guiImage", {
@ -36,7 +37,8 @@ local function newFeedItem(pfp, name, date, body)
text = date,
textAlign = enums.align.middleRight,
textSize = 14,
textAlpha = 0.4
textAlpha = 0.4,
textWrap = true
})
teverse.construct("guiTextBox", {
@ -59,6 +61,8 @@ return {
iconId = "sliders-h",
iconType = "faSolid",
setup = function(page)
page.backgroundAlpha = 1.0
local feed = teverse.construct("guiScrollView", {
parent = page,
size = guiCoord(1, 0, 1, 50),
@ -67,7 +71,7 @@ return {
strokeRadius = 3
})
teverse.bp
teverse.guiHelper
.bind(feed, "xs", {
size = guiCoord(1, 0, 1, 50),
position = guiCoord(0, 0, 0, -50)
@ -85,7 +89,7 @@ return {
strokeRadius = 3
})
teverse.bp
teverse.guiHelper
.bind(tevs, "xs", {
size = guiCoord(1, -20, 0, 70),
position = guiCoord(0, 10, 0, 50)
@ -99,13 +103,13 @@ return {
position = guiCoord(0, 10, 0, 0)
})
teverse.construct("guiTextBox", {
local tevCoins = teverse.construct("guiTextBox", {
parent = tevs,
size = guiCoord(0.5, -20, 0, 40),
size = guiCoord(0.5, 0, 0, 40),
position = guiCoord(0.5, 0, 0.5, -15),
backgroundAlpha = 0,
text = "975",
textSize = 40,
text = "",
textSize = 34,
textAlign = "middleLeft",
textColour = colour(1, 1, 1),
textFont = "tevurl:fonts/openSansBold.ttf"
@ -142,7 +146,7 @@ return {
strokeRadius = 3
})
teverse.bp
teverse.guiHelper
.bind(membership, "xs", {
size = guiCoord(1, -20, 0, 70),
position = guiCoord(0, 10, 0, 80 + 50)
@ -168,18 +172,26 @@ return {
textFont = "tevurl:fonts/openSansLight.ttf"
})
teverse.construct("guiTextBox", {
local membershipText = teverse.construct("guiTextBox", {
parent = membership,
size = guiCoord(0.5, -20, 0, 40),
size = guiCoord(0.5, 0, 0, 40),
position = guiCoord(0.5, 0, 0.5, -15),
backgroundAlpha = 0,
text = "Free",
textSize = 40,
textSize = 34,
textAlign = "middleLeft",
textColour = colour(1, 1, 1),
textFont = "tevurl:fonts/openSansBold.ttf"
})
local membertype = teverse.networking.localClient.membership
if membership == "plus" then
membershipText.text = "Plus"
elseif membership == "pro" then
membershipText.text = "Pro"
else
membershipText.text = "Free"
end
teverse.construct("guiIcon", {
parent = membership,
size = guiCoord(0, 40, 0, 40),
@ -199,7 +211,7 @@ return {
strokeRadius = 3
})
teverse.bp
teverse.guiHelper
.bind(version, "xs", {
size = guiCoord(1, -20, 0, 70),
position = guiCoord(0, 10, 0, 160 + 50)
@ -231,7 +243,7 @@ return {
position = guiCoord(0.5, 0, 0.5, -15),
backgroundAlpha = 0,
text = _TEV_BUILD,
textSize = 40,
textSize = 34,
textAlign = "middleLeft",
textColour = colour(1, 1, 1),
textFont = "tevurl:fonts/openSansBold.ttf"
@ -248,13 +260,21 @@ return {
iconAlpha = 0.9
})
teverse.http:get("https://teverse.com/api/users/me/tevs", {
["Authorization"] = "BEARER " .. teverse.userToken
}, function(code, body)
if code == 200 then
tevCoins.text = body
end
end)
local feedItems = teverse.construct("guiFrame", {
parent = feed,
backgroundAlpha = 1,
clip = true
})
teverse.bp
teverse.guiHelper
.bind(feedItems, "xs", {
size = guiCoord(1, -20, 1, -(240 + 50)),
position = guiCoord(0, 10, 0, 240 + 50)
@ -268,25 +288,81 @@ return {
position = guiCoord(0, 10, 0, 80)
})
teverse.construct("guiTextBox", {
size = guiCoord(1, -20, 0, 26),
position = guiCoord(0, 10, 0, 0),
backgroundAlpha = 0,
local input = teverse.construct("guiTextBox", {
parent = feedItems,
text = "Feed",
textSize = 26,
textFont = "tevurl:fonts/openSansBold.ttf"
size = guiCoord(1, -20, 0, 30),
position = guiCoord(0, 10, 0, 10),
strokeAlpha = 0.15,
strokeRadius = 3,
textEditable = true,
textAlign = "topLeft"
})
local function pushItem(item)
local y = item.absoluteSize.y
for i,v in pairs(feedItems.children) do
v.position = guiCoord(0, 10, 0, y)
y = y + v.absoluteSize.y + 10
end
item.parent = feedItems
local newestFeed = ""
local lastRefresh = 0
local function refresh()
lastRefresh = os.clock()
teverse.http:get("https://teverse.com/api/feed", {
["Authorization"] = "BEARER " .. teverse.userToken
}, function(code, body)
if code == 200 then
lastRefresh = os.clock()
local json = teverse.json:decode(body)
if json[1].id == newestFeed then
-- no change from last refresh
return nil
else
-- may require refactoring
for _,v in pairs(feedItems.children) do
if v.name == "feedItem" then
v:destroy()
end
end
end
newestFeed = json[1].id
local y = 50
for _,v in pairs(json) do
local date = os.date("%d/%m/%Y %H:%M", os.parseISO8601(v.postedAt))
local item = newFeedItem("tevurl:asset/user/" .. v.postedBy.id, v.postedBy.username, date, v.message)
item.parent = feedItems
local dy = item:child("body").textDimensions.y
item.size = guiCoord(1, -20, 0, dy + 28)
item.position = guiCoord(0, 10, 0, y)
y = y + dy + 28
end
feed.canvasSize = guiCoord(1, 0, 0, feedItems.absolutePosition.y + y + 100)
end
end)
end
pushItem(newFeedItem("tevurl:asset/user/" .. teverse.networking.localClient.id, teverse.networking.localClient.name, "Now", "test"))
local submitting = false
input:on("keyUp", function(keycode)
if keycode == "KEY_RETURN" and not submitting then
submitting = true
input.textEditable = false
input.textAlpha = 0.5
local payload = teverse.json:encode({ message = input.text })
teverse.http:post("https://teverse.com/api/feed", payload, {
["Authorization"] = "BEARER " .. teverse.userToken,
["Content-Type"] = "application/json"
}, function(code, body)
refresh()
input.text = ""
input.textEditable = true
input.textAlpha = 1.0
end)
end
end)
refresh()
spawn(function()
while sleep(2.5) do
if page.Visible and os.clock() - lastRefresh > 2 then
refresh()
end
end
end)
end
}

View File

@ -12,8 +12,8 @@ controller.setup = function()
parent = navBar,
backgroundAlpha = 0
})
teverse.bp
teverse.guiHelper
.gridConstraint(navContainer, {
cellSize = guiCoord(0, 40, 0, 40),
cellMargin = guiCoord(0, 25, 0, 25)
@ -68,7 +68,7 @@ controller.setup = function()
backgroundColour = colour.rgb(242, 244, 245)
})
teverse.bp
teverse.guiHelper
.bind(body, "xs", {
size = guiCoord(1, 90, 1, -5),
position = guiCoord(0, -45, 0, -60)
@ -90,7 +90,7 @@ controller.setup = function()
visible = false
})
teverse.bp
teverse.guiHelper
.bind(container, "xs", {
size = guiCoord(1, -120, 1, -80),
position = guiCoord(0, 60, 0, 80)
@ -135,9 +135,9 @@ controller.setup = function()
table.insert(pages, {container, icon})
end
setupPage(require("tevgit:core/dashboard/pages/home"))
setupPage(require("tevgit:core/dashboard/pages/apps"))
setupPage(require("tevgit:core/dashboard/pages/develop"))
setupPage(require("tevgit:core/dashboard/pages/home.lua"))
setupPage(require("tevgit:core/dashboard/pages/apps.lua"))
setupPage(require("tevgit:core/dashboard/pages/develop.lua"))
end
return controller

View File

@ -1,5 +1,5 @@
local main = teverse.construct("guiFrame", {
parent = teverse.coreInterface,
parent = teverse.interface,
backgroundColour = colour.rgb(52, 58, 64),
size = guiCoord(1, 0, 1, 100),
position = guiCoord(0, 0, 0, -50)

View File

@ -1,142 +1,140 @@
return function()
-- Textbox colour/border radius/shadow demo
local colours = {
colour(1, 0, 0),
colour(1, 1, 0),
colour(0, 1, 0),
colour(0, 1, 1),
colour(0, 0, 1),
colour(1, 0, 1),
colour(1, 1, 1),
colour(0, 0, 0)
}
-- Textbox colour/border radius/shadow demo
local size = 1/#colours
local lastColour = colour(0,0,0)
for i = 1, #colours do
teverse.construct("guiTextBox", {
parent = teverse.interface,
size = guiCoord(size, 0, 0, 50),
position = guiCoord(size * (i - 1), 0, 0, 0),
backgroundColour = colours[i],
text = "#" .. colours[i]:hex(),
textShadowSize = 2,
textColour = colour(1, 1, 1)
})
local colours = {
colour(1, 0, 0),
colour(1, 1, 0),
colour(0, 1, 0),
colour(0, 1, 1),
colour(0, 0, 1),
colour(1, 0, 1),
colour(1, 1, 1),
colour(0, 0, 0)
}
local c = colours[i] * colour(0.9, 0.9, 0.9)
teverse.construct("guiGradientFrame", {
parent = teverse.interface,
size = guiCoord(size, 2, 0, 20),
position = guiCoord(size * (i - 1), -1, 0, 60),
backgroundColour = lastColour,
backgroundColourB = c,
start = guiCoord(0.4, 0, 0, 0),
finish = guiCoord(0.6, 0, size * (i - 1), 0)
})
local size = 1/#colours
local lastColour = colour(0,0,0)
for i = 1, #colours do
teverse.construct("guiTextBox", {
parent = teverse.interface,
size = guiCoord(size, 0, 0, 50),
position = guiCoord(size * (i - 1), 0, 0, 0),
backgroundColour = colours[i],
text = "#" .. colours[i]:hex(),
textShadowSize = 2,
textColour = colour(1, 1, 1)
})
lastColour = c
local c = colours[i] * colour(0.9, 0.9, 0.9)
teverse.construct("guiGradientFrame", {
parent = teverse.interface,
size = guiCoord(size, 2, 0, 20),
position = guiCoord(size * (i - 1), -1, 0, 60),
backgroundColour = lastColour,
backgroundColourB = c,
start = guiCoord(0.4, 0, 0, 0),
finish = guiCoord(0.6, 0, size * (i - 1), 0)
})
lastColour = c
end
-- Textbox Align Demo
local reverseAlign = {}
for k,v in pairs(enums.align) do
reverseAlign[tonumber(v)] = k
end
local txtGuis = {}
local size = 1/3
local i = 0
local y = 90
for a = 0, 8 do
i = i + 1
local gui = teverse.construct("guiTextBox", {
parent = teverse.interface,
size = guiCoord(size, -1, 0, 28),
position = guiCoord(size * (i - 1), 0, 0, y),
backgroundColour = colour(1, 1, 1),
text = "enums.align." .. reverseAlign[a],
textSize = 14,
textAlign = a,
strokeRadius = 5
})
table.insert(txtGuis, gui)
if i > 2 then
i = 0
y = y + 29
end
end
-- Textbox Align Demo
for i = 1, #colours do
teverse.construct("guiImage", {
position = guiCoord(0, (i-1) * 75, 0, y),
size = guiCoord(0, 75, 0, 50),
parent = teverse.interface,
backgroundAlpha = 0,
image = "tevurl:img/tTiled.png",
imageBottomRight = vector2(3, 2),
imageColour = colours[i]
})
end
local reverseAlign = {}
for k,v in pairs(enums.align) do
reverseAlign[v] = k
end
local size = 1/#colours
y = y + 60
local previous = 0
for i = 1, #colours do
local new = math.random(1, 50)
local a = teverse.construct("guiLine", {
pointA = guiCoord(size*(i-1), 0, 0, y + previous),
pointB = guiCoord(size*(i), 0, 0, y + new),
parent = teverse.interface,
lineWidth = 5,
lineAlpha = 0.5,
lineColour = colours[i],
lineCap = enums.lineCap.round
})
previous = new
end
local txtGuis = {}
local size = 1/3
local i = 0
local y = 90
for a = 0, 8 do
i = i + 1
local gui = teverse.construct("guiTextBox", {
parent = teverse.interface,
size = guiCoord(size, -1, 0, 28),
position = guiCoord(size * (i - 1), 0, 0, y),
backgroundColour = colour(1, 1, 1),
text = "enums.align." .. reverseAlign[a],
textSize = 14,
textAlign = a,
strokeRadius = 5
})
table.insert(txtGuis, gui)
if i > 2 then
i = 0
y = y + 29
end
end
for i = 1, #colours do
teverse.construct("guiImage", {
position = guiCoord(0, (i-1) * 75, 0, y),
size = guiCoord(0, 75, 0, 50),
parent = teverse.interface,
backgroundAlpha = 0,
image = "tevurl:img/tTiled.png",
imageBottomRight = vector2(3, 2),
imageColour = colours[i]
})
end
local size = 1/#colours
y = y + 60
local previous = 0
for i = 1, #colours do
local new = math.random(1, 50)
local a = teverse.construct("guiLine", {
pointA = guiCoord(size*(i-1), 0, 0, y + previous),
pointB = guiCoord(size*(i), 0, 0, y + new),
parent = teverse.interface,
lineWidth = 5,
lineAlpha = 0.5,
lineColour = colours[i],
lineCap = enums.lineCap.round
})
previous = new
end
for i = 1, #colours do
local new = math.random(1, 50)
local a = teverse.construct("guiLineBezier", {
pointA = guiCoord(0, 0, 0, y + (i * 10)),
controlA = guiCoord(0, 50, 0, y+100),
pointB = guiCoord(1, 0, 0, y - 30 + (i * 10)),
controlB = guiCoord(1, -200, 0, y-100),
parent = teverse.interface,
lineWidth = 2,
lineColour = colours[i],
lineCap = enums.lineCap.round
})
previous = new
end
y = y + 60
-- create an arrow using lines:
local arrow = teverse.construct("guiLine", {
pointA = guiCoord(0, 100, 0, y ),
pointB = guiCoord(0, 100, 0, y + 50),
for i = 1, #colours do
local new = math.random(1, 50)
local a = teverse.construct("guiLineBezier", {
pointA = guiCoord(0, 0, 0, y + (i * 10)),
controlA = guiCoord(0, 50, 0, y+100),
pointB = guiCoord(1, 0, 0, y - 30 + (i * 10)),
controlB = guiCoord(1, -200, 0, y-100),
parent = teverse.interface,
lineWidth = 2,
-- rotation = 0.4
lineColour = colours[i],
lineCap = enums.lineCap.round
})
previous = new
end
teverse.construct("guiLine", {
parent = arrow,
pointA = guiCoord(0, 0, 0, 0 ),
pointB = guiCoord(0, 10, 0, -10),
lineWidth = 2
})
y = y + 60
teverse.construct("guiLine", {
parent = arrow,
pointA = guiCoord(0, 0, 0, 0 ),
pointB = guiCoord(0, -10, 0, -10),
lineWidth = 2
})
end
-- create an arrow using lines:
local arrow = teverse.construct("guiLine", {
pointA = guiCoord(0, 100, 0, y ),
pointB = guiCoord(0, 100, 0, y + 50),
parent = teverse.interface,
lineWidth = 2,
-- rotation = 0.4
})
teverse.construct("guiLine", {
parent = arrow,
pointA = guiCoord(0, 0, 0, 0 ),
pointB = guiCoord(0, 10, 0, -10),
lineWidth = 2
})
teverse.construct("guiLine", {
parent = arrow,
pointA = guiCoord(0, 0, 0, 0 ),
pointB = guiCoord(0, -10, 0, -10),
lineWidth = 2
})

30
core/tests/http.lua Normal file
View File

@ -0,0 +1,30 @@
-- test that the http api is functional
return function()
print("Running http tests!")
print("tested")
local code, body = teverse.http:get("https://teverse.com/")
print ("Http Test #1 https", code == 200 and "PASS" or "FAIL")
local code, body = teverse.http:get("http://teverse.com/")
print ("Http Test #2 http", code == 301 and "PASS" or "FAIL")
teverse.http:get("https://teverse.com/", function(code, body)
print ("Http Test #3 https async", code == 200 and "PASS" or "FAIL")
end)
teverse.http:get("http://teverse.com/", function(code, body)
print ("Http Test #4 http async", code == 301 and "PASS" or "FAIL")
end)
local code, body = teverse.http:get("https://teverse.com/", {
["header-name"] = "test"
})
print ("Http Test #5 https header", code == 200 and "PASS" or "FAIL")
teverse.http:get("https://teverse.com/", {
["header-name"] = "test"
}, function(code, body)
print ("Http Test #6 https async header", code == 200 and "PASS" or "FAIL")
end)
end

View File

@ -0,0 +1,35 @@
local container = teverse.construct("guiFrame", {
parent = teverse.coreInterface,
size = guiCoord(0, 300, 0, 400),
position = guiCoord(0, 20, 0, 20),
backgroundAlpha = 0.9,
zIndex = 1000,
strokeRadius = 2,
strokeAlpha = 0.2,
visible = false
})
teverse.construct("guiTextBox", {
parent = container,
size = guiCoord(1, -10, 0, 20),
position = guiCoord(0, 5, 0, 0),
backgroundAlpha = 0.0,
textSize = 16,
textAlign = "middleLeft",
text = "Console"
})
local txt = teverse.construct("guiTextBox", {
parent = container,
size = guiCoord(1, -10, 1, -25),
position = guiCoord(0, 5, 0, 20),
backgroundAlpha = 0.95,
strokeAlpha = 0.2,
textWrap = true
})
teverse.debug:on("print", function(msg)
txt.text = string.sub(os.date("%H:%M:%S") .. " : " .. msg .. "\n" .. txt.text, 0, 500)
end)
return container

81
core/teverseUI/main.lua Normal file
View File

@ -0,0 +1,81 @@
-- This is the main interface loaded into coreinterface
local console = require("tevgit:core/teverseUI/console.lua")
local container = teverse.construct("guiFrame", {
parent = teverse.coreInterface,
size = guiCoord(0, 77, 0, 26),
position = guiCoord(1, -81, 1, -30),
backgroundAlpha = 0.0,
strokeRadius = 13,
zIndex = 1000
})
local homebtn
local ico = teverse.construct("guiIcon", {
parent = container,
size = guiCoord(0, 20, 0, 20),
position = guiCoord(1, -23, 0.5, -10),
iconId = "wrench",
iconType = "faSolid",
iconColour = colour(0, 0, 0),
iconMax = 12,
iconAlpha = 0.75,
strokeRadius = 10,
strokeAlpha = 0.5,
backgroundAlpha = 1
})
local lastClick = 0
ico:on("mouseLeftDown", function()
if os.clock() - lastClick < 0.4 then
-- double click
lastClick = 0
console.visible = not console.visible
else
lastClick = os.clock()
end
end)
--if teverse.dev.localTevGit then
homebtn = teverse.construct("guiTextBox", {
parent = container,
size = guiCoord(0, 40, 0, 14),
position = guiCoord(0, 6, 0.5, -7),
text = "HOME",
textAlign = "middle",
textFont = "tevurl:fonts/openSansLight.ttf",
textColour = colour(0, 0, 0),
textSize = 14,
strokeRadius = 7,
strokeAlpha = 0.5,
backgroundAlpha = 0,
visible = false
})
homebtn:on("mouseLeftUp", function()
teverse.apps:loadDashboard()
end)
ico:on("mouseLeftUp", function()
container.backgroundAlpha = 1.0
homebtn.visible = true
if teverse.dev.state == "dashboard" then
if teverse.dev.localTevGit then
homebtn.text = "RESET"
homebtn.visible = true
else
homebtn.visible = false
end
else
homebtn.text = "HOME"
homebtn.visible = true
end
repeat sleep(0.1) until teverse.input.mousePosition.y < container.absolutePosition.y - 25
container.backgroundAlpha = 0.0
homebtn.visible = false
end)

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,7 @@ 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", 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,7 +36,7 @@ return {
backgroundAlpha = 0
})
engine.construct("guiImage", container, {
teverse.construct("guiImage", container, {
size = guiCoord(0, 48, 0, 48),
position = guiCoord(0.33, 0, -0.15, 0),
texture = "fa:s-caret-up",
@ -45,7 +45,7 @@ return {
backgroundAlpha = 0
})
local bodyContainer = engine.construct("guiFrame", container, {
local bodyContainer = teverse.construct("guiFrame", container, {
size = guiCoord(0.95, 0, 0.4, 0),
position = guiCoord(0.025, 0, 0.23, 0),
backgroundColour = globals.defaultColours.white,
@ -55,7 +55,7 @@ return {
borderColour = globals.defaultColours.secondary
})
engine.construct("guiImage", bodyContainer, {
teverse.construct("guiImage", bodyContainer, {
size = guiCoord(0, 16, 0, 16),
position = guiCoord(0.04, 0, 0.25, 0),
texture = "fa:s-info-circle",
@ -63,7 +63,7 @@ return {
backgroundColour = globals.defaultColours.white,
})
engine.construct("guiTextBox", bodyContainer, {
teverse.construct("guiTextBox", bodyContainer, {
size = guiCoord(0.82, 0, 1, 0),
position = guiCoord(0.15, 0, 0, 0),
text = text,
@ -78,7 +78,7 @@ return {
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", globals.workshop.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,7 +87,7 @@ return {
backgroundAlpha = 0
})
engine.construct("guiImage", container, {
teverse.construct("guiImage", container, {
size = guiCoord(0, 48, 0, 48),
position = guiCoord(-0.03, 0, -0.06, 0),
texture = "fa:s-caret-left",
@ -96,7 +96,7 @@ return {
backgroundAlpha = 0
})
local bodyContainer = engine.construct("guiFrame", container, {
local bodyContainer = teverse.construct("guiFrame", container, {
size = guiCoord(0.8, 0, 0.9, 0),
position = guiCoord(0.133, 0, 0.05, 0),
backgroundColour = globals.defaultColours.white,
@ -106,7 +106,7 @@ return {
borderColour = globals.defaultColours.primary
})
engine.construct("guiImage", bodyContainer, {
teverse.construct("guiImage", bodyContainer, {
size = guiCoord(0, 16, 0, 16),
position = guiCoord(0.05, 0, 0.3, 0),
texture = "fa:s-info-circle",
@ -114,7 +114,7 @@ return {
backgroundColour = globals.defaultColours.white,
})
engine.construct("guiTextBox", bodyContainer, {
teverse.construct("guiTextBox", bodyContainer, {
size = guiCoord(0.82, 0, 1, 0),
position = guiCoord(0.15, 0, 0, 0),
text = text,

View File

@ -22,25 +22,25 @@ return {
self.id = idValue -- Unique Indentifier
self.pages = {} -- Where we store our pages for sidebar
engine.construct("guiFrame", globals.workshop.interface, {
teverse.construct("guiFrame", 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", 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", 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("guiImage", toolsContainer, {
size = guiCoord(0, 20, 0, 20),
position = guiCoord(0.25, 0, 0.1, 0),
texture = "fa:s-location-arrow",
@ -48,7 +48,7 @@ return {
backgroundColour = globals.defaultColours.white,
})
local moveTool = engine.construct("guiImage", toolsContainer, {
local moveTool = teverse.construct("guiImage", toolsContainer, {
size = guiCoord(0, 20, 0, 20),
position = guiCoord(0.25, 0, 0.32, 0),
texture = "fa:s-arrows-alt-h",
@ -56,7 +56,7 @@ return {
backgroundColour = globals.defaultColours.white,
})
local rotateTool = engine.construct("guiImage", toolsContainer, {
local rotateTool = teverse.construct("guiImage", toolsContainer, {
size = guiCoord(0, 20, 0, 20),
position = guiCoord(0.25, 0, 0.54, 0),
texture = "fa:s-sync",
@ -64,7 +64,7 @@ return {
backgroundColour = globals.defaultColours.white,
})
local sizeTool = engine.construct("guiImage", toolsContainer, {
local sizeTool = teverse.construct("guiImage", toolsContainer, {
size = guiCoord(0, 20, 0, 20),
position = guiCoord(0.25, 0, 0.76, 0),
texture = "fa:s-expand",
@ -72,7 +72,7 @@ return {
backgroundColour = globals.defaultColours.white,
})
local moreToolsContainer = engine.construct("guiFrame", globals.workshop.interface, {
local moreToolsContainer = teverse.construct("guiFrame", globals.workshop.interface, {
name = "moreToolsContainer",
size = guiCoord(0.04, 0, 1, 0),
position = guiCoord(0, 0, 0.255, 0),
@ -98,7 +98,7 @@ return {
zIndexRange = 101
end
local iconContainer = engine.construct("guiFrame", moreToolsContainer, {
local iconContainer = teverse.construct("guiFrame", moreToolsContainer, {
name = pageName,
size = guiCoord(1, 0, 1, 0),
position = guiCoord(0, 0, 0, 0),
@ -129,7 +129,7 @@ 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("guiImage", 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

View File

@ -26,13 +26,13 @@ return {
self.titleIcon = titleIconValue
self.keys = {} -- Where item keys are stored
local container = engine.construct("guiFrame", globals.workshop.interface, {
local container = teverse.construct("guiFrame", 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("guiImage", container, {
size = guiCoord(0, 28, 0, 28),
position = guiCoord(0.01, 0, 0.1, 0),
texture = titleIconValue,
@ -41,7 +41,7 @@ return {
handleEvents = false,
})
engine.construct("guiTextBox", container, {
teverse.construct("guiTextBox", container, {
size = guiCoord(0.5, 0, 0.1, 0),
position = guiCoord(0.04, 0, 0.05, 0),
text = titleValue,
@ -51,7 +51,7 @@ return {
readOnly = true
})
engine.construct("guiTextBox", container, {
teverse.construct("guiTextBox", container, {
size = guiCoord(0.48, 0, 0.1, 0),
position = guiCoord(0.86, 0, 0.1, 0),
text = globals.user[2],
@ -60,14 +60,14 @@ return {
readOnly = true
})
local userIcon = engine.construct("guiFrame", container, {
local userIcon = teverse.construct("guiFrame", 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", container, {
size = guiCoord(0, 16, 0, 16),
position = guiCoord(0.836, 0, 0.5, 0),
backgroundColour = globals.defaultColours.green,
@ -78,7 +78,7 @@ return {
zIndex = 100
})
local undoButton = engine.construct("guiImage", container, {
local undoButton = teverse.construct("guiImage", container, {
size = guiCoord(0, 20, 0, 20),
position = guiCoord(0.92, 0, 0.2, 0),
texture = "fa:s-arrow-left",
@ -86,7 +86,7 @@ return {
backgroundColour = globals.defaultColours.white,
})
local redoButton = engine.construct("guiImage", container, {
local redoButton = teverse.construct("guiImage", container, {
size = guiCoord(0, 20, 0, 20),
position = guiCoord(0.94, 0, 0.2, 0),
texture = "fa:s-arrow-right",
@ -94,7 +94,7 @@ return {
backgroundColour = globals.defaultColours.white,
})
local settingsButton = engine.construct("guiImage", container, {
local settingsButton = teverse.construct("guiImage", container, {
size = guiCoord(0, 20, 0, 20),
position = guiCoord(0.97, 0, 0.2, 0),
texture = "fa:s-sliders-h",
@ -117,7 +117,7 @@ return {
]]--
table.insert(self.keys, {name})
local button = engine.construct("guiButton", container, {
local button = teverse.construct("guiButton", container, {
size = guiCoord(0.056, 0, 0.9, 0),
position = guiCoord(0.2+(#self.keys*0.07), 0, 0.05, 0),
text = name,

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,17 +15,17 @@ 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:isAuthenticated() -- Set & Streamline user instance as a global
globals.developerMode = (not globals.dev.hasLocalTevGit) or (globals.dev:hasLocalTevGit()) -- Set developmode boolean as a global
local loadingScreen = engine.construct("guiFrame", workshop.interface, {
local loadingScreen = teverse.construct("guiFrame", dev.interface, {
size = guiCoord(1, 0, 1, 0),
backgroundColour = globals.defaultColours.background,
zIndex = 1000
})
engine.construct("guiTextBox", loadingScreen, {
teverse.construct("guiTextBox", loadingScreen, {
size = guiCoord(0.5, 0, 0.5, 0),
position = guiCoord(0.25, 0, 0.25, 0),
align = enums.align.middle,
@ -42,7 +42,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.
@ -54,19 +54,20 @@ return function(workshop)
function, method
]]--
local success, message = pcall(init, workshop)
local success, message = pcall(init, dev)
local teverse = dev -- Laziness
-- If initialize phase fails, prompt to the error screen
if (not success) then
workshop.interface:destroyAllChildren()
teverse.interface:destroyAllChildren()
local errorScreen = engine.construct("guiFrame", workshop.interface, {
local errorScreen = teverse.construct("guiFrame", teverse.interface, {
size = guiCoord(1, 0, 1, 0),
backgroundColour = globals.defaultColours.background,
zIndex = 10000
})
engine.construct("guiTextBox", errorScreen, {
teverse.construct("guiTextBox", errorScreen, {
size = guiCoord(0.8, 0, 0.8, 0),
position = guiCoord(0.1, 0, 0.1, 0),
backgroundColour = globals.defaultColours.background,
@ -77,17 +78,17 @@ return function(workshop)
})
-- Bind the "return" key on the keyboard as temporary fast-reload keybind
engine.input:on("keyPressed", function(keyboard)
teverse.input:on("keyPressed", function(keyboard)
if keyboard.key == enums.key["return"] then
workshop:reloadCreate()
teverse:reloadCreate()
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)
teverse.input:on("keyPressed", function(keyboard)
if keyboard.key == enums.key["f12"] then
workshop:reloadCreate()
teverse:reloadCreate()
end
end)
end