From cf377f15b803deebb18ea95a28b592c6ef484ae3 Mon Sep 17 00:00:00 2001 From: Kazhnuz Date: Sun, 2 Aug 2020 10:18:40 +0200 Subject: [PATCH] feat: make possible to load all Battle maps --- .../datas/gamedata/maps/battle/init.lua | 1 + sonic-radiance.love/scenes/debug/commons/menu.lua | 9 +++++++-- sonic-radiance.love/scenes/debug/menu/init.lua | 10 +++++++++- sonic-radiance.love/scenes/test_scene/init.lua | 10 ++++------ 4 files changed, 21 insertions(+), 9 deletions(-) create mode 100644 sonic-radiance.love/datas/gamedata/maps/battle/init.lua diff --git a/sonic-radiance.love/datas/gamedata/maps/battle/init.lua b/sonic-radiance.love/datas/gamedata/maps/battle/init.lua new file mode 100644 index 0000000..5a88bd3 --- /dev/null +++ b/sonic-radiance.love/datas/gamedata/maps/battle/init.lua @@ -0,0 +1 @@ +return {"aroom", "bhighway", "crouge", "cruins", "ebeach", "ghill", "hsummit", "library", "mdepot", "tlab"} diff --git a/sonic-radiance.love/scenes/debug/commons/menu.lua b/sonic-radiance.love/scenes/debug/commons/menu.lua index 4dcb1f0..8f03803 100644 --- a/sonic-radiance.love/scenes/debug/commons/menu.lua +++ b/sonic-radiance.love/scenes/debug/commons/menu.lua @@ -65,13 +65,18 @@ function menu.SubMenuWidget:action() end -- SceneWidget -function menu.SceneWidget:new(scene, menuName, newScene, newSceneName) +function menu.SceneWidget:new(scene, menuName, newScene, newSceneName, sceneArgument) menu.SceneWidget.super.new(self, scene, menuName, newSceneName) self.newScene = newScene + self.sceneArgument = sceneArgument end function menu.SceneWidget:action() - self.newScene() + if (self.sceneArgument ~= nil) then + self.newScene(self.sceneArgument) + else + self.newScene() + end end diff --git a/sonic-radiance.love/scenes/debug/menu/init.lua b/sonic-radiance.love/scenes/debug/menu/init.lua index f395090..e95973f 100644 --- a/sonic-radiance.love/scenes/debug/menu/init.lua +++ b/sonic-radiance.love/scenes/debug/menu/init.lua @@ -62,9 +62,17 @@ end function DebugMenu:buildOtherMenu() self:addSubMenu("other", "BaseMenu", "Other gameplay") - menu.commons.SceneWidget(self, "other", scenes.test, "Sonic Battle Maps") + self:addSubMenu("battle", "other", "Sonic Battle Maps") + local mapList = require "datas.gamedata.maps.battle" + for i, name in ipairs(mapList) do + local mapData = require("datas.gamedata.maps.battle." .. name) + local trueName = mapData.name + menu.commons.SceneWidget(self, "battle", scenes.test, trueName, name) + end + menu.commons.SceneWidget(self, "other", scenes.test2, "Shadow Shot Maps") + menu.commons.SubMenuWidget(self, "battle", "other", "Back") menu.commons.SubMenuWidget(self, "other", "BaseMenu", "Back") end diff --git a/sonic-radiance.love/scenes/test_scene/init.lua b/sonic-radiance.love/scenes/test_scene/init.lua index 0a19dea..a8e37a4 100644 --- a/sonic-radiance.love/scenes/test_scene/init.lua +++ b/sonic-radiance.love/scenes/test_scene/init.lua @@ -26,17 +26,15 @@ local MovePlayer = Scene:extend() local World = require "game.modules.world" -function MovePlayer:new(playerNumber, cameraMode) - local playerNumber = playerNumber or 1 - local cameraMode = cameraMode or "split" +function MovePlayer:new(map) MovePlayer.super.new(self) self.assets:batchImport("scenes.test_scene.assets") - World(self, "battle", "tlab") + World(self, "battle", map) - self.world:setPlayerNumber(playerNumber) - self.world.cameras:setMode(cameraMode) + self.world:setPlayerNumber(1) + self.world.cameras:setMode("split") self.world:loadMap() end