implemented daily double, adding/removing players, fixed font sizes, completed multiple choice

This commit is contained in:
2026-05-10 14:29:56 -07:00
parent cd0b9337fa
commit c3496cfdbe
30 changed files with 610 additions and 798 deletions
+90 -10
View File
@@ -1,11 +1,35 @@
local gui, color, theme, utils, board, yaml, loader, system, elements, scoreUpdater
local activePlayer
local playerList = {}
local playerStaticList = {}
local scoreboard = {}
function GetActivePlayer()
if not activePlayer then return end
return activePlayer.link
end
local function GetPlayerPos()
for i,v in pairs(playerStaticList) do
if v == GetActivePlayer() then
return i
end
end
end
function GetNextPlayer()
local pos = GetPlayerPos()
if pos >= #playerStaticList then
activePlayer = playerStaticList[1].Ref.Frame
else
activePlayer = playerStaticList[pos + 1].Ref.Frame
end
scoreboard:RenderPlayer(playerList)
return GetActivePlayer()
end
function love.filedropped(file)
file:open("r")
local data = file:read()
@@ -33,8 +57,6 @@ function init()
end
function ScoreBoard(frame, x, y, w, h, sx, sy, sw, sh)
local scoreboard = {}
-- Colors
local C_BG_PANEL = color.new("#1a1a2e")
local C_BG_HEADER = color.new("#16213e")
@@ -85,7 +107,7 @@ function ScoreBoard(frame, x, y, w, h, sx, sy, sw, sh)
}, headernum, headerplayer, headerscore)
local updateList = {header, headernum, headerplayer, headerscore}
local playerList = {}
local function ScoreResize()
scoreUpdater:newThread(function()
thread.skip(2)
@@ -113,6 +135,7 @@ function ScoreBoard(frame, x, y, w, h, sx, sy, sw, sh)
Name = name,
Score = score,
Icon = icon,
UUID = multi.generate_uuid7(),
Add = function(self, amt)
self.Score = tostring(tonumber(self.Score) + amt)
table.sort(playerList, function(a, b)
@@ -126,6 +149,7 @@ function ScoreBoard(frame, x, y, w, h, sx, sy, sw, sh)
end,
}
table.insert(playerList, player)
table.insert(playerStaticList, player)
scoreboard:RenderPlayer(playerList)
ScoreResize()
return player
@@ -140,6 +164,66 @@ function ScoreBoard(frame, x, y, w, h, sx, sy, sw, sh)
end
end
local add_player = leaderboard:newFrame(5,-5,-10,0,0,1-PLAYER_HEIGHT,1,PLAYER_HEIGHT)
local remove_player = leaderboard:newTextButton("Remove Selected",5,-10,-10,0,0,1-2*PLAYER_HEIGHT,1,PLAYER_HEIGHT)
remove_player.color = color.new("#a13a3a")
remove_player:OnReleased(function()
local player = GetActivePlayer()
uuid = player.UUID
for i = 1, #playerList do
if playerList[i].UUID == uuid then
table.remove(playerList,i)
break
end
end
for i = 1, #playerStaticList do
if playerStaticList[i].UUID == uuid then
table.remove(playerStaticList,i)
break
end
end
scoreboard:RenderPlayer(playerList)
player.Ref.Frame:destroy()
end)
add_player.color = C_BORDER_NRM
local textbox = add_player:newTextBox("Player name",0,0,0,0,.015,.1,.8,.8)
textbox.textColor = C_GOLD
textbox.blink = false
textbox.color = C_BORDER_TOP
textbox.textColor = C_WHITE
textbox:OnPressed(function()
textbox.text = ""
end)
-- A bit glitchy
-- gui:setHotKey({"return"})(function()
-- local object_focus = gui:getObjectFocus()
-- if object_focus:hasType(gui.TYPE_BOX) then
-- scoreboard:AddPlayer(textbox.text, "0")
-- end
-- end)
local addbutton = add_player:newTextButton("Add",5,0,-10,0,.815,.1,.185,.8)
addbutton.color = color.new("#7eae5b")
addbutton:OnReleased(function()
scoreboard:AddPlayer(textbox.text, "0")
end)
gui.apply({
setFont = {20},
align = gui.ALIGN_CENTER
},textbox,addbutton,remove_player)
thread:newThread(function()
while true do
thread.sleep(.01)
textbox:centerFont()
addbutton:centerFont()
remove_player:centerFont()
end
end)
function scoreboard:RenderPlayer(list)
for index, player in ipairs(list) do
if player.Ref then
@@ -216,7 +300,7 @@ function ScoreBoard(frame, x, y, w, h, sx, sy, sw, sh)
end
gui.Events.OnResized(ScoreResize)
ScoreResize()
return scoreboard
end
@@ -225,6 +309,7 @@ require("gui.addons.players")
-- local webp = require("webp")
function love.load()
init()
gui:cacheImage({"assets/checked.png","assets/unchecked.png"})
gui:setAspectSize(1920, 1080)
gui.aspect_ratio = true
local bg = gui:newFrame()
@@ -235,12 +320,7 @@ function love.load()
qframe.color = color.new("#060ee9")
local scoreboard = ScoreBoard(bg, 0, 0, 0, 0, .015, .05, .170, .9)
p1 = scoreboard:AddPlayer("Epicknex", "0")
p2 = scoreboard:AddPlayer("Bob", "0")
p3 = scoreboard:AddPlayer("John", "0")
p4 = scoreboard:AddPlayer("Billy", "0")
board.buildBoard(qframe, "anime")
board.buildBoard(qframe, "ai-anime")
-- gui:newVideoPlayer("test.ogv",0,0,428,240)
-- local img = webp.load("test.webp")