Merge pull request 'feature/end-window' (#31) from feature/end-window into master
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
Reviewed-on: #31
This commit was merged in pull request #31.
This commit is contained in:
@@ -24,6 +24,7 @@ decision/decision.go_to_home.lua
|
|||||||
decision/decision.go_to_toilet.lua
|
decision/decision.go_to_toilet.lua
|
||||||
decision/decision.go_to_walking_to_office.lua
|
decision/decision.go_to_walking_to_office.lua
|
||||||
decision/decision.go_to_office.lua
|
decision/decision.go_to_office.lua
|
||||||
|
decision/decision.go_to_end.lua
|
||||||
decision/decision.go_to_walking_to_home.lua
|
decision/decision.go_to_walking_to_home.lua
|
||||||
decision/decision.go_to_sleep.lua
|
decision/decision.go_to_sleep.lua
|
||||||
decision/decision.do_work.lua
|
decision/decision.do_work.lua
|
||||||
@@ -40,6 +41,7 @@ screen/screen.walking_to_home.lua
|
|||||||
screen/screen.work.lua
|
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.splash.lua
|
window/window.splash.lua
|
||||||
window/window.intro.lua
|
window/window.intro.lua
|
||||||
window/window.menu.lua
|
window/window.menu.lua
|
||||||
|
|||||||
7
inc/decision/decision.go_to_end.lua
Normal file
7
inc/decision/decision.go_to_end.lua
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
Decision.register({
|
||||||
|
id = "go_to_end",
|
||||||
|
label = "Break the cycle",
|
||||||
|
handle = function()
|
||||||
|
Window.set_current("end")
|
||||||
|
end,
|
||||||
|
})
|
||||||
@@ -10,11 +10,11 @@ local _decisions = {}
|
|||||||
--- @param[opt] decision.handle function Called when the decision is selected. Defaults to noop.
|
--- @param[opt] decision.handle function Called when the decision is selected. Defaults to noop.
|
||||||
function Decision.register(decision)
|
function Decision.register(decision)
|
||||||
if not decision or not decision.id then
|
if not decision or not decision.id then
|
||||||
PopupWindow.show({"Error: Invalid decision object registered (missing id)!"})
|
trace("Error: Invalid decision object registered (missing id)!")
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
if not decision.label then
|
if not decision.label then
|
||||||
PopupWindow.show({"Error: Invalid decision object registered (missing label)!"})
|
trace("Error: Invalid decision object registered (missing label)!")
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -92,7 +92,7 @@ end
|
|||||||
function Decision.filter_available(decisions_list)
|
function Decision.filter_available(decisions_list)
|
||||||
local available = {}
|
local available = {}
|
||||||
for _, decision in ipairs(decisions_list) do
|
for _, decision in ipairs(decisions_list) do
|
||||||
if decision and decision.condition() then
|
if decision and (not decision.condition or decision.condition()) then
|
||||||
table.insert(available, decision)
|
table.insert(available, decision)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -42,6 +42,10 @@ function Context.initial_data()
|
|||||||
current_situation = nil,
|
current_situation = nil,
|
||||||
},
|
},
|
||||||
day_count = 1,
|
day_count = 1,
|
||||||
|
_end = {
|
||||||
|
state = "choice",
|
||||||
|
selection = 1,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +1,18 @@
|
|||||||
|
--- @section Day
|
||||||
local _day_increase_handlers = {}
|
local _day_increase_handlers = {}
|
||||||
|
|
||||||
|
--- Increases the day count and triggers registered handlers.
|
||||||
|
--- @within Day
|
||||||
function Day.increase()
|
function Day.increase()
|
||||||
Context.day_count = Context.day_count + 1
|
Context.day_count = Context.day_count + 1
|
||||||
for _, handler in ipairs(_day_increase_handlers) do
|
for _, handler in ipairs(_day_increase_handlers) do
|
||||||
handler()
|
handler()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Registers a handler to be called when the day increases.
|
||||||
|
--- @within Day
|
||||||
|
--- @param handler function The function to call when the day increases.
|
||||||
function Day.register_handler(handler)
|
function Day.register_handler(handler)
|
||||||
table.insert(_day_increase_handlers, handler)
|
table.insert(_day_increase_handlers, handler)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -131,7 +131,9 @@ function Meter.draw()
|
|||||||
local bar_x = 182
|
local bar_x = 182
|
||||||
local label_x = 228
|
local label_x = 228
|
||||||
local line_h = 5
|
local line_h = 5
|
||||||
local start_y = 11
|
local start_y = 1
|
||||||
|
|
||||||
|
|
||||||
local bar_offset = math.floor((line_h - bar_h) / 2)
|
local bar_offset = math.floor((line_h - bar_h) / 2)
|
||||||
|
|
||||||
local meter_list = {
|
local meter_list = {
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ function Timer.draw()
|
|||||||
if Context.meters.hidden and not Context.stat_screen_active then return end
|
if Context.meters.hidden and not Context.stat_screen_active then return end
|
||||||
|
|
||||||
local cx = 10
|
local cx = 10
|
||||||
local cy = 20
|
local cy = 8
|
||||||
local r_outer = 5
|
local r_outer = 5
|
||||||
local r_inner = 3
|
local r_inner = 3
|
||||||
local progress = Context.timer.progress
|
local progress = Context.timer.progress
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ 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"
|
||||||
})
|
})
|
||||||
|
|||||||
75
inc/window/window.end.lua
Normal file
75
inc/window/window.end.lua
Normal file
@@ -0,0 +1,75 @@
|
|||||||
|
--- Draws the end screen window.
|
||||||
|
--- @within EndWindow
|
||||||
|
function EndWindow.draw()
|
||||||
|
cls(Config.colors.black)
|
||||||
|
|
||||||
|
if Context._end.state == "choice" then
|
||||||
|
local lines = {
|
||||||
|
"This is not a workplace.",
|
||||||
|
"This is a cycle.",
|
||||||
|
"And if it is a cycle...",
|
||||||
|
"it can be broken."
|
||||||
|
}
|
||||||
|
|
||||||
|
local y = 40
|
||||||
|
for _, line in ipairs(lines) do
|
||||||
|
Print.text_center(line, Config.screen.width / 2, y, Config.colors.white)
|
||||||
|
y = y + 10
|
||||||
|
end
|
||||||
|
|
||||||
|
y = y + 20
|
||||||
|
local yes_color = Context._end.selection == 1 and Config.colors.light_blue or Config.colors.white
|
||||||
|
local no_color = Context._end.selection == 2 and Config.colors.light_blue or Config.colors.white
|
||||||
|
|
||||||
|
local yes_text = (Context._end.selection == 1 and "> YES" or " YES")
|
||||||
|
local no_text = (Context._end.selection == 2 and "> NO" or " NO")
|
||||||
|
|
||||||
|
local centerX = Config.screen.width / 2
|
||||||
|
Print.text(yes_text, centerX - 40, y, yes_color)
|
||||||
|
Print.text(no_text, centerX + 10, y, no_color)
|
||||||
|
elseif Context._end.state == "ending" then
|
||||||
|
Print.text_center("Game over -- good ending.", Config.screen.width / 2, 50, Config.colors.light_blue)
|
||||||
|
Print.text_center("Congratulations!", Config.screen.width / 2, 70, Config.colors.white)
|
||||||
|
Print.text_center("Press Z to return to menu", Config.screen.width / 2, 110, Config.colors.light_grey)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Updates the end screen logic.
|
||||||
|
--- @within EndWindow
|
||||||
|
function EndWindow.update()
|
||||||
|
if Context._end.state == "choice" then
|
||||||
|
if Input.left() or Input.up() then
|
||||||
|
if Context._end.selection == 2 then
|
||||||
|
Audio.sfx_beep()
|
||||||
|
Context._end.selection = 1
|
||||||
|
end
|
||||||
|
elseif Input.right() or Input.down() then
|
||||||
|
if Context._end.selection == 1 then
|
||||||
|
Audio.sfx_beep()
|
||||||
|
Context._end.selection = 2
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if Input.menu_confirm() then
|
||||||
|
Audio.sfx_select()
|
||||||
|
if Context._end.selection == 1 then
|
||||||
|
Context._end.state = "ending"
|
||||||
|
else
|
||||||
|
-- NO: increment day and go home
|
||||||
|
Day.increase()
|
||||||
|
Context.game.current_screen = "home"
|
||||||
|
Window.set_current("game")
|
||||||
|
-- Initialize home screen
|
||||||
|
local home_screen = Screen.get_by_id("home")
|
||||||
|
if home_screen and home_screen.init then
|
||||||
|
home_screen.init()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
elseif Context._end.state == "ending" then
|
||||||
|
if Input.menu_confirm() then
|
||||||
|
Window.set_current("menu")
|
||||||
|
MenuWindow.refresh_menu_items()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -6,12 +6,12 @@ local _selected_decision_index = 1
|
|||||||
--- @within GameWindow
|
--- @within GameWindow
|
||||||
function GameWindow.draw()
|
function GameWindow.draw()
|
||||||
local screen = Screen.get_by_id(Context.game.current_screen)
|
local screen = Screen.get_by_id(Context.game.current_screen)
|
||||||
|
if not screen then return end
|
||||||
if screen.background then
|
if screen.background then
|
||||||
Map.draw(screen.background)
|
Map.draw(screen.background)
|
||||||
elseif screen.background_color then
|
elseif screen.background_color then
|
||||||
rect(0, 0, Config.screen.width, Config.screen.height, screen.background_color)
|
rect(0, 0, Config.screen.width, Config.screen.height, screen.background_color)
|
||||||
end
|
end
|
||||||
UI.draw_top_bar(screen.name)
|
|
||||||
if not Context.stat_screen_active and #_available_decisions > 0 then
|
if not Context.stat_screen_active and #_available_decisions > 0 then
|
||||||
Decision.draw(_available_decisions, _selected_decision_index)
|
Decision.draw(_available_decisions, _selected_decision_index)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -30,3 +30,6 @@ Window.register("minigame_ddr", MinigameDDRWindow)
|
|||||||
|
|
||||||
MysteriousManWindow = {}
|
MysteriousManWindow = {}
|
||||||
Window.register("mysterious_man", MysteriousManWindow)
|
Window.register("mysterious_man", MysteriousManWindow)
|
||||||
|
|
||||||
|
EndWindow = {}
|
||||||
|
Window.register("end", EndWindow)
|
||||||
|
|||||||
Reference in New Issue
Block a user