diff --git a/.luacheckrc b/.luacheckrc index 9264fa8..82871bd 100644 --- a/.luacheckrc +++ b/.luacheckrc @@ -22,6 +22,7 @@ globals = { "Meter", "Minigame", "Window", + "ContinuedWindow", "TTGIntroWindow", "BriefIntroWindow", "TitleIntroWindow", diff --git a/impostor.inc b/impostor.inc index 3818fb7..eac5459 100644 --- a/impostor.inc +++ b/impostor.inc @@ -58,6 +58,7 @@ window/window.minigame.rhythm.lua window/window.minigame.ddr.lua window/window.mysterious_man.lua window/window.discussion.lua +window/window.continued.lua window/window.game.lua system/system.main.lua meta/meta.assets.lua diff --git a/inc/window/window.continued.lua b/inc/window/window.continued.lua new file mode 100644 index 0000000..ef85f6d --- /dev/null +++ b/inc/window/window.continued.lua @@ -0,0 +1,75 @@ +--- @section ContinuedWindow +ContinuedWindow.timer = 300 -- 5 seconds at 60fps +ContinuedWindow.text = [[ +### ### ### ### + # # # # # # + # # # ### ## + # # # # # # + # ### ### ### + +### ### # # ### ### # # # # ### ## +# # # ## # # # ## # # # # # # +# # # # ## # # # ## # # ## # # +# # # # # # # # # # # # # # +### ### # # # ### # # ### ### ## + +]] + +--- Draws the continued window. +--- @within ContinuedWindow +function ContinuedWindow.draw() + cls(Config.colors.black) + local lines = {} + local max_len = 0 + -- Get all lines and find max length + for line in (ContinuedWindow.text .. "\n"):gmatch("(.-)\n") do + table.insert(lines, line) + if #line > max_len then max_len = #line end + end + + -- Clean up empty lines from the start/end + if #lines > 0 and lines[1] == "" then table.remove(lines, 1) end + if #lines > 0 and lines[#lines] == "" then table.remove(lines, #lines) end + + local char_w = 4 + local char_h = 5 + local line_gap = 0 + local word_gap = 6 + + local total_h = 0 + for _, line in ipairs(lines) do + if line:find("#") then + total_h = total_h + char_h + line_gap + else + total_h = total_h + word_gap + end + end + total_h = total_h - line_gap + + local current_y = (Config.screen.height - total_h) / 2 + local x_offset = (Config.screen.width - (max_len * char_w)) / 2 + + for _, line in ipairs(lines) do + if line:find("#") then + for j = 1, #line do + local char = line:sub(j, j) + if char == "#" then + rect(x_offset + (j - 1) * char_w, current_y, char_w - 1, char_h - 1, Config.colors.light_blue) + end + end + current_y = current_y + char_h + line_gap + else + current_y = current_y + word_gap + end + end +end + +--- Updates the continued window logic. +--- @within ContinuedWindow +function ContinuedWindow.update() + ContinuedWindow.timer = ContinuedWindow.timer - 1 + if ContinuedWindow.timer <= 0 or Input.select() or Input.menu_confirm() then + Window.set_current("menu") + MenuWindow.refresh_menu_items() + end +end diff --git a/inc/window/window.menu.lua b/inc/window/window.menu.lua index 23517a8..80dbe99 100644 --- a/inc/window/window.menu.lua +++ b/inc/window/window.menu.lua @@ -74,6 +74,13 @@ function MenuWindow.audio_test() GameWindow.set_state("audiotest") end +--- Opens the continued screen. +--- @within MenuWindow +function MenuWindow.continued() + ContinuedWindow.timer = 300 + GameWindow.set_state("continued") +end + --- Refreshes menu items. --- @within MenuWindow function MenuWindow.refresh_menu_items() @@ -87,6 +94,7 @@ function MenuWindow.refresh_menu_items() table.insert(_menu_items, {label = "Load Game", decision = MenuWindow.load_game}) table.insert(_menu_items, {label = "Configuration", decision = MenuWindow.configuration}) table.insert(_menu_items, {label = "Audio Test", decision = MenuWindow.audio_test}) + table.insert(_menu_items, {label = "To Be Continued...", decision = MenuWindow.continued}) table.insert(_menu_items, {label = "Exit", decision = MenuWindow.exit}) Context.current_menu_item = 1 diff --git a/inc/window/window.register.lua b/inc/window/window.register.lua index 7746845..0865dd5 100644 --- a/inc/window/window.register.lua +++ b/inc/window/window.register.lua @@ -39,3 +39,6 @@ Window.register("end", EndWindow) DiscussionWindow = {} Window.register("discussion", DiscussionWindow) + +ContinuedWindow = {} +Window.register("continued", ContinuedWindow)