Compare commits

...

6 Commits

Author SHA1 Message Date
Jay b8d8291aee Tween debug chart 2020-07-02 00:55:27 +01:00
Jay 38a45502b6 Develop page bug fix 2020-07-02 00:28:55 +01:00
Jay 9485122cb7 Fixed scroll issue 2020-07-01 23:01:31 +01:00
Jay 6710150f27 App page 2020-07-01 22:28:59 +01:00
teverse ffaf6219b7 Updated minimum version for networkdebug 2020-07-01 21:19:12 +01:00
teverse b8e836be8c Network debug utility 2020-07-01 21:15:41 +01:00
5 changed files with 306 additions and 90 deletions

View File

@ -0,0 +1,69 @@
return function(app)
local appGui = teverse.construct("guiFrame", {
strokeRadius = 2,
dropShadowAlpha = 0.15,
strokeAlpha = 0.05
})
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
})
local img = teverse.construct("guiImage", {
size = guiCoord(1, 0, 1, 0),
parent = appGui,
active = false,
zIndex = -1
})
local launch = teverse.construct("guiTextBox", {
parent = appGui,
size = guiCoord(0, 80, 0, 24),
position = guiCoord(1, -90, 1, -34),
backgroundColour = colour.rgb(61, 164, 54),
text = "LAUNCH",
textAlign = "middle",
textColour = colour(1, 1, 1),
textFont = "tevurl:fonts/openSansBold.ttf",
textSize = 18,
strokeRadius = 12,
dropShadowAlpha = 0.1
})
launch:on("mouseEnter", function()
launch.backgroundColour = colour.rgb(81, 184, 64)
launch.dropShadowAlpha = 0.0
launch:waitFor("mouseExit")
launch.backgroundColour = colour.rgb(61, 164, 54)
launch.dropShadowAlpha = 0.1
end)
if (app.iconUrl and app.iconUrl ~= "") then
img.image = app.iconUrl
else
img.image = "tevurl:img/tevapp.png"
end
return appGui, launch
end

View File

@ -1,55 +1,10 @@
local function createApp(app)
local appGui = teverse.construct("guiFrame", {
strokeRadius = 2,
dropShadowAlpha = 0.15,
strokeAlpha = 0.05
})
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
})
local img = teverse.construct("guiImage", {
size = guiCoord(1, 0, 1, 0),
parent = appGui,
active = false,
zIndex = -1
})
if (app.iconUrl and app.iconUrl ~= "") then
img.image = app.iconUrl
else
img.image = "tevurl:img/tevapp.png"
end
return appGui
end
local createApp = require("tevgit:core/dashboard/appCard.lua")
return {
name = "Apps",
iconId = "shapes",
iconType = "faSolid",
scrollView = true,
setup = function(page)
local loading = teverse.construct("guiTextBox", {
parent = page,
@ -105,7 +60,7 @@ return {
end
if _DEVICE:sub(0, 6) ~= "iPhone" then
local appGui = createApp({
local appGui, button = createApp({
id = "",
name = "Learn Code",
owner = {
@ -114,7 +69,7 @@ return {
})
appGui.name = "a"
appGui.parent = appsContainer
appGui:on("mouseLeftUp", function()
button:on("mouseLeftUp", function()
if not loading.visible then
loading.visible = false
teverse.apps:loadString("require('tevgit:core/tutorials/main.lua')")
@ -129,9 +84,9 @@ return {
local apps = teverse.json:decode(body)
subtitle.text = "Found " .. #apps .. " public apps:"
for _,app in pairs(apps) do
local appGui = createApp(app)
local appGui, button = createApp(app)
appGui.parent = appsContainer
appGui:on("mouseLeftUp", function()
button:on("mouseLeftUp", function()
if not loading.visible then
loading.text = "Loading App " .. (app.packageNetworked and "Online" or "Offline")
loading.visible = true
@ -149,5 +104,18 @@ return {
subtitle.text = "Server error."
end
end)
local function calculateScrollHeight()
local y = 0
for _,v in pairs(appsContainer.children) do
y = math.max(y, v.absolutePosition.y + 320)
end
appsContainer.size = guiCoord(1.0, -20, 0, y - appsContainer.absolutePosition.y)
page.canvasSize = guiCoord(1, 0, 0, y - appsContainer.absolutePosition.y)
end
calculateScrollHeight()
appsContainer:on("childAdded", calculateScrollHeight)
teverse.input:on("screenResized", calculateScrollHeight)
end
}

View File

@ -1,44 +1,10 @@
local function createApp(app)
local appGui = teverse.construct("guiFrame", {
strokeRadius = 2,
dropShadowAlpha = 0.15,
strokeAlpha = 0.05
})
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
})
local img = teverse.construct("guiImage", {
size = guiCoord(1, 0, 1, 0),
parent = appGui,
active = false,
zIndex = -1
})
if (app.iconUrl and app.iconUrl ~= "") then
img.image = app.iconUrl
else
img.image = "tevurl:img/tevapp.png"
end
return appGui
end
local createApp = require("tevgit:core/dashboard/appCard.lua")
return {
name = "Develop",
iconId = "layer-group",
iconType = "faSolid",
scrollView = true,
setup = function(page)
local loading = teverse.construct("guiTextBox", {
parent = page,
@ -154,15 +120,25 @@ return {
cellMargin = guiCoord(0, 15, 0, 25)
})
teverse.guiHelper
.bind(appsContainer, "xs", {
size = guiCoord(1, -20, 1, -330),
position = guiCoord(0, 10, 0, 330)
})
.bind(appsContainer, "lg", {
size = guiCoord(1, 0, 1, -150),
position = guiCoord(0, 0, 0, 150)
})
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 = createApp(app)
local appGui, launchButton = createApp(app)
appGui.parent = appsContainer
appGui:on("mouseLeftUp", function()
launchButton:on("mouseLeftUp", function()
if not loading.visible then
loading.text = "Loading App " .. (app.packageNetworked and "Online" or "Offline")
loading.visible = true
@ -181,5 +157,18 @@ return {
end
end)
local function calculateScrollHeight()
local y = 0
for _,v in pairs(appsContainer.children) do
y = math.max(y, v.absolutePosition.y + 390)
end
appsContainer.size = guiCoord(1.0, -20, 0, y - appsContainer.absolutePosition.y)
page.canvasSize = guiCoord(1, 0, 0, y - appsContainer.absolutePosition.y)
end
calculateScrollHeight()
appsContainer:on("childAdded", calculateScrollHeight)
teverse.input:on("screenResized", calculateScrollHeight)
end
}

View File

@ -81,7 +81,7 @@ controller.setup = function()
local pages = {}
local function setupPage(page)
local container = teverse.construct("guiFrame", {
local container = teverse.construct(page.scrollView and "guiScrollView" or "guiFrame", {
parent = body,
size = guiCoord(1, -40, 1, -80),
position = guiCoord(0, 10, 0, 80),
@ -90,6 +90,11 @@ controller.setup = function()
visible = false
})
if page.scrollView then
container.scrollbarWidth = 4
container.active = true
end
teverse.guiHelper
.bind(container, "xs", {
size = guiCoord(1, -120, 1, -80),

185
utilities/networkDebug.lua Normal file
View File

@ -0,0 +1,185 @@
local pingScale = 300
local downloadScale = 1024 * 1
local uploadScale = 1024 * 1
return function()
local main = teverse.construct("guiFrame", {
size = guiCoord(0, 250, 0, 200),
position = guiCoord(1, -250, 1, -260),
strokeAlpha = 0.5
})
local container = teverse.construct("guiFrame", {
parent = main,
size = guiCoord(1, 0, 1, -100),
position = guiCoord(0, 0, 0, 0),
strokeAlpha = 0.5
})
if _TEV_VERSION_MINOR == 24 and _TEV_VERSION_PATCH < 3 then
teverse.construct("guiTextBox", {
parent = container,
size = guiCoord(0.8, 0, 0.8, 0),
position = guiCoord(0.1, 0, 0.1, 0),
backgroundAlpha = 0,
textAlign = "middle",
textColour = colour(0.5, 0, 0),
textSize = 16,
text = "Network stats are not stable on your version. 0.24.3 is required.",
textMultiline = true,
textWrap = true
})
return main
end
local pingContainer = teverse.construct("guiFrame", {
parent = container,
size = guiCoord(1, -40, 1, -10),
position = guiCoord(0, 0, 0, 5),
backgroundAlpha = 0,
clip = true
})
local pingLabel = teverse.construct("guiTextBox", {
parent = container,
size = guiCoord(0, 32, 0, 12),
backgroundAlpha = 0,
textAlign = "middleRight",
textColour = colour(1, 0, 0),
textSize = 12
})
local receivedContainer = teverse.construct("guiFrame", {
parent = container,
size = guiCoord(1, -50, 1, -10),
position = guiCoord(0, 0, 0, 5),
backgroundAlpha = 0,
clip = true
})
local receivedLabel = teverse.construct("guiTextBox", {
parent = container,
size = guiCoord(0, 45, 0, 12),
backgroundAlpha = 0,
textAlign = "middleRight",
textColour = colour(0, 0.5, 0),
textSize = 12
})
local sentContainer = teverse.construct("guiFrame", {
parent = container,
size = guiCoord(1, -50, 1, -10),
position = guiCoord(0, 0, 0, 5),
backgroundAlpha = 0,
clip = true
})
local sentLabel = teverse.construct("guiTextBox", {
parent = container,
size = guiCoord(0, 45, 0, 12),
backgroundAlpha = 0,
textAlign = "middleRight",
textColour = colour(0, 0, 0.5),
textSize = 12
})
local statOutput = teverse.construct("guiTextBox", {
parent = main,
size = guiCoord(1, -10, 0, 100),
position = guiCoord(0, 5, 1, -95),
backgroundAlpha = 0,
textAlign = "topLeft",
textColour = colour(0, 0, 0),
textSize = 14,
text = "",
textMultiline = true,
textWrap = true
})
spawn(function()
local lastPing = -1
local lastReceive = 0
local lastSend = 0
-- Needs reworked
while sleep(0.5) do
local stats = teverse.networking:getStats()
pingLabel.text = stats.lastPing .. "ms"
pingLabel.position = guiCoord(1.0, -35, math.min(1 - (stats.lastPing / pingScale), 1), -13)
local newLine = teverse.construct("guiLine", {
parent = pingContainer,
pointA = guiCoord(1.0, 0, 1 - (lastPing / pingScale), -1),
pointB = guiCoord(1.1, 0, 1 - (stats.lastPing / pingScale), -1),
lineColour = colour(1, 0, 0)
})
lastPing = stats.lastPing
local pingChildren = pingContainer.children
for i,v in pairs(pingChildren) do
teverse.tween:begin(v, 0.5, {
pointA = v.pointA - guiCoord(0.1, 0, 0, 0),
pointB = v.pointB - guiCoord(0.1, 0, 0, 0)
}, "linear")
if #pingChildren == 12 and i == 1 then
v:destroy()
end
end
receivedLabel.text = string.format("%.2f kb-i", stats.lastSecondMessageBytesReceived/1024)
receivedLabel.position = guiCoord(1.0, -50, math.min(1 - (stats.lastSecondMessageBytesReceived / downloadScale), 1), -13)
local newLine = teverse.construct("guiLine", {
parent = receivedContainer,
pointA = guiCoord(1.0, 0, 1 - (lastReceive / downloadScale), -1),
pointB = guiCoord(1.1, 0, 1 - (stats.lastSecondMessageBytesReceived / downloadScale), -1),
lineColour = colour(0, 0.5, 0)
})
lastReceive = stats.lastSecondMessageBytesReceived
local receivedChildren = receivedContainer.children
for i,v in pairs(receivedChildren) do
teverse.tween:begin(v, 0.5, {
pointA = v.pointA - guiCoord(0.1, 0, 0, 0),
pointB = v.pointB - guiCoord(0.1, 0, 0, 0)
}, "linear")
if #receivedChildren == 12 and i == 1 then
v:destroy()
end
end
sentLabel.text = string.format("%.2f kb-o", stats.lastSecondMessageBytesSent/1024)
sentLabel.position = guiCoord(1.0, -50, math.min(1 - (stats.lastSecondMessageBytesSent / downloadScale), 1), -13)
local newLine = teverse.construct("guiLine", {
parent = sentContainer,
pointA = guiCoord(1.0, 0, 1 - (lastSend / downloadScale), -1),
pointB = guiCoord(1.1, 0, 1 - (stats.lastSecondMessageBytesSent / downloadScale), -1),
lineColour = colour(0, 0, 0.5)
})
lastSend = stats.lastSecondMessageBytesSent
local sentChildren = sentContainer.children
for i,v in pairs(sentChildren) do
teverse.tween:begin(v, 0.5, {
pointA = v.pointA - guiCoord(0.1, 0, 0, 0),
pointB = v.pointB - guiCoord(0.1, 0, 0, 0)
}, "linear")
if #sentChildren == 12 and i == 1 then
v:destroy()
end
end
statOutput.text = "Ping Avg: " .. stats.averagePing .. "ms\n" ..
"Lowest Ping: " .. stats.lowestPing .. "ms\n" ..
"Last Ping: " .. stats.lastPing .. "ms\n" ..
"---------\n" ..
"1s Packet Loss: " .. stats.packetlossLastSecond .. "\n" ..
"Packet Loss: " .. stats.packetlossTotal .. "\n" ..
"Send Buffer: " .. stats.messagesInSendBuffer
end
end)
return main
end