Compare commits

...

3 Commits

Author SHA1 Message Date
Jay 2e92d94a9f Merge branch 'master' of https://github.com/teverse/teverse 2020-04-29 20:18:55 +01:00
Jay c6e33b743d Added shader 2020-04-29 20:18:52 +01:00
Sanjay 2e0fa7a913
Feature flair system + flair to wall feed (#72)
* Refactored Workshop to TevX Format

* Implement flair system + wall feed flair

* Remove unneeded HTTP GET call, restructured newFeedItem()

* Fix posting bug

* fix vsc conflict errors

* Fix vsc merge conflict error
2020-04-29 20:18:03 +01:00
4 changed files with 101 additions and 12 deletions

View File

@ -1,4 +1,74 @@
local function newFeedItem(pfp, name, date, body)
-- Copyright 2020- Teverse.com
-- Used to display the home screen of the teverse application
local globals = require("tevgit:workshop/library/globals.lua") -- globals; variables or instances that can be shared between files
local function createFlair(parent, data)
local username = parent:child("username").text
if data then
local flairCount = 0
-- Beta(Tester) Insignia
if data.postedBy.beta == true then
teverse.construct("guiIcon", {
parent = parent:child("username"),
size = guiCoord(0, 10, 0, 10),
position = guiCoord(0, parent:child("username").textDimensions.x+((flairCount*10)+2), 0, 6),
iconType = "faSolid",
iconId = "flask",
iconColour = colour.rgb(220, 53, 69),
})
flairCount = flairCount + 1
end
-- Plus Membership Insignia
if data.postedBy.membership == "plus" then
teverse.construct("guiIcon", {
parent = parent:child("username"),
size = guiCoord(0, 10, 0, 10),
position = guiCoord(0, parent:child("username").textDimensions.x+((flairCount*10)+2), 0, 6),
iconType = "faSolid",
iconId = "thermometer-empty",
iconColour = globals.defaultColours.primary
})
flairCount = flairCount + 1
end
-- Pro Membership Insignia
if data.postedBy.membership == "pro" then
teverse.construct("guiIcon", {
parent = parent:child("username"),
size = guiCoord(0, 10, 0, 10),
position = guiCoord(0, parent:child("username").textDimensions.x+((flairCount*10)+2), 0, 6),
iconType = "faSolid",
iconId = "thermometer-full",
iconColour = globals.defaultColours.purple
})
parent:child("username").textColour = globals.defaultColours.purple
parent:child("body").textColour = globals.defaultColours.purple
flairCount = flairCount + 1
end
-- Mod/Staff Insignia
--[[
if then
teverse.construct("guiIcon", {
parent = parent:child("username"),
size = guiCoord(0, 10, 0, 10),
position = guiCoord(0, parent:child("username").textDimensions.x+((flairCount*10)+2), 0, 6),
iconType = "faSolid",
iconId = "shield-alt",
iconColour = globals.defaultColours.blue
})
parent:child("username").textColour = globals.defaultColours.blue
parent:child("body").textColour = globals.defaultColours.blue
flairCount = flairCount + 1
end
]]--
end
end
local function newFeedItem(date, data)
local item = teverse.construct("guiFrame", {
size = guiCoord(1, -20, 0, 48),
position = guiCoord(0, 10, 0, 40),
@ -10,19 +80,19 @@ local function newFeedItem(pfp, name, date, body)
name = "profilePicture",
size = guiCoord(0, 30, 0, 30),
position = guiCoord(0, 0, 0, 5),
image = pfp,
image = "tevurl:asset/user/"..(data.postedBy.id),
parent = item,
strokeRadius = 15,
strokeAlpha = 0.04
})
local name = teverse.construct("guiTextBox", {
local username = teverse.construct("guiTextBox", {
name = "username",
size = guiCoord(1, -40, 0, 20),
position = guiCoord(0, 40, 0, 3),
backgroundAlpha = 0,
parent = item,
text = name,
text = data.postedBy.username,
textSize = 20,
textAlpha = 0.6,
textFont = "tevurl:fonts/openSansBold.ttf"
@ -47,11 +117,13 @@ local function newFeedItem(pfp, name, date, body)
position = guiCoord(0, 40, 0, 22),
backgroundAlpha = 0,
parent = item,
text = body,
text = data.message,
textWrap = true,
textAlign = enums.align.topLeft,
textSize = 16
textSize = 16,
})
createFlair(item, data)
return item
end
@ -309,9 +381,9 @@ return {
}, function(code, body)
if code == 200 then
lastRefresh = os.clock()
local json = teverse.json:decode(body)
if #json > 0 then
if json[1].id == newestFeed then
local data = teverse.json:decode(body)
if #data > 0 then
if data[1].id == newestFeed then
-- no change from last refresh
return nil
else
@ -322,11 +394,11 @@ return {
end
end
end
newestFeed = json[1].id
newestFeed = data[1].id
local y = 50
for _,v in pairs(json) do
for _,v in pairs(data) 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)
local item = newFeedItem(date, v)
item.parent = feedItems
local dy = item:child("body").textDimensions.y
item.size = guiCoord(1, -20, 0, dy + 28)

6
shaders/test/fragment.sc Normal file
View File

@ -0,0 +1,6 @@
$input v_color0
void main()
{
gl_FragColor = v_color0;
}

View File

@ -0,0 +1,3 @@
vec4 v_color0 : COLOR0 = vec4(1.0, 1.0, 1.0, 1.0);
vec3 a_position : POSITION;
vec4 a_color0 : COLOR0;

8
shaders/test/vertex.sc Normal file
View File

@ -0,0 +1,8 @@
$input a_position, a_color0
$output v_color0
void main()
{
gl_Position = mul(u_modelViewProj, vec4(a_position, 1.0));
v_color0 = a_color0;
}