ddcd393d2a
Fixes #85
115 lines
3.2 KiB
Lua
115 lines
3.2 KiB
Lua
local commons = require "scenes.debug.commons.menu"
|
|
local listMenu = require "game.modules.menus.fancy"
|
|
|
|
local defTransitions = require "core.modules.transitions"
|
|
local radTransitions = require "game.modules.transitions"
|
|
|
|
local menu = {}
|
|
menu.commons = commons
|
|
menu.ExitWidget = listMenu.BaseWidget:extend()
|
|
menu.SaveWidget = listMenu.BaseWidget:extend()
|
|
menu.LoadWidget = listMenu.BaseWidget:extend()
|
|
menu.LevelUpWidget = listMenu.BaseWidget:extend()
|
|
menu.AddRemoveWidget = listMenu.BaseWidget:extend()
|
|
menu.ChangeLeaderWidget = listMenu.BaseWidget:extend()
|
|
menu.ItemWidget = listMenu.BaseWidget:extend()
|
|
menu.TitleWidget = listMenu.BaseWidget:extend()
|
|
menu.StartGameWidget = listMenu.BaseWidget:extend()
|
|
|
|
|
|
-- TitleWidget
|
|
function menu.StartGameWidget:new(scene, menuName)
|
|
local str = "Start game"
|
|
if (game.exists) then
|
|
str = "Continue game"
|
|
end
|
|
menu.TitleWidget.super.new(self, scene, menuName, str, "")
|
|
end
|
|
|
|
function menu.StartGameWidget:action()
|
|
self.scene.assets:playSFX("mSelect")
|
|
core.screen:startTransition(defTransitions.circle, defTransitions.default, function() scenes.overworld() end, 424/2, 240/2)
|
|
self.scene.tweens:newTween(0, 0.5, {borderY = 0}, "inOutQuart")
|
|
end
|
|
|
|
-- TitleWidget
|
|
function menu.TitleWidget:new(scene, menuName)
|
|
menu.TitleWidget.super.new(self, scene, menuName, "Return to Title", "")
|
|
end
|
|
|
|
function menu.TitleWidget:action()
|
|
self.scene.assets:playSFX("mBack")
|
|
core.screen:startTransition(defTransitions.circle, radTransitions.borders, function() scenes.title(true) end, 424/2, 240/2)
|
|
end
|
|
|
|
-- ExitWidget
|
|
function menu.ExitWidget:new(scene, menuName)
|
|
menu.ExitWidget.super.new(self, scene, menuName, "Exit", "")
|
|
end
|
|
|
|
function menu.ExitWidget:action()
|
|
self.scene.assets:playSFX("mSelect")
|
|
love.event.quit("000")
|
|
end
|
|
|
|
-- Save game
|
|
function menu.SaveWidget:new(scene, menuName)
|
|
menu.SaveWidget.super.new(self, scene, menuName, "Save game", "")
|
|
end
|
|
|
|
function menu.SaveWidget:action()
|
|
game:write()
|
|
end
|
|
|
|
-- Save game
|
|
function menu.LoadWidget:new(scene, menuName, slot)
|
|
menu.LoadWidget.super.new(self, scene, menuName, "Load file ", slot)
|
|
self.slot = slot
|
|
end
|
|
|
|
function menu.LoadWidget:action()
|
|
game:read(self.slot)
|
|
end
|
|
|
|
-- Level Up
|
|
function menu.LevelUpWidget:new(scene, menuName, character)
|
|
menu.LevelUpWidget.super.new(self, scene, menuName, "Levelup to", character.level + 1)
|
|
self.character = character
|
|
end
|
|
|
|
function menu.LevelUpWidget:action()
|
|
self.character:levelUp()
|
|
end
|
|
|
|
-- Add Remove Widget
|
|
function menu.AddRemoveWidget:new(scene, menuName, character)
|
|
menu.AddRemoveWidget.super.new(self, scene, menuName, "Add/Remove", character.name)
|
|
self.character = character
|
|
end
|
|
|
|
function menu.AddRemoveWidget:action()
|
|
game.characters:addOrRemoveToTeam(self.character.simplename)
|
|
end
|
|
|
|
--Change Team Leader
|
|
function menu.ChangeLeaderWidget:new(scene, menuName)
|
|
menu.ChangeLeaderWidget.super.new(self, scene, menuName, "Change active character", "")
|
|
end
|
|
|
|
function menu.ChangeLeaderWidget:action()
|
|
game.characters:setActiveCharacter(1)
|
|
end
|
|
|
|
-- ItemWidget
|
|
function menu.ItemWidget:new(scene, menuName, itemdata)
|
|
menu.ItemWidget.super.new(self, scene, menuName, itemdata.fullname, "")
|
|
self.category = menuName
|
|
self.itemName = itemdata.name
|
|
end
|
|
|
|
function menu.ItemWidget:action()
|
|
game.loot:addItem(self.category, self.itemName, 1)
|
|
end
|
|
|
|
|
|
return menu
|