moved zoom into base templates, fixed performance and memory issues
This commit is contained in:
+21
-70
@@ -19,30 +19,10 @@ local playerList = {}
|
||||
local playerStaticList = {}
|
||||
local scoreboard = {}
|
||||
|
||||
-- Create a table to manage GUI elements
|
||||
local manage = {}
|
||||
|
||||
local boardLog = log:child("board")
|
||||
|
||||
-- Function to resize fonts for all managed elements
|
||||
boardLog:debug("Creating resize fonts handler")
|
||||
local function resizeFonts()
|
||||
-- Use multi-threading to improve performance
|
||||
thread.skip(2)
|
||||
-- Iterate over each element in the 'manage' table
|
||||
for i = 1, #manage do
|
||||
local elem = manage[i]
|
||||
|
||||
-- Check if the current element has a centerFont property
|
||||
if elem.centerFont then
|
||||
-- Adjust font size and re-center the text
|
||||
elem:fitFont(nil, nil, {scale = 2/3})
|
||||
elem:centerFont()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
gui.Events.OnResized(resizeFonts)
|
||||
|
||||
local completed_questions = 0
|
||||
local min_questions = 0
|
||||
@@ -236,12 +216,8 @@ function Menu(frame, path)
|
||||
label.color = color.bg
|
||||
label.textColor = color.status_font
|
||||
label:setRoundness(20,20,60)
|
||||
local updateLabel = function()
|
||||
label:fitFont(nil, nil, {scale = 2/3})
|
||||
label:centerFont()
|
||||
end
|
||||
boardUpdater:newThread(updateLabel)
|
||||
gui.Events.OnResized(updateLabel)
|
||||
label:scaleFont(2/3)
|
||||
label:centerFont()
|
||||
|
||||
local data = loader:new(path)
|
||||
board, question, dailydouble = qframe:newFrame(), qframe:newFrame(), qframe:newImageLabel("assets/images/double.jpg")
|
||||
@@ -315,7 +291,8 @@ function Menu(frame, path)
|
||||
img:fullFrame()
|
||||
end
|
||||
|
||||
table.insert(manage,c)
|
||||
c:scaleFont(.25)
|
||||
c:centerFont()
|
||||
|
||||
for tier = 1,tiers do
|
||||
local t = board:newTextButton("$" .. start + inc*(tier-1),0,0,0,0,(1/#index.categories)*(cat-1),1/(tiers+1)*tier,(1/#index.categories),1/(tiers+1))
|
||||
@@ -407,13 +384,10 @@ function Menu(frame, path)
|
||||
end)
|
||||
end)
|
||||
end))
|
||||
table.insert(manage,t)
|
||||
t:centerFont()
|
||||
t:scaleFont(.5)
|
||||
end
|
||||
end
|
||||
|
||||
resizeFonts()
|
||||
resizeFonts()
|
||||
|
||||
return background
|
||||
end
|
||||
|
||||
@@ -514,30 +488,16 @@ function ScoreBoard(frame, x, y, w, h, sx, sy, sw, sh)
|
||||
textColor = C_TEXT_MUTED,
|
||||
}, headernum, headerplayer, headerscore)
|
||||
|
||||
local updateList = {header, headernum, headerplayer, headerscore}
|
||||
|
||||
local function ScoreResize()
|
||||
scoreUpdater:newThread(function()
|
||||
thread.skip(2)
|
||||
|
||||
for _,object in pairs(updateList) do
|
||||
object:fitFont(nil, nil, {scale = 5/6})
|
||||
object:centerFont()
|
||||
end
|
||||
|
||||
for _,object in pairs(playerList) do
|
||||
if type(object) == "table" and object.Ref then
|
||||
for i, player in pairs(object.Ref) do
|
||||
if player:hasType(gui.TYPE_TEXT) then
|
||||
player:fitFont(nil, nil, {scale = 5/6})
|
||||
player:centerFont()
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end)
|
||||
end
|
||||
local updateList = {headernum, headerplayer, headerscore}
|
||||
|
||||
header:centerFont()
|
||||
header:scaleFont(2/3)
|
||||
|
||||
for _,object in pairs(updateList) do
|
||||
object:fitFont(nil, nil, {scale = 5/6})
|
||||
object:centerFont()
|
||||
end
|
||||
|
||||
function scoreboard:AddPlayer(name, score, icon)
|
||||
local player = {
|
||||
Name = name,
|
||||
@@ -553,13 +513,11 @@ function ScoreBoard(frame, x, y, w, h, sx, sy, sw, sh)
|
||||
return tonumber(a.Score) > tonumber(b.Score)
|
||||
end)
|
||||
scoreboard:RenderPlayer(playerList)
|
||||
ScoreResize()
|
||||
end,
|
||||
}
|
||||
table.insert(playerList, player)
|
||||
table.insert(playerStaticList, player)
|
||||
scoreboard:RenderPlayer(playerList)
|
||||
ScoreResize()
|
||||
return player
|
||||
end
|
||||
|
||||
@@ -578,13 +536,7 @@ function ScoreBoard(frame, x, y, w, h, sx, sy, sw, sh)
|
||||
remove_player:setFont(20)
|
||||
remove_player.align = gui.ALIGN_CENTER
|
||||
local embededWatch = {remove_player}
|
||||
|
||||
gui.Events.OnMousePressed(boardUpdater:newFunction(function()
|
||||
for i,v in pairs(embededWatch) do
|
||||
v:centerFont()
|
||||
v:centerFont()
|
||||
end
|
||||
end))
|
||||
remove_player:centerFont()
|
||||
|
||||
local function embedTextEdit(reference, default, but_text, callback)
|
||||
reference.color = C_BORDER_NRM
|
||||
@@ -604,10 +556,9 @@ function ScoreBoard(frame, x, y, w, h, sx, sy, sw, sh)
|
||||
end)
|
||||
gui.apply({
|
||||
setFont = {20},
|
||||
align = gui.ALIGN_CENTER
|
||||
align = gui.ALIGN_CENTER,
|
||||
centerFont = {},
|
||||
},textbox,button,reference)
|
||||
table.insert(embededWatch,textbox)
|
||||
table.insert(embededWatch,button)
|
||||
end
|
||||
|
||||
remove_player.color = color.new("#a13a3a")
|
||||
@@ -709,7 +660,9 @@ function ScoreBoard(frame, x, y, w, h, sx, sy, sw, sh)
|
||||
gui.apply({
|
||||
visibility = 0,
|
||||
drawBorder = false,
|
||||
textColor = MapColor(index)
|
||||
textColor = MapColor(index),
|
||||
scaleFont = {5/6},
|
||||
centerFont = {}
|
||||
},playernum, playerName, playerScore, playerIcon, playerLine)
|
||||
|
||||
player.Ref = {playerName, playerScore, playernum, playerIcon, playerLine, Frame = playerFrame}
|
||||
@@ -717,8 +670,6 @@ function ScoreBoard(frame, x, y, w, h, sx, sy, sw, sh)
|
||||
end
|
||||
end
|
||||
|
||||
gui.Events.OnResized(ScoreResize)
|
||||
ScoreResize()
|
||||
return scoreboard
|
||||
end
|
||||
|
||||
|
||||
+5
-16
@@ -25,17 +25,9 @@ function Menu(frame)
|
||||
title.visibility = 0
|
||||
title.textColor = color.title_font
|
||||
title.drawBorder = false
|
||||
title:centerFont()
|
||||
|
||||
titleLog:debug("Creating font thread")
|
||||
proc:newThread(function()
|
||||
local function enabled()
|
||||
return background.visible
|
||||
end
|
||||
while true do
|
||||
thread.hold(enabled)
|
||||
title:centerFont()
|
||||
end
|
||||
end)
|
||||
|
||||
local items = 0
|
||||
local MenuOption = function(str)
|
||||
@@ -43,13 +35,10 @@ function Menu(frame)
|
||||
local text = item:newTextLabel(str)
|
||||
text:fullFrame()
|
||||
text.align = gui.ALIGN_CENTER
|
||||
thread:newThread(function()
|
||||
thread.skip(2)
|
||||
text:fitFont(nil,nil,{scale = 1/2})
|
||||
text:centerFont()
|
||||
text.visibility = 0
|
||||
text.textColor = color.new("#24269a")
|
||||
end)
|
||||
text:scaleFont(.4)
|
||||
text:centerFont()
|
||||
text.visibility = 0
|
||||
text.textColor = color.new("#24269a")
|
||||
items = items + 1
|
||||
return item, text
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user