Compare commits
8 Commits
feature/ta
...
screen-exi
| Author | SHA1 | Date | |
|---|---|---|---|
| 883ad5fcbf | |||
| 30c894c2f0 | |||
| eb30ac0b0b | |||
| cd85a7214c | |||
| a00db92703 | |||
| 9c18812e95 | |||
| 10b7dfd24b | |||
| 4d8f01187b |
@@ -17,13 +17,16 @@ globals = {
|
|||||||
"Print",
|
"Print",
|
||||||
"Input",
|
"Input",
|
||||||
"Audio",
|
"Audio",
|
||||||
|
"AsciiArt",
|
||||||
"Config",
|
"Config",
|
||||||
"Context",
|
"Context",
|
||||||
"Meter",
|
"Meter",
|
||||||
"Minigame",
|
"Minigame",
|
||||||
"Window",
|
"Window",
|
||||||
"SplashWindow",
|
"ContinuedWindow",
|
||||||
"IntroWindow",
|
"TTGIntroWindow",
|
||||||
|
"BriefIntroWindow",
|
||||||
|
"TitleIntroWindow",
|
||||||
"MenuWindow",
|
"MenuWindow",
|
||||||
"GameWindow",
|
"GameWindow",
|
||||||
"PopupWindow",
|
"PopupWindow",
|
||||||
|
|||||||
@@ -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
|
||||||
@@ -46,8 +47,9 @@ screen/screen.work.lua
|
|||||||
window/window.manager.lua
|
window/window.manager.lua
|
||||||
window/window.register.lua
|
window/window.register.lua
|
||||||
window/window.end.lua
|
window/window.end.lua
|
||||||
window/window.splash.lua
|
window/window.intro.title.lua
|
||||||
window/window.intro.lua
|
window/window.intro.ttg.lua
|
||||||
|
window/window.intro.brief.lua
|
||||||
window/window.menu.lua
|
window/window.menu.lua
|
||||||
window/window.configuration.lua
|
window/window.configuration.lua
|
||||||
window/window.audiotest.lua
|
window/window.audiotest.lua
|
||||||
@@ -57,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
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ Decision.register({
|
|||||||
id = "go_to_office",
|
id = "go_to_office",
|
||||||
label = "Go to Office",
|
label = "Go to Office",
|
||||||
handle = function()
|
handle = function()
|
||||||
Glitch.show()
|
|
||||||
Util.go_to_screen_by_id("office")
|
Util.go_to_screen_by_id("office")
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -20,7 +20,6 @@ function Config.initial_data()
|
|||||||
meter_bg = 1
|
meter_bg = 1
|
||||||
},
|
},
|
||||||
timing = {
|
timing = {
|
||||||
splash_duration = 120,
|
|
||||||
minigame_win_duration = 180
|
minigame_win_duration = 180
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -37,21 +36,19 @@ end
|
|||||||
|
|
||||||
local CONFIG_SAVE_BANK = 7
|
local CONFIG_SAVE_BANK = 7
|
||||||
local CONFIG_MAGIC_VALUE_ADDRESS = 2
|
local CONFIG_MAGIC_VALUE_ADDRESS = 2
|
||||||
local CONFIG_SPLASH_DURATION_ADDRESS = 3
|
|
||||||
local CONFIG_MAGIC_VALUE = 0xDE
|
local CONFIG_MAGIC_VALUE = 0xDE
|
||||||
|
|
||||||
--- Saves the current configuration.
|
--- Saves the current configuration.
|
||||||
--- @within Config
|
--- @within Config
|
||||||
function Config.save()
|
function Config.save()
|
||||||
mset(CONFIG_MAGIC_VALUE, CONFIG_MAGIC_VALUE_ADDRESS, CONFIG_SAVE_BANK)
|
mset(CONFIG_MAGIC_VALUE, CONFIG_MAGIC_VALUE_ADDRESS, CONFIG_SAVE_BANK)
|
||||||
mset(Config.timing.splash_duration, CONFIG_SPLASH_DURATION_ADDRESS, CONFIG_SAVE_BANK)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Loads saved configuration.
|
--- Loads saved configuration.
|
||||||
--- @within Config
|
--- @within Config
|
||||||
function Config.load()
|
function Config.load()
|
||||||
if mget(CONFIG_MAGIC_VALUE_ADDRESS, CONFIG_SAVE_BANK) == CONFIG_MAGIC_VALUE then
|
if mget(CONFIG_MAGIC_VALUE_ADDRESS, CONFIG_SAVE_BANK) == CONFIG_MAGIC_VALUE then
|
||||||
Config.timing.splash_duration = mget(CONFIG_SPLASH_DURATION_ADDRESS, CONFIG_SAVE_BANK)
|
return
|
||||||
else
|
else
|
||||||
Config.reset()
|
Config.reset()
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ Context = {}
|
|||||||
--- @return result table Initial context data or nil. </br>
|
--- @return result table Initial context data or nil. </br>
|
||||||
--- Fields: </br>
|
--- Fields: </br>
|
||||||
--- * current_menu_item (number) Index of the currently selected menu item.<br/>
|
--- * current_menu_item (number) Index of the currently selected menu item.<br/>
|
||||||
--- * splash_timer (number) Remaining frames for the splash screen timer.<br/>
|
|
||||||
--- * popup (table) Popup window state. Contains: `show` (boolean) whether popup is visible, `content` (table) array of strings to display.<br/>
|
--- * popup (table) Popup window state. Contains: `show` (boolean) whether popup is visible, `content` (table) array of strings to display.<br/>
|
||||||
--- * game_in_progress (boolean) Whether a game is currently active.<br/>
|
--- * game_in_progress (boolean) Whether a game is currently active.<br/>
|
||||||
--- * minigame_ddr (table) DDR minigame state (see Minigame.get_default_ddr).<br/>
|
--- * minigame_ddr (table) DDR minigame state (see Minigame.get_default_ddr).<br/>
|
||||||
@@ -24,7 +23,6 @@ Context = {}
|
|||||||
function Context.initial_data()
|
function Context.initial_data()
|
||||||
return {
|
return {
|
||||||
current_menu_item = 1,
|
current_menu_item = 1,
|
||||||
splash_timer = Config.timing.splash_duration,
|
|
||||||
popup = {
|
popup = {
|
||||||
show = false,
|
show = false,
|
||||||
content = {}
|
content = {}
|
||||||
|
|||||||
@@ -16,3 +16,4 @@ Day = {}
|
|||||||
Timer = {}
|
Timer = {}
|
||||||
Trigger = {}
|
Trigger = {}
|
||||||
Discussion = {}
|
Discussion = {}
|
||||||
|
AsciiArt = {}
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ Screen.register({
|
|||||||
"go_to_toilet",
|
"go_to_toilet",
|
||||||
"go_to_walking_to_office",
|
"go_to_walking_to_office",
|
||||||
"go_to_sleep",
|
"go_to_sleep",
|
||||||
"go_to_end",
|
|
||||||
},
|
},
|
||||||
background = "bedroom",
|
background = "bedroom",
|
||||||
draw = function()
|
draw = function()
|
||||||
|
|||||||
@@ -21,6 +21,9 @@ function Screen.register(screen_data)
|
|||||||
end
|
end
|
||||||
if not screen_data.init then
|
if not screen_data.init then
|
||||||
screen_data.init = function() end
|
screen_data.init = function() end
|
||||||
|
end
|
||||||
|
if not screen_data.exit then
|
||||||
|
screen_data.exit = function() end
|
||||||
end
|
end
|
||||||
if not screen_data.update then
|
if not screen_data.update then
|
||||||
screen_data.update = function() end
|
screen_data.update = function() end
|
||||||
|
|||||||
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
|
||||||
@@ -5,11 +5,12 @@ local initialized_game = false
|
|||||||
--- @within Main
|
--- @within Main
|
||||||
--- @return boolean initialized_game True if game has been initialized, false otherwise.
|
--- @return boolean initialized_game True if game has been initialized, false otherwise.
|
||||||
local function init_game()
|
local function init_game()
|
||||||
if initialized_game then return end
|
if initialized_game then return false end
|
||||||
Context.reset()
|
Context.reset()
|
||||||
Window.set_current("splash") -- Set initial window using new manager
|
Window.set_current("intro_title") -- Set initial window using new manager
|
||||||
MenuWindow.refresh_menu_items()
|
MenuWindow.refresh_menu_items()
|
||||||
initialized_game = true
|
initialized_game = true
|
||||||
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Main game loop (TIC-80 callback).
|
--- Main game loop (TIC-80 callback).
|
||||||
@@ -24,9 +25,9 @@ function TIC()
|
|||||||
Meter.update()
|
Meter.update()
|
||||||
Timer.update()
|
Timer.update()
|
||||||
Trigger.update()
|
Trigger.update()
|
||||||
|
Glitch.draw()
|
||||||
if Context.game_in_progress then
|
if Context.game_in_progress then
|
||||||
Meter.draw()
|
Meter.draw()
|
||||||
Timer.draw()
|
Timer.draw()
|
||||||
Glitch.draw()
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -12,9 +12,19 @@ end
|
|||||||
--- @within UI
|
--- @within UI
|
||||||
--- @param items table A table of menu items.<br/>
|
--- @param items table A table of menu items.<br/>
|
||||||
--- @param selected_item number The index of the currently selected item.<br/>
|
--- @param selected_item number The index of the currently selected item.<br/>
|
||||||
--- @param x number The x-coordinate for the menu.<br/>
|
--- @param x number The x-coordinate for the menu (ignored if centered is true).<br/>
|
||||||
--- @param y number The y-coordinate for the menu.<br/>
|
--- @param y number The y-coordinate for the menu.<br/>
|
||||||
function UI.draw_menu(items, selected_item, x, y)
|
--- @param[opt] centered boolean Whether to center the menu block horizontally. Defaults to false.<br/>
|
||||||
|
function UI.draw_menu(items, selected_item, x, y, centered)
|
||||||
|
if centered then
|
||||||
|
local max_w = 0
|
||||||
|
for _, item in ipairs(items) do
|
||||||
|
local w = print(item.label, 0, -10, 0, false, 1, false)
|
||||||
|
if w > max_w then max_w = w end
|
||||||
|
end
|
||||||
|
x = (Config.screen.width - max_w) / 2
|
||||||
|
end
|
||||||
|
|
||||||
for i, item in ipairs(items) do
|
for i, item in ipairs(items) do
|
||||||
local current_y = y + (i-1)*10
|
local current_y = y + (i-1)*10
|
||||||
if i == selected_item then
|
if i == selected_item then
|
||||||
|
|||||||
@@ -14,10 +14,14 @@ end
|
|||||||
--- @within Util
|
--- @within Util
|
||||||
--- @param screen_id string The ID of the screen to go to.<br/>
|
--- @param screen_id string The ID of the screen to go to.<br/>
|
||||||
function Util.go_to_screen_by_id(screen_id)
|
function Util.go_to_screen_by_id(screen_id)
|
||||||
local screen = Screen.get_by_id(screen_id)
|
local prev_screen = Screen.get_by_id(Context.game.current_screen)
|
||||||
if screen then
|
local new_screen = Screen.get_by_id(screen_id)
|
||||||
|
if new_screen then
|
||||||
Context.game.current_screen = screen_id
|
Context.game.current_screen = screen_id
|
||||||
screen.init()
|
if prev_screen and prev_screen.exit then
|
||||||
|
prev_screen.exit()
|
||||||
|
end
|
||||||
|
new_screen.init()
|
||||||
else
|
else
|
||||||
PopupWindow.show({"Error: Screen '" .. screen_id .. "' not found!"})
|
PopupWindow.show({"Error: Screen '" .. screen_id .. "' not found!"})
|
||||||
end
|
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
|
||||||
@@ -59,7 +59,7 @@ function EndWindow.update()
|
|||||||
else
|
else
|
||||||
-- NO: increment day and go home
|
-- NO: increment day and go home
|
||||||
Day.increase()
|
Day.increase()
|
||||||
Context.game.current_screen = "home"
|
Util.go_to_screen_by_id("home")
|
||||||
Window.set_current("game")
|
Window.set_current("game")
|
||||||
-- Initialize home screen
|
-- Initialize home screen
|
||||||
local home_screen = Screen.get_by_id("home")
|
local home_screen = Screen.get_by_id("home")
|
||||||
|
|||||||
37
inc/window/window.intro.brief.lua
Normal file
37
inc/window/window.intro.brief.lua
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
--- @section BriefIntroWindow
|
||||||
|
BriefIntroWindow.y = Config.screen.height
|
||||||
|
BriefIntroWindow.speed = 0.5
|
||||||
|
BriefIntroWindow.text = [[
|
||||||
|
Norman Reds’ everyday life
|
||||||
|
seems ordinary: work,
|
||||||
|
meetings, coffee, and
|
||||||
|
endless notifications.
|
||||||
|
But beneath him, or around
|
||||||
|
him — something is
|
||||||
|
constantly building, and
|
||||||
|
it soon becomes clear
|
||||||
|
that there is more going
|
||||||
|
on than meets the eye.
|
||||||
|
]]
|
||||||
|
|
||||||
|
--- Draws the brief intro window.
|
||||||
|
--- @within BriefIntroWindow
|
||||||
|
function BriefIntroWindow.draw()
|
||||||
|
local x = (Config.screen.width - 132) / 2
|
||||||
|
Print.text(BriefIntroWindow.text, x, BriefIntroWindow.y, Config.colors.light_blue)
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Updates the brief intro window logic.
|
||||||
|
--- @within BriefIntroWindow
|
||||||
|
function BriefIntroWindow.update()
|
||||||
|
BriefIntroWindow.y = BriefIntroWindow.y - BriefIntroWindow.speed
|
||||||
|
|
||||||
|
local lines = 1
|
||||||
|
for _ in string.gmatch(BriefIntroWindow.text, "\n") do
|
||||||
|
lines = lines + 1
|
||||||
|
end
|
||||||
|
|
||||||
|
if BriefIntroWindow.y < -lines * 8 or Input.select() or Input.menu_confirm() then
|
||||||
|
Window.set_current("menu")
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -1,41 +0,0 @@
|
|||||||
--- @section IntroWindow
|
|
||||||
IntroWindow.y = Config.screen.height
|
|
||||||
IntroWindow.speed = 0.5
|
|
||||||
IntroWindow.text = [[
|
|
||||||
Norman Reds’ everyday life
|
|
||||||
seems ordinary: work,
|
|
||||||
meetings, coffee, and
|
|
||||||
endless notifications.
|
|
||||||
But beneath him, or around
|
|
||||||
him — something is
|
|
||||||
constantly building, and
|
|
||||||
it soon becomes clear
|
|
||||||
that there is more going
|
|
||||||
on than meets the eye.
|
|
||||||
]]
|
|
||||||
|
|
||||||
--- Draws the intro window.
|
|
||||||
--- @within IntroWindow
|
|
||||||
function IntroWindow.draw()
|
|
||||||
local x = (Config.screen.width - 132) / 2
|
|
||||||
Print.text(IntroWindow.text, x, IntroWindow.y, Config.colors.light_blue)
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Updates the intro window logic.
|
|
||||||
--- @within IntroWindow
|
|
||||||
function IntroWindow.update()
|
|
||||||
IntroWindow.y = IntroWindow.y - IntroWindow.speed
|
|
||||||
|
|
||||||
local lines = 1
|
|
||||||
for _ in string.gmatch(IntroWindow.text, "\n") do
|
|
||||||
lines = lines + 1
|
|
||||||
end
|
|
||||||
|
|
||||||
if IntroWindow.y < -lines * 8 then
|
|
||||||
Window.set_current("menu")
|
|
||||||
end
|
|
||||||
|
|
||||||
if Input.menu_confirm() then
|
|
||||||
Window.set_current("menu")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
36
inc/window/window.intro.title.lua
Normal file
36
inc/window/window.intro.title.lua
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
--- @section TitleIntroWindow
|
||||||
|
TitleIntroWindow.timer = 180 -- 3 seconds at 60fps
|
||||||
|
TitleIntroWindow.text = [[
|
||||||
|
## ### ### ### ### ### ### ### ## # #
|
||||||
|
# # # # # # # # # # # # # #
|
||||||
|
# # ### ### # # # # # ### # # #
|
||||||
|
# # # # # # # # # # # # #
|
||||||
|
## ### # ### # # ### # ### ## #
|
||||||
|
|
||||||
|
# # ### ### ## # #
|
||||||
|
## # # # # # # ## #
|
||||||
|
# ## # # # #### # ##
|
||||||
|
# # # # # # # # #
|
||||||
|
# # ### # # # # #
|
||||||
|
|
||||||
|
### # # ### #### ### ### #### ###
|
||||||
|
# ## ## # # # # # # # # # #
|
||||||
|
# # # # ### # # ### # # # ###
|
||||||
|
# # # # # # # # # # # #
|
||||||
|
### # # # #### ### # #### # #
|
||||||
|
]]
|
||||||
|
|
||||||
|
--- Draws the title intro window.
|
||||||
|
--- @within TitleIntroWindow
|
||||||
|
function TitleIntroWindow.draw()
|
||||||
|
AsciiArt.draw(TitleIntroWindow.text, {})
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Updates the title intro window logic.
|
||||||
|
--- @within TitleIntroWindow
|
||||||
|
function TitleIntroWindow.update()
|
||||||
|
TitleIntroWindow.timer = TitleIntroWindow.timer - 1
|
||||||
|
if TitleIntroWindow.timer <= 0 or Input.select() or Input.menu_confirm() then
|
||||||
|
Window.set_current("intro_ttg")
|
||||||
|
end
|
||||||
|
end
|
||||||
33
inc/window/window.intro.ttg.lua
Normal file
33
inc/window/window.intro.ttg.lua
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
--- @section TTGIntroWindow
|
||||||
|
TTGIntroWindow.timer = 180
|
||||||
|
TTGIntroWindow.glitch_started = false
|
||||||
|
TTGIntroWindow.text = [[
|
||||||
|
###### ###### ######
|
||||||
|
## ## #
|
||||||
|
## ## # ####
|
||||||
|
## ## # #
|
||||||
|
## ## ######
|
||||||
|
]]
|
||||||
|
|
||||||
|
--- Draws the TTG intro window.
|
||||||
|
--- @within TTGIntroWindow
|
||||||
|
function TTGIntroWindow.draw()
|
||||||
|
local bounds = AsciiArt.draw(TTGIntroWindow.text, {})
|
||||||
|
if not bounds then return end
|
||||||
|
Print.text_center("Teletype Games", (Config.screen.width / 2 + 3) , (bounds.bottom + 4), Config.colors.light_blue)
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Updates the TTG intro window logic.
|
||||||
|
--- @within TTGIntroWindow
|
||||||
|
function TTGIntroWindow.update()
|
||||||
|
if not TTGIntroWindow.glitch_started then
|
||||||
|
Glitch.show()
|
||||||
|
TTGIntroWindow.glitch_started = true
|
||||||
|
end
|
||||||
|
|
||||||
|
TTGIntroWindow.timer = TTGIntroWindow.timer - 1
|
||||||
|
if TTGIntroWindow.timer <= 0 or Input.select() or Input.menu_confirm() then
|
||||||
|
Glitch.hide()
|
||||||
|
Window.set_current("intro_brief")
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -4,7 +4,7 @@ local _windows = {}
|
|||||||
--- Registers a window table.
|
--- Registers a window table.
|
||||||
--- @within Window
|
--- @within Window
|
||||||
--- @param id string The ID of the window (e.g., "splash", "menu").</br>
|
--- @param id string The ID of the window (e.g., "splash", "menu").</br>
|
||||||
--- @param window_table table The actual window module table (e.g., SplashWindow).</br>
|
--- @param window_table table The actual window module table (e.g., GameWindow).</br>
|
||||||
function Window.register(id, window_table)
|
function Window.register(id, window_table)
|
||||||
_windows[id] = window_table
|
_windows[id] = window_table
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -4,8 +4,15 @@ local _menu_items = {}
|
|||||||
--- Draws the menu window.
|
--- Draws the menu window.
|
||||||
--- @within MenuWindow
|
--- @within MenuWindow
|
||||||
function MenuWindow.draw()
|
function MenuWindow.draw()
|
||||||
UI.draw_top_bar("Main Menu")
|
UI.draw_top_bar("Definitely not an Impostor")
|
||||||
UI.draw_menu(_menu_items, Context.current_menu_item, 108, 70)
|
|
||||||
|
local menu_h = #_menu_items * 10
|
||||||
|
local y = 10 + (Config.screen.height - 10 - 10 - menu_h) / 2
|
||||||
|
UI.draw_menu(_menu_items, Context.current_menu_item, 0, y, true)
|
||||||
|
|
||||||
|
local ttg_text = "TTG"
|
||||||
|
local ttg_w = print(ttg_text, 0, -10, 0, false, 1, false)
|
||||||
|
Print.text(ttg_text, Config.screen.width - ttg_w - 5, Config.screen.height - 10, Config.colors.light_blue)
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Updates the menu window logic.
|
--- Updates the menu window logic.
|
||||||
@@ -67,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()
|
||||||
@@ -80,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
|
||||||
|
|||||||
@@ -1,8 +1,11 @@
|
|||||||
SplashWindow = {}
|
TitleIntroWindow = {}
|
||||||
Window.register("splash", SplashWindow)
|
Window.register("intro_title", TitleIntroWindow)
|
||||||
|
|
||||||
IntroWindow = {}
|
TTGIntroWindow = {}
|
||||||
Window.register("intro", IntroWindow)
|
Window.register("intro_ttg", TTGIntroWindow)
|
||||||
|
|
||||||
|
BriefIntroWindow = {}
|
||||||
|
Window.register("intro_brief", BriefIntroWindow)
|
||||||
|
|
||||||
MenuWindow = {}
|
MenuWindow = {}
|
||||||
Window.register("menu", MenuWindow)
|
Window.register("menu", MenuWindow)
|
||||||
@@ -36,3 +39,6 @@ Window.register("end", EndWindow)
|
|||||||
|
|
||||||
DiscussionWindow = {}
|
DiscussionWindow = {}
|
||||||
Window.register("discussion", DiscussionWindow)
|
Window.register("discussion", DiscussionWindow)
|
||||||
|
|
||||||
|
ContinuedWindow = {}
|
||||||
|
Window.register("continued", ContinuedWindow)
|
||||||
|
|||||||
@@ -1,16 +0,0 @@
|
|||||||
--- Draws the splash window.
|
|
||||||
--- @within SplashWindow
|
|
||||||
function SplashWindow.draw()
|
|
||||||
local txt = "Definitely not an Impostor"
|
|
||||||
local y = (Config.screen.height - 6) / 2
|
|
||||||
Print.text_center(txt, Config.screen.width / 2, y, Config.colors.white)
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Updates the splash window logic.
|
|
||||||
--- @within SplashWindow
|
|
||||||
function SplashWindow.update()
|
|
||||||
Context.splash_timer = Context.splash_timer - 1
|
|
||||||
if Context.splash_timer <= 0 or Input.menu_confirm() then
|
|
||||||
Window.set_current("intro")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
Reference in New Issue
Block a user