parent
0c1f18ec64
commit
049c0c22f3
3 changed files with 97 additions and 0 deletions
BIN
sonic-radiance.love/assets/gui/emeralds.png
Normal file
BIN
sonic-radiance.love/assets/gui/emeralds.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.8 KiB |
|
@ -153,5 +153,36 @@ function gui.newTextBox(filename, width, height)
|
||||||
return texture
|
return texture
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function gui.getEmeraldsTexture(number)
|
||||||
|
local canvas = love.graphics.newCanvas(95, 31)
|
||||||
|
local emeralds = love.graphics.newImage("assets/gui/emeralds.png")
|
||||||
|
love.graphics.setCanvas( canvas )
|
||||||
|
for i = 1, 7, 1 do
|
||||||
|
local emerald
|
||||||
|
local x = (i-1)*12
|
||||||
|
if (i > number) then
|
||||||
|
emerald = love.graphics.newQuad(0,0,23,17,23*8, 17)
|
||||||
|
else
|
||||||
|
emerald = love.graphics.newQuad((i*23),0,23,17,23*8, 17)
|
||||||
|
--emerald = love.graphics.newQuad((i*23),0,23,17,23*7, 17)
|
||||||
|
end
|
||||||
|
|
||||||
|
local isPair = (i%2 == 0)
|
||||||
|
local y = 0
|
||||||
|
if (isPair == true) then
|
||||||
|
y = 14
|
||||||
|
end
|
||||||
|
love.graphics.draw(emeralds, emerald,x,y)
|
||||||
|
emerald:release()
|
||||||
|
end
|
||||||
|
|
||||||
|
love.graphics.setCanvas( )
|
||||||
|
local imagedata = canvas:newImageData()
|
||||||
|
local texture = love.graphics.newImage( imagedata )
|
||||||
|
imagedata:release()
|
||||||
|
canvas:release()
|
||||||
|
return texture
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
return gui
|
return gui
|
||||||
|
|
66
sonic-radiance.love/scenes/menus/titlescreen/menu.lua
Normal file
66
sonic-radiance.love/scenes/menus/titlescreen/menu.lua
Normal file
|
@ -0,0 +1,66 @@
|
||||||
|
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"
|
||||||
|
local charutils = require "game.utils.characters"
|
||||||
|
|
||||||
|
|
||||||
|
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()
|
||||||
|
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
|
||||||
|
local data = charutils.getCharacterData(charName)
|
||||||
|
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()
|
||||||
|
game:read(self.saveid)
|
||||||
|
scenes.debug.menu()
|
||||||
|
end
|
||||||
|
|
||||||
|
return SaveMenu
|
Loading…
Reference in a new issue