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)
|
||||
|
||||
+10
-3
@@ -4,6 +4,13 @@ local menu = require("gui.core.menus")
|
||||
-- local proc = gui:getProcessor():newProcessor("settings")
|
||||
|
||||
function Menu(frame)
|
||||
local background = frame:newImageLabel("assets/images/background.jpg")
|
||||
background:fullFrame()
|
||||
end
|
||||
local background = frame:newFrame():fullFrame()
|
||||
background:setShader(gui.SHADERS.background,{
|
||||
colA = color.shaderColA,
|
||||
colB = color.shaderColB,
|
||||
colC = color.shaderColC
|
||||
})
|
||||
background:shaderTime()
|
||||
end
|
||||
|
||||
return menu.registerMenu("settings", Menu)
|
||||
+9
-3
@@ -5,7 +5,8 @@ local proc = gui:getProcessor():newProcessor("main-title")
|
||||
|
||||
local APP_VERSION = love.filesystem.read("version.txt")
|
||||
|
||||
local board = require("menus.board")
|
||||
local boardMenu = require("menus.board")
|
||||
local settingsMenu = require("menus.settings")
|
||||
|
||||
local titleLog = log:child("title")
|
||||
|
||||
@@ -59,16 +60,21 @@ function Menu(frame)
|
||||
play:OnReleased(function()
|
||||
titleLog:debug("Play button pressed")
|
||||
if love.filesystem.getInfo("quiz") then
|
||||
menu.getMenu("board"):visible(true, "quiz", true)
|
||||
boardMenu:visible(true, "quiz", true)
|
||||
return
|
||||
else
|
||||
gui:newFilePicker("File picker test",nil, {".zip"}, function(file)
|
||||
titleLog:info("File picked: %s", file)
|
||||
menu.getMenu("board"):visible(true, file:gsub("\\","/"):gsub(love.filesystem.getSaveDirectory(),""):sub(2,-1))
|
||||
boardMenu:visible(true, file:gsub("\\","/"):gsub(love.filesystem.getSaveDirectory(),""):sub(2,-1))
|
||||
end)
|
||||
end
|
||||
end)
|
||||
|
||||
settings:OnReleased(function()
|
||||
titleLog:debug("Settings button pressed")
|
||||
settingsMenu:visible(true)
|
||||
end)
|
||||
|
||||
quit:OnReleased(function(self, x, y)
|
||||
print("Quit Pressed",x,y,self:getAbsolutes())
|
||||
titleLog:debug("Quit button pressed")
|
||||
|
||||
Reference in New Issue
Block a user