From cb5f9eec5a83d2a8ead17b0c2fd2bac701130da0 Mon Sep 17 00:00:00 2001 From: Kazhnuz Date: Sat, 1 Aug 2020 14:01:08 +0200 Subject: [PATCH] feat: background viewer --- .../scenes/debug/commons/menu.lua | 9 ++++- sonic-radiance.love/scenes/debug/init.lua | 5 ++- .../scenes/debug/menu/init.lua | 1 + .../scenes/debug/viewers/battleBack/init.lua | 40 +++++++++++++++++++ .../scenes/debug/viewers/battleBack/menu.lua | 18 +++++++++ 5 files changed, 71 insertions(+), 2 deletions(-) create mode 100644 sonic-radiance.love/scenes/debug/viewers/battleBack/init.lua create mode 100644 sonic-radiance.love/scenes/debug/viewers/battleBack/menu.lua diff --git a/sonic-radiance.love/scenes/debug/commons/menu.lua b/sonic-radiance.love/scenes/debug/commons/menu.lua index 3e89687..4dcb1f0 100644 --- a/sonic-radiance.love/scenes/debug/commons/menu.lua +++ b/sonic-radiance.love/scenes/debug/commons/menu.lua @@ -13,7 +13,7 @@ CONST.MENU = {} CONST.MENU.X = 16 CONST.MENU.Y = 48 CONST.MENU.W = 424/2 -CONST.MENU.ITEM_NUMBER = 10 +CONST.MENU.ITEM_NUMBER = 8 CONST.MENU.ITEM_HEIGHT = 18 -- Basic menu structure @@ -28,6 +28,13 @@ function menu.DebugMenu:drawCursor() end +function menu.DebugMenu:draw() + love.graphics.setColor(0, 0, 0, 0.5) + love.graphics.rectangle("fill", self.x, self.y, self.w, self.h) + utils.graphics.resetColor() + menu.DebugMenu.super.draw(self) +end + -- Widget function menu.DebugWidget:new(scene, menu_name, label) local font = scene.assets.fonts["small"] diff --git a/sonic-radiance.love/scenes/debug/init.lua b/sonic-radiance.love/scenes/debug/init.lua index 1cf1b92..f255393 100644 --- a/sonic-radiance.love/scenes/debug/init.lua +++ b/sonic-radiance.love/scenes/debug/init.lua @@ -1,3 +1,6 @@ return { - menu = require "scenes.debug.menu" + menu = require "scenes.debug.menu", + viewers = { + battleBack = require "scenes.debug.viewers.battleBack" + } } diff --git a/sonic-radiance.love/scenes/debug/menu/init.lua b/sonic-radiance.love/scenes/debug/menu/init.lua index 39c33a4..bae199c 100644 --- a/sonic-radiance.love/scenes/debug/menu/init.lua +++ b/sonic-radiance.love/scenes/debug/menu/init.lua @@ -36,6 +36,7 @@ end function DebugMenu:buildBattleMenu() self:addSubMenu("combat", "BaseMenu", "Battle System") menu.commons.SceneWidget(self, "combat", scenes.cbs, "Launch Battle") + menu.commons.SceneWidget(self, "combat", scenes.debug.viewers.battleBack, "Background Viewer") menu.commons.SubMenuWidget(self, "combat", "BaseMenu", "Back") end diff --git a/sonic-radiance.love/scenes/debug/viewers/battleBack/init.lua b/sonic-radiance.love/scenes/debug/viewers/battleBack/init.lua new file mode 100644 index 0000000..e368bb4 --- /dev/null +++ b/sonic-radiance.love/scenes/debug/viewers/battleBack/init.lua @@ -0,0 +1,40 @@ +local Scene = require "core.modules.scenes" +local menu = require "scenes.debug.viewers.battleBack.menu" + +local BackgroundViewer = Scene:extend() +local Background = require "game.modules.drawing.parallaxBackground" +local backgroundList = require "datas.gamedata.maps.shoot.zones" + + +function BackgroundViewer:new() + BackgroundViewer.super.new(self) + self.assets:batchImport("scenes.debug.commons.assets") + menu.commons.DebugMenu(self, "MainMenu") + + self:setBackground("city") + + for backId, backgroundData in pairs(backgroundList) do + menu.ShowBackgroundWidget(self, "MainMenu", backgroundData.name, backId) + end + menu.commons.SceneWidget(self, "MainMenu", scenes.debug.menu, "Back") + + self.menusystem:activate() + self.menusystem:switchMenu("MainMenu") +end + + +function BackgroundViewer:update(dt) + if (love.keyboard.isDown("z") and (not self.menusystem.isActive)) then + self.menusystem:activate() + end +end + +function BackgroundViewer:setBackground(newBackground) + self.background = Background(self, 5, 1, newBackground) +end + +function BackgroundViewer:draw() + self.background:draw() +end + +return BackgroundViewer diff --git a/sonic-radiance.love/scenes/debug/viewers/battleBack/menu.lua b/sonic-radiance.love/scenes/debug/viewers/battleBack/menu.lua new file mode 100644 index 0000000..dd1230d --- /dev/null +++ b/sonic-radiance.love/scenes/debug/viewers/battleBack/menu.lua @@ -0,0 +1,18 @@ +local commons = require "scenes.debug.commons.menu" +local menu = {} +menu.commons = commons +menu.ShowBackgroundWidget = menu.commons.DebugWidget:extend() + +-- ShowBackground +function menu.ShowBackgroundWidget:new(scene, menuName, backgroundName, backgroundId) + menu.ShowBackgroundWidget.super.new(self, scene, menuName, backgroundName) + self.backgroundId = backgroundId +end + +function menu.ShowBackgroundWidget:action() + self.scene:setBackground(self.backgroundId) + self.scene.menusystem:deactivate() +end + + +return menu