fixed drift in timer
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
local gui, color, theme, utils, board, yaml, loader, system, elements, scoreUpdater
|
||||
|
||||
local gui, color, theme, utils, board, yaml, loader, scoreUpdater
|
||||
local activePlayer
|
||||
local playerList = {}
|
||||
local playerStaticList = {}
|
||||
@@ -49,8 +48,7 @@ function init()
|
||||
board = require("board")
|
||||
yaml = require("yaml")
|
||||
loader = require("loader")
|
||||
system = require("gui.addons.system")
|
||||
elements = require("gui.elements")
|
||||
require("gui.addons")
|
||||
|
||||
scoreUpdater = gui:getProcessor():newProcessor("score-updater")
|
||||
scoreUpdater.Start()
|
||||
@@ -165,7 +163,44 @@ function ScoreBoard(frame, x, y, w, h, sx, sy, sw, sh)
|
||||
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)
|
||||
local edit_player = leaderboard:newFrame(5,-10,-10,0,0,1-2*PLAYER_HEIGHT,1,PLAYER_HEIGHT)
|
||||
local remove_player = leaderboard:newTextButton("Remove Selected",5,-15,-10,0,0,1-3*PLAYER_HEIGHT,1,PLAYER_HEIGHT)
|
||||
remove_player:setFont(20)
|
||||
remove_player.align = gui.ALIGN_CENTER
|
||||
local embededWatch = {remove_player}
|
||||
scoreUpdater:newThread(function()
|
||||
while true do
|
||||
thread.sleep(.01)
|
||||
for i,v in pairs(embededWatch) do
|
||||
v:centerFont()
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
local function embedTextEdit(reference, default, but_text, callback)
|
||||
reference.color = C_BORDER_NRM
|
||||
local textbox = reference:newTextBox(default,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)
|
||||
|
||||
local button = reference:newTextButton(but_text,5,0,-10,0,.815,.1,.185,.8)
|
||||
button.color = color.new("#7eae5b")
|
||||
button:OnReleased(function()
|
||||
callback(textbox)
|
||||
end)
|
||||
gui.apply({
|
||||
setFont = {20},
|
||||
align = gui.ALIGN_CENTER
|
||||
},textbox,button,reference)
|
||||
table.insert(embededWatch,textbox)
|
||||
table.insert(embededWatch,button)
|
||||
end
|
||||
|
||||
remove_player.color = color.new("#a13a3a")
|
||||
remove_player:OnReleased(function()
|
||||
local player = GetActivePlayer()
|
||||
@@ -185,42 +220,16 @@ function ScoreBoard(frame, x, y, w, h, sx, sy, sw, sh)
|
||||
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 = ""
|
||||
|
||||
embedTextEdit(add_player, "Player Name", "Add", function(self)
|
||||
scoreboard:AddPlayer(self.text, "0")
|
||||
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()
|
||||
embedTextEdit(edit_player, "Modify Score", "Edit", function(self)
|
||||
local player = GetActivePlayer()
|
||||
if player then
|
||||
player.Score = self.text
|
||||
scoreboard:RenderPlayer(playerList)
|
||||
end
|
||||
end)
|
||||
|
||||
@@ -305,22 +314,51 @@ function ScoreBoard(frame, x, y, w, h, sx, sy, sw, sh)
|
||||
end
|
||||
|
||||
|
||||
require("gui.addons.players")
|
||||
|
||||
-- local webp = require("webp")
|
||||
init()
|
||||
|
||||
local function noOf(sx,sy,sw,sh)
|
||||
return nil,nil,nil,nil,sx,sy,sw,sh
|
||||
end
|
||||
|
||||
function love.load()
|
||||
init()
|
||||
gui:cacheImage({"assets/checked.png","assets/unchecked.png"})
|
||||
gui:setAspectSize(1920, 1080)
|
||||
gui.aspect_ratio = true
|
||||
-- local ext = require("gui.addons.extensions")
|
||||
local bg = gui:newFrame()
|
||||
bg:fullFrame()
|
||||
bg.color = color.new("#242f9b")
|
||||
|
||||
-- pb = bg:newProgressBar(0, 0, 200, 40, 0, 0, 0, 0, 200, 0)
|
||||
|
||||
-- thread:newThread(function()
|
||||
-- for i=1,200 do
|
||||
-- thread.sleep(.01)
|
||||
-- pb:add(1)
|
||||
-- end
|
||||
-- end)
|
||||
|
||||
-- local group = bg:newRadioGroup({
|
||||
-- padding = 5,
|
||||
-- "Option A",
|
||||
-- "Option B",
|
||||
-- "Option C"
|
||||
-- },0,0,0,0, 80)
|
||||
|
||||
-- group.OnSelectionChanged(function(group, selection)
|
||||
-- print(selection:getLabel())
|
||||
-- end)
|
||||
|
||||
|
||||
|
||||
|
||||
local qframe = bg:newFrame(0, 0, 0, 0, .2, .05, .75, .9)
|
||||
qframe.color = color.new("#060ee9")
|
||||
local scoreboard = ScoreBoard(bg, 0, 0, 0, 0, .015, .05, .170, .9)
|
||||
|
||||
board.buildBoard(qframe, "ai-anime")
|
||||
board.buildBoard(qframe, "anime")
|
||||
|
||||
-- gui:newVideoPlayer("test.ogv",0,0,428,240)
|
||||
-- local img = webp.load("test.webp")
|
||||
|
||||
Reference in New Issue
Block a user