Compare commits

...

2 Commits

Author SHA1 Message Date
Jay 155e2ac581 Hide apps on non dev 2020-05-01 13:28:53 +01:00
Jay 3c2e30b424 tutorial framework start 2020-05-01 13:26:51 +01:00
6 changed files with 171 additions and 49 deletions

View File

@ -1,13 +1,17 @@
-- This script is ran when the user is running a shared app -- This script is ran when the user is running a shared app
local appsContainer = teverse.construct("guiTextBox", { local disclaimer = teverse.construct("guiTextBox", {
parent = teverse.coreInterface, parent = teverse.coreInterface,
size = guiCoord(1, 0, 0, 15), size = guiCoord(1, -60, 0, 20),
position = guiCoord(0, 0, 1, -15), position = guiCoord(0, 30, 1, -20),
backgroundAlpha = 0, backgroundAlpha = 0,
text = "You are running user generated code", text = "You are running user generated code",
textShadowSize = 4, textShadowSize = 2,
textSize = 12, textSize = 12,
textColour = colour(1, 1, 1), textColour = colour(1, 1, 1),
textAlign = "middle" textAlign = "middle"
}) })
disclaimer:on("mouseLeftUp", function()
teverse.apps:reload()
end)

View File

@ -1,3 +1,51 @@
local function createApp(app)
local appGui = teverse.construct("guiFrame", {
strokeAlpha = 0.1,
strokeRadius = 4
})
teverse.guiHelper.hoverColour(appGui, colour.rgb(247, 247, 247))
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
})
return appGui
end
return { return {
name = "Apps", name = "Apps",
iconId = "shapes", iconId = "shapes",
@ -57,6 +105,23 @@ return {
}) })
end end
if teverse.dev.localTevGit then
local appGui = createApp({
id = "",
name = "Learn Code",
owner = {
username = "Teverse"
}
})
appGui.parent = appsContainer
appGui:on("mouseLeftUp", function()
if not loading.visible then
loading.visible = false
teverse.apps:loadString("require('tevgit:core/tutorials/main.lua')")
end
end)
end
teverse.http:get("https://teverse.com/api/apps", { teverse.http:get("https://teverse.com/api/apps", {
["Authorization"] = "BEARER " .. teverse.userToken ["Authorization"] = "BEARER " .. teverse.userToken
}, function(code, body) }, function(code, body)
@ -64,13 +129,8 @@ return {
local apps = teverse.json:decode(body) local apps = teverse.json:decode(body)
subtitle.text = "Found " .. #apps .. " public apps." subtitle.text = "Found " .. #apps .. " public apps."
for _,app in pairs(apps) do for _,app in pairs(apps) do
local appGui = teverse.construct("guiFrame", { local appGui = createApp(app)
parent = appsContainer, appGui.parent = appsContainer
strokeAlpha = 0.1,
strokeRadius = 4
})
teverse.guiHelper.hoverColour(appGui, colour.rgb(247, 247, 247))
appGui:on("mouseLeftUp", function() appGui:on("mouseLeftUp", function()
if not loading.visible then if not loading.visible then
loading.text = "Working..." loading.text = "Working..."
@ -89,43 +149,6 @@ return {
end) end)
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 end
else else
subtitle.text = "Server error." subtitle.text = "Server error."

View File

@ -0,0 +1,9 @@
return {
titleDesc = function(title, description)
return {
type = "titleDesc",
title = title,
description = description
}
end
}

View File

@ -0,0 +1,3 @@
return {
require("tevgit:core/tutorials/lessons/helloworld.lua")
}

View File

@ -0,0 +1,10 @@
local framework = require("tevgit:core/tutorials/framework.lua")
return {
name = "Hello World",
description = "test test test",
tutorial = {
framework.titleDesc("Test ", "Description"),
framework.titleDesc("Test2 ", "Description2")
}
}

73
core/tutorials/main.lua Normal file
View File

@ -0,0 +1,73 @@
local containerNegativePadding = teverse.construct("guiFrame", {
parent = teverse.interface,
size = guiCoord(1, 0, 1, 100),
position = guiCoord(0, 0, 0, -50)
})
local container = teverse.construct("guiScrollView", {
parent = containerNegativePadding,
size = guiCoord(1, 0, 1, -100),
position = guiCoord(0, 0, 0, 50),
backgroundAlpha = 0,
})
teverse.construct("guiTextBox", {
parent = container,
size = guiCoord(1.0, -20, 0, 48),
position = guiCoord(0, 10, 0, 10),
backgroundAlpha = 0,
text = "Learn Code",
textSize = 48,
textAlign = "middleLeft"
})
local y = 70
for i,v in pairs(require("tevgit:core/tutorials/lessons.lua")) do
local lesson = teverse.construct("guiFrame", {
parent = container,
position = guiCoord(0, 10, 0, y),
size = guiCoord(1, -20, 0, 50),
backgroundColour = colour.rgb(245, 245, 245),
dropShadowAlpha = 0.2,
strokeRadius = 3
})
teverse.construct("guiTextBox", {
parent = lesson,
size = guiCoord(0, 40, 1, -10),
position = guiCoord(0, 5, 0, 5),
backgroundAlpha = 0,
text = string.format("%02d", i),
textSize = 32,
textAlign = "middle",
textFont = "tevurl:fonts/firaCodeMedium.otf",
textColour = colour.rgb(211, 54, 130)
})
teverse.construct("guiTextBox", {
parent = lesson,
size = guiCoord(1.0, -60, 0, 22),
position = guiCoord(0, 50, 0, 5),
backgroundAlpha = 0,
text = v.name,
textSize = 22,
textAlign = "middleLeft",
textFont = "tevurl:fonts/openSansBold.ttf"
})
local desc = teverse.construct("guiTextBox", {
parent = lesson,
size = guiCoord(1.0, -60, 1, -25),
position = guiCoord(0, 50, 0, 25),
backgroundAlpha = 0,
text = v.description,
textSize = 18,
textAlign = "topLeft",
textWrap = true
})
lesson.size = guiCoord(1, -20, 0, 29 + desc.textDimensions.y)
y = y + 25 + desc.textDimensions.y
end