2021-04-05 12:05:51 +02:00
|
|
|
local RadianceMenu = require "game.modules.menus.parents.menu"
|
|
|
|
local RadianceWidget = require "game.modules.menus.parents.widget"
|
|
|
|
local SaveMenu = RadianceMenu:extend()
|
|
|
|
local SaveWidget = RadianceWidget:extend()
|
|
|
|
|
|
|
|
local gui = require "game.modules.gui"
|
|
|
|
|
2021-05-05 08:30:32 +02:00
|
|
|
local defTransitions = require "birb.modules.transitions"
|
2021-04-05 12:29:45 +02:00
|
|
|
local radTransitions = require "game.modules.transitions"
|
2021-04-05 12:05:51 +02:00
|
|
|
|
|
|
|
local HPADDING = 68
|
|
|
|
local VPADDING = 28
|
|
|
|
|
|
|
|
function SaveMenu:new(scene)
|
|
|
|
local w, h = 424 - (HPADDING * 2), 240 - (VPADDING * 2)
|
|
|
|
|
|
|
|
SaveMenu.super.new(self, scene, "save", HPADDING, VPADDING + 1, w, h, 3)
|
|
|
|
local metadata = game:getMetadata()
|
|
|
|
for i, save in ipairs(metadata) do
|
|
|
|
SaveWidget(self.scene, i, save)
|
|
|
|
end
|
|
|
|
self.textBox = gui.newTextBox("assets/gui/dialogbox.png", w - 8, (h / 3))
|
|
|
|
end
|
|
|
|
|
|
|
|
function SaveMenu:cancelAction()
|
2021-04-11 10:32:49 +02:00
|
|
|
self.scene.assets:playSFX("mBack")
|
2021-04-05 12:05:51 +02:00
|
|
|
self.scene.menusystem:reset()
|
|
|
|
self.scene.haveMenu = false
|
|
|
|
end
|
|
|
|
|
|
|
|
function SaveWidget:new(scene, saveid, savedata)
|
|
|
|
SaveWidget.super.new(self, scene, "save")
|
|
|
|
self.scene.menusystem:switchMenu("save")
|
|
|
|
self.saveid = saveid
|
|
|
|
self.savedata = savedata
|
|
|
|
self.emeralds = gui.getEmeraldsTexture(self.savedata.emeralds)
|
|
|
|
end
|
|
|
|
|
|
|
|
function SaveWidget:drawCanvas()
|
|
|
|
local basex, basey = 4, 2
|
|
|
|
love.graphics.draw(self.menu.textBox, basex, basey)
|
|
|
|
if (self.savedata.exist) then
|
|
|
|
local str = "Save " .. self.saveid
|
|
|
|
str = str .. "(" .. utils.math.numberToString(self.savedata.completion,3) .. "%)"
|
|
|
|
str = str .. " - " .. utils.time.toString(self.savedata.gametime)
|
|
|
|
str = str .. "\n"
|
|
|
|
str = str .. self.savedata.location .. "\n"
|
|
|
|
str = str .. "Rings: " .. self.savedata.rings
|
|
|
|
self.font:draw(str, basex + 8, basey + 4)
|
|
|
|
|
|
|
|
for i, charName in ipairs(self.savedata.team) do
|
2021-05-15 21:43:15 +02:00
|
|
|
local data = core.datas:get("characters", charName)
|
2021-04-05 12:05:51 +02:00
|
|
|
local x = 18*(#self.savedata.team - i + 1) + 4 + basex
|
|
|
|
self.scene.assets.tileset["charicons"]:drawTile(data.icon,self.width - x, basey + 4)
|
|
|
|
end
|
|
|
|
|
|
|
|
love.graphics.draw(self.emeralds, basex + 168, basey + 21)
|
|
|
|
else
|
|
|
|
self.font:draw("New save", basex + 8, basey + 4)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
function SaveWidget:action()
|
2021-04-11 10:32:49 +02:00
|
|
|
self.scene.assets:playSFX("mSelect")
|
2021-04-05 12:05:51 +02:00
|
|
|
game:read(self.saveid)
|
2021-08-15 16:26:05 +02:00
|
|
|
core.screen:startTransition(radTransitions.borders, defTransitions.circle, function() scenes.menus.main() end, 424/2, 240/2)
|
2021-04-05 12:05:51 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
return SaveMenu
|