feat: add basic debug menu
This commit is contained in:
parent
a3cf5bef63
commit
4b9ba5eed6
8 changed files with 229 additions and 1 deletions
|
@ -40,6 +40,8 @@ function Game:new()
|
||||||
self.characters = Characters(self)
|
self.characters = Characters(self)
|
||||||
self.ennemies = Ennemies(self)
|
self.ennemies = Ennemies(self)
|
||||||
self.skills = Skills(self)
|
self.skills = Skills(self)
|
||||||
|
|
||||||
|
self.version = "0.0.0"
|
||||||
end
|
end
|
||||||
|
|
||||||
function Game:setData(data)
|
function Game:setData(data)
|
||||||
|
|
|
@ -30,7 +30,7 @@ function love.load()
|
||||||
core = Core(true)
|
core = Core(true)
|
||||||
game = Game()
|
game = Game()
|
||||||
|
|
||||||
scenes.cbs()
|
scenes.debug.menu()
|
||||||
end
|
end
|
||||||
|
|
||||||
function love.update(dt)
|
function love.update(dt)
|
||||||
|
|
51
sonic-radiance.love/scenes/debug/commons/assets.lua
Normal file
51
sonic-radiance.love/scenes/debug/commons/assets.lua
Normal file
|
@ -0,0 +1,51 @@
|
||||||
|
return {
|
||||||
|
["tilesets"] = {
|
||||||
|
{"charicons", "assets/sprites/characters/charicons"},
|
||||||
|
{"normaltiles", "assets/backgrounds/normaltile"},
|
||||||
|
{"sptiles", "assets/backgrounds/specialtile"},
|
||||||
|
{"borders", "assets/backgrounds/borders"},
|
||||||
|
},
|
||||||
|
["sprites"] = {
|
||||||
|
{"cursorground", "assets/gui/cursor/ground"},
|
||||||
|
{"hitGFX", "assets/sprites/gfx/hit"},
|
||||||
|
},
|
||||||
|
["textures"] = {
|
||||||
|
{"menucursor", "assets/gui/cursor-menulist.png"},
|
||||||
|
{"statusbar", "assets/gui/status_bar.png"},
|
||||||
|
{"cursorpeak", "assets/gui/cursor/peak.png"},
|
||||||
|
{"actorsShadow", "assets/sprites/shadow.png"},
|
||||||
|
{"emptytile", "assets/backgrounds/tilemask.png"},
|
||||||
|
|
||||||
|
{"e_speedster", "assets/gui/emblem_speedster.png"},
|
||||||
|
{"e_technic", "assets/gui/emblem_technic.png"},
|
||||||
|
{"e_power", "assets/gui/emblem_power.png"},
|
||||||
|
|
||||||
|
{"m_speedster", "assets/gui/emblem_speedster_mask.png"},
|
||||||
|
{"m_technic", "assets/gui/emblem_technic_mask.png"},
|
||||||
|
{"m_power", "assets/gui/emblem_power_mask.png"},
|
||||||
|
|
||||||
|
{"hudturn", "assets/gui/strings/hudturn.png"},
|
||||||
|
{"battlecompleted", "assets/gui/strings/battle_completed.png" }
|
||||||
|
},
|
||||||
|
["fonts"] = {
|
||||||
|
{"small", "assets/gui/fonts/PixelOperator.ttf", 16},
|
||||||
|
{"victory", "assets/gui/fonts/vipnagorgialla.ttf", 12}
|
||||||
|
},
|
||||||
|
["imagefonts"] = {
|
||||||
|
{"hudnbrs", "assets/gui/fonts/hudnumbers"},
|
||||||
|
{"hudnbrs_small", "assets/gui/fonts/hudsmallnumbers"},
|
||||||
|
},
|
||||||
|
["sfx"] = {
|
||||||
|
{"hit", "assets/sfx/hit.wav"},
|
||||||
|
{"hitconnect", "assets/sfx/hitconnect.wav"},
|
||||||
|
{"jump", "assets/sfx/jump.wav"},
|
||||||
|
{"woosh", "assets/sfx/woosh.wav"},
|
||||||
|
{"spincharge", "assets/sfx/spincharge.wav"},
|
||||||
|
{"spinrelease", "assets/sfx/spinrelease.wav"},
|
||||||
|
|
||||||
|
{"mBack", "assets/sfx/menus/back.wav"},
|
||||||
|
{"mBeep", "assets/sfx/menus/beep.wav"},
|
||||||
|
{"mSelect", "assets/sfx/menus/select.wav"},
|
||||||
|
{"mError", "assets/sfx/menus/error.wav"},
|
||||||
|
}
|
||||||
|
}
|
60
sonic-radiance.love/scenes/debug/commons/menu.lua
Normal file
60
sonic-radiance.love/scenes/debug/commons/menu.lua
Normal file
|
@ -0,0 +1,60 @@
|
||||||
|
local menu = {}
|
||||||
|
|
||||||
|
local ListBox = require "core.modules.menusystem.listbox"
|
||||||
|
local Widget = require "core.modules.menusystem.widgets"
|
||||||
|
|
||||||
|
menu.DebugMenu = ListBox:extend()
|
||||||
|
menu.DebugWidget = Widget.Text:extend()
|
||||||
|
menu.SubMenuWidget = menu.DebugWidget:extend()
|
||||||
|
|
||||||
|
local CONST = {}
|
||||||
|
CONST.MENU = {}
|
||||||
|
CONST.MENU.X = 16
|
||||||
|
CONST.MENU.Y = 48
|
||||||
|
CONST.MENU.W = 424/2
|
||||||
|
CONST.MENU.ITEM_NUMBER = 10
|
||||||
|
CONST.MENU.ITEM_HEIGHT = 18
|
||||||
|
|
||||||
|
-- Basic menu structure
|
||||||
|
function menu.DebugMenu:new(scene, name)
|
||||||
|
self.scene = scene
|
||||||
|
local x, y = CONST.MENU.X, CONST.MENU.Y
|
||||||
|
local w, h = CONST.MENU.W, CONST.MENU.ITEM_NUMBER * CONST.MENU.ITEM_HEIGHT
|
||||||
|
menu.DebugMenu.super.new(self, scene.menusystem, name, x, y, w, h, CONST.MENU.ITEM_NUMBER)
|
||||||
|
end
|
||||||
|
|
||||||
|
function menu.DebugMenu:drawCursor()
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Widget
|
||||||
|
function menu.DebugWidget:new(scene, menu_name, label)
|
||||||
|
local font = scene.assets.fonts["small"]
|
||||||
|
self.scene = scene
|
||||||
|
local widgetMenu = scene.menusystem.menus[menu_name]
|
||||||
|
menu.DebugWidget.super.new(self, widgetMenu, font, label)
|
||||||
|
end
|
||||||
|
|
||||||
|
function menu.DebugWidget:drawCanvas()
|
||||||
|
local h = math.floor(self.height / 2) - (self.font:getHeight() / 2)
|
||||||
|
self.font:draw(self.label, 8, h, -1, "left")
|
||||||
|
end
|
||||||
|
|
||||||
|
function menu.DebugWidget:drawSelected(x, y, w, h)
|
||||||
|
love.graphics.setColor(1, 1, 0, 1)
|
||||||
|
self:draw(x, y, w, h)
|
||||||
|
utils.graphics.resetColor()
|
||||||
|
end
|
||||||
|
|
||||||
|
-- SubMenuWidget
|
||||||
|
function menu.SubMenuWidget:new(scene, menu_name, newmenu, name)
|
||||||
|
menu.SubMenuWidget.super.new(self, scene, menu_name, name)
|
||||||
|
self.newmenu = newmenu or "BaseMenu"
|
||||||
|
end
|
||||||
|
|
||||||
|
function menu.SubMenuWidget:action()
|
||||||
|
self.scene.menusystem:switchMenu(self.newmenu)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
return menu
|
3
sonic-radiance.love/scenes/debug/init.lua
Normal file
3
sonic-radiance.love/scenes/debug/init.lua
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
return {
|
||||||
|
menu = require "scenes.debug.menu"
|
||||||
|
}
|
75
sonic-radiance.love/scenes/debug/menu/init.lua
Normal file
75
sonic-radiance.love/scenes/debug/menu/init.lua
Normal file
|
@ -0,0 +1,75 @@
|
||||||
|
local Scene = require "core.modules.scenes"
|
||||||
|
local menu = require "scenes.debug.menu.menu"
|
||||||
|
|
||||||
|
local DebugMenu = Scene:extend()
|
||||||
|
|
||||||
|
function DebugMenu:new()
|
||||||
|
DebugMenu.super.new(self)
|
||||||
|
self.assets:batchImport("scenes.debug.commons.assets")
|
||||||
|
menu.commons.DebugMenu(self, "BaseMenu")
|
||||||
|
menu.SceneWidget(self, "BaseMenu", scenes.title, "Launch Game")
|
||||||
|
self:buildBattleMenu()
|
||||||
|
self:buildOverworldMenu()
|
||||||
|
self:buildSaveMenu()
|
||||||
|
self:buildOtherMenu()
|
||||||
|
self:buildOptionsMenu()
|
||||||
|
menu.ExitWidget(self, "BaseMenu")
|
||||||
|
|
||||||
|
self.menusystem:activate()
|
||||||
|
self.menusystem:switchMenu("BaseMenu")
|
||||||
|
end
|
||||||
|
|
||||||
|
function DebugMenu:buildOptionsMenu()
|
||||||
|
self:addSubMenu("options", "BaseMenu", "Options")
|
||||||
|
self:addSubMenu("backgrounds", "options", "Set Background")
|
||||||
|
menu.ShowBackgroundWidget(self, "options")
|
||||||
|
|
||||||
|
menu.commons.SubMenuWidget(self, "backgrounds", "options", "Back")
|
||||||
|
menu.commons.SubMenuWidget(self, "options", "BaseMenu", "Back")
|
||||||
|
end
|
||||||
|
|
||||||
|
function DebugMenu:buildOverworldMenu()
|
||||||
|
self:addSubMenu("overworld", "BaseMenu", "Overworld")
|
||||||
|
menu.commons.SubMenuWidget(self, "overworld", "BaseMenu", "Back")
|
||||||
|
end
|
||||||
|
|
||||||
|
function DebugMenu:buildBattleMenu()
|
||||||
|
self:addSubMenu("combat", "BaseMenu", "Battle System")
|
||||||
|
menu.SceneWidget(self, "combat", scenes.cbs, "Launch Battle")
|
||||||
|
|
||||||
|
menu.commons.SubMenuWidget(self, "combat", "BaseMenu", "Back")
|
||||||
|
end
|
||||||
|
|
||||||
|
function DebugMenu:buildSaveMenu()
|
||||||
|
self:addSubMenu("save", "BaseMenu", "Save System")
|
||||||
|
menu.commons.SubMenuWidget(self, "save", "BaseMenu", "Back")
|
||||||
|
end
|
||||||
|
|
||||||
|
function DebugMenu:buildOtherMenu()
|
||||||
|
self:addSubMenu("other", "BaseMenu", "Other gameplay")
|
||||||
|
menu.SceneWidget(self, "other", scenes.test, "Minigame Engine")
|
||||||
|
|
||||||
|
menu.commons.SubMenuWidget(self, "other", "BaseMenu", "Back")
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function DebugMenu:update(dt)
|
||||||
|
if (love.keyboard.isDown("space") and (not self.menusystem.isActive)) then
|
||||||
|
self.menusystem:activate()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function DebugMenu:addSubMenu(submenu, parent, name)
|
||||||
|
local parent = parent or "BaseMenu"
|
||||||
|
menu.commons.DebugMenu(self, submenu)
|
||||||
|
menu.commons.SubMenuWidget(self, parent, submenu, name .. " >")
|
||||||
|
end
|
||||||
|
|
||||||
|
function DebugMenu:draw()
|
||||||
|
if (self.menusystem.isActive) then
|
||||||
|
self.assets.fonts["small"]:print("## SONIC RADIANCE - DEBUG MENU ##", 424/2, 8, "center")
|
||||||
|
self.assets.fonts["small"]:print("v" .. game.version, 424 - 8, 240 - 22, "right")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return DebugMenu;
|
36
sonic-radiance.love/scenes/debug/menu/menu.lua
Normal file
36
sonic-radiance.love/scenes/debug/menu/menu.lua
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
local commons = require "scenes.debug.commons.menu"
|
||||||
|
local menu = {}
|
||||||
|
menu.commons = commons
|
||||||
|
menu.ExitWidget = commons.DebugWidget:extend()
|
||||||
|
menu.ShowBackgroundWidget = commons.DebugWidget:extend()
|
||||||
|
menu.SceneWidget = commons.DebugWidget:extend()
|
||||||
|
|
||||||
|
-- ExitWidget
|
||||||
|
function menu.ExitWidget:new(scene, menuName)
|
||||||
|
menu.ExitWidget.super.new(self, scene, menuName, "Exit")
|
||||||
|
end
|
||||||
|
|
||||||
|
function menu.ExitWidget:action()
|
||||||
|
love.event.quit("000")
|
||||||
|
end
|
||||||
|
|
||||||
|
-- ShowBackground
|
||||||
|
function menu.ShowBackgroundWidget:new(scene, menuName)
|
||||||
|
menu.ShowBackgroundWidget.super.new(self, scene, menuName, "Show Background")
|
||||||
|
end
|
||||||
|
|
||||||
|
function menu.ShowBackgroundWidget:action()
|
||||||
|
self.scene.menusystem:deactivate()
|
||||||
|
end
|
||||||
|
|
||||||
|
-- SceneWidget
|
||||||
|
function menu.SceneWidget:new(scene, menuName, newScene, newSceneName)
|
||||||
|
menu.SceneWidget.super.new(self, scene, menuName, newSceneName)
|
||||||
|
self.newScene = newScene
|
||||||
|
end
|
||||||
|
|
||||||
|
function menu.SceneWidget:action()
|
||||||
|
self.newScene()
|
||||||
|
end
|
||||||
|
|
||||||
|
return menu
|
|
@ -2,4 +2,5 @@ return {
|
||||||
test = require "scenes.test_scene",
|
test = require "scenes.test_scene",
|
||||||
title = require "scenes.titlescreen",
|
title = require "scenes.titlescreen",
|
||||||
cbs = require "scenes.battlesystem",
|
cbs = require "scenes.battlesystem",
|
||||||
|
debug = require "scenes.debug",
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue