Compare commits

..

6 Commits

Author SHA1 Message Date
Jay ba2a9f1c0d Extension is now enforced 2020-04-11 20:49:57 +01:00
Jay b052012515 Fix dashboard 2020-04-11 20:48:51 +01:00
Jay 264df6c040 Rename login.lua to main.lua 2020-04-11 20:40:06 +01:00
Jay 90bbc0743c Update Screen 2020-04-11 20:37:49 +01:00
Jay 901b8a815f update api test 2020-04-11 19:18:06 +01:00
Jay 6c2956aa1a Added TevX core scripts 2020-04-11 18:44:47 +01:00
21 changed files with 761 additions and 1 deletions

2
core/dashboard/main.lua Normal file
View File

@ -0,0 +1,2 @@
local ui = require("tevgit:core/dashboard/ui.lua")
ui.setup()

View File

@ -0,0 +1,8 @@
return {
name = "Apps",
iconId = "shapes",
iconType = "faSolid",
setup = function(page)
end
}

View File

@ -0,0 +1,8 @@
return {
name = "Develop",
iconId = "layer-group",
iconType = "faSolid",
setup = function(page)
end
}

View File

@ -0,0 +1,292 @@
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
})
teverse.construct("guiImage", {
name = "profilePicture",
size = guiCoord(0, 30, 0, 30),
position = guiCoord(0, 0, 0, 5),
image = pfp,
parent = item,
strokeRadius = 15,
strokeAlpha = 0.04
})
local name = teverse.construct("guiTextBox", {
name = "username",
size = guiCoord(1, -40, 0, 20),
position = guiCoord(0, 40, 0, 3),
backgroundAlpha = 0,
parent = item,
text = name,
textSize = 20,
textAlpha = 0.6,
textFont = "tevurl:fonts/openSansBold.ttf"
})
teverse.construct("guiTextBox", {
name = "date",
size = guiCoord(1, -50, 0, 14),
position = guiCoord(0, 40, 0, 3),
backgroundAlpha = 0,
parent = item,
text = date,
textAlign = enums.align.middleRight,
textSize = 14,
textAlpha = 0.4
})
teverse.construct("guiTextBox", {
name = "body",
size = guiCoord(1, -50, 1, -28),
position = guiCoord(0, 40, 0, 22),
backgroundAlpha = 0,
parent = item,
text = body,
textWrap = true,
textAlign = enums.align.topLeft,
textSize = 16
})
return item
end
return {
name = "Home",
iconId = "sliders-h",
iconType = "faSolid",
setup = function(page)
local feed = teverse.construct("guiScrollView", {
parent = page,
size = guiCoord(1, 0, 1, 50),
position = guiCoord(0, 0, 0, -50),
backgroundAlpha = 0,
strokeRadius = 3
})
teverse.bp
.bind(feed, "xs", {
size = guiCoord(1, 0, 1, 50),
position = guiCoord(0, 0, 0, -50)
})
.bind(feed, "lg", {
size = guiCoord(1, 0, 1, 0),
position = guiCoord(0, 0, 0, 0)
})
local tevs = teverse.construct("guiFrame", {
parent = feed,
size = guiCoord(1/3, -20, 0, 70),
position = guiCoord(0, 10, 0, 0),
backgroundColour = colour.rgb(74, 140, 122),
strokeRadius = 3
})
teverse.bp
.bind(tevs, "xs", {
size = guiCoord(1, -20, 0, 70),
position = guiCoord(0, 10, 0, 50)
})
.bind(tevs, "sm", {
size = guiCoord(1/3, -20, 0, 70),
position = guiCoord(0, 10, 0, 50)
})
.bind(tevs, "lg", {
size = guiCoord(1/3, -20, 0, 70),
position = guiCoord(0, 10, 0, 0)
})
teverse.construct("guiTextBox", {
parent = tevs,
size = guiCoord(0.5, -20, 0, 40),
position = guiCoord(0.5, 0, 0.5, -15),
backgroundAlpha = 0,
text = "975",
textSize = 40,
textAlign = "middleLeft",
textColour = colour(1, 1, 1),
textFont = "tevurl:fonts/openSansBold.ttf"
})
teverse.construct("guiTextBox", {
parent = tevs,
size = guiCoord(0.5, -10, 0, 18),
position = guiCoord(0.5, 0, 0.5, -24),
backgroundAlpha = 0,
text = "Tevs",
textSize = 18,
textAlign = "middleLeft",
textColour = colour(1, 1, 1),
textFont = "tevurl:fonts/openSansLight.ttf"
})
teverse.construct("guiIcon", {
parent = tevs,
size = guiCoord(0, 40, 0, 40),
position = guiCoord(0.5, -60, 0.5, -20),
iconMax = 40,
iconColour = colour(1, 1, 1),
iconType = "faSolid",
iconId = "coins",
iconAlpha = 0.9
})
local membership = teverse.construct("guiFrame", {
parent = feed,
size = guiCoord(1/3, -20, 0, 70),
position = guiCoord(1/3, 10, 0, 0),
backgroundColour = colour.rgb(235, 187, 83),
strokeRadius = 3
})
teverse.bp
.bind(membership, "xs", {
size = guiCoord(1, -20, 0, 70),
position = guiCoord(0, 10, 0, 80 + 50)
})
.bind(membership, "sm", {
size = guiCoord(1/3, -20, 0, 70),
position = guiCoord(1/3, 10, 0, 50)
})
.bind(membership, "lg", {
size = guiCoord(1/3, -20, 0, 70),
position = guiCoord(1/3, 10, 0, 0)
})
teverse.construct("guiTextBox", {
parent = membership,
size = guiCoord(0.5, -5, 0, 18),
position = guiCoord(0.5, 0, 0.5, -24),
backgroundAlpha = 0,
text = "Membership",
textSize = 18,
textAlign = "middleLeft",
textColour = colour(1, 1, 1),
textFont = "tevurl:fonts/openSansLight.ttf"
})
teverse.construct("guiTextBox", {
parent = membership,
size = guiCoord(0.5, -20, 0, 40),
position = guiCoord(0.5, 0, 0.5, -15),
backgroundAlpha = 0,
text = "Free",
textSize = 40,
textAlign = "middleLeft",
textColour = colour(1, 1, 1),
textFont = "tevurl:fonts/openSansBold.ttf"
})
teverse.construct("guiIcon", {
parent = membership,
size = guiCoord(0, 40, 0, 40),
position = guiCoord(0.5, -60, 0.5, -20),
iconMax = 40,
iconColour = colour(1, 1, 1),
iconType = "faSolid",
iconId = "crown",
iconAlpha = 0.9
})
local version = teverse.construct("guiFrame", {
parent = feed,
size = guiCoord(1/3, -20, 0, 70),
position = guiCoord(2/3, 10, 0, 0),
backgroundColour = colour.rgb(216, 100, 89),
strokeRadius = 3
})
teverse.bp
.bind(version, "xs", {
size = guiCoord(1, -20, 0, 70),
position = guiCoord(0, 10, 0, 160 + 50)
})
.bind(version, "sm", {
size = guiCoord(1/3, -20, 0, 70),
position = guiCoord(2/3, 10, 0, 50)
})
.bind(version, "lg", {
size = guiCoord(1/3, -20, 0, 70),
position = guiCoord(2/3, 10, 0, 0)
})
teverse.construct("guiTextBox", {
parent = version,
size = guiCoord(0.5, -5, 0, 18),
position = guiCoord(0.5, 0, 0.5, -24),
backgroundAlpha = 0,
text = "Build",
textSize = 18,
textAlign = "middleLeft",
textColour = colour(1, 1, 1),
textFont = "tevurl:fonts/openSansLight.ttf"
})
teverse.construct("guiTextBox", {
parent = version,
size = guiCoord(0.5, 0, 0, 40),
position = guiCoord(0.5, 0, 0.5, -15),
backgroundAlpha = 0,
text = _TEV_BUILD,
textSize = 40,
textAlign = "middleLeft",
textColour = colour(1, 1, 1),
textFont = "tevurl:fonts/openSansBold.ttf"
})
teverse.construct("guiIcon", {
parent = version,
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-branch",
iconAlpha = 0.9
})
local feedItems = teverse.construct("guiFrame", {
parent = feed,
backgroundAlpha = 1,
clip = true
})
teverse.bp
.bind(feedItems, "xs", {
size = guiCoord(1, -20, 1, -(240 + 50)),
position = guiCoord(0, 10, 0, 240 + 50)
})
.bind(feedItems, "sm", {
size = guiCoord(1, -20, 1, -(70 + 60)),
position = guiCoord(0, 10, 0, 70 + 60)
})
.bind(feedItems, "lg", {
size = guiCoord(1/3, -20, 1, -80),
position = guiCoord(0, 10, 0, 80)
})
teverse.construct("guiTextBox", {
size = guiCoord(1, -20, 0, 26),
position = guiCoord(0, 10, 0, 0),
backgroundAlpha = 0,
parent = feedItems,
text = "Feed",
textSize = 26,
textFont = "tevurl:fonts/openSansBold.ttf"
})
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
end
pushItem(newFeedItem("tevurl:asset/user/" .. teverse.networking.localClient.id, teverse.networking.localClient.name, "Now", "test"))
end
}

143
core/dashboard/ui.lua Normal file
View File

@ -0,0 +1,143 @@
local controller = {}
controller.setup = function()
local navBar = teverse.construct("guiFrame", {
strokeAlpha = 0.1,
parent = teverse.interface,
zIndex = 10,
backgroundColour = colour.rgb(52, 58, 64)
})
local navContainer = teverse.construct("guiFrame", {
parent = navBar,
backgroundAlpha = 0
})
teverse.bp
.gridConstraint(navContainer, {
cellSize = guiCoord(0, 40, 0, 40),
cellMargin = guiCoord(0, 25, 0, 25)
})
.bind(navBar, "xs", {
position = guiCoord(0, -45, 1, -65),
size = guiCoord(1, 90, 0, 105)
})
.bind(navContainer, "xs", {
position = guiCoord(0, 80, 0.5, -40),
size = guiCoord(1, -160, 0, 40)
})
.bind(navBar, "lg", {
position = guiCoord(0, 0, 0, 0),
size = guiCoord(0, 65, 1, 0)
})
.bind(navContainer, "lg", {
position = guiCoord(0.5, -20, 0, 80),
size = guiCoord(0, 40, 1, -80)
})
local profilePictureContainer = teverse.construct("guiFrame", {
parent = navContainer,
backgroundAlpha = 0,
name = "0"
})
local profilePicture = teverse.construct("guiImage", {
size = guiCoord(0, 30, 0, 30),
position = guiCoord(0.5, -15, 0.5, -15),
image = "tevurl:asset/user/" .. teverse.networking.localClient.id,
parent = profilePictureContainer,
strokeRadius = 30,
name = "0"
})
local status = teverse.construct("guiImage", {
size = guiCoord(0, 8, 0, 8),
position = guiCoord(1, -8, 1, -8),
backgroundColour = colour(0, 0.9, 0),
strokeRadius = 6,
strokeWidth = 2,
strokeAlpha = 1,
strokeColour = colour.rgb(52, 58, 64),
parent = profilePicture
})
local body = teverse.construct("guiFrame", {
size = guiCoord(1, -65, 1, 0),
position = guiCoord(0, 65, 0, 0),
parent = teverse.interface,
backgroundColour = colour.rgb(242, 244, 245)
})
teverse.bp
.bind(body, "xs", {
size = guiCoord(1, 90, 1, -5),
position = guiCoord(0, -45, 0, -60)
})
.bind(body, "lg", {
size = guiCoord(1, -65, 1, 0),
position = guiCoord(0, 65, 0, 0)
})
local pages = {}
local function setupPage(page)
local container = teverse.construct("guiFrame", {
parent = body,
size = guiCoord(1, -40, 1, -80),
position = guiCoord(0, 10, 0, 80),
backgroundAlpha = 0,
strokeRadius = 3,
visible = false
})
teverse.bp
.bind(container, "xs", {
size = guiCoord(1, -120, 1, -80),
position = guiCoord(0, 60, 0, 80)
})
.bind(container, "lg", {
size = guiCoord(1, 0, 1, -10),
position = guiCoord(0, 0, 0, 10)
})
local icon = teverse.construct("guiIcon", {
name = tostring(#pages + 1),
size = guiCoord(0, 40, 0, 40),
position = guiCoord(0.5, -20, 1, -60),
parent = navContainer,
iconId = page.iconId,
iconType = page.iconType,
iconAlpha = 0.75,
iconMax = 20,
backgroundColour = colour(0, 0, 0),
strokeRadius = 3
})
icon:on("mouseLeftUp", function()
for _,v in pairs(pages) do
v[1].visible = false
v[2].iconAlpha = 0.75
v[2].backgroundAlpha = 0.0
end
container.visible = true
icon.iconAlpha = 1.0
icon.backgroundAlpha = 0.2
end)
page.setup(container)
if #pages == 0 then
container.visible = true
icon.iconAlpha = 1.0
icon.backgroundAlpha = 0.2
end
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"))
end
return controller

80
core/login/main.lua Normal file
View File

@ -0,0 +1,80 @@
local main = teverse.construct("guiFrame", {
parent = teverse.coreInterface,
backgroundColour = colour.rgb(52, 58, 64),
size = guiCoord(1, 0, 1, 100),
position = guiCoord(0, 0, 0, -50)
})
teverse.construct("guiImage", {
position = guiCoord(0.5, -750, 0.5, -750),
size = guiCoord(0, 1500, 0, 1500),
parent = main,
backgroundAlpha = 0,
image = "tevurl:img/tTiled.png",
imageBottomRight = vector2(90, 90),
imageColour = colour:rgb(28, 33, 38),
imageAlpha = 0.25,
zIndex = -1
})
local gui = teverse.construct("guiTextBox", {
parent = main,
size = guiCoord(0.8, 0, 0, 70),
position = guiCoord(0.1, 0, 0.5, -35),
backgroundAlpha = 0,
text = "teverse",
textSize = 70,
textAlign = enums.align.middle,
textShadowSize = 2,
textColour = colour(1, 1, 1),
textFont = "tevurl:fonts/moskUltraBold.ttf"
})
local login = teverse.construct("guiTextBox", {
parent = main,
size = guiCoord(0, 80, 0, 26),
position = guiCoord(0.5, -40, 0.5, 45),
backgroundColour = colour(1, 1, 1),
text = "Login",
textFont = "tevurl:fonts/openSansBold.ttf",
textSize = 24,
textAlign = enums.align.middle,
strokeRadius = 3,
visible = false
})
login.size = guiCoord(0, login.textDimensions.x + 30, 0, 26)
login.position = guiCoord(0.5, -(login.textDimensions.x + 30)/2, 0.5, 45)
local db = false
local listenerid = login:on("mouseLeftDown", function()
if db then return end
teverse.openUrl("https://teverse.com/dashboard?client=1")
login.visible = false
sleep(2)
login.visible = true
end)
teverse.networking:on("_localAuthenticating", function(state)
if state ~= "failed" then
db = true
login.text = "Authenticating..."
login.size = guiCoord(0, login.textDimensions.x + 30, 0, 26)
login.position = guiCoord(0.5, -(login.textDimensions.x + 30)/2, 0.5, 45)
else
db = false
login.text = "Login"
login.size = guiCoord(0, login.textDimensions.x + 30, 0, 26)
login.position = guiCoord(0.5, -(login.textDimensions.x + 30)/2, 0.5, 45)
end
end)
sleep(1)
login.visible = true
while teverse.networking.localClient == nil do
sleep(1.5)
end
print("Logged in as " .. teverse.networking.localClient.name)
main:destroy()

24
core/tests/api.lua Normal file
View File

@ -0,0 +1,24 @@
-- Uses to test integrity of a sandbox
return function()
print(_VERSION)
print("Safety Test (TevC)", tevC == nil and "PASS" or "FAIL")
print("Safety Test (jit)", jit == nil and "PASS" or "FAIL")
print("Safety Test (ffi)", ffi == nil and "PASS" or "FAIL")
print("Safety Test (events)", events == nil and "PASS" or "FAIL")
print("Safety Test (os.open)", os.open == nil and "PASS" or "FAIL")
print("Safety Test (os.write)", os.write == nil and "PASS" or "FAIL")
print("Safety Test (teverse.userToken)", teverse.userToken == nil and "PASS" or "FAIL")
print("Safety Test (globaltest)", globaltest == nil and "PASS" or "FAIL")
print("Require Test (Has teverse overriden default require)", (require ~= nil and require("ping") == "pong") and "PASS" or "FAIL")
local result = teverse.load("tevgit:core/tests/tevgit.lua")
print("Require Test #3", result == "Hello World!" and "PASS" or "FAIL")
local a = os.clock()
print("Running Scheduler Test #1", a)
sleep(1)
local elapsed = os.clock() - a
print("Scheduler Test #1", elapsed >= 1.0 and "PASS" or "FAIL", elapsed)
end

142
core/tests/gui.lua Normal file
View File

@ -0,0 +1,142 @@
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)
}
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 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[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
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),
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
})
end

View File

@ -1,2 +1,2 @@
-- used internally to validate that our api is working
return "Hello World!"
return "Hello World!"

61
core/update/main.lua Normal file
View File

@ -0,0 +1,61 @@
local main = teverse.construct("guiFrame", {
parent = teverse.interface,
backgroundColour = colour.rgb(52, 58, 64),
size = guiCoord(1, 0, 1, 100),
position = guiCoord(0, 0, 0, -50)
})
teverse.construct("guiImage", {
position = guiCoord(0.5, -750, 0.5, -750),
size = guiCoord(0, 1500, 0, 1500),
parent = main,
backgroundAlpha = 0,
image = "tevurl:img/tTiled.png",
imageBottomRight = vector2(90, 90),
imageColour = colour:rgb(28, 33, 38),
imageAlpha = 0.25,
zIndex = -1
})
local dialog = teverse.construct("guiFrame", {
parent = main,
size = guiCoord(0, 200, 0, 100),
position = guiCoord(0.5, -100, 0.5, -50),
backgroundColour = colour(1, 1, 1),
strokeAlpha = 0,
strokeRadius = 3
})
local gui = teverse.construct("guiTextBox", {
parent = dialog,
size = guiCoord(0.8, 0, 0, 40),
position = guiCoord(0.1, 0, 0, 5),
backgroundAlpha = 0,
text = "teverse",
textSize = 40,
textAlign = enums.align.middle,
textColour = colour.rgb(61, 66, 71),
textFont = "tevurl:fonts/moskUltraBold.ttf"
})
local gui = teverse.construct("guiTextBox", {
parent = dialog,
size = guiCoord(0.8, 0, 1, -50),
position = guiCoord(0.1, 0, 0, 50),
backgroundAlpha = 0,
text = "An update is in progress\nPlease be patient",
textWrap = true,
textSize = 16,
textAlign = enums.align.topMiddle,
textColour = colour.rgb(61, 66, 71)
})
if _OS == "OSX" or _OS == "IOS" then
-- We distribute updates via the app store on iOS/OSX
gui.text = "A new version is available, please check the App Store."
end
teverse.networking:on("_update", function(message)
print('got ', message)
gui.text = message
end)