continue-window #36
@@ -17,11 +17,13 @@ globals = {
|
|||||||
"Print",
|
"Print",
|
||||||
"Input",
|
"Input",
|
||||||
"Audio",
|
"Audio",
|
||||||
|
"AsciiArt",
|
||||||
"Config",
|
"Config",
|
||||||
"Context",
|
"Context",
|
||||||
"Meter",
|
"Meter",
|
||||||
"Minigame",
|
"Minigame",
|
||||||
"Window",
|
"Window",
|
||||||
|
"ContinuedWindow",
|
||||||
"TTGIntroWindow",
|
"TTGIntroWindow",
|
||||||
"BriefIntroWindow",
|
"BriefIntroWindow",
|
||||||
"TitleIntroWindow",
|
"TitleIntroWindow",
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ init/init.context.lua
|
|||||||
system/system.util.lua
|
system/system.util.lua
|
||||||
system/system.print.lua
|
system/system.print.lua
|
||||||
system/system.input.lua
|
system/system.input.lua
|
||||||
|
system/system.asciiart.lua
|
||||||
logic/logic.meter.lua
|
logic/logic.meter.lua
|
||||||
logic/logic.focus.lua
|
logic/logic.focus.lua
|
||||||
logic/logic.day.lua
|
logic/logic.day.lua
|
||||||
@@ -58,6 +59,7 @@ window/window.minigame.rhythm.lua
|
|||||||
window/window.minigame.ddr.lua
|
window/window.minigame.ddr.lua
|
||||||
window/window.mysterious_man.lua
|
window/window.mysterious_man.lua
|
||||||
window/window.discussion.lua
|
window/window.discussion.lua
|
||||||
|
window/window.continued.lua
|
||||||
window/window.game.lua
|
window/window.game.lua
|
||||||
system/system.main.lua
|
system/system.main.lua
|
||||||
meta/meta.assets.lua
|
meta/meta.assets.lua
|
||||||
|
|||||||
@@ -16,3 +16,4 @@ Day = {}
|
|||||||
Timer = {}
|
Timer = {}
|
||||||
Trigger = {}
|
Trigger = {}
|
||||||
Discussion = {}
|
Discussion = {}
|
||||||
|
AsciiArt = {}
|
||||||
|
|||||||
63
inc/system/system.asciiart.lua
Normal file
63
inc/system/system.asciiart.lua
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
--- @section AsciiArt
|
||||||
|
AsciiArt = {}
|
||||||
|
|
||||||
|
--- Draws ASCII art text using rectangles.
|
||||||
|
--- @param text string The ASCII art text to draw.
|
||||||
|
--- @param options table Configuration options (char_w, char_h, line_gap, word_gap, color, x, y).
|
||||||
|
function AsciiArt.draw(text, options)
|
||||||
|
options = options or {}
|
||||||
|
local char_w = options.char_w or 4
|
||||||
|
local char_h = options.char_h or 5
|
||||||
|
local line_gap = options.line_gap or 0
|
||||||
|
local word_gap = options.word_gap or 6
|
||||||
|
local color = options.color or Config.colors.light_blue
|
||||||
|
|
||||||
|
local lines = {}
|
||||||
|
local max_len = 0
|
||||||
|
-- Get all lines and find max length
|
||||||
|
for line in (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
|
||||||
|
while #lines > 0 and lines[1]:gsub("%s+", "") == "" do table.remove(lines, 1) end
|
||||||
|
while #lines > 0 and lines[#lines]:gsub("%s+", "") == "" do table.remove(lines, #lines) end
|
||||||
|
|
||||||
|
if #lines == 0 then return end
|
||||||
|
|
||||||
|
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 = options.y or (Config.screen.height - total_h) / 2
|
||||||
|
local x_offset = options.x or (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, color)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
current_y = current_y + char_h + line_gap
|
||||||
|
else
|
||||||
|
current_y = current_y + word_gap
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return {
|
||||||
|
x = x_offset,
|
||||||
|
y = options.y or (Config.screen.height - total_h) / 2,
|
||||||
|
width = max_len * char_w,
|
||||||
|
height = total_h,
|
||||||
|
bottom = (options.y or (Config.screen.height - total_h) / 2) + total_h
|
||||||
|
}
|
||||||
|
end
|
||||||
33
inc/window/window.continued.lua
Normal file
33
inc/window/window.continued.lua
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
--- @section ContinuedWindow
|
||||||
|
ContinuedWindow.timer = 300 -- 5 seconds at 60fps
|
||||||
|
ContinuedWindow.text = [[
|
||||||
|
### ### ### ###
|
||||||
|
# # # # # #
|
||||||
|
# # # ### ##
|
||||||
|
# # # # # #
|
||||||
|
# ### ### ###
|
||||||
|
|
||||||
|
### ### # # ### ### # # # # ### ##
|
||||||
|
# # # ## # # # ## # # # # # #
|
||||||
|
# # # # ## # # # ## # # ## # #
|
||||||
|
# # # # # # # # # # # # # #
|
||||||
|
### ### # # # ### # # ### ### ##
|
||||||
|
|
||||||
|
]]
|
||||||
|
|
||||||
|
--- Draws the continued window.
|
||||||
|
--- @within ContinuedWindow
|
||||||
|
function ContinuedWindow.draw()
|
||||||
|
cls(Config.colors.black)
|
||||||
|
AsciiArt.draw(ContinuedWindow.text, {})
|
||||||
|
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
|
||||||
@@ -23,49 +23,7 @@ TitleIntroWindow.text = [[
|
|||||||
--- Draws the title intro window.
|
--- Draws the title intro window.
|
||||||
--- @within TitleIntroWindow
|
--- @within TitleIntroWindow
|
||||||
function TitleIntroWindow.draw()
|
function TitleIntroWindow.draw()
|
||||||
local lines = {}
|
AsciiArt.draw(TitleIntroWindow.text, {})
|
||||||
local max_len = 0
|
|
||||||
-- Get all lines and find max length
|
|
||||||
for line in (TitleIntroWindow.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
|
end
|
||||||
|
|
||||||
--- Updates the title intro window logic.
|
--- Updates the title intro window logic.
|
||||||
|
|||||||
@@ -12,34 +12,11 @@ TTGIntroWindow.text = [[
|
|||||||
--- Draws the TTG intro window.
|
--- Draws the TTG intro window.
|
||||||
--- @within TTGIntroWindow
|
--- @within TTGIntroWindow
|
||||||
function TTGIntroWindow.draw()
|
function TTGIntroWindow.draw()
|
||||||
if not TTGIntroWindow.glitch_started then
|
local bounds = AsciiArt.draw(TTGIntroWindow.text, {})
|
||||||
Glitch.show()
|
if not bounds then return end
|
||||||
TTGIntroWindow.glitch_started = true
|
Print.text_center("Teletype Games", (Config.screen.width / 2 + 3) , (bounds.bottom + 4), Config.colors.light_blue)
|
||||||
end
|
|
||||||
|
|
||||||
local lines = {}
|
|
||||||
local max_len = 0
|
|
||||||
for line in TTGIntroWindow.text:gmatch("[^\r\n]+") do
|
|
||||||
table.insert(lines, line)
|
|
||||||
if #line > max_len then max_len = #line end
|
|
||||||
end
|
|
||||||
|
|
||||||
local char_w = 6
|
|
||||||
local char_h = 7
|
|
||||||
local y = (Config.screen.height - (#lines * char_h + 12)) / 2
|
|
||||||
local x_offset = (Config.screen.width - (max_len * char_w)) / 2
|
|
||||||
|
|
||||||
for i, line in ipairs(lines) do
|
|
||||||
for j = 1, #line do
|
|
||||||
local char = line:sub(j, j)
|
|
||||||
if char == "#" then
|
|
||||||
rect(x_offset + (j - 1) * char_w, y + (i - 1) * char_h, char_w - 1, char_h - 1, Config.colors.light_blue)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
Print.text_center("Teletype Games", Config.screen.width / 2, y + #lines * char_h + 4, Config.colors.light_blue)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Updates the TTG intro window logic.
|
--- Updates the TTG intro window logic.
|
||||||
--- @within TTGIntroWindow
|
--- @within TTGIntroWindow
|
||||||
function TTGIntroWindow.update()
|
function TTGIntroWindow.update()
|
||||||
|
|||||||
@@ -74,6 +74,13 @@ function MenuWindow.audio_test()
|
|||||||
GameWindow.set_state("audiotest")
|
GameWindow.set_state("audiotest")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Opens the continued screen.
|
||||||
|
--- @within MenuWindow
|
||||||
|
function MenuWindow.continued()
|
||||||
|
ContinuedWindow.timer = 300
|
||||||
|
GameWindow.set_state("continued")
|
||||||
|
end
|
||||||
|
|
||||||
--- Refreshes menu items.
|
--- Refreshes menu items.
|
||||||
--- @within MenuWindow
|
--- @within MenuWindow
|
||||||
function MenuWindow.refresh_menu_items()
|
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 = "Load Game", decision = MenuWindow.load_game})
|
||||||
table.insert(_menu_items, {label = "Configuration", decision = MenuWindow.configuration})
|
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 = "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})
|
table.insert(_menu_items, {label = "Exit", decision = MenuWindow.exit})
|
||||||
|
|
||||||
Context.current_menu_item = 1
|
Context.current_menu_item = 1
|
||||||
|
|||||||
@@ -39,3 +39,6 @@ Window.register("end", EndWindow)
|
|||||||
|
|
||||||
DiscussionWindow = {}
|
DiscussionWindow = {}
|
||||||
Window.register("discussion", DiscussionWindow)
|
Window.register("discussion", DiscussionWindow)
|
||||||
|
|
||||||
|
ContinuedWindow = {}
|
||||||
|
Window.register("continued", ContinuedWindow)
|
||||||
|
|||||||
Reference in New Issue
Block a user