Ajout des derniers développement #1

Merged
kazhnuz merged 68 commits from chronicles-cbs into master 2020-08-02 11:14:18 +02:00
4 changed files with 33 additions and 2 deletions
Showing only changes of commit f83c67f96a - Show all commits

View file

@ -35,6 +35,7 @@ Game.gui = require "game.modules.gui"
function Game:new() function Game:new()
self.slot = -1 self.slot = -1
self.slotNumber = 3
self.gametime = 0 self.gametime = 0
self.characters = Characters(self) self.characters = Characters(self)
@ -95,7 +96,7 @@ function Game:getSaveFile(saveslot, absolute)
end end
function Game:resetSaves() function Game:resetSaves()
for i=1, 3 do for i=1, self.slotNumber do
filepath = self:getSaveFile(i, true) filepath = self:getSaveFile(i, true)
if love.filesystem.exists("save" .. i .. ".save") then if love.filesystem.exists("save" .. i .. ".save") then
love.filesystem.remove( "save" .. i .. ".save" ) love.filesystem.remove( "save" .. i .. ".save" )

View file

@ -7,7 +7,7 @@ end
function GamePanel:drawContent(x, y) function GamePanel:drawContent(x, y)
local debugString = "# Save system data" .. "\n" local debugString = "# Save system data" .. "\n"
debugString = debugString .. "Current slot: " .. game.slot .. " / 3" .. "\n" debugString = debugString .. "Current slot: " .. game.slot .. " / " .. game.slotNumber .. "\n"
debugString = debugString .. "Gametime: " .. game:getTimeString() .. "\n" debugString = debugString .. "Gametime: " .. game:getTimeString() .. "\n"
love.graphics.print(debugString, x, y) love.graphics.print(debugString, x, y)

View file

@ -43,8 +43,16 @@ function DebugMenu:buildSaveMenu()
self:addCharacterMenu(name, data) self:addCharacterMenu(name, data)
end end
self:addSubMenu("load", "save", "Load Saves")
for i=1, game.slotNumber do
menu.LoadWidget(self, "load", i)
end
menu.SaveWidget(self, "save")
menu.commons.SubMenuWidget(self, "save", "BaseMenu", "Back") menu.commons.SubMenuWidget(self, "save", "BaseMenu", "Back")
menu.commons.SubMenuWidget(self, "characters", "save", "Back") menu.commons.SubMenuWidget(self, "characters", "save", "Back")
menu.commons.SubMenuWidget(self, "load", "save", "Back")
end end
function DebugMenu:addCharacterMenu(name, data) function DebugMenu:addCharacterMenu(name, data)

View file

@ -3,6 +3,8 @@ local menu = {}
menu.commons = commons menu.commons = commons
menu.ExitWidget = commons.DebugWidget:extend() menu.ExitWidget = commons.DebugWidget:extend()
menu.ShowBackgroundWidget = commons.DebugWidget:extend() menu.ShowBackgroundWidget = commons.DebugWidget:extend()
menu.SaveWidget = commons.DebugWidget:extend()
menu.LoadWidget = commons.DebugWidget:extend()
-- ExitWidget -- ExitWidget
function menu.ExitWidget:new(scene, menuName) function menu.ExitWidget:new(scene, menuName)
@ -22,4 +24,24 @@ function menu.ShowBackgroundWidget:action()
self.scene.menusystem:deactivate() self.scene.menusystem:deactivate()
end end
-- Save game
function menu.SaveWidget:new(scene, menuName)
menu.ShowBackgroundWidget.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.ShowBackgroundWidget.super.new(self, scene, menuName, "Load file " .. slot)
self.slot = slot
end
function menu.LoadWidget:action()
game:read(self.slot)
end
return menu return menu