Compare commits
2 Commits
4d0fb606af
...
v1.0.2
| Author | SHA1 | Date | |
|---|---|---|---|
| 6b864a2d9b | |||
| 0c90ab885e |
@@ -0,0 +1,3 @@
|
|||||||
|
bin/*
|
||||||
|
love/*
|
||||||
|
game.love
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
settings:
|
|
||||||
increment: 100
|
|
||||||
start: 100
|
|
||||||
tiers: 5
|
|
||||||
dailyDouble:
|
|
||||||
enabled: true
|
|
||||||
minQuestions: 7
|
|
||||||
count: 2
|
|
||||||
|
|
||||||
categories:
|
|
||||||
- name: shounen
|
|
||||||
displayName: "Shounen"
|
|
||||||
- name: villains
|
|
||||||
displayName: "Villains"
|
|
||||||
- name: openings
|
|
||||||
displayName: "Openings"
|
|
||||||
- name: studios
|
|
||||||
displayName: "Studios & Staff"
|
|
||||||
- name: plot-twists
|
|
||||||
displayName: "Plot Twists"
|
|
||||||
@@ -1,33 +0,0 @@
|
|||||||
questions:
|
|
||||||
- title: "The iconic opening 'Guren no Yumiya' by Linked Horizon belongs to this anime."
|
|
||||||
time-limit: 15
|
|
||||||
answer: "Attack on Titan"
|
|
||||||
template: "whatis"
|
|
||||||
|
|
||||||
- title: "Which anime features the opening 'Unravel' by TK from Ling Tosite Sigure?"
|
|
||||||
answer: 2
|
|
||||||
choices:
|
|
||||||
- "Parasyte"
|
|
||||||
- "Tokyo Ghoul"
|
|
||||||
- "Deadman Wonderland"
|
|
||||||
- "Elfen Lied"
|
|
||||||
template: "multiplechoice"
|
|
||||||
|
|
||||||
- title: "'Cruel Angel's Thesis' is the legendary opening theme of this 1995 mecha anime."
|
|
||||||
time-limit: 20
|
|
||||||
answer: "Neon Genesis Evangelion"
|
|
||||||
template: "whatis"
|
|
||||||
|
|
||||||
- title: "Which of these bands performed 'Again', the first opening of Fullmetal Alchemist: Brotherhood?"
|
|
||||||
answer: 4
|
|
||||||
choices:
|
|
||||||
- "Asian Kung-Fu Generation"
|
|
||||||
- "Flow"
|
|
||||||
- "Scandal"
|
|
||||||
- "YUI"
|
|
||||||
template: "multiplechoice"
|
|
||||||
|
|
||||||
- title: "This artist performed 'Gurenge', the first opening of Demon Slayer: Kimetsu no Yaiba, which became a massive hit in Japan."
|
|
||||||
time-limit: 25
|
|
||||||
answer: "LiSA"
|
|
||||||
template: "whatis"
|
|
||||||
@@ -1,33 +0,0 @@
|
|||||||
questions:
|
|
||||||
- title: "In Code Geass, Lelouch's Geass ability compels anyone who makes direct eye contact with him to do this."
|
|
||||||
time-limit: 20
|
|
||||||
answer: "Obey any one order he gives them"
|
|
||||||
template: "whatis"
|
|
||||||
|
|
||||||
- title: "At the end of Madoka Magica, Madoka's wish rewrites the laws of the universe to do what?"
|
|
||||||
answer: 2
|
|
||||||
choices:
|
|
||||||
- "Destroy all witches that have ever existed and will ever exist"
|
|
||||||
- "Erase all witches before they are born, taking herself out of existence"
|
|
||||||
- "Turn every magical girl back into a normal human"
|
|
||||||
- "Destroy Kyubey and the incubator race"
|
|
||||||
template: "multiplechoice"
|
|
||||||
|
|
||||||
- title: "In Fullmetal Alchemist: Brotherhood, Edward and Alphonse discover their mother was not actually revived — what they created during their human transmutation was this."
|
|
||||||
time-limit: 30
|
|
||||||
answer: "A soulless body / failed homunculus (not their mother)"
|
|
||||||
template: "whatis"
|
|
||||||
|
|
||||||
- title: "Which of these correctly describes the twist at the end of Assassination Classroom?"
|
|
||||||
answer: 3
|
|
||||||
choices:
|
|
||||||
- "Koro-sensei was always a government weapon and willingly lets himself be killed"
|
|
||||||
- "The students refuse to kill Koro-sensei and he escapes to space"
|
|
||||||
- "Koro-sensei asks his students to be the ones to kill him as his final wish"
|
|
||||||
- "Nagisa kills the minister of defense and Koro-sensei is freed"
|
|
||||||
template: "multiplechoice"
|
|
||||||
|
|
||||||
- title: "In Gurren Lagann, Simon discovers that the key to piloting Lagann is not a special device but actually this."
|
|
||||||
time-limit: 25
|
|
||||||
answer: "His own drill / fighting spirit (spiral power)"
|
|
||||||
template: "whatis"
|
|
||||||
@@ -1,33 +0,0 @@
|
|||||||
questions:
|
|
||||||
- title: "This is the name of the signature technique Naruto Uzumaki uses to create physical copies of himself."
|
|
||||||
time-limit: 15
|
|
||||||
answer: "Shadow Clone Jutsu"
|
|
||||||
template: "whatis"
|
|
||||||
|
|
||||||
- title: "In Dragon Ball Z, Goku achieved this transformation for the first time during his battle against Frieza on Namek."
|
|
||||||
time-limit: 20
|
|
||||||
answer: "Super Saiyan"
|
|
||||||
template: "whatis"
|
|
||||||
|
|
||||||
- title: "Which of these is the name of Ichigo Kurosaki's Zanpakuto in Bleach?"
|
|
||||||
answer: 3
|
|
||||||
choices:
|
|
||||||
- "Zangetsu"
|
|
||||||
- "Senbonzakura"
|
|
||||||
- "Tensa Zangetsu"
|
|
||||||
- "Ryujin Jakka"
|
|
||||||
template: "multiplechoice"
|
|
||||||
|
|
||||||
- title: "In Hunter x Hunter, this is the name of the system of power that allows users to manipulate their life energy."
|
|
||||||
time-limit: 25
|
|
||||||
answer: "Nen"
|
|
||||||
template: "whatis"
|
|
||||||
|
|
||||||
- title: "Which of these Devil Fruits did Monkey D. Luffy eat, giving him his rubber powers?"
|
|
||||||
answer: 2
|
|
||||||
choices:
|
|
||||||
- "Mera Mera no Mi"
|
|
||||||
- "Gomu Gomu no Mi"
|
|
||||||
- "Hana Hana no Mi"
|
|
||||||
- "Bara Bara no Mi"
|
|
||||||
template: "multiplechoice"
|
|
||||||
@@ -1,33 +0,0 @@
|
|||||||
questions:
|
|
||||||
- title: "This animation studio, co-founded by Hayao Miyazaki, produced Spirited Away, My Neighbor Totoro, and Princess Mononoke."
|
|
||||||
time-limit: 15
|
|
||||||
answer: "Studio Ghibli"
|
|
||||||
template: "whatis"
|
|
||||||
|
|
||||||
- title: "Which studio produced Fullmetal Alchemist: Brotherhood, Sword of the Stranger, and Mob Psycho 100?"
|
|
||||||
answer: 1
|
|
||||||
choices:
|
|
||||||
- "Bones"
|
|
||||||
- "Madhouse"
|
|
||||||
- "White Fox"
|
|
||||||
- "A-1 Pictures"
|
|
||||||
template: "multiplechoice"
|
|
||||||
|
|
||||||
- title: "This director is known for helming Cowboy Bebop, Samurai Champloo, and Space Dandy."
|
|
||||||
time-limit: 25
|
|
||||||
answer: "Shinichiro Watanabe"
|
|
||||||
template: "whatis"
|
|
||||||
|
|
||||||
- title: "Which studio is responsible for the long-running adaptations of One Piece and Dragon Ball Super?"
|
|
||||||
answer: 3
|
|
||||||
choices:
|
|
||||||
- "Pierrot"
|
|
||||||
- "Sunrise"
|
|
||||||
- "Toei Animation"
|
|
||||||
- "TMS Entertainment"
|
|
||||||
template: "multiplechoice"
|
|
||||||
|
|
||||||
- title: "This legendary animator, known as 'the god of manga', created Astro Boy and is considered the father of modern anime and manga."
|
|
||||||
time-limit: 20
|
|
||||||
answer: "Osamu Tezuka"
|
|
||||||
template: "whatis"
|
|
||||||
|
Before Width: | Height: | Size: 961 KiB |
|
Before Width: | Height: | Size: 1.1 MiB |
|
Before Width: | Height: | Size: 256 KiB |
|
Before Width: | Height: | Size: 1.8 MiB |
@@ -1,24 +0,0 @@
|
|||||||
settings:
|
|
||||||
increment: 100 # how much each tier increases by
|
|
||||||
start: 100 # starting amount see tier's comment
|
|
||||||
tiers: 5 # 5 tiers 100, 200, 300, 400, 500 based on above settings
|
|
||||||
dailyDouble:
|
|
||||||
enabled: true # should daily double be enabled?
|
|
||||||
minQuestions: 7 # how many questions need to be answered before a daily double can appear?
|
|
||||||
count: 2 # how many daily doubles should there be?
|
|
||||||
categories: # the name of each category should correspond to a yaml file with the same name
|
|
||||||
- name: shounen # name must be alphanumeric, cannot start with a number or contain special characters "-" and "." are ok if they are not at the beginning
|
|
||||||
displayName: "Shounen" # if blank will use name
|
|
||||||
image: "anime/assets/14018-3193093789.gif" # if set will display image instead of name, categories are referenced by name which is required
|
|
||||||
- name: openings
|
|
||||||
displayName: "Openings" # if blank will use name
|
|
||||||
- name: sadness
|
|
||||||
displayName: "Sadness" # if blank will use name
|
|
||||||
- name: random
|
|
||||||
displayName: Random # if blank will use name
|
|
||||||
- name: you-would-have-though
|
|
||||||
displayName: "You would have\nthought" # if blank will use name
|
|
||||||
- name: wtf-is-that
|
|
||||||
displayName: "Wtf is that!?" # if blank will use name
|
|
||||||
- name: owo
|
|
||||||
displayName: "owo" # if blank will use name
|
|
||||||
@@ -1,35 +0,0 @@
|
|||||||
questions: # expects a list equal to the tier
|
|
||||||
- title: "Name at least 10 of the characters here"
|
|
||||||
time-limit: 60 # If omitted there is no time limit
|
|
||||||
answer: 10
|
|
||||||
image: "anime/assets/shounen_name_characters.png"
|
|
||||||
template: "one-image" # template to use
|
|
||||||
display-answer: true # displays the correct answer before returning to the main screen
|
|
||||||
- title: "What anime is this?"
|
|
||||||
time-limit: 30 # If omitted there is no time limit
|
|
||||||
answer: "steins;gate"
|
|
||||||
imageA: "anime/assets/beer.jpg"
|
|
||||||
imageB: "anime/assets/gate.jpg"
|
|
||||||
display-answer: true # displays the correct answer before returning to the main screen
|
|
||||||
template: "imageword" # template to use
|
|
||||||
- title: "What is 2+2"
|
|
||||||
answer: 2 # positon of correct answer
|
|
||||||
choices:
|
|
||||||
- "22"
|
|
||||||
- "4" # this is 2
|
|
||||||
- "9000"
|
|
||||||
- "-4"
|
|
||||||
- "wack"
|
|
||||||
template: "multiplechoice"
|
|
||||||
- title: "Who directed the groundbreaking film 'Akira',\nwhich helped introduce anime to Western audiences?"
|
|
||||||
time-limit: 10 # If omitted there is no time limit
|
|
||||||
answer: "Katsuhiro Otomo"
|
|
||||||
template: "whatis" # template to use
|
|
||||||
display-answer: true # displays the correct answer before returning to the main screen
|
|
||||||
- title: "What is this?"
|
|
||||||
answer: "Bunny shit"
|
|
||||||
video: "anime/assets/bunny.ogv"
|
|
||||||
start: 4
|
|
||||||
playFor: 3
|
|
||||||
template: "whatvideo" # template to use
|
|
||||||
display-answer: true # displays the correct answer before returning to the main screen
|
|
||||||
|
After Width: | Height: | Size: 613 KiB |
|
After Width: | Height: | Size: 1.0 MiB |
@@ -1,290 +0,0 @@
|
|||||||
local gui = require("gui")
|
|
||||||
local color = require("gui.core.color")
|
|
||||||
local loader = require("loader")
|
|
||||||
local theme = require("gui.core.theme")
|
|
||||||
local fmt = require("fmt")
|
|
||||||
local timer = require("utils")
|
|
||||||
local multi, thread = require("multi"):init()
|
|
||||||
|
|
||||||
local timesup = love.audio.newSource("assets/sounds/timesup.mp3", "static")
|
|
||||||
local double = love.audio.newSource("assets/sounds/double.mp3", "static")
|
|
||||||
|
|
||||||
local boardUpdater = gui:getProcessor():newProcessor("board-updater")
|
|
||||||
boardUpdater.Start()
|
|
||||||
|
|
||||||
local activePlayer
|
|
||||||
local playerList = {}
|
|
||||||
local playerStaticList = {}
|
|
||||||
local scoreboard = {}
|
|
||||||
|
|
||||||
-- Create a table to manage GUI elements
|
|
||||||
local manage = {}
|
|
||||||
|
|
||||||
-- Function to resize fonts for all managed elements
|
|
||||||
local function resizeFonts()
|
|
||||||
-- Use multi-threading to improve performance
|
|
||||||
multi:newThread(function()
|
|
||||||
-- Introduce a small delay to avoid too many iterations at once
|
|
||||||
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)
|
|
||||||
end
|
|
||||||
|
|
||||||
gui.Events.OnResized(resizeFonts)
|
|
||||||
|
|
||||||
local completed_questions = 0
|
|
||||||
local min_questions = 0
|
|
||||||
local dd_count = 0
|
|
||||||
local dd_enabled = false
|
|
||||||
local applied_dd = false
|
|
||||||
local board, question
|
|
||||||
|
|
||||||
function gui:cleanup()
|
|
||||||
for i = #self.children, 1, -1 do
|
|
||||||
self.children[i]:destroy()
|
|
||||||
end
|
|
||||||
self.children = {}
|
|
||||||
completed_questions = completed_questions + 1
|
|
||||||
end
|
|
||||||
|
|
||||||
local function pickUniqueIndices(t, count)
|
|
||||||
assert(#t >= count, "Not enough elements to pick " .. count .. " unique items")
|
|
||||||
|
|
||||||
local indices = {}
|
|
||||||
for i = 1, #t do indices[i] = i end
|
|
||||||
|
|
||||||
-- partial Fisher-Yates shuffle
|
|
||||||
for i = 1, count do
|
|
||||||
local j = math.random(i, #indices)
|
|
||||||
indices[i], indices[j] = indices[j], indices[i]
|
|
||||||
end
|
|
||||||
|
|
||||||
return unpack(indices, 1, count)
|
|
||||||
end
|
|
||||||
|
|
||||||
local function pickFiltered(items, count)
|
|
||||||
-- Filter to only elements whose text contains "$"
|
|
||||||
local filtered = {}
|
|
||||||
for _, item in ipairs(items) do
|
|
||||||
if item.text:find("%$") then
|
|
||||||
filtered[#filtered + 1] = item
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Use pickUniqueIndices to select from filtered results
|
|
||||||
local picks = { pickUniqueIndices(filtered, count) }
|
|
||||||
local results = {}
|
|
||||||
for _, idx in ipairs(picks) do
|
|
||||||
results[#results + 1] = filtered[idx]
|
|
||||||
end
|
|
||||||
|
|
||||||
return unpack(results)
|
|
||||||
end
|
|
||||||
|
|
||||||
function applyDD()
|
|
||||||
if not applied_dd and completed_questions > min_questions then
|
|
||||||
local dd = 0
|
|
||||||
local dd_list = {}
|
|
||||||
local dds = {pickFiltered(board.children, dd_count)}
|
|
||||||
for i,v in pairs(dds) do
|
|
||||||
print(i,v)
|
|
||||||
v.isDouble = true
|
|
||||||
end
|
|
||||||
applied_dd = true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local function buildBoard(frame, path)
|
|
||||||
local data = loader:new(path)
|
|
||||||
board, question, dailydouble = frame:newFrame(), frame:newFrame(), frame:newImageLabel("assets/images/double.jpg")
|
|
||||||
index = data.index
|
|
||||||
board:fullFrame()
|
|
||||||
question:fullFrame()
|
|
||||||
dailydouble:fullFrame()
|
|
||||||
dailydouble.visible = false
|
|
||||||
question.visible = false
|
|
||||||
question.color = color.new("#060ce9")
|
|
||||||
local tiers = index.settings.tiers or 5
|
|
||||||
local start = index.settings.start or 100
|
|
||||||
local inc = index.settings.increment or 100
|
|
||||||
|
|
||||||
if index.settings.dailyDouble and index.settings.dailyDouble.enabled then
|
|
||||||
local dd = index.settings.dailyDouble
|
|
||||||
dd_enabled = dd.enabled
|
|
||||||
min_questions = dd.minQuestions
|
|
||||||
dd_count = dd.count
|
|
||||||
end
|
|
||||||
for cat,v in pairs(index.categories) do
|
|
||||||
local c
|
|
||||||
if v.image then
|
|
||||||
c = board:newImageLabel(v.image, 0, 0, 0, 0,(1/#index.categories)*(cat-1),0,1/#index.categories,1/(tiers+1))
|
|
||||||
else
|
|
||||||
c = board:newTextLabel(v.displayName or v.name,0,0,0,0,(1/#index.categories)*(cat-1),0,1/#index.categories,1/(tiers+1))
|
|
||||||
c.align = gui.ALIGN_CENTER
|
|
||||||
c.textColor = color.new("#ffffff")
|
|
||||||
c.color = color.new("#060ce9")
|
|
||||||
end
|
|
||||||
|
|
||||||
c.UUID = multi.generate_uuid7() -- Each otpion gets a unique UUID
|
|
||||||
|
|
||||||
img = c:newImageButton("assets/images/placeholder.jpg")
|
|
||||||
img.visibility = 0
|
|
||||||
|
|
||||||
img:OnReleased(function(self)
|
|
||||||
self.visible = false
|
|
||||||
end)
|
|
||||||
|
|
||||||
img:fullFrame()
|
|
||||||
table.insert(manage,c)
|
|
||||||
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))
|
|
||||||
t.textColor = color.new("#9b9024")
|
|
||||||
t.align = gui.ALIGN_CENTER
|
|
||||||
t.color = color.new("#060ce9")
|
|
||||||
t.category = v.name
|
|
||||||
t.index = tier
|
|
||||||
t.price = start + inc*(tier-1)
|
|
||||||
t:OnReleased(boardUpdater:newFunction(function(self)
|
|
||||||
if self.text == "" or GetActivePlayer() == nil then return end
|
|
||||||
if dd_enabled then
|
|
||||||
applyDD() -- check and run DD if conditions meet
|
|
||||||
end
|
|
||||||
if index.categories[cat].questions == nil then fmt.Printf("Question not defined: File: %v Category: %v - %v\n",path,index.categories[cat].name,start + inc*(tier-1)) return end
|
|
||||||
local q = index.categories[cat].questions[self.index]
|
|
||||||
if q == nil then fmt.Printf("Question contains no data: File: %v Category: %v Tier: %v\n",path,index.categories[cat].name,start + inc*(tier-1)) return end
|
|
||||||
self.textVisibility = 0
|
|
||||||
local template = LoadTemplate(q.template, path)
|
|
||||||
question.visible = true
|
|
||||||
local player = GetActivePlayer()
|
|
||||||
local tm
|
|
||||||
local stop
|
|
||||||
fmt.Printf("--------------------\nQuestion: %v \nAnswer: %v\n--------------------\n",q["title"],q["answer"])
|
|
||||||
local mul = 1
|
|
||||||
boardUpdater:newThread(function()
|
|
||||||
if self.isDouble then
|
|
||||||
mul = 2
|
|
||||||
double:play()
|
|
||||||
dailydouble.visible = true
|
|
||||||
thread.hold(function()
|
|
||||||
return not double:isPlaying()
|
|
||||||
end)
|
|
||||||
dailydouble.visible = false
|
|
||||||
end
|
|
||||||
if q["time-limit"] then
|
|
||||||
tm = timer.startTimer({duration = q["time-limit"]})
|
|
||||||
tm.OnStop(function()
|
|
||||||
-- Make sound? Subtract if daily double
|
|
||||||
if stop then return end
|
|
||||||
timesup:play()
|
|
||||||
end)
|
|
||||||
end
|
|
||||||
local finished = false
|
|
||||||
template.index(question, q, function(ans)
|
|
||||||
if finished then return end
|
|
||||||
player = GetActivePlayer()
|
|
||||||
if tm then
|
|
||||||
tm:Cleanup()
|
|
||||||
end
|
|
||||||
stop = true
|
|
||||||
if ans then
|
|
||||||
player:Add(self.price*mul)
|
|
||||||
finished = true
|
|
||||||
question.visible = false
|
|
||||||
question:cleanup()
|
|
||||||
elseif ans == false then
|
|
||||||
player:Add(-self.price*mul)
|
|
||||||
player = GetNextPlayer()
|
|
||||||
else
|
|
||||||
finished = true
|
|
||||||
question.visible = false
|
|
||||||
question:cleanup()
|
|
||||||
end -- nil is a valid option where you weren't right or wrong, you just skipped
|
|
||||||
self.text = ""
|
|
||||||
end)
|
|
||||||
boardUpdater:newThread("QuestionUpdater",function()
|
|
||||||
while true do
|
|
||||||
template.update(dt)
|
|
||||||
thread.yield()
|
|
||||||
if self.text == "" then return end
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
end)
|
|
||||||
end))
|
|
||||||
table.insert(manage,t)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
resizeFonts()
|
|
||||||
resizeFonts()
|
|
||||||
end
|
|
||||||
|
|
||||||
local qUpdater = gui:getProcessor():newProcessor("question-updater")
|
|
||||||
qUpdater.Start()
|
|
||||||
|
|
||||||
function LoadTemplate(name, path)
|
|
||||||
|
|
||||||
if love.filesystem.getInfo("templates/" .. name .. ".lua") then
|
|
||||||
data = love.filesystem.read("templates/" .. name .. ".lua")
|
|
||||||
elseif love.filesystem.getInfo(path .."/templates/" .. name .. ".lua") then
|
|
||||||
data = love.filesystem.read(path .."/templates/" .. name .. ".lua")
|
|
||||||
end
|
|
||||||
|
|
||||||
local template, err = loadstring(data)
|
|
||||||
|
|
||||||
if err ~= nil then
|
|
||||||
error(err)
|
|
||||||
end
|
|
||||||
|
|
||||||
local timer = function(wait, callback)
|
|
||||||
multi:newAlarm(wait):OnRing(callback)
|
|
||||||
end
|
|
||||||
|
|
||||||
local env = { -- lua built-ins except io/os code execution
|
|
||||||
pairs=pairs,
|
|
||||||
print=print,
|
|
||||||
tostring=tostring,
|
|
||||||
tonumber=tonumber,
|
|
||||||
type=type,
|
|
||||||
assert=assert,
|
|
||||||
ipairs=ipairs,
|
|
||||||
table=table,
|
|
||||||
math=math,
|
|
||||||
string=string,
|
|
||||||
next=next,
|
|
||||||
pcall=pcall,
|
|
||||||
select=select,
|
|
||||||
xpcall=xpcall,
|
|
||||||
utf8=utf8,
|
|
||||||
clock = require("socket").gettime,
|
|
||||||
ALIGN_CENTER = gui.ALIGN_CENTER,
|
|
||||||
ALIGN_LEFT = gui.ALIGN_LEFT,
|
|
||||||
ALIGN_RIGHT = gui.ALIGN_RIGHT,
|
|
||||||
ALIGN_JUSTIFY = gui.ALIGN_JUSTIFY,
|
|
||||||
-- Global vars
|
|
||||||
color = color,
|
|
||||||
error = multi.error,
|
|
||||||
theme = theme,
|
|
||||||
gui = gui,
|
|
||||||
timer = timer,
|
|
||||||
-- love stuff
|
|
||||||
newSource = love.audio.newSource
|
|
||||||
}
|
|
||||||
|
|
||||||
env._G = env
|
|
||||||
local isoTemplate = multi.isolateFunction(template, env)
|
|
||||||
|
|
||||||
return isoTemplate()
|
|
||||||
end
|
|
||||||
|
|
||||||
return {
|
|
||||||
buildBoard = buildBoard
|
|
||||||
}
|
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
function love.conf(t)
|
function love.conf(t)
|
||||||
t.identity = nil -- The name of the save directory (string)
|
t.identity = "Jeopardy"
|
||||||
t.version = "11.5" -- The LOVE version this game was made for (string)
|
t.version = "11.5" -- The LOVE version this game was made for (string)
|
||||||
t.console = true -- Attach a console (boolean, Windows only)
|
t.console = true -- Attach a console (boolean, Windows only)
|
||||||
|
|
||||||
t.window.title = "GuiManagerTest" -- The window title (string)
|
t.window.title = "Jeopardy" -- The window title (string)
|
||||||
t.window.icon = nil -- Filepath to an image to use as the window's icon (string)
|
t.window.icon = nil -- Filepath to an image to use as the window's icon (string)
|
||||||
t.window.width = 1920 -- The window width (number)
|
t.window.width = 1920 -- The window width (number)
|
||||||
t.window.height = 1080 -- The window height (number)
|
t.window.height = 1080 -- The window height (number)
|
||||||
@@ -13,7 +13,7 @@ function love.conf(t)
|
|||||||
t.window.minheight = 1 -- Minimum window height if the window is resizable (number)
|
t.window.minheight = 1 -- Minimum window height if the window is resizable (number)
|
||||||
t.window.fullscreen = false -- Enable fullscreen (boolean)
|
t.window.fullscreen = false -- Enable fullscreen (boolean)
|
||||||
t.window.fullscreentype = "desktop" -- Standard fullscreen or desktop fullscreen mode (string)
|
t.window.fullscreentype = "desktop" -- Standard fullscreen or desktop fullscreen mode (string)
|
||||||
t.window.vsync = false -- Enable vertical sync (boolean)
|
t.window.vsync = true -- Enable vertical sync (boolean)
|
||||||
t.window.fsaa = 4 -- The number of samples to use with multi-sampled antialiasing (number)
|
t.window.fsaa = 4 -- The number of samples to use with multi-sampled antialiasing (number)
|
||||||
t.window.display = 1 -- Index of the monitor to show the window in (number)
|
t.window.display = 1 -- Index of the monitor to show the window in (number)
|
||||||
t.window.highdpi = true -- Enable high-dpi mode for the window on a Retina display (boolean)
|
t.window.highdpi = true -- Enable high-dpi mode for the window on a Retina display (boolean)
|
||||||
@@ -29,7 +29,7 @@ function love.conf(t)
|
|||||||
t.modules.keyboard = true -- Enable the keyboard module (boolean)
|
t.modules.keyboard = true -- Enable the keyboard module (boolean)
|
||||||
t.modules.math = true -- Enable the math module (boolean)
|
t.modules.math = true -- Enable the math module (boolean)
|
||||||
t.modules.mouse = true -- Enable the mouse module (boolean)
|
t.modules.mouse = true -- Enable the mouse module (boolean)
|
||||||
t.modules.physics = true -- Enable the physics module (boolean)
|
t.modules.physics = false -- Enable the physics module (boolean)
|
||||||
t.modules.sound = true -- Enable the sound module (boolean)
|
t.modules.sound = true -- Enable the sound module (boolean)
|
||||||
t.modules.system = true -- Enable the system module (boolean)
|
t.modules.system = true -- Enable the system module (boolean)
|
||||||
t.modules.timer = true -- Enable the timer module (boolean)
|
t.modules.timer = true -- Enable the timer module (boolean)
|
||||||
|
|||||||
@@ -1,40 +1,79 @@
|
|||||||
local gui, color, theme, utils, board, yaml, loader, scoreUpdater
|
local logger = require("utils/logger")
|
||||||
|
local lovehandler = require("utils/love_file_handler")
|
||||||
|
|
||||||
multi, thread = require("multi"):init({priority=true})
|
multi, thread = require("multi"):init({priority=true})
|
||||||
multi.setClock(require("socket").gettime) -- When on linux os.clock doesn't reture actual seconds the program has elapsed for
|
multi.setClock(require("socket").gettime) -- When on linux os.clock doesn't reture actual seconds the program has elapsed for
|
||||||
GLOBAL, THREAD = require("multi.integration.loveManager"):init()
|
GLOBAL, THREAD = require("multi.integration.loveManager"):init()
|
||||||
|
|
||||||
gui = require("gui")
|
|
||||||
color = require("gui.core.color")
|
|
||||||
theme = require("gui.core.theme")
|
local fileHandler, logCtrl = lovehandler.new("logs/jeopardy.log", {
|
||||||
utils = require("utils")
|
max_size = 512 * 1024, -- rotate at 512 KB
|
||||||
board = require("board")
|
max_files = 3,
|
||||||
yaml = require("yaml")
|
buffered = false, -- write every line immediately (safest for games)
|
||||||
loader = require("loader")
|
})
|
||||||
|
|
||||||
|
lovehandler.auto_flush_on_quit(logCtrl)
|
||||||
|
|
||||||
|
log = logger.new("jeopardy", {
|
||||||
|
level = logger.LEVELS.DEBUG,
|
||||||
|
handlers = {
|
||||||
|
logger.handlers.ConsoleHandler({ colours = true }),
|
||||||
|
fileHandler,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
local gui = require("gui")
|
||||||
|
local color = require("gui.core.color")
|
||||||
|
local title = require("menus.title")
|
||||||
|
local menu = require("gui.core.menus")
|
||||||
|
|
||||||
|
color.indexColor("bg","#2b348b")
|
||||||
|
color.indexColor("tile_bg","#5459e4")
|
||||||
|
color.indexColor("header_tile","#2a2e91")
|
||||||
|
color.indexColor("status_font", "#e4b82a")
|
||||||
|
color.indexColor("title_font","#b16d24")
|
||||||
|
color.indexColor("question_bg","#363ac8")
|
||||||
|
color.indexColor("tile_font","#ffffff")
|
||||||
|
color.indexColor("header_font","#fef6eeda")
|
||||||
|
|
||||||
require("gui.addons")
|
require("gui.addons")
|
||||||
|
|
||||||
title = require("menus.title")
|
gui:setHotKey({"f11"})(function()
|
||||||
|
fullscreen, fstype = love.window.getFullscreen()
|
||||||
|
love.window.setFullscreen(not fullscreen, "desktop")
|
||||||
|
end)
|
||||||
|
|
||||||
|
local loadLog = log:child("load")
|
||||||
|
local old = multi.error
|
||||||
|
|
||||||
|
multi.error = function(self, err)
|
||||||
|
loadLog:error("Error: %s", err)
|
||||||
|
love.quit()
|
||||||
|
end
|
||||||
|
|
||||||
function love.load()
|
function love.load()
|
||||||
|
loadLog:info("Starting Jeopardy Game")
|
||||||
|
loadLog:debug("Setting game identity to jeopardy")
|
||||||
|
love.filesystem.setIdentity("jeopardy")
|
||||||
|
loadLog:trace("Creating save directory")
|
||||||
|
success = love.filesystem.createDirectory("")
|
||||||
|
if not success then
|
||||||
|
loadLog:fatal("Unable to create save directory")
|
||||||
|
love.quit()
|
||||||
|
end
|
||||||
|
loadLog:trace("Creating save directory")
|
||||||
gui:cacheImage({"assets/images/checked.png","assets/images/unchecked.png","assets/images/speaker.png"})
|
gui:cacheImage({"assets/images/checked.png","assets/images/unchecked.png","assets/images/speaker.png"})
|
||||||
gui:setAspectSize(1920, 1080)
|
gui:setAspectSize(1920, 1080)
|
||||||
gui.aspect_ratio = true
|
gui.aspect_ratio = true
|
||||||
|
loadLog:debug("Creating main background image")
|
||||||
local bg = gui:newFrame()
|
local bg = gui:newImageLabel("assets/images/background.png")
|
||||||
bg:fullFrame()
|
bg:fullFrame()
|
||||||
bg.color = color.new("#242f9b")
|
|
||||||
|
|
||||||
require("menus.menus").init(bg)
|
|
||||||
|
|
||||||
|
loadLog:debug("Init menu module")
|
||||||
|
menu.init(bg)
|
||||||
|
loadLog:debug("Displaying title menu")
|
||||||
title:visible(true)
|
title:visible(true)
|
||||||
|
|
||||||
bg:OnUpdate(function(self, dt)
|
|
||||||
if self.__blur then
|
|
||||||
-- pulse the blur between 2 and 12
|
|
||||||
local t = love.timer.getTime()
|
|
||||||
self:setBlurRadius(7 + 5 * math.sin(t * 2))
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function love.update(dt)
|
function love.update(dt)
|
||||||
|
|||||||
@@ -1,17 +1,18 @@
|
|||||||
local gui = require("gui")
|
local gui = require("gui")
|
||||||
local color = require("gui.core.color")
|
local color = require("gui.core.color")
|
||||||
local loader = require("loader")
|
local loader = require("utils/loader")
|
||||||
local theme = require("gui.core.theme")
|
local theme = require("gui.core.theme")
|
||||||
local fmt = require("fmt")
|
local fmt = require("utils/fmt")
|
||||||
local timer = require("utils")
|
local timer = require("utils/utils")
|
||||||
local multi, thread = require("multi"):init()
|
local multi, thread = require("multi"):init()
|
||||||
local menu = require("menus.menus")
|
local menu = require("gui.core.menus")
|
||||||
|
|
||||||
local timesup = love.audio.newSource("assets/sounds/timesup.mp3", "static")
|
local timesup = love.audio.newSource("assets/sounds/timesup.mp3", "static")
|
||||||
local double = love.audio.newSource("assets/sounds/double.mp3", "static")
|
local double = love.audio.newSource("assets/sounds/double.mp3", "static")
|
||||||
|
|
||||||
local boardUpdater = gui:getProcessor():newProcessor("board-updater")
|
local boardUpdater = gui:getProcessor():newProcessor("board-updater")
|
||||||
boardUpdater.Start()
|
local scoreUpdater = gui:getProcessor():newProcessor("score-updater")
|
||||||
|
local qUpdater = gui:getProcessor():newProcessor("question-updater")
|
||||||
|
|
||||||
local activePlayer
|
local activePlayer
|
||||||
local playerList = {}
|
local playerList = {}
|
||||||
@@ -21,7 +22,10 @@ local scoreboard = {}
|
|||||||
-- Create a table to manage GUI elements
|
-- Create a table to manage GUI elements
|
||||||
local manage = {}
|
local manage = {}
|
||||||
|
|
||||||
|
local boardLog = log:child("board")
|
||||||
|
|
||||||
-- Function to resize fonts for all managed elements
|
-- Function to resize fonts for all managed elements
|
||||||
|
boardLog:debug("Creating resize fonts handler")
|
||||||
local function resizeFonts()
|
local function resizeFonts()
|
||||||
-- Use multi-threading to improve performance
|
-- Use multi-threading to improve performance
|
||||||
multi:newThread(function()
|
multi:newThread(function()
|
||||||
@@ -50,14 +54,6 @@ local dd_enabled = false
|
|||||||
local applied_dd = false
|
local applied_dd = false
|
||||||
local board, question
|
local board, question
|
||||||
|
|
||||||
function gui:cleanup()
|
|
||||||
for i = #self.children, 1, -1 do
|
|
||||||
self.children[i]:destroy()
|
|
||||||
end
|
|
||||||
self.children = {}
|
|
||||||
completed_questions = completed_questions + 1
|
|
||||||
end
|
|
||||||
|
|
||||||
local function pickUniqueIndices(t, count)
|
local function pickUniqueIndices(t, count)
|
||||||
assert(#t >= count, "Not enough elements to pick " .. count .. " unique items")
|
assert(#t >= count, "Not enough elements to pick " .. count .. " unique items")
|
||||||
|
|
||||||
@@ -94,26 +90,39 @@ end
|
|||||||
|
|
||||||
function applyDD()
|
function applyDD()
|
||||||
if not applied_dd and completed_questions > min_questions then
|
if not applied_dd and completed_questions > min_questions then
|
||||||
|
boardLog:debug("Creating double jeopardy questions: %d",dd_count)
|
||||||
local dd = 0
|
local dd = 0
|
||||||
local dd_list = {}
|
local dd_list = {}
|
||||||
local dds = {pickFiltered(board.children, dd_count)}
|
local dds = {pickFiltered(board.children, dd_count)}
|
||||||
for i,v in pairs(dds) do
|
for i,v in pairs(dds) do
|
||||||
print(i,v)
|
|
||||||
v.isDouble = true
|
v.isDouble = true
|
||||||
end
|
end
|
||||||
applied_dd = true
|
applied_dd = true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local qUpdater = gui:getProcessor():newProcessor("question-updater")
|
local templateLog = log:child("template")
|
||||||
qUpdater.Start()
|
|
||||||
|
|
||||||
function LoadTemplate(name, path)
|
function LoadTemplate(name, path)
|
||||||
|
boardLog:debug("Loading Template: %s", name)
|
||||||
if love.filesystem.getInfo("templates/" .. name .. ".lua") then
|
if love.filesystem.getInfo(path .."/templates/" .. name .. ".lua") then
|
||||||
data = love.filesystem.read("templates/" .. name .. ".lua")
|
|
||||||
elseif love.filesystem.getInfo(path .."/templates/" .. name .. ".lua") then
|
|
||||||
data = love.filesystem.read(path .."/templates/" .. name .. ".lua")
|
data = love.filesystem.read(path .."/templates/" .. name .. ".lua")
|
||||||
|
elseif love.filesystem.getInfo("templates/" .. name .. ".lua") then
|
||||||
|
data = love.filesystem.read("templates/" .. name .. ".lua")
|
||||||
|
else
|
||||||
|
boardLog:error("Error Loading Template: %s", name)
|
||||||
|
gui:newMessageBox({
|
||||||
|
title = "Error!",
|
||||||
|
message = "Unable to load template: " .. name,
|
||||||
|
buttons = { "Yes", "No" },
|
||||||
|
onChoice = function(label, idx)
|
||||||
|
if label == "Yes" then
|
||||||
|
doCallback(selected)
|
||||||
|
pickerWindow.visible = false
|
||||||
|
pickerWindow:setTag("visual")
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local template, err = loadstring(data)
|
local template, err = loadstring(data)
|
||||||
@@ -154,7 +163,8 @@ function LoadTemplate(name, path)
|
|||||||
gui = gui,
|
gui = gui,
|
||||||
timer = timer,
|
timer = timer,
|
||||||
-- love stuff
|
-- love stuff
|
||||||
newSource = love.audio.newSource
|
newSource = love.audio.newSource,
|
||||||
|
log = templateLog
|
||||||
}
|
}
|
||||||
|
|
||||||
env._G = env
|
env._G = env
|
||||||
@@ -163,22 +173,98 @@ function LoadTemplate(name, path)
|
|||||||
return isoTemplate()
|
return isoTemplate()
|
||||||
end
|
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
|
||||||
|
end
|
||||||
|
|
||||||
|
function gui:cleanup()
|
||||||
|
for i = #self.children, 1, -1 do
|
||||||
|
self.children[i]:destroy()
|
||||||
|
end
|
||||||
|
self.children = {}
|
||||||
|
completed_questions = completed_questions + 1
|
||||||
|
end
|
||||||
|
|
||||||
|
local reset = boardUpdater:newConnection()
|
||||||
|
|
||||||
|
local default_text = "Pick a Category"
|
||||||
|
|
||||||
function Menu(frame, path)
|
function Menu(frame, path)
|
||||||
local qframe = frame:newFrame(0, 0, 0, 0, .2, .05, .75, .9)
|
boardLog:info("Building board")
|
||||||
qframe.color = color.new("#060ee9")
|
if path:match(".zip") then
|
||||||
local scoreboard = ScoreBoard(frame, 0, 0, 0, 0, .015, .05, .170, .9)
|
-- local basename = path:match("([^/\\]+)$")
|
||||||
|
local success = love.filesystem.mount(path, "quiz", true)
|
||||||
|
if not success then
|
||||||
|
gui:newMessageBox({
|
||||||
|
title = "Return to the main menu?",
|
||||||
|
message = "Couldn't load file: " .. path,
|
||||||
|
buttons = { "Return", "Quit" },
|
||||||
|
onChoice = function(label, idx)
|
||||||
|
if label == "Return" then
|
||||||
|
return menu.getMenu("title"):visible(true)
|
||||||
|
else
|
||||||
|
os.exit()
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
return
|
||||||
|
end
|
||||||
|
path = "quiz"
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Start the processors now
|
||||||
|
boardLog:debug("Starting processors")
|
||||||
|
boardUpdater.Start()
|
||||||
|
qUpdater.Start()
|
||||||
|
scoreUpdater.Start()
|
||||||
|
|
||||||
|
local scoreboard = ScoreBoard(frame, 0, 0, 0, 0, .06, .1, .170, .8)
|
||||||
|
|
||||||
|
local qframe = frame:newFrame(0, 0, 0, 0, .24, .1, .70, .8)
|
||||||
|
|
||||||
|
local label = frame:newTextLabel(default_text, 0, 10, 0, -20, .29, 0, .6, .1)
|
||||||
|
label.visibility = .85
|
||||||
|
label.drawBorder = false
|
||||||
|
label.align = gui.ALIGN_CENTER
|
||||||
|
label.color = color.bg
|
||||||
|
label.textColor = color.status_font
|
||||||
|
label:setRoundness(20,20,60)
|
||||||
|
|
||||||
|
boardUpdater:newThread(function()
|
||||||
|
local test = function()
|
||||||
|
return label.text ~= ""
|
||||||
|
end
|
||||||
|
while true do
|
||||||
|
thread.hold(test)
|
||||||
|
label:centerFont()
|
||||||
|
label:fitFont(nil, nil, {scale = 2/3})
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
local data = loader:new(path)
|
local data = loader:new(path)
|
||||||
board, question, dailydouble = qframe:newFrame(), qframe:newFrame(), qframe:newImageLabel("assets/images/double.jpg")
|
board, question, dailydouble = qframe:newFrame(), qframe:newFrame(), qframe:newImageLabel("assets/images/double.jpg")
|
||||||
index = data.index
|
index = data.index
|
||||||
|
|
||||||
|
local cosmetics = index.cosmetics or {}
|
||||||
|
manageCosmetics(frame, cosmetics)
|
||||||
|
|
||||||
board:fullFrame()
|
board:fullFrame()
|
||||||
question:fullFrame()
|
question:fullFrame()
|
||||||
dailydouble:fullFrame()
|
dailydouble:fullFrame()
|
||||||
|
|
||||||
dailydouble.visible = false
|
dailydouble.visible = false
|
||||||
question.visible = false
|
question.visible = false
|
||||||
question.color = color.new("#060ce9")
|
question.color = color.question_bg
|
||||||
|
|
||||||
local tiers = index.settings.tiers or 5
|
local tiers = index.settings.tiers or 5
|
||||||
local start = index.settings.start or 100
|
local start = index.settings.start or 100
|
||||||
@@ -190,6 +276,29 @@ function Menu(frame, path)
|
|||||||
min_questions = dd.minQuestions
|
min_questions = dd.minQuestions
|
||||||
dd_count = dd.count
|
dd_count = dd.count
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local autoreveal = false
|
||||||
|
if index.dev and index.dev.enabled then
|
||||||
|
if index.dev["auto-reveal"] then
|
||||||
|
autoreveal = true
|
||||||
|
end
|
||||||
|
if type(index.dev.players) == "table" then
|
||||||
|
for i,v in ipairs(index.dev.players) do
|
||||||
|
if type(v) == "string" then
|
||||||
|
scoreboard:AddPlayer(v, 0)
|
||||||
|
elseif type(v) == "table" then
|
||||||
|
scoreboard:AddPlayer(v.name, v.score, v.icon)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
reset(function()
|
||||||
|
question:cleanup()
|
||||||
|
manageCosmetics(frame, cosmetics, true)
|
||||||
|
label.text = default_text
|
||||||
|
end)
|
||||||
|
|
||||||
for cat,v in pairs(index.categories) do
|
for cat,v in pairs(index.categories) do
|
||||||
local c
|
local c
|
||||||
if v.image then
|
if v.image then
|
||||||
@@ -197,12 +306,13 @@ function Menu(frame, path)
|
|||||||
else
|
else
|
||||||
c = board:newTextLabel(v.displayName or v.name,0,0,0,0,(1/#index.categories)*(cat-1),0,1/#index.categories,1/(tiers+1))
|
c = board:newTextLabel(v.displayName or v.name,0,0,0,0,(1/#index.categories)*(cat-1),0,1/#index.categories,1/(tiers+1))
|
||||||
c.align = gui.ALIGN_CENTER
|
c.align = gui.ALIGN_CENTER
|
||||||
c.textColor = color.new("#ffffff")
|
c.textColor = color.header_font
|
||||||
c.color = color.new("#060ce9")
|
c.color = color.header_tile
|
||||||
end
|
end
|
||||||
|
|
||||||
c.UUID = multi.generate_uuid7() -- Each otpion gets a unique UUID
|
c.UUID = multi.generate_uuid7() -- Each otpion gets a unique UUID
|
||||||
|
|
||||||
|
if not autoreveal then
|
||||||
img = c:newImageButton("assets/images/placeholder.jpg")
|
img = c:newImageButton("assets/images/placeholder.jpg")
|
||||||
img.visibility = 0
|
img.visibility = 0
|
||||||
|
|
||||||
@@ -211,12 +321,15 @@ function Menu(frame, path)
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
img:fullFrame()
|
img:fullFrame()
|
||||||
|
end
|
||||||
|
|
||||||
table.insert(manage,c)
|
table.insert(manage,c)
|
||||||
|
|
||||||
for tier = 1,tiers do
|
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))
|
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))
|
||||||
t.textColor = color.new("#9b9024")
|
t.textColor = color.tile_font
|
||||||
t.align = gui.ALIGN_CENTER
|
t.align = gui.ALIGN_CENTER
|
||||||
t.color = color.new("#060ce9")
|
t.color = color.tile_bg
|
||||||
t.category = v.name
|
t.category = v.name
|
||||||
t.index = tier
|
t.index = tier
|
||||||
t.price = start + inc*(tier-1)
|
t.price = start + inc*(tier-1)
|
||||||
@@ -225,16 +338,31 @@ function Menu(frame, path)
|
|||||||
if dd_enabled then
|
if dd_enabled then
|
||||||
applyDD() -- check and run DD if conditions meet
|
applyDD() -- check and run DD if conditions meet
|
||||||
end
|
end
|
||||||
if index.categories[cat].questions == nil then fmt.Printf("Question not defined: File: %v Category: %v - %v\n",path,index.categories[cat].name,start + inc*(tier-1)) return end
|
if index.categories[cat].questions == nil then boardLog:info("Question not defined: File: %s Category: %s - %s\n",path,index.categories[cat].name,start + inc*(tier-1)) return end
|
||||||
|
local globals = index.categories[cat].global
|
||||||
|
if not globals then
|
||||||
|
globals = {}
|
||||||
|
end
|
||||||
local q = index.categories[cat].questions[self.index]
|
local q = index.categories[cat].questions[self.index]
|
||||||
if q == nil then fmt.Printf("Question contains no data: File: %v Category: %v Tier: %v\n",path,index.categories[cat].name,start + inc*(tier-1)) return end
|
if not q then return end
|
||||||
|
label.text = t.category .. " - " .. t.price
|
||||||
|
boardLog:debug("Displaying question for: %s - %s", t.category, t.price)
|
||||||
|
local mt = debug.getmetatable(q)
|
||||||
|
if mt then
|
||||||
|
mt.__metatable = nil
|
||||||
|
end
|
||||||
|
setmetatable(q, {__index = globals})
|
||||||
|
if q == nil then boardLog:info("Question contains no data: File: %s Category: %s Tier: %s\n",path,index.categories[cat].name,start + inc*(tier-1)) return end
|
||||||
|
if q.cosmetics then
|
||||||
|
manageCosmetics(frame, q.cosmetics)
|
||||||
|
end
|
||||||
self.textVisibility = 0
|
self.textVisibility = 0
|
||||||
local template = LoadTemplate(q.template, path)
|
local template = LoadTemplate(q.template, path)
|
||||||
question.visible = true
|
question.visible = true
|
||||||
local player = GetActivePlayer()
|
local player = GetActivePlayer()
|
||||||
local tm
|
local tm
|
||||||
local stop
|
local stop
|
||||||
fmt.Printf("--------------------\nQuestion: %v \nAnswer: %v\n--------------------\n",q["title"],q["answer"])
|
boardLog:info("Question: '%s' Answer: '%s'",q["title"],q["answer"])
|
||||||
local mul = 1
|
local mul = 1
|
||||||
boardUpdater:newThread(function()
|
boardUpdater:newThread(function()
|
||||||
if self.isDouble then
|
if self.isDouble then
|
||||||
@@ -255,7 +383,8 @@ function Menu(frame, path)
|
|||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
local finished = false
|
local finished = false
|
||||||
template.index(question, q, function(ans)
|
template.index(question, q, function(ans, m)
|
||||||
|
local m = m or 1
|
||||||
if finished then return end
|
if finished then return end
|
||||||
player = GetActivePlayer()
|
player = GetActivePlayer()
|
||||||
if tm then
|
if tm then
|
||||||
@@ -263,17 +392,17 @@ function Menu(frame, path)
|
|||||||
end
|
end
|
||||||
stop = true
|
stop = true
|
||||||
if ans then
|
if ans then
|
||||||
player:Add(self.price*mul)
|
player:Add((self.price*mul)*m)
|
||||||
finished = true
|
finished = true
|
||||||
question.visible = false
|
question.visible = false
|
||||||
question:cleanup()
|
reset:Fire()
|
||||||
elseif ans == false then
|
elseif ans == false then
|
||||||
player:Add(-self.price*mul)
|
player:Add(-self.price*mul)
|
||||||
player = GetNextPlayer()
|
player = GetNextPlayer()
|
||||||
else
|
else
|
||||||
finished = true
|
finished = true
|
||||||
question.visible = false
|
question.visible = false
|
||||||
question:cleanup()
|
reset:Fire()
|
||||||
end -- nil is a valid option where you weren't right or wrong, you just skipped
|
end -- nil is a valid option where you weren't right or wrong, you just skipped
|
||||||
self.text = ""
|
self.text = ""
|
||||||
end)
|
end)
|
||||||
@@ -296,8 +425,7 @@ function Menu(frame, path)
|
|||||||
return background
|
return background
|
||||||
end
|
end
|
||||||
|
|
||||||
scoreUpdater = gui:getProcessor():newProcessor("score-updater")
|
|
||||||
scoreUpdater.Start()
|
|
||||||
|
|
||||||
function GetActivePlayer()
|
function GetActivePlayer()
|
||||||
if not activePlayer then return end
|
if not activePlayer then return end
|
||||||
@@ -407,7 +535,7 @@ function ScoreBoard(frame, x, y, w, h, sx, sy, sw, sh)
|
|||||||
function scoreboard:AddPlayer(name, score, icon)
|
function scoreboard:AddPlayer(name, score, icon)
|
||||||
local player = {
|
local player = {
|
||||||
Name = name,
|
Name = name,
|
||||||
Score = score,
|
Score = score or 0,
|
||||||
Icon = icon,
|
Icon = icon,
|
||||||
UUID = multi.generate_uuid7(),
|
UUID = multi.generate_uuid7(),
|
||||||
Add = function(self, amt)
|
Add = function(self, amt)
|
||||||
|
|||||||
@@ -1,54 +0,0 @@
|
|||||||
local gui = require("gui")
|
|
||||||
local menu = {}
|
|
||||||
local menus = {}
|
|
||||||
local frame
|
|
||||||
local menuRef = {}
|
|
||||||
local mt = {
|
|
||||||
__index = menuRef
|
|
||||||
}
|
|
||||||
|
|
||||||
function menu.registerMenu(name, menu, delete)
|
|
||||||
local c = {}
|
|
||||||
c.MenuFunc = menu
|
|
||||||
c.Delete = delete
|
|
||||||
setmetatable(c, mt)
|
|
||||||
menus[name] = c
|
|
||||||
return c
|
|
||||||
end
|
|
||||||
|
|
||||||
function menu.getMenu(name)
|
|
||||||
return menus[name] or nil, "Menu ".. name .. " not found."
|
|
||||||
end
|
|
||||||
|
|
||||||
function menu.init(f)
|
|
||||||
frame = f
|
|
||||||
end
|
|
||||||
|
|
||||||
function menu.hideMenus()
|
|
||||||
for k,v in pairs(menus) do
|
|
||||||
if v.frame then
|
|
||||||
if v.Delete then
|
|
||||||
v.frame:destroy()
|
|
||||||
menus[k] = nil
|
|
||||||
else
|
|
||||||
v.frame.visible = false
|
|
||||||
v.frame.active = false
|
|
||||||
v.frame:setParent(gui.virtual)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function menuRef:visible(value, ...)
|
|
||||||
menu.hideMenus()
|
|
||||||
if self.__menuConfigured and self.frame then
|
|
||||||
self.frame.visible = true
|
|
||||||
self.frame.active = true
|
|
||||||
self.frame:setParent(frame)
|
|
||||||
else
|
|
||||||
self.__menuConfigured = true
|
|
||||||
self.frame = self.MenuFunc(frame, ...)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
return menu
|
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
local gui = require("gui")
|
local gui = require("gui")
|
||||||
local color = require("gui.core.color")
|
local color = require("gui.core.color")
|
||||||
local menu = require("menus.menus")
|
local menu = require("gui.core.menus")
|
||||||
-- local proc = gui:getProcessor():newProcessor("settings")
|
-- local proc = gui:getProcessor():newProcessor("settings")
|
||||||
|
|
||||||
function Menu(frame)
|
function Menu(frame)
|
||||||
|
|||||||
@@ -1,16 +1,21 @@
|
|||||||
local gui = require("gui")
|
local gui = require("gui")
|
||||||
local color = require("gui.core.color")
|
local color = require("gui.core.color")
|
||||||
local menu = require("menus.menus")
|
local menu = require("gui.core.menus")
|
||||||
local proc = gui:getProcessor():newProcessor("main-title")
|
local proc = gui:getProcessor():newProcessor("main-title")
|
||||||
|
|
||||||
|
local APP_VERSION = love.filesystem.read("version.txt")
|
||||||
|
|
||||||
local board = require("menus.board")
|
local board = require("menus.board")
|
||||||
|
|
||||||
|
local titleLog = log:child("title")
|
||||||
|
|
||||||
function Menu(frame)
|
function Menu(frame)
|
||||||
local background = frame:newImageLabel("assets/images/background.jpg")
|
local background = frame:newImageLabel("assets/images/background.jpg")
|
||||||
background:fullFrame()
|
background:fullFrame()
|
||||||
local title = frame:newTextLabel("Jeopardy",0,0,0,0,0,.1,1,.25)
|
local title = background:newTextLabel("Jeopardy",0,0,0,0,0,.1,1,.25)
|
||||||
title:setFont("assets/fonts/gyparody.ttf",300)
|
title:setFont("assets/fonts/gyparody.ttf",300)
|
||||||
|
|
||||||
|
titleLog:debug("Setting title shader")
|
||||||
title:setShader(gui.SHADERS.vignette,{
|
title:setShader(gui.SHADERS.vignette,{
|
||||||
intensity = .5,
|
intensity = .5,
|
||||||
smoothness = .8
|
smoothness = .8
|
||||||
@@ -18,9 +23,10 @@ function Menu(frame)
|
|||||||
|
|
||||||
title.align = gui.ALIGN_CENTER
|
title.align = gui.ALIGN_CENTER
|
||||||
title.visibility = 0
|
title.visibility = 0
|
||||||
title.textColor = color.new("#b16d24")
|
title.textColor = color.title_font
|
||||||
title.drawBorder = false
|
title.drawBorder = false
|
||||||
|
|
||||||
|
titleLog:debug("Creating font thread")
|
||||||
proc:newThread(function()
|
proc:newThread(function()
|
||||||
local function enabled()
|
local function enabled()
|
||||||
return background.visible
|
return background.visible
|
||||||
@@ -62,9 +68,46 @@ function Menu(frame)
|
|||||||
},play,settings,quit)
|
},play,settings,quit)
|
||||||
|
|
||||||
play:OnReleased(function()
|
play:OnReleased(function()
|
||||||
background.visible = false
|
titleLog:debug("Play button pressed")
|
||||||
menu.getMenu("board"):visible(true,"anime")
|
if love.filesystem.getInfo("quiz") then
|
||||||
|
menu.getMenu("board"):visible(true, "quiz")
|
||||||
|
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))
|
||||||
end)
|
end)
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
|
quit:OnReleased(function()
|
||||||
|
titleLog:debug("Quit button pressed")
|
||||||
|
local f = frame:newFrame()
|
||||||
|
f:fullFrame()
|
||||||
|
f.visibility = .8
|
||||||
|
f.color = color.black
|
||||||
|
local cm = menu.getCurrentMenu()
|
||||||
|
cm:setTag("visual")
|
||||||
|
quit:setShader()
|
||||||
|
gui:newMessageBox({
|
||||||
|
title = "Confirm",
|
||||||
|
message = "Are you sure you want to exit the game?",
|
||||||
|
buttons = { "Yes", "No" },
|
||||||
|
onChoice = function(label, idx)
|
||||||
|
if label == "Yes" then os.exit() end
|
||||||
|
cm:removeTag("visual")
|
||||||
|
f:destroy()
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
end)
|
||||||
|
|
||||||
|
local version = frame:newTextLabel("Version: " .. APP_VERSION, -150,-30, 150, 30, 1, 1)
|
||||||
|
thread:newThread(function()
|
||||||
|
thread.skip(2)
|
||||||
|
version:fitFont()
|
||||||
|
end)
|
||||||
|
version.textColor = color.new("#b16d24")
|
||||||
|
version.visibility = 0
|
||||||
|
|
||||||
return background
|
return background
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -0,0 +1,19 @@
|
|||||||
|
:: Read the first line of version.txt and assign it to the MY_VERSION variable
|
||||||
|
for /f "usebackq delims=" %%i in ("version.txt") do (
|
||||||
|
set "userInput=%%i"
|
||||||
|
goto :done
|
||||||
|
)
|
||||||
|
|
||||||
|
:done
|
||||||
|
"C:\Program Files\7-Zip\7z.exe" a -tzip game.love templates version.txt assets multi\integration\loveManager multi\integration\sharedExtensions multi\init.lua utils gui menus conf.lua main.lua
|
||||||
|
rd /s /q "bin\%userInput%"
|
||||||
|
if not exist "bin\%userInput%" mkdir "bin\%userInput%"
|
||||||
|
copy /b love\love.exe + game.love "bin\%userInput%\Jeopardy.exe"
|
||||||
|
copy /b love\love.dll "bin\%userInput%\love.dll"
|
||||||
|
copy /b lovel\lua51.dll "bin\%userInput%\lua51.dll"
|
||||||
|
copy /b love\mpg123.dll "bin\%userInput%\mpg123.dll"
|
||||||
|
copy /b love\msvcp120.dll "bin\%userInput%\msvcp120.dll"
|
||||||
|
copy /b love\msvcr120.dll "bin\%userInput%\msvcr120.dll"
|
||||||
|
copy /b love\OpenAL32.dll "bin\%userInput%\OpenAL32.dll"
|
||||||
|
copy /b love\SDL2.dll "bin\%userInput%\SDL2.dll"
|
||||||
|
copy /b love\license.txt "bin\%userInput%\license.txt"
|
||||||
|
Before Width: | Height: | Size: 29 KiB |
@@ -9,8 +9,8 @@ local function index(window, q, callback)
|
|||||||
label = window:newTextLabel(" " ..q.title.. " ",0,0,0,0,0,0,1,.2)
|
label = window:newTextLabel(" " ..q.title.. " ",0,0,0,0,0,0,1,.2)
|
||||||
label.align = ALIGN_CENTER
|
label.align = ALIGN_CENTER
|
||||||
label.textColor = color.white
|
label.textColor = color.white
|
||||||
label.color = color.new("#060ce9")
|
label.color = color.new("#363ac8")
|
||||||
label.borderColor = color.new("#060ce9")
|
label.borderColor = color.new("#363ac8")
|
||||||
|
|
||||||
if not q.imageA or q.imageA == "" then
|
if not q.imageA or q.imageA == "" then
|
||||||
error("Missing 'imageA' field for question!")
|
error("Missing 'imageA' field for question!")
|
||||||
|
|||||||
@@ -21,10 +21,10 @@ local function index(window, q, callback)
|
|||||||
label = window:newTextLabel(" " ..q.title.. " ",noOf(0,0,1,.3))
|
label = window:newTextLabel(" " ..q.title.. " ",noOf(0,0,1,.3))
|
||||||
label.align = ALIGN_CENTER
|
label.align = ALIGN_CENTER
|
||||||
label.textColor = color.white
|
label.textColor = color.white
|
||||||
label.color = color.new("#060ce9")
|
label.color = color.new("#363ac8")
|
||||||
label:setFont(50)
|
label:setFont(50)
|
||||||
choices = window:newFrame(noOf(0,.3,1,.7))
|
choices = window:newFrame(noOf(0,.3,1,.7))
|
||||||
choices.color = color.new("#060ce9")
|
choices.color = color.new("#363ac8")
|
||||||
|
|
||||||
function choices:newChoice(choice, i)
|
function choices:newChoice(choice, i)
|
||||||
local c = choices:newFrame(noOf(.25,(i-1)/#q.choices,.5,1/#q.choices))
|
local c = choices:newFrame(noOf(.25,(i-1)/#q.choices,.5,1/#q.choices))
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ local function index(window, q, callback)
|
|||||||
label = window:newTextLabel(" " ..q.title.. " ",0,0,0,0,0,0,1,.2)
|
label = window:newTextLabel(" " ..q.title.. " ",0,0,0,0,0,0,1,.2)
|
||||||
label.align = ALIGN_CENTER
|
label.align = ALIGN_CENTER
|
||||||
label.textColor = color.white
|
label.textColor = color.white
|
||||||
label.color = color.new("#060ce9")
|
label.color = color.new("#363ac8")
|
||||||
if not q.image or q.image == "" then
|
if not q.image or q.image == "" then
|
||||||
error("Missing 'image' field for question!")
|
error("Missing 'image' field for question!")
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ local function index(window, q, callback)
|
|||||||
label.align = ALIGN_CENTER
|
label.align = ALIGN_CENTER
|
||||||
label:fullFrame()
|
label:fullFrame()
|
||||||
label.textColor = color.white
|
label.textColor = color.white
|
||||||
label.color = color.new("#060ce9")
|
label.color = color.new("#363ac8")
|
||||||
local correct = window:newTextButton("Correct",0,-200,0,100,0,1,.5)
|
local correct = window:newTextButton("Correct",0,-200,0,100,0,1,.5)
|
||||||
correct.color = color.new("#52b11b")
|
correct.color = color.new("#52b11b")
|
||||||
local wrong = window:newTextButton("Wrong",0,-200,0,100,.5,1,.5)
|
local wrong = window:newTextButton("Wrong",0,-200,0,100,.5,1,.5)
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ local function index(window, q, callback)
|
|||||||
label = window:newTextLabel(" " ..q.title.. " ",0,0,0,0,0,0,1,.2)
|
label = window:newTextLabel(" " ..q.title.. " ",0,0,0,0,0,0,1,.2)
|
||||||
label.align = ALIGN_CENTER
|
label.align = ALIGN_CENTER
|
||||||
label.textColor = color.white
|
label.textColor = color.white
|
||||||
label.color = color.new("#060ce9")
|
label.color = color.new("#363ac8")
|
||||||
imageHolder = frame:newImageButton("assets/images/speaker.png",0,0,0,0,0,0,.3,.4)
|
imageHolder = frame:newImageButton("assets/images/speaker.png",0,0,0,0,0,0,.3,.4)
|
||||||
imageHolder:setAspectSize(imageHolder.imageWidth,imageHolder.imageHeight)
|
imageHolder:setAspectSize(imageHolder.imageWidth,imageHolder.imageHeight)
|
||||||
imageHolder:centerX(true)
|
imageHolder:centerX(true)
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ local function index(window, q, callback)
|
|||||||
label = window:newTextLabel(" " ..q.title.. " ",0,0,0,0,0,0,1,.2)
|
label = window:newTextLabel(" " ..q.title.. " ",0,0,0,0,0,0,1,.2)
|
||||||
label.align = ALIGN_CENTER
|
label.align = ALIGN_CENTER
|
||||||
label.textColor = color.white
|
label.textColor = color.white
|
||||||
label.color = color.new("#060ce9")
|
label.color = color.new("#363ac8")
|
||||||
local holder = frame:newFrame(-300, -200, 600, 400, .5, .5)
|
local holder = frame:newFrame(-300, -200, 600, 400, .5, .5)
|
||||||
holder:centerX(true)
|
holder:centerX(true)
|
||||||
holder:centerY(true)
|
holder:centerY(true)
|
||||||
|
|||||||
@@ -0,0 +1,197 @@
|
|||||||
|
--- test_logger.lua — Demonstrates and tests all logger.lua features
|
||||||
|
|
||||||
|
-- Adjust path if needed
|
||||||
|
package.path = "./?.lua;" .. package.path
|
||||||
|
local Logger = require("utils/logger")
|
||||||
|
|
||||||
|
local PASS = 0
|
||||||
|
local FAIL = 0
|
||||||
|
|
||||||
|
local function test(label, cond)
|
||||||
|
if cond then
|
||||||
|
print(string.format(" [PASS] %s", label))
|
||||||
|
PASS = PASS + 1
|
||||||
|
else
|
||||||
|
io.stderr:write(string.format(" [FAIL] %s\n", label))
|
||||||
|
FAIL = FAIL + 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
print("━━━ logger.lua test suite ━━━\n")
|
||||||
|
|
||||||
|
-- ── 1. Basic levels ────────────────────────────────────────────────────────
|
||||||
|
print("▶ 1. Basic level output (INFO+)")
|
||||||
|
do
|
||||||
|
local handler, get, clear = Logger.handlers.MemoryHandler()
|
||||||
|
local log = Logger.new("basic", { level = Logger.LEVELS.INFO, handlers = { handler } })
|
||||||
|
|
||||||
|
log:trace("should be filtered")
|
||||||
|
log:debug("should be filtered")
|
||||||
|
log:info("hello %s", "world")
|
||||||
|
log:warn("disk %d%%", 90)
|
||||||
|
log:error("boom")
|
||||||
|
log:fatal("catastrophe")
|
||||||
|
|
||||||
|
local records = get()
|
||||||
|
test("TRACE filtered", records[1].level == Logger.LEVELS.INFO)
|
||||||
|
test("INFO captured", records[1].message == "hello world")
|
||||||
|
test("WARN captured", records[2].message == "disk 90%")
|
||||||
|
test("ERROR captured", records[3].level == Logger.LEVELS.ERROR)
|
||||||
|
test("FATAL captured", records[4].level == Logger.LEVELS.FATAL)
|
||||||
|
test("exactly 4 records", #records == 4)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- ── 2. Level filtering ─────────────────────────────────────────────────────
|
||||||
|
print("\n▶ 2. Dynamic level changes")
|
||||||
|
do
|
||||||
|
local handler, get = Logger.handlers.MemoryHandler()
|
||||||
|
local log = Logger.new("dyn", { handlers = { handler } })
|
||||||
|
|
||||||
|
log:set_level(Logger.LEVELS.DEBUG)
|
||||||
|
log:debug("visible")
|
||||||
|
log:set_level(Logger.LEVELS.ERROR)
|
||||||
|
log:info("invisible")
|
||||||
|
log:error("visible again")
|
||||||
|
|
||||||
|
local records = get()
|
||||||
|
test("DEBUG visible at DEBUG level", records[1].message == "visible")
|
||||||
|
test("INFO invisible at ERROR level", records[2].message == "visible again")
|
||||||
|
test("total 2 records", #records == 2)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- ── 3. is_enabled ──────────────────────────────────────────────────────────
|
||||||
|
print("\n▶ 3. is_enabled()")
|
||||||
|
do
|
||||||
|
local log = Logger.new("enabled", { level = Logger.LEVELS.WARN })
|
||||||
|
test("WARN enabled", log:is_enabled(Logger.LEVELS.WARN))
|
||||||
|
test("INFO disabled", not log:is_enabled(Logger.LEVELS.INFO))
|
||||||
|
test("ERROR enabled", log:is_enabled(Logger.LEVELS.ERROR))
|
||||||
|
end
|
||||||
|
|
||||||
|
-- ── 4. Custom format ───────────────────────────────────────────────────────
|
||||||
|
print("\n▶ 4. Custom format string")
|
||||||
|
do
|
||||||
|
local handler, get = Logger.handlers.MemoryHandler()
|
||||||
|
local log = Logger.new("fmt", {
|
||||||
|
format = "{level}|{name}|{message}",
|
||||||
|
handlers = { handler },
|
||||||
|
})
|
||||||
|
log:info("hi")
|
||||||
|
local f = get()[1].formatted
|
||||||
|
test("contains level", f:find("INFO") ~= nil)
|
||||||
|
test("contains name", f:find("fmt") ~= nil)
|
||||||
|
test("contains message", f:find("hi") ~= nil)
|
||||||
|
test("pipe separator", f:find("|") ~= nil)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- ── 5. Filters ─────────────────────────────────────────────────────────────
|
||||||
|
print("\n▶ 5. Custom filter")
|
||||||
|
do
|
||||||
|
local handler, get = Logger.handlers.MemoryHandler()
|
||||||
|
local log = Logger.new("filter", { level = Logger.LEVELS.DEBUG, handlers = { handler } })
|
||||||
|
|
||||||
|
-- only pass records whose message contains "keep"
|
||||||
|
log:add_filter(function(rec) return rec.message:find("keep") ~= nil end)
|
||||||
|
|
||||||
|
log:info("drop this")
|
||||||
|
log:info("keep this")
|
||||||
|
log:warn("also drop")
|
||||||
|
log:debug("keep me too")
|
||||||
|
|
||||||
|
local records = get()
|
||||||
|
test("only 'keep' records pass", #records == 2)
|
||||||
|
test("first kept record", records[1].message == "keep this")
|
||||||
|
test("second kept record", records[2].message == "keep me too")
|
||||||
|
end
|
||||||
|
|
||||||
|
-- ── 6. Multiple handlers ───────────────────────────────────────────────────
|
||||||
|
print("\n▶ 6. Multiple handlers")
|
||||||
|
do
|
||||||
|
local h1, get1 = Logger.handlers.MemoryHandler()
|
||||||
|
local h2, get2 = Logger.handlers.MemoryHandler()
|
||||||
|
local log = Logger.new("multi", { handlers = { h1 } })
|
||||||
|
log:add_handler(h2)
|
||||||
|
|
||||||
|
log:info("broadcast")
|
||||||
|
|
||||||
|
test("handler1 received", #get1() == 1)
|
||||||
|
test("handler2 received", #get2() == 1)
|
||||||
|
test("same message", get1()[1].message == get2()[1].message)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- ── 7. Child loggers ───────────────────────────────────────────────────────
|
||||||
|
print("\n▶ 7. Child loggers")
|
||||||
|
do
|
||||||
|
local handler, get = Logger.handlers.MemoryHandler()
|
||||||
|
local parent = Logger.new("app", { handlers = { handler } })
|
||||||
|
local child = parent:child("db")
|
||||||
|
|
||||||
|
parent:info("parent message")
|
||||||
|
child:info("child message")
|
||||||
|
|
||||||
|
local records = get()
|
||||||
|
test("parent name", records[1].name == "app")
|
||||||
|
test("child name", records[2].name == "app.db")
|
||||||
|
test("child shares handler", #records == 2)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- ── 8. Logger.get() registry ──────────────────────────────────────────────
|
||||||
|
print("\n▶ 8. Logger.get() registry")
|
||||||
|
do
|
||||||
|
local a = Logger.get("svc.auth")
|
||||||
|
local b = Logger.get("svc.auth")
|
||||||
|
test("same instance returned", a == b)
|
||||||
|
|
||||||
|
local c = Logger.get("svc.payments")
|
||||||
|
test("different names differ", a ~= c)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- ── 9. Format with no args ────────────────────────────────────────────────
|
||||||
|
print("\n▶ 9. Message with no format args")
|
||||||
|
do
|
||||||
|
local handler, get = Logger.handlers.MemoryHandler()
|
||||||
|
local log = Logger.new("noargs", { handlers = { handler } })
|
||||||
|
log:info("plain string, no args")
|
||||||
|
test("plain string works", get()[1].message == "plain string, no args")
|
||||||
|
end
|
||||||
|
|
||||||
|
-- ── 10. FileHandler ───────────────────────────────────────────────────────
|
||||||
|
print("\n▶ 10. FileHandler")
|
||||||
|
do
|
||||||
|
local path = "test_logger_output.log"
|
||||||
|
os.remove(path)
|
||||||
|
|
||||||
|
local fh = Logger.handlers.FileHandler({ path = path })
|
||||||
|
local log = Logger.new("file", { handlers = { fh } })
|
||||||
|
log:info("written to file")
|
||||||
|
log:warn("second line")
|
||||||
|
|
||||||
|
local f = io.open(path)
|
||||||
|
local content = f and f:read("*a") or ""
|
||||||
|
if f then f:close() end
|
||||||
|
|
||||||
|
test("file created", content ~= "")
|
||||||
|
test("INFO line present", content:find("written to file") ~= nil)
|
||||||
|
test("WARN line present", content:find("second line") ~= nil)
|
||||||
|
test("two newlines", select(2, content:gsub("\n","")) == 2)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- ── 11. Console handler (visual) ──────────────────────────────────────────
|
||||||
|
print("\n▶ 11. ConsoleHandler — visual check (colours enabled)")
|
||||||
|
do
|
||||||
|
local log = Logger.new("visual", {
|
||||||
|
level = Logger.LEVELS.TRACE,
|
||||||
|
handlers = { Logger.handlers.ConsoleHandler({ colours = true }) },
|
||||||
|
})
|
||||||
|
log:trace("trace message")
|
||||||
|
log:debug("debug message")
|
||||||
|
log:info ("info message")
|
||||||
|
log:warn ("warn message")
|
||||||
|
log:error("error message")
|
||||||
|
log:fatal("fatal message")
|
||||||
|
test("no crash", true)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- ── Summary ────────────────────────────────────────────────────────────────
|
||||||
|
print(string.format("\n━━━ Results: %d passed, %d failed ━━━", PASS, FAIL))
|
||||||
|
if FAIL > 0 then os.exit(1) end
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
[2026-06-08 19:40:49] [INFO ] [file] written to file
|
||||||
|
[2026-06-08 19:40:49] [WARN ] [file] second line
|
||||||
@@ -1,245 +0,0 @@
|
|||||||
-- local gui = require("gui")
|
|
||||||
-- local color = require("gui.core.color")
|
|
||||||
-- local transition = require("gui.core.transitions")
|
|
||||||
-- local multi = require("multi"):init()
|
|
||||||
-- local timer = transition.glide(3.5,1.5,5)
|
|
||||||
|
|
||||||
-- local function startTimer(opt)
|
|
||||||
-- local default = {
|
|
||||||
-- duration = 30,
|
|
||||||
-- autoText = true,
|
|
||||||
-- autoColor = true,
|
|
||||||
-- autoCleanup = true,
|
|
||||||
-- startColor = color.green,
|
|
||||||
-- textColor = color.black,
|
|
||||||
-- warnColor = color.yellow,
|
|
||||||
-- timeColor = color.red,
|
|
||||||
-- finegrained = false,
|
|
||||||
-- visibility = 1
|
|
||||||
-- }
|
|
||||||
|
|
||||||
-- if type(opt) == "number" then
|
|
||||||
-- local d = opt
|
|
||||||
-- opt = default
|
|
||||||
-- opt.duration = d
|
|
||||||
-- elseif type(opt) ~= "table" then
|
|
||||||
-- opt = default
|
|
||||||
-- elseif type(opt) == "table" then
|
|
||||||
-- for i,v in pairs(opt) do
|
|
||||||
-- default[i] = v
|
|
||||||
-- end
|
|
||||||
-- opt = default
|
|
||||||
-- end
|
|
||||||
|
|
||||||
-- local timeRemaining = opt.duration or 30
|
|
||||||
|
|
||||||
-- transition.glide:SetFPS(60)
|
|
||||||
-- local handle = timer(3.5, 1.5, timeRemaining)
|
|
||||||
-- local tpie = gui:newFrame():makeArc("pie",-200, 0, 100,1 ,0 ,0 ,1.5*math.pi, 3.5*math.pi, 360)
|
|
||||||
-- local tlabel = tpie:newTextLabel("")
|
|
||||||
-- tlabel.textColor = opt.textColor
|
|
||||||
-- tlabel.align = gui.ALIGN_CENTER
|
|
||||||
-- tlabel:fullFrame()
|
|
||||||
-- tlabel.visibility = 0
|
|
||||||
-- tpie.color = opt.startColor
|
|
||||||
-- tpie.visibility = opt.visibility
|
|
||||||
|
|
||||||
-- local tm, num
|
|
||||||
-- local func = function(p,t)
|
|
||||||
-- if num ~= timeRemaining-math.floor(t) then
|
|
||||||
-- num = timeRemaining-math.floor(t)
|
|
||||||
-- end
|
|
||||||
|
|
||||||
-- if opt.autoColor then
|
|
||||||
-- tpie.color = opt.startColor
|
|
||||||
-- if num <= timeRemaining/3 then
|
|
||||||
-- tpie.color = opt.timeColor
|
|
||||||
-- elseif num <= timeRemaining/2 then
|
|
||||||
-- tpie.color = opt.warnColor
|
|
||||||
-- end
|
|
||||||
-- end
|
|
||||||
|
|
||||||
-- tpie:makeArc("pie", -200, 0, 100, 1, 0, 0, 1.5 * math.pi, p * math.pi, 360)
|
|
||||||
|
|
||||||
-- if opt.autoText then
|
|
||||||
-- tlabel.text = num
|
|
||||||
-- tlabel:fitFont(nil, nil, {scale=1/2})
|
|
||||||
-- tlabel:centerFont()
|
|
||||||
-- end
|
|
||||||
|
|
||||||
-- if num == 0 then
|
|
||||||
-- thread:newThread("Pie Timer",function()
|
|
||||||
-- thread.yield()
|
|
||||||
-- if opt.autoText then
|
|
||||||
-- tlabel.text = "Time"
|
|
||||||
-- tlabel:fitFont(nil, nil, {scale=1/2})
|
|
||||||
-- tlabel:centerFont()
|
|
||||||
-- end
|
|
||||||
-- tpie:makeArc("pie", -200, 0, 100, 1, 0, 0, 1.5 * math.pi, 3.5 * math.pi, 360)
|
|
||||||
-- tm.OnStop:Fire(tm)
|
|
||||||
-- if opt.autoCleanup then
|
|
||||||
-- tm:Cleanup()
|
|
||||||
-- end
|
|
||||||
-- tm.OnTime:Destroy()
|
|
||||||
-- tm.OnStop:Destroy()
|
|
||||||
-- end)
|
|
||||||
-- end
|
|
||||||
|
|
||||||
-- return tm, num, t
|
|
||||||
-- end
|
|
||||||
|
|
||||||
-- tm = {
|
|
||||||
-- Duration = timeRemaining,
|
|
||||||
-- Cleanup = function() handle:Kill() tpie:destroy() tm.Cleanup = function() end end,
|
|
||||||
-- SetText = function(str) tlabel.text = str end,
|
|
||||||
-- SetColor = function(c) tpie.color = c end,
|
|
||||||
-- OnStop = multi:newConnection()
|
|
||||||
-- }
|
|
||||||
|
|
||||||
-- if opt.finegrained then
|
|
||||||
-- tm.OnTime = func % handle.OnStep
|
|
||||||
-- else
|
|
||||||
-- tm.OnTime = function(self, sec, t) return math.floor(t) == t, self, sec end / (func % handle.OnStep)
|
|
||||||
-- end
|
|
||||||
|
|
||||||
-- return tm
|
|
||||||
-- end
|
|
||||||
|
|
||||||
-- return {
|
|
||||||
-- startTimer = startTimer
|
|
||||||
-- }
|
|
||||||
|
|
||||||
local gui = require("gui")
|
|
||||||
local color = require("gui.core.color")
|
|
||||||
local multi, thread = require("multi"):init()
|
|
||||||
|
|
||||||
local function startTimer(opt)
|
|
||||||
local default = {
|
|
||||||
duration = 30,
|
|
||||||
autoText = true,
|
|
||||||
autoColor = true,
|
|
||||||
autoCleanup = false,
|
|
||||||
startColor = color.green,
|
|
||||||
textColor = color.black,
|
|
||||||
warnColor = color.yellow,
|
|
||||||
timeColor = color.red,
|
|
||||||
finegrained = false,
|
|
||||||
visibility = 1
|
|
||||||
}
|
|
||||||
|
|
||||||
if type(opt) == "number" then
|
|
||||||
local d = opt
|
|
||||||
opt = default
|
|
||||||
opt.duration = d
|
|
||||||
elseif type(opt) ~= "table" then
|
|
||||||
opt = default
|
|
||||||
else
|
|
||||||
for i, v in pairs(opt) do
|
|
||||||
default[i] = v
|
|
||||||
end
|
|
||||||
opt = default
|
|
||||||
end
|
|
||||||
|
|
||||||
local timeRemaining = opt.duration or 30
|
|
||||||
|
|
||||||
local tpie = gui:newFrame():makeArc("pie", -200, 0, 100, 1, 0, 0, 1.5*math.pi, 3.5*math.pi, 360)
|
|
||||||
local tlabel = tpie:newTextLabel("")
|
|
||||||
tlabel.textColor = opt.textColor
|
|
||||||
tlabel.align = gui.ALIGN_CENTER
|
|
||||||
tlabel:fullFrame()
|
|
||||||
tlabel.visibility = 0
|
|
||||||
tpie.color = opt.startColor
|
|
||||||
tpie.visibility = opt.visibility
|
|
||||||
|
|
||||||
local tm
|
|
||||||
local stopped = false
|
|
||||||
local onTimeConn = multi:newConnection()
|
|
||||||
local onStopConn = multi:newConnection()
|
|
||||||
|
|
||||||
local function cleanup()
|
|
||||||
if stopped then return end
|
|
||||||
stopped = true
|
|
||||||
if onTimeConn and not onTimeConn.destroyed then
|
|
||||||
onTimeConn:Destroy()
|
|
||||||
end
|
|
||||||
if not tpie.destroyed then
|
|
||||||
tpie:destroy()
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local timerThread = thread:newThread("Pie Timer", function()
|
|
||||||
local startTime = love.timer.getTime()
|
|
||||||
local lastSecond = timeRemaining
|
|
||||||
|
|
||||||
while not stopped do
|
|
||||||
thread.sleep(1/60)
|
|
||||||
|
|
||||||
local now = love.timer.getTime()
|
|
||||||
local elapsed = now - startTime
|
|
||||||
local t = math.min(elapsed, timeRemaining)
|
|
||||||
local num = timeRemaining - math.floor(t)
|
|
||||||
local p = 3.5 - (t / timeRemaining) * 2
|
|
||||||
|
|
||||||
if opt.autoColor then
|
|
||||||
tpie.color = opt.startColor
|
|
||||||
if num <= timeRemaining / 3 then
|
|
||||||
tpie.color = opt.timeColor
|
|
||||||
elseif num <= timeRemaining / 2 then
|
|
||||||
tpie.color = opt.warnColor
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
tpie:makeArc("pie", -200, 0, 100, 1, 0, 0, 1.5*math.pi, p*math.pi, 360)
|
|
||||||
|
|
||||||
if opt.autoText then
|
|
||||||
tlabel.text = num
|
|
||||||
tlabel:fitFont(nil, nil, {scale=1/2})
|
|
||||||
tlabel:centerFont()
|
|
||||||
end
|
|
||||||
|
|
||||||
if opt.finegrained then
|
|
||||||
onTimeConn:Fire(tm, num, t)
|
|
||||||
elseif num < lastSecond then
|
|
||||||
-- crossed a second boundary
|
|
||||||
lastSecond = num
|
|
||||||
onTimeConn:Fire(tm, num, t)
|
|
||||||
end
|
|
||||||
|
|
||||||
if elapsed >= timeRemaining then
|
|
||||||
break
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Timer finished
|
|
||||||
if stopped then return end
|
|
||||||
|
|
||||||
if opt.autoText then
|
|
||||||
tlabel.text = "Time"
|
|
||||||
tlabel:fitFont(nil, nil, {scale=1/2})
|
|
||||||
tlabel:centerFont()
|
|
||||||
end
|
|
||||||
tpie:makeArc("pie", -200, 0, 100, 1, 0, 0, 1.5*math.pi, 3.5*math.pi, 360)
|
|
||||||
|
|
||||||
local onStop = onStopConn
|
|
||||||
cleanup()
|
|
||||||
onStop:Fire(tm)
|
|
||||||
end)
|
|
||||||
|
|
||||||
tm = {
|
|
||||||
Duration = timeRemaining,
|
|
||||||
OnTime = onTimeConn,
|
|
||||||
OnStop = onStopConn,
|
|
||||||
SetText = function(str) tlabel.text = str end,
|
|
||||||
SetColor = function(c) tpie.color = c end,
|
|
||||||
Cleanup = function()
|
|
||||||
timerThread:Kill()
|
|
||||||
cleanup()
|
|
||||||
end,
|
|
||||||
}
|
|
||||||
|
|
||||||
return tm
|
|
||||||
end
|
|
||||||
|
|
||||||
return {
|
|
||||||
startTimer = startTimer
|
|
||||||
}
|
|
||||||
@@ -1,23 +1,30 @@
|
|||||||
local yaml = require("yaml")
|
local yaml = require("utils/yaml")
|
||||||
local loader = {}
|
local loader = {}
|
||||||
loader.__index = loader
|
loader.__index = loader
|
||||||
|
|
||||||
|
local loaderLog = log:child("loader")
|
||||||
|
|
||||||
function loader:new(path_or_file)
|
function loader:new(path_or_file)
|
||||||
local c = {}
|
local c = {}
|
||||||
setmetatable(c, loader)
|
setmetatable(c, loader)
|
||||||
c.source = path_or_file
|
c.source = path_or_file
|
||||||
local file = love.filesystem.read(path_or_file .. "/index.yml")
|
local file = love.filesystem.read(path_or_file .. "/index.yml")
|
||||||
|
|
||||||
if not file then
|
if not file then
|
||||||
error("Unable to load file: ".. path_or_file .."/index.yml")
|
loaderLog:error("Unable to load file: %s/index.yml", path_or_file)
|
||||||
end
|
end
|
||||||
|
|
||||||
c.index = yaml.parse(file)
|
c.index = yaml.parse(file)
|
||||||
|
|
||||||
for i,v in pairs(c.index.categories) do
|
for i,v in pairs(c.index.categories) do
|
||||||
local link = love.filesystem.read(path_or_file .. "/" .. v.name .. ".yml")
|
local link = love.filesystem.read(path_or_file .. "/" .. v.name .. ".yml")
|
||||||
if not link then
|
if not link then
|
||||||
print("Error! Cannot find file: " .. path_or_file .."/" .. v.name .. ".yml")
|
loaderLog:error("Error! Cannot find file: %s/%s.yml", path_or_file,v.name)
|
||||||
else
|
else
|
||||||
local category = yaml.parse(link)
|
local category = yaml.parse(link)
|
||||||
c.index.categories[i].questions = category.questions
|
c.index.categories[i].questions = category.questions
|
||||||
|
c.index.categories[i].global = category.global or {}
|
||||||
|
c.index.categories[i].cosmetics = category.cosmetics or {}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return c
|
return c
|
||||||
@@ -0,0 +1,300 @@
|
|||||||
|
--- logger.lua — A feature-rich logging library for Lua
|
||||||
|
-- Supports log levels, multiple handlers, formatting, and filtering.
|
||||||
|
--
|
||||||
|
-- Usage:
|
||||||
|
-- local Logger = require("logger")
|
||||||
|
-- local log = Logger.new("MyApp")
|
||||||
|
-- log:info("Server started on port %d", 8080)
|
||||||
|
-- log:warn("Disk usage at %d%%", 92)
|
||||||
|
-- log:error("Connection refused: %s", err)
|
||||||
|
|
||||||
|
local Logger = {}
|
||||||
|
Logger.__index = Logger
|
||||||
|
|
||||||
|
-- ── Level definitions ──────────────────────────────────────────────────────
|
||||||
|
|
||||||
|
Logger.LEVELS = {
|
||||||
|
TRACE = 1,
|
||||||
|
DEBUG = 2,
|
||||||
|
INFO = 3,
|
||||||
|
WARN = 4,
|
||||||
|
ERROR = 5,
|
||||||
|
FATAL = 6,
|
||||||
|
OFF = 7, -- disable all output
|
||||||
|
}
|
||||||
|
|
||||||
|
-- Reverse map: number → name
|
||||||
|
local LEVEL_NAMES = {}
|
||||||
|
for name, val in pairs(Logger.LEVELS) do
|
||||||
|
LEVEL_NAMES[val] = name
|
||||||
|
end
|
||||||
|
|
||||||
|
-- ANSI colour codes (used by the ConsoleHandler when colours are enabled)
|
||||||
|
local COLOURS = {
|
||||||
|
[1] = "\27[36m", -- TRACE cyan
|
||||||
|
[2] = "\27[34m", -- DEBUG blue
|
||||||
|
[3] = "\27[32m", -- INFO green
|
||||||
|
[4] = "\27[33m", -- WARN yellow
|
||||||
|
[5] = "\27[31m", -- ERROR red
|
||||||
|
[6] = "\27[35m", -- FATAL magenta
|
||||||
|
RESET = "\27[0m",
|
||||||
|
}
|
||||||
|
|
||||||
|
-- ── Utility helpers ────────────────────────────────────────────────────────
|
||||||
|
|
||||||
|
--- Returns an ISO-8601-style timestamp: "2025-06-08 14:32:01"
|
||||||
|
local function timestamp()
|
||||||
|
return os.date("%Y-%m-%d %H:%M:%S")
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Safe string formatting — falls back gracefully when fmt is not a string
|
||||||
|
local function safe_format(fmt, ...)
|
||||||
|
if select("#", ...) == 0 then
|
||||||
|
return tostring(fmt)
|
||||||
|
end
|
||||||
|
local ok, result = pcall(string.format, tostring(fmt), ...)
|
||||||
|
return ok and result or (tostring(fmt) .. " " .. table.concat({...}, " "))
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Pads or truncates a string to a fixed width
|
||||||
|
local function pad(s, width)
|
||||||
|
s = tostring(s)
|
||||||
|
if #s >= width then return s:sub(1, width) end
|
||||||
|
return s .. string.rep(" ", width - #s)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- ── Built-in Handlers ──────────────────────────────────────────────────────
|
||||||
|
|
||||||
|
--- ConsoleHandler — writes to stdout (or stderr for ERROR+)
|
||||||
|
-- Options:
|
||||||
|
-- colours (bool, default true) — enable ANSI colours
|
||||||
|
-- stderr (bool, default false) — always write to stderr
|
||||||
|
local function ConsoleHandler(opts)
|
||||||
|
opts = opts or {}
|
||||||
|
local use_colour = (opts.colours ~= false)
|
||||||
|
local force_stderr = opts.stderr or false
|
||||||
|
|
||||||
|
return function(record)
|
||||||
|
local line = record.formatted
|
||||||
|
if use_colour then
|
||||||
|
local c = COLOURS[record.level] or ""
|
||||||
|
line = c .. line .. COLOURS.RESET
|
||||||
|
end
|
||||||
|
local dest = (force_stderr or record.level >= Logger.LEVELS.ERROR) and io.stderr or io.stdout
|
||||||
|
dest:write(line .. "\n")
|
||||||
|
dest:flush()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
--- FileHandler — appends log records to a file
|
||||||
|
-- Options:
|
||||||
|
-- path (string, required) — path to the log file
|
||||||
|
-- max_size (number, optional) — rotate when file exceeds this many bytes
|
||||||
|
-- max_files(number, optional) — keep this many rotated files (default 5)
|
||||||
|
local function FileHandler(opts)
|
||||||
|
assert(opts and opts.path, "FileHandler requires opts.path")
|
||||||
|
local path = opts.path
|
||||||
|
local max_size = opts.max_size -- nil = never rotate
|
||||||
|
local max_files = opts.max_files or 5
|
||||||
|
local file
|
||||||
|
|
||||||
|
local function open_file()
|
||||||
|
file = assert(io.open(path, "a"), "Cannot open log file: " .. path)
|
||||||
|
end
|
||||||
|
|
||||||
|
local function rotate()
|
||||||
|
if file then file:close(); file = nil end
|
||||||
|
-- shift old files: .4 → .5, .3 → .4, …, .1 → .2, base → .1
|
||||||
|
for i = max_files - 1, 1, -1 do
|
||||||
|
os.rename(path .. "." .. i, path .. "." .. (i + 1))
|
||||||
|
end
|
||||||
|
os.rename(path, path .. ".1")
|
||||||
|
open_file()
|
||||||
|
end
|
||||||
|
|
||||||
|
open_file()
|
||||||
|
|
||||||
|
return function(record)
|
||||||
|
if not file then open_file() end
|
||||||
|
file:write(record.formatted .. "\n")
|
||||||
|
file:flush()
|
||||||
|
if max_size then
|
||||||
|
local pos = file:seek("cur")
|
||||||
|
if pos and pos >= max_size then rotate() end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
--- MemoryHandler — stores records in a Lua table (useful for testing)
|
||||||
|
-- Returns handler, get_records() function
|
||||||
|
local function MemoryHandler(opts)
|
||||||
|
opts = opts or {}
|
||||||
|
local limit = opts.limit or 10000
|
||||||
|
local records = {}
|
||||||
|
|
||||||
|
local handler = function(record)
|
||||||
|
if #records >= limit then table.remove(records, 1) end
|
||||||
|
table.insert(records, record)
|
||||||
|
end
|
||||||
|
|
||||||
|
local function get_records() return records end
|
||||||
|
local function clear() records = {} end
|
||||||
|
|
||||||
|
return handler, get_records, clear
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Expose built-ins
|
||||||
|
Logger.handlers = {
|
||||||
|
ConsoleHandler = ConsoleHandler,
|
||||||
|
FileHandler = FileHandler,
|
||||||
|
MemoryHandler = MemoryHandler,
|
||||||
|
}
|
||||||
|
|
||||||
|
-- ── Formatter ─────────────────────────────────────────────────────────────
|
||||||
|
-- Tokens in the format string:
|
||||||
|
-- {time} — timestamp
|
||||||
|
-- {level} — padded level name (5 chars)
|
||||||
|
-- {name} — logger name
|
||||||
|
-- {message} — the log message
|
||||||
|
|
||||||
|
local DEFAULT_FORMAT = "[{time}] [{level}] [{name}] {message}"
|
||||||
|
|
||||||
|
local function escape_replacement(s)
|
||||||
|
-- In Lua's gsub, '%' in the replacement string is special; escape it.
|
||||||
|
return (s:gsub("%%", "%%%%"))
|
||||||
|
end
|
||||||
|
|
||||||
|
local function apply_format(fmt, record)
|
||||||
|
return (fmt
|
||||||
|
:gsub("{time}", escape_replacement(record.time))
|
||||||
|
:gsub("{level}", escape_replacement(pad(record.level_name, 5)))
|
||||||
|
:gsub("{name}", escape_replacement(record.name))
|
||||||
|
:gsub("{message}", escape_replacement(record.message)))
|
||||||
|
end
|
||||||
|
|
||||||
|
-- ── Logger constructor ─────────────────────────────────────────────────────
|
||||||
|
|
||||||
|
--- Create a new logger instance.
|
||||||
|
-- @param name string — logger name shown in output
|
||||||
|
-- @param opts table — optional configuration:
|
||||||
|
-- level (number) — minimum level, default INFO
|
||||||
|
-- format (string) — format string, default DEFAULT_FORMAT
|
||||||
|
-- handlers (table) — list of handler functions; defaults to ConsoleHandler
|
||||||
|
function Logger.new(name, opts)
|
||||||
|
opts = opts or {}
|
||||||
|
local self = setmetatable({}, Logger)
|
||||||
|
self.name = name or "root"
|
||||||
|
self.level = opts.level or Logger.LEVELS.INFO
|
||||||
|
self.format = opts.format or DEFAULT_FORMAT
|
||||||
|
self._handlers = opts.handlers or { ConsoleHandler() }
|
||||||
|
self._filters = {} -- list of predicate functions
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
-- ── Configuration API ──────────────────────────────────────────────────────
|
||||||
|
|
||||||
|
--- Set the minimum log level (Logger.LEVELS.*)
|
||||||
|
function Logger:set_level(level)
|
||||||
|
assert(type(level) == "number", "level must be a number from Logger.LEVELS")
|
||||||
|
self.level = level
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Add a handler function
|
||||||
|
function Logger:add_handler(handler)
|
||||||
|
table.insert(self._handlers, handler)
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Remove all handlers and replace with the given ones
|
||||||
|
function Logger:set_handlers(handlers)
|
||||||
|
self._handlers = handlers
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Add a filter predicate — a function(record) → bool
|
||||||
|
-- If ANY filter returns false the record is dropped.
|
||||||
|
function Logger:add_filter(fn)
|
||||||
|
table.insert(self._filters, fn)
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Set the output format string
|
||||||
|
function Logger:set_format(fmt)
|
||||||
|
self.format = fmt
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
-- ── Core emit logic ────────────────────────────────────────────────────────
|
||||||
|
|
||||||
|
function Logger:_emit(level, fmt, ...)
|
||||||
|
if level < self.level then return end
|
||||||
|
|
||||||
|
local record = {
|
||||||
|
time = timestamp(),
|
||||||
|
level = level,
|
||||||
|
level_name = LEVEL_NAMES[level] or ("LVL" .. level),
|
||||||
|
name = self.name,
|
||||||
|
message = safe_format(fmt, ...),
|
||||||
|
}
|
||||||
|
record.formatted = apply_format(self.format, record)
|
||||||
|
|
||||||
|
-- run filters
|
||||||
|
for _, filter in ipairs(self._filters) do
|
||||||
|
if not filter(record) then return end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- dispatch to handlers
|
||||||
|
for _, handler in ipairs(self._handlers) do
|
||||||
|
local ok, err = pcall(handler, record)
|
||||||
|
if not ok then
|
||||||
|
io.stderr:write("[logger] handler error: " .. tostring(err) .. "\n")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- ── Convenience level methods ──────────────────────────────────────────────
|
||||||
|
|
||||||
|
function Logger:trace(fmt, ...) self:_emit(Logger.LEVELS.TRACE, fmt, ...) end
|
||||||
|
function Logger:debug(fmt, ...) self:_emit(Logger.LEVELS.DEBUG, fmt, ...) end
|
||||||
|
function Logger:info (fmt, ...) self:_emit(Logger.LEVELS.INFO, fmt, ...) end
|
||||||
|
function Logger:warn (fmt, ...) self:_emit(Logger.LEVELS.WARN, fmt, ...) end
|
||||||
|
function Logger:error(fmt, ...) self:_emit(Logger.LEVELS.ERROR, fmt, ...) end
|
||||||
|
function Logger:fatal(fmt, ...) self:_emit(Logger.LEVELS.FATAL, fmt, ...) end
|
||||||
|
|
||||||
|
--- Log at a given numeric level
|
||||||
|
function Logger:log(level, fmt, ...)
|
||||||
|
self:_emit(level, fmt, ...)
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Returns true if the given level would be emitted
|
||||||
|
function Logger:is_enabled(level)
|
||||||
|
return level >= self.level
|
||||||
|
end
|
||||||
|
|
||||||
|
-- ── Child loggers ──────────────────────────────────────────────────────────
|
||||||
|
|
||||||
|
--- Create a child logger that inherits handlers/format but has its own name.
|
||||||
|
function Logger:child(name, opts)
|
||||||
|
opts = opts or {}
|
||||||
|
return Logger.new(self.name .. "." .. name, {
|
||||||
|
level = opts.level or self.level,
|
||||||
|
format = opts.format or self.format,
|
||||||
|
handlers = opts.handlers or self._handlers,
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
|
-- ── Module-level root logger ───────────────────────────────────────────────
|
||||||
|
|
||||||
|
Logger._root = Logger.new("root")
|
||||||
|
|
||||||
|
--- Get / lazily create a named logger backed by the root's handlers.
|
||||||
|
local _registry = {}
|
||||||
|
function Logger.get(name)
|
||||||
|
if not _registry[name] then
|
||||||
|
_registry[name] = Logger._root:child(name)
|
||||||
|
end
|
||||||
|
return _registry[name]
|
||||||
|
end
|
||||||
|
|
||||||
|
return Logger
|
||||||
@@ -0,0 +1,222 @@
|
|||||||
|
--- love_file_handler.lua — LÖVE2D file handler for logger.lua
|
||||||
|
--
|
||||||
|
-- Uses love.filesystem to write logs into LÖVE's save directory, which works
|
||||||
|
-- correctly on every platform LÖVE supports (Windows, macOS, Linux, Android).
|
||||||
|
--
|
||||||
|
-- Requires:
|
||||||
|
-- logger.lua in the same directory (or on package.path)
|
||||||
|
-- LÖVE2D 11.x+ (love.filesystem must be available)
|
||||||
|
--
|
||||||
|
-- Usage inside main.lua / conf.lua:
|
||||||
|
--
|
||||||
|
-- local Logger = require("logger")
|
||||||
|
-- local LoveHandler = require("love_file_handler")
|
||||||
|
--
|
||||||
|
-- local log = Logger.new("game", {
|
||||||
|
-- handlers = {
|
||||||
|
-- Logger.handlers.ConsoleHandler(), -- print() fallback
|
||||||
|
-- LoveHandler.new("logs/game.log"), -- love.filesystem
|
||||||
|
-- },
|
||||||
|
-- })
|
||||||
|
--
|
||||||
|
-- function love.load()
|
||||||
|
-- log:info("Game started — LÖVE %s", love.getVersion())
|
||||||
|
-- end
|
||||||
|
|
||||||
|
-- ── Sanity check ──────────────────────────────────────────────────────────
|
||||||
|
|
||||||
|
assert(love and love.filesystem,
|
||||||
|
"love_file_handler requires the LÖVE2D runtime (love.filesystem)")
|
||||||
|
|
||||||
|
-- ── Module table ──────────────────────────────────────────────────────────
|
||||||
|
|
||||||
|
local LoveHandler = {}
|
||||||
|
|
||||||
|
-- ── Helpers ───────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
|
--- Ensure every directory component in `path` exists.
|
||||||
|
-- love.filesystem.createDirectory is recursive on LÖVE 11+.
|
||||||
|
local function ensure_dir(path)
|
||||||
|
local dir = path:match("^(.*)/[^/]+$")
|
||||||
|
if dir and dir ~= "" then
|
||||||
|
love.filesystem.createDirectory(dir)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Return current file size in bytes, or 0 on error / missing file.
|
||||||
|
local function file_size(path)
|
||||||
|
local info = love.filesystem.getInfo(path)
|
||||||
|
return info and info.size or 0
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Shift rotated files: .4→.5, .3→.4, …, base→.1
|
||||||
|
local function rotate(path, max_files)
|
||||||
|
for i = max_files - 1, 1, -1 do
|
||||||
|
local src = path .. "." .. i
|
||||||
|
local dest = path .. "." .. (i + 1)
|
||||||
|
if love.filesystem.getInfo(src) then
|
||||||
|
-- love.filesystem has no rename; copy + delete
|
||||||
|
local data = love.filesystem.read(src)
|
||||||
|
if data then
|
||||||
|
love.filesystem.write(dest, data)
|
||||||
|
love.filesystem.remove(src)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
-- move base → .1
|
||||||
|
if love.filesystem.getInfo(path) then
|
||||||
|
local data = love.filesystem.read(path)
|
||||||
|
if data then
|
||||||
|
love.filesystem.write(path .. ".1", data)
|
||||||
|
love.filesystem.remove(path)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- ── Constructor ───────────────────────────────────────────────────────────
|
||||||
|
|
||||||
|
--- Create a new LÖVE2D file handler.
|
||||||
|
--
|
||||||
|
-- @param path string Path inside the LÖVE save directory.
|
||||||
|
-- Subdirectories are created automatically.
|
||||||
|
-- Default: "logs/game.log"
|
||||||
|
--
|
||||||
|
-- @param opts table Optional settings:
|
||||||
|
-- max_size (number) Rotate when the log file reaches this many bytes.
|
||||||
|
-- Default: 1 MB (1 048 576). Set to 0 to disable.
|
||||||
|
-- max_files (number) How many rotated files to keep. Default: 5.
|
||||||
|
-- buffered (bool) Accumulate lines in memory and flush in batches.
|
||||||
|
-- Reduces I/O overhead on mobile / web exports.
|
||||||
|
-- Default: false.
|
||||||
|
-- flush_size (number) Lines to buffer before auto-flushing (buffered mode).
|
||||||
|
-- Default: 20.
|
||||||
|
-- on_error (func) Called with (err_string) on any I/O error.
|
||||||
|
-- Default: prints a warning to love.graphics console.
|
||||||
|
--
|
||||||
|
-- @return handler, control_table
|
||||||
|
-- handler — function accepted by Logger:add_handler()
|
||||||
|
-- control — table with :flush(), :close(), :path(), :size() methods
|
||||||
|
function LoveHandler.new(path, opts)
|
||||||
|
path = path or "logs/game.log"
|
||||||
|
opts = opts or {}
|
||||||
|
|
||||||
|
local max_size = (opts.max_size == nil) and (1024 * 1024) or opts.max_size
|
||||||
|
local max_files = opts.max_files or 5
|
||||||
|
local buffered = opts.buffered or false
|
||||||
|
local flush_size = opts.flush_size or 20
|
||||||
|
local on_error = opts.on_error or function(err)
|
||||||
|
if love.graphics and love.graphics.print then
|
||||||
|
print("[love_file_handler] I/O error: " .. tostring(err))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- State
|
||||||
|
local buffer = {} -- pending lines (buffered mode)
|
||||||
|
local closed = false
|
||||||
|
|
||||||
|
ensure_dir(path)
|
||||||
|
|
||||||
|
-- ── Internal write ────────────────────────────────────────────────────
|
||||||
|
|
||||||
|
local function raw_write(lines)
|
||||||
|
if #lines == 0 then return end
|
||||||
|
local text = table.concat(lines, "\n") .. "\n"
|
||||||
|
|
||||||
|
-- Rotate if needed
|
||||||
|
if max_size and max_size > 0 and file_size(path) + #text >= max_size then
|
||||||
|
rotate(path, max_files)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Append
|
||||||
|
local ok, err = love.filesystem.append(path, text)
|
||||||
|
if not ok then
|
||||||
|
on_error(tostring(err))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- ── Public control table ──────────────────────────────────────────────
|
||||||
|
|
||||||
|
local control = {}
|
||||||
|
|
||||||
|
--- Flush buffered lines to disk immediately.
|
||||||
|
function control:flush()
|
||||||
|
if #buffer > 0 then
|
||||||
|
raw_write(buffer)
|
||||||
|
buffer = {}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Close the handler (flushes first). After close() the handler is a no-op.
|
||||||
|
function control:close()
|
||||||
|
self:flush()
|
||||||
|
closed = true
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Full path as seen by love.filesystem.
|
||||||
|
function control:path()
|
||||||
|
return path
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Real filesystem path to the save directory file (for external tools).
|
||||||
|
function control:real_path()
|
||||||
|
local save_dir = love.filesystem.getSaveDirectory()
|
||||||
|
return save_dir .. "/" .. path
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Current log file size in bytes.
|
||||||
|
function control:size()
|
||||||
|
return file_size(path)
|
||||||
|
end
|
||||||
|
|
||||||
|
--- List rotated files that exist (e.g. {"logs/game.log.1", ...})
|
||||||
|
function control:rotated_files()
|
||||||
|
local result = {}
|
||||||
|
for i = 1, max_files do
|
||||||
|
local p = path .. "." .. i
|
||||||
|
if love.filesystem.getInfo(p) then
|
||||||
|
table.insert(result, p)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return result
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Read the entire current log file as a string (nil on error).
|
||||||
|
function control:read()
|
||||||
|
self:flush()
|
||||||
|
return love.filesystem.read(path)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- ── Handler function ──────────────────────────────────────────────────
|
||||||
|
|
||||||
|
local function handler(record)
|
||||||
|
if closed then return end
|
||||||
|
|
||||||
|
if buffered then
|
||||||
|
table.insert(buffer, record.formatted)
|
||||||
|
if #buffer >= flush_size then
|
||||||
|
raw_write(buffer)
|
||||||
|
buffer = {}
|
||||||
|
end
|
||||||
|
else
|
||||||
|
raw_write({ record.formatted })
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return handler, control
|
||||||
|
end
|
||||||
|
|
||||||
|
-- ── Convenience: hook love.quit to flush ──────────────────────────────────
|
||||||
|
|
||||||
|
--- Wrap love.quit so a control table's flush() is called automatically.
|
||||||
|
-- Call once per handler after Logger.new(); safe to call multiple times.
|
||||||
|
--
|
||||||
|
-- @param control The control table returned by LoveHandler.new()
|
||||||
|
function LoveHandler.auto_flush_on_quit(control)
|
||||||
|
local original_quit = love.quit or function() end
|
||||||
|
love.quit = function()
|
||||||
|
control:flush()
|
||||||
|
return original_quit()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return LoveHandler
|
||||||
@@ -0,0 +1,134 @@
|
|||||||
|
local gui = require("gui")
|
||||||
|
local color = require("gui.core.color")
|
||||||
|
local multi, thread = require("multi"):init()
|
||||||
|
|
||||||
|
local function startTimer(opt)
|
||||||
|
local default = {
|
||||||
|
duration = 30,
|
||||||
|
autoText = true,
|
||||||
|
autoColor = true,
|
||||||
|
autoCleanup = false,
|
||||||
|
startColor = color.green,
|
||||||
|
textColor = color.black,
|
||||||
|
warnColor = color.yellow,
|
||||||
|
timeColor = color.red,
|
||||||
|
finegrained = false,
|
||||||
|
visibility = 1
|
||||||
|
}
|
||||||
|
|
||||||
|
if type(opt) == "number" then
|
||||||
|
local d = opt
|
||||||
|
opt = default
|
||||||
|
opt.duration = d
|
||||||
|
elseif type(opt) ~= "table" then
|
||||||
|
opt = default
|
||||||
|
else
|
||||||
|
for i, v in pairs(opt) do
|
||||||
|
default[i] = v
|
||||||
|
end
|
||||||
|
opt = default
|
||||||
|
end
|
||||||
|
|
||||||
|
local timeRemaining = opt.duration or 30
|
||||||
|
|
||||||
|
local tpie = gui:newFrame():makeArc("pie", -200, 0, 100, 1, 0, 0, 1.5*math.pi, 3.5*math.pi, 360)
|
||||||
|
local tlabel = tpie:newTextLabel("")
|
||||||
|
tlabel.textColor = opt.textColor
|
||||||
|
tlabel.align = gui.ALIGN_CENTER
|
||||||
|
tlabel:fullFrame()
|
||||||
|
tlabel.visibility = 0
|
||||||
|
tpie.color = opt.startColor
|
||||||
|
tpie.visibility = opt.visibility
|
||||||
|
|
||||||
|
local tm
|
||||||
|
local stopped = false
|
||||||
|
local onTimeConn = multi:newConnection()
|
||||||
|
local onStopConn = multi:newConnection()
|
||||||
|
|
||||||
|
local function cleanup()
|
||||||
|
if stopped then return end
|
||||||
|
stopped = true
|
||||||
|
if onTimeConn and not onTimeConn.destroyed then
|
||||||
|
onTimeConn:Destroy()
|
||||||
|
end
|
||||||
|
if not tpie.destroyed then
|
||||||
|
tpie:destroy()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local timerThread = thread:newThread("Pie Timer", function()
|
||||||
|
local startTime = love.timer.getTime()
|
||||||
|
local lastSecond = timeRemaining
|
||||||
|
|
||||||
|
while not stopped do
|
||||||
|
thread.sleep(1/60)
|
||||||
|
|
||||||
|
local now = love.timer.getTime()
|
||||||
|
local elapsed = now - startTime
|
||||||
|
local t = math.min(elapsed, timeRemaining)
|
||||||
|
local num = timeRemaining - math.floor(t)
|
||||||
|
local p = 3.5 - (t / timeRemaining) * 2
|
||||||
|
|
||||||
|
if opt.autoColor then
|
||||||
|
tpie.color = opt.startColor
|
||||||
|
if num <= timeRemaining / 3 then
|
||||||
|
tpie.color = opt.timeColor
|
||||||
|
elseif num <= timeRemaining / 2 then
|
||||||
|
tpie.color = opt.warnColor
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
tpie:makeArc("pie", -200, 0, 100, 1, 0, 0, 1.5*math.pi, p*math.pi, 360)
|
||||||
|
|
||||||
|
if opt.autoText then
|
||||||
|
tlabel.text = num
|
||||||
|
tlabel:fitFont(nil, nil, {scale=1/2})
|
||||||
|
tlabel:centerFont()
|
||||||
|
end
|
||||||
|
|
||||||
|
if opt.finegrained then
|
||||||
|
onTimeConn:Fire(tm, num, t)
|
||||||
|
elseif num < lastSecond then
|
||||||
|
-- crossed a second boundary
|
||||||
|
lastSecond = num
|
||||||
|
onTimeConn:Fire(tm, num, t)
|
||||||
|
end
|
||||||
|
|
||||||
|
if elapsed >= timeRemaining then
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Timer finished
|
||||||
|
if stopped then return end
|
||||||
|
|
||||||
|
if opt.autoText then
|
||||||
|
tlabel.text = "Time"
|
||||||
|
tlabel:fitFont(nil, nil, {scale=1/2})
|
||||||
|
tlabel:centerFont()
|
||||||
|
end
|
||||||
|
tpie:makeArc("pie", -200, 0, 100, 1, 0, 0, 1.5*math.pi, 3.5*math.pi, 360)
|
||||||
|
|
||||||
|
local onStop = onStopConn
|
||||||
|
cleanup()
|
||||||
|
onStop:Fire(tm)
|
||||||
|
end)
|
||||||
|
|
||||||
|
tm = {
|
||||||
|
Duration = timeRemaining,
|
||||||
|
OnTime = onTimeConn,
|
||||||
|
OnStop = onStopConn,
|
||||||
|
SetText = function(str) tlabel.text = str end,
|
||||||
|
SetColor = function(c) tpie.color = c end,
|
||||||
|
Cleanup = function()
|
||||||
|
timerThread:Kill()
|
||||||
|
cleanup()
|
||||||
|
end,
|
||||||
|
}
|
||||||
|
|
||||||
|
return tm
|
||||||
|
end
|
||||||
|
|
||||||
|
return {
|
||||||
|
startTimer = startTimer
|
||||||
|
}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
1.0.2
|
||||||