added zip utils
This commit is contained in:
+44
-17
@@ -38,7 +38,9 @@ local dd_enabled = false
|
||||
local applied_dd = false
|
||||
local board, question
|
||||
|
||||
local function cleanUp()
|
||||
local function cleanUp(frameRef)
|
||||
boardLog:debug("Cleaning up state and returning to title screen")
|
||||
scoreboard:removeAllPlayers()
|
||||
activePlayer = nil
|
||||
handler_conn:Remove()
|
||||
playerList = {}
|
||||
@@ -55,6 +57,7 @@ local function cleanUp()
|
||||
applied_dd = false
|
||||
board = nil
|
||||
question = nil
|
||||
frameRef:destroy()
|
||||
end
|
||||
|
||||
local function pickUniqueIndices(t, count)
|
||||
@@ -189,16 +192,23 @@ end
|
||||
|
||||
local function manageCosmetics(frame, cosmetics)
|
||||
boardLog:debug("Managing cosmetics")
|
||||
if cosmetics["bg-img"] then
|
||||
frame:setImage(cosmetics["bg-img"])
|
||||
else
|
||||
frame:setImage("assets/images/background.png")
|
||||
end
|
||||
if type(cosmetics.colors) == "table" then
|
||||
for i,v in pairs(cosmetics.colors) do
|
||||
color.reindexColor((i:gsub("-","_")),v)
|
||||
end
|
||||
end
|
||||
if cosmetics["bg-img"] then
|
||||
frame:setImage(cosmetics["bg-img"])
|
||||
frame:setShader()
|
||||
else
|
||||
-- frame:setImage("assets/images/background.png")
|
||||
frame:setImage(nil)
|
||||
frame:setShader(gui.SHADERS.background,{
|
||||
colA = color.shaderColA,
|
||||
colB = color.shaderColB,
|
||||
colC = color.shaderColC
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
function gui:cleanup()
|
||||
@@ -210,7 +220,7 @@ function gui:cleanup()
|
||||
end
|
||||
|
||||
function Menu(frame, path, deb)
|
||||
local frameRef = frame:newFrame():fullFrame()
|
||||
local frameRef = frame:newImageLabel():fullFrame()
|
||||
frameRef.visibility = 0
|
||||
boardLog:info("Building board")
|
||||
if path:match(".zip") then
|
||||
@@ -262,10 +272,7 @@ function Menu(frame, path, deb)
|
||||
refresh.align = gui.ALIGN_CENTER
|
||||
refresh.color = color.green
|
||||
refresh:OnReleased(function()
|
||||
boardLog:debug("Cleaning up state and returning to title screen")
|
||||
scoreboard:removeAllPlayers()
|
||||
cleanUp()
|
||||
frameRef:destroy()
|
||||
cleanUp(frameRef)
|
||||
menu.getMenu("title"):visible(true)
|
||||
menu.getMenu("board"):visible(frame, path, deb)
|
||||
end)
|
||||
@@ -284,6 +291,8 @@ function Menu(frame, path, deb)
|
||||
|
||||
local function displayAnswer(q)
|
||||
dframe.text = q.answer
|
||||
dframe.textColor = color.white
|
||||
|
||||
dframe.visible = true
|
||||
dframe.click = q["display-mode"] == "click"
|
||||
local sleep = 5
|
||||
@@ -334,6 +343,7 @@ function Menu(frame, path, deb)
|
||||
OnExit = function(self)
|
||||
self:setShader()
|
||||
end,
|
||||
shaderTime = {true},
|
||||
OnReleased=function(self)
|
||||
if self.text == "Skip" then
|
||||
handler_conn:Fire()
|
||||
@@ -342,10 +352,11 @@ function Menu(frame, path, deb)
|
||||
return
|
||||
end
|
||||
local val = self.text == "Correct"
|
||||
print(multiply)
|
||||
handler_conn:Fire(val, multiply)
|
||||
if val then
|
||||
reference:Unconnect()
|
||||
if val then
|
||||
if reference then
|
||||
reference:Unconnect()
|
||||
end
|
||||
handler.visible = false
|
||||
end
|
||||
end,
|
||||
@@ -368,7 +379,16 @@ function Menu(frame, path, deb)
|
||||
index = data.index
|
||||
|
||||
local cosmetics = index.cosmetics or {}
|
||||
manageCosmetics(frame, cosmetics)
|
||||
cosmetics.colors = cosmetics.colors or {}
|
||||
|
||||
for i,v in pairs(color.listColors()) do
|
||||
if not cosmetics.colors[v] then
|
||||
cosmetics.colors[v] = color.rgbToHex(color[v])
|
||||
end
|
||||
end
|
||||
|
||||
frameRef:shaderTime()
|
||||
manageCosmetics(frameRef, cosmetics)
|
||||
|
||||
board:fullFrame()
|
||||
question:fullFrame()
|
||||
@@ -407,7 +427,7 @@ function Menu(frame, path, deb)
|
||||
|
||||
reset(function(q)
|
||||
question:cleanup()
|
||||
manageCosmetics(frame, cosmetics)
|
||||
manageCosmetics(frameRef, cosmetics)
|
||||
label.text = default_text
|
||||
if q["display-answer"] then
|
||||
displayAnswer(q)
|
||||
@@ -449,6 +469,13 @@ function Menu(frame, path, deb)
|
||||
t.category = v.name
|
||||
t.index = tier
|
||||
t.price = start + inc*(tier-1)
|
||||
t:OnEnter(function(self)
|
||||
self:setShader(gui.SHADERS.glow)
|
||||
end)
|
||||
t:OnExit(function(self)
|
||||
self:setShader()
|
||||
end)
|
||||
t:shaderTime(true)
|
||||
t:OnReleased(boardUpdater:newFunction(function(self)
|
||||
if self.text == "" or GetActivePlayer() == nil then return end
|
||||
if dd_enabled then
|
||||
@@ -470,7 +497,7 @@ function Menu(frame, path, deb)
|
||||
setmetatable(q, {__index = globals})
|
||||
if q == nil then boardLog:debug("Question contains no data: File: %s Category: %s Tier: %s",path,index.categories[cat].name,start + inc*(tier-1)) return end
|
||||
if q.cosmetics then
|
||||
manageCosmetics(frame, q.cosmetics)
|
||||
manageCosmetics(frameRef, q.cosmetics)
|
||||
end
|
||||
self.textVisibility = 0
|
||||
local template = LoadTemplate(q.template, path)
|
||||
|
||||
Reference in New Issue
Block a user