Merge pull request 'remove manager postfixes' (#8) from feature-remove-manager-postfixes into master
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
Reviewed-on: #8
This commit was merged in pull request #8.
This commit is contained in:
@@ -3,13 +3,15 @@
|
|||||||
|
|
||||||
globals = {
|
globals = {
|
||||||
"Util",
|
"Util",
|
||||||
"DecisionManager",
|
"Decision",
|
||||||
"ScreenManager",
|
"Screen",
|
||||||
"UI",
|
"UI",
|
||||||
"Print",
|
"Print",
|
||||||
"Input",
|
"Input",
|
||||||
"Audio",
|
"Audio",
|
||||||
"Context",
|
"Context",
|
||||||
|
"Meters",
|
||||||
|
"Minigames",
|
||||||
"mset",
|
"mset",
|
||||||
"mget",
|
"mget",
|
||||||
"btnp",
|
"btnp",
|
||||||
@@ -30,7 +32,7 @@ globals = {
|
|||||||
"exit",
|
"exit",
|
||||||
"trace",
|
"trace",
|
||||||
"index_menu",
|
"index_menu",
|
||||||
"MapManager",
|
"Map",
|
||||||
"map",
|
"map",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
DecisionManager.register({
|
Decision.register({
|
||||||
id = "go_to_home",
|
id = "go_to_home",
|
||||||
label = "Go to Home",
|
label = "Go to Home",
|
||||||
handle = function()
|
handle = function()
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
DecisionManager.register({
|
Decision.register({
|
||||||
id = "go_to_office",
|
id = "go_to_office",
|
||||||
label = "Go to Office",
|
label = "Go to Office",
|
||||||
handle = function()
|
handle = function()
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
DecisionManager.register({
|
Decision.register({
|
||||||
id = "go_to_toilet",
|
id = "go_to_toilet",
|
||||||
label = "Go to Toilet",
|
label = "Go to Toilet",
|
||||||
handle = function()
|
handle = function()
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
DecisionManager.register({
|
Decision.register({
|
||||||
id = "go_to_walking_to_home",
|
id = "go_to_walking_to_home",
|
||||||
label = "Walking to home",
|
label = "Walking to home",
|
||||||
handle = function()
|
handle = function()
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
DecisionManager.register({
|
Decision.register({
|
||||||
id = "go_to_walking_to_office",
|
id = "go_to_walking_to_office",
|
||||||
label = "Walking to office",
|
label = "Walking to office",
|
||||||
handle = function()
|
handle = function()
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
local _decisions = {}
|
local _decisions = {}
|
||||||
|
|
||||||
function DecisionManager.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)!"})
|
PopupWindow.show({"Error: Invalid decision object registered (missing id)!"})
|
||||||
return
|
return
|
||||||
@@ -22,10 +22,10 @@ function DecisionManager.register(decision)
|
|||||||
_decisions[decision.id] = decision
|
_decisions[decision.id] = decision
|
||||||
end
|
end
|
||||||
|
|
||||||
function DecisionManager.get(id)
|
function Decision.get(id)
|
||||||
return _decisions[id]
|
return _decisions[id]
|
||||||
end
|
end
|
||||||
|
|
||||||
function DecisionManager.get_all()
|
function Decision.get_all()
|
||||||
return _decisions
|
return _decisions
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
DecisionManager.register({
|
Decision.register({
|
||||||
id = "play_button_mash",
|
id = "play_button_mash",
|
||||||
label = "Play Button Mash",
|
label = "Play Button Mash",
|
||||||
handle = function() Meters.hide() MinigameButtonMashWindow.start(WINDOW_GAME) end,
|
handle = function() Meters.hide() MinigameButtonMashWindow.start(WINDOW_GAME) end,
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
DecisionManager.register({
|
Decision.register({
|
||||||
id = "play_ddr",
|
id = "play_ddr",
|
||||||
label = "Play DDR (Random)",
|
label = "Play DDR (Random)",
|
||||||
handle = function() Meters.hide() MinigameDDRWindow.start(WINDOW_GAME, nil) end,
|
handle = function() Meters.hide() MinigameDDRWindow.start(WINDOW_GAME, nil) end,
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
DecisionManager.register({
|
Decision.register({
|
||||||
id = "play_rhythm",
|
id = "play_rhythm",
|
||||||
label = "Play Rhythm Game",
|
label = "Play Rhythm Game",
|
||||||
handle = function() Meters.hide() MinigameRhythmWindow.start(WINDOW_GAME) end,
|
handle = function() Meters.hide() MinigameRhythmWindow.start(WINDOW_GAME) end,
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ local function reset_context_to_initial_state()
|
|||||||
Context.screen_indices_by_id = {}
|
Context.screen_indices_by_id = {}
|
||||||
local screen_order = {"home", "toilet", "walking_to_office", "office", "walking_to_home"}
|
local screen_order = {"home", "toilet", "walking_to_office", "office", "walking_to_home"}
|
||||||
for i, screen_id in ipairs(screen_order) do
|
for i, screen_id in ipairs(screen_order) do
|
||||||
local screen_data = ScreenManager.get_by_id(screen_id)
|
local screen_data = Screen.get_by_id(screen_id)
|
||||||
if screen_data then
|
if screen_data then
|
||||||
table.insert(Context.screens, screen_data)
|
table.insert(Context.screens, screen_data)
|
||||||
Context.screen_indices_by_id[screen_id] = i
|
Context.screen_indices_by_id[screen_id] = i
|
||||||
|
|||||||
@@ -11,9 +11,9 @@ local MinigameDDRWindow = {}
|
|||||||
Util = {}
|
Util = {}
|
||||||
Meters = {}
|
Meters = {}
|
||||||
Minigames = {}
|
Minigames = {}
|
||||||
DecisionManager = {}
|
Decision = {}
|
||||||
ScreenManager = {}
|
Screen = {}
|
||||||
MapManager = {}
|
Map = {}
|
||||||
UI = {}
|
UI = {}
|
||||||
Print = {}
|
Print = {}
|
||||||
Input = {}
|
Input = {}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
MapManager.register({
|
Map.register({
|
||||||
id = "bedroom",
|
id = "bedroom",
|
||||||
from_x = 0,
|
from_x = 0,
|
||||||
from_y = 0,
|
from_y = 0,
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
local _maps = {}
|
local _maps = {}
|
||||||
|
|
||||||
function MapManager.get_maps_array()
|
function Map.get_maps_array()
|
||||||
local maps_array = {}
|
local maps_array = {}
|
||||||
for _, map_data in pairs(_maps) do
|
for _, map_data in pairs(_maps) do
|
||||||
table.insert(maps_array, map_data)
|
table.insert(maps_array, map_data)
|
||||||
@@ -8,19 +8,19 @@ function MapManager.get_maps_array()
|
|||||||
return maps_array
|
return maps_array
|
||||||
end
|
end
|
||||||
|
|
||||||
function MapManager.register(map_data)
|
function Map.register(map_data)
|
||||||
if _maps[map_data.id] then
|
if _maps[map_data.id] then
|
||||||
trace("Warning: Overwriting map with id: " .. map_data.id)
|
trace("Warning: Overwriting map with id: " .. map_data.id)
|
||||||
end
|
end
|
||||||
_maps[map_data.id] = map_data
|
_maps[map_data.id] = map_data
|
||||||
end
|
end
|
||||||
|
|
||||||
function MapManager.get_by_id(map_id)
|
function Map.get_by_id(map_id)
|
||||||
return _maps[map_id]
|
return _maps[map_id]
|
||||||
end
|
end
|
||||||
|
|
||||||
function MapManager.draw(map_id)
|
function Map.draw(map_id)
|
||||||
local map_data = MapManager.get_by_id(map_id)
|
local map_data = Map.get_by_id(map_id)
|
||||||
if not map_data then
|
if not map_data then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
ScreenManager.register({
|
Screen.register({
|
||||||
id = "home",
|
id = "home",
|
||||||
name = "Home",
|
name = "Home",
|
||||||
decisions = {
|
decisions = {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
local _screens = {}
|
local _screens = {}
|
||||||
|
|
||||||
function ScreenManager.get_screens_array()
|
function Screen.get_screens_array()
|
||||||
local screens_array = {}
|
local screens_array = {}
|
||||||
for _, screen_data in pairs(_screens) do
|
for _, screen_data in pairs(_screens) do
|
||||||
table.insert(screens_array, screen_data)
|
table.insert(screens_array, screen_data)
|
||||||
@@ -8,13 +8,13 @@ function ScreenManager.get_screens_array()
|
|||||||
return screens_array
|
return screens_array
|
||||||
end
|
end
|
||||||
|
|
||||||
function ScreenManager.register(screen_data)
|
function Screen.register(screen_data)
|
||||||
if _screens[screen_data.id] then
|
if _screens[screen_data.id] then
|
||||||
trace("Warning: Overwriting screen with id: " .. screen_data.id)
|
trace("Warning: Overwriting screen with id: " .. screen_data.id)
|
||||||
end
|
end
|
||||||
_screens[screen_data.id] = screen_data
|
_screens[screen_data.id] = screen_data
|
||||||
end
|
end
|
||||||
|
|
||||||
function ScreenManager.get_by_id(screen_id)
|
function Screen.get_by_id(screen_id)
|
||||||
return _screens[screen_id]
|
return _screens[screen_id]
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
ScreenManager.register({
|
Screen.register({
|
||||||
id = "office",
|
id = "office",
|
||||||
name = "Office",
|
name = "Office",
|
||||||
decisions = {
|
decisions = {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
ScreenManager.register({
|
Screen.register({
|
||||||
id = "toilet",
|
id = "toilet",
|
||||||
name = "Toilet",
|
name = "Toilet",
|
||||||
decisions = {
|
decisions = {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
ScreenManager.register({
|
Screen.register({
|
||||||
id = "walking_to_home",
|
id = "walking_to_home",
|
||||||
name = "Walking to home",
|
name = "Walking to home",
|
||||||
decisions = {
|
decisions = {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
ScreenManager.register({
|
Screen.register({
|
||||||
id = "walking_to_office",
|
id = "walking_to_office",
|
||||||
name = "Walking to office",
|
name = "Walking to office",
|
||||||
decisions = {
|
decisions = {
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
function GameWindow.draw()
|
function GameWindow.draw()
|
||||||
local screen = Context.screens[Context.current_screen]
|
local screen = Context.screens[Context.current_screen]
|
||||||
MapManager.draw(screen.background)
|
Map.draw(screen.background)
|
||||||
UI.draw_top_bar(screen.name)
|
UI.draw_top_bar(screen.name)
|
||||||
if screen and screen.decisions and #screen.decisions > 0 then
|
if screen and screen.decisions and #screen.decisions > 0 then
|
||||||
local available_decisions = {}
|
local available_decisions = {}
|
||||||
for _, decision_id in ipairs(screen.decisions) do
|
for _, decision_id in ipairs(screen.decisions) do
|
||||||
local decision = DecisionManager.get(decision_id)
|
local decision = Decision.get(decision_id)
|
||||||
if decision and decision.condition() then
|
if decision and decision.condition() then
|
||||||
table.insert(available_decisions, decision)
|
table.insert(available_decisions, decision)
|
||||||
end
|
end
|
||||||
@@ -39,7 +39,7 @@ function GameWindow.update()
|
|||||||
if screen and screen.decisions and #screen.decisions > 0 then
|
if screen and screen.decisions and #screen.decisions > 0 then
|
||||||
local available_decisions = {}
|
local available_decisions = {}
|
||||||
for _, decision_id in ipairs(screen.decisions) do
|
for _, decision_id in ipairs(screen.decisions) do
|
||||||
local decision = DecisionManager.get(decision_id)
|
local decision = Decision.get(decision_id)
|
||||||
if decision and decision.condition() then table.insert(available_decisions, decision)
|
if decision and decision.condition() then table.insert(available_decisions, decision)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user