parent
b28d9bf624
commit
cf5da3177d
3 changed files with 110 additions and 28 deletions
|
@ -0,0 +1,75 @@
|
|||
local BasicPage = Object:extend()
|
||||
|
||||
local menu = require "game.modules.menus.fancy"
|
||||
local gui = require "game.modules.gui"
|
||||
local const = require "scenes.overworld.screens.mainmenu.const"
|
||||
|
||||
function BasicPage:new(view, character)
|
||||
self.view = view
|
||||
self.character = game.characters.list[character]
|
||||
|
||||
self.statBox = gui.newTextBox("assets/gui/dialogbox.png", const.CHARPAGESIZE, 48+8)
|
||||
self.nameBox = gui.newTextBox("assets/gui/dialogbox.png", const.CHARPAGESIZE, 40)
|
||||
end
|
||||
|
||||
function BasicPage:getMenuWidgets()
|
||||
|
||||
end
|
||||
|
||||
function BasicPage:update(dt)
|
||||
|
||||
end
|
||||
|
||||
function BasicPage:draw()
|
||||
self:drawIdentity(const.X, const.Y)
|
||||
self:drawLevel(const.X, 100)
|
||||
self:drawStats(const.X, 160)
|
||||
--self:drawWeakStrong(const.X, 160)
|
||||
end
|
||||
|
||||
function BasicPage:drawIdentity(x, y)
|
||||
local identityString = self.character.fullname .. "\n"
|
||||
identityString = identityString .. "Class: " .. self.character.data.class
|
||||
|
||||
love.graphics.draw(self.nameBox, x, y)
|
||||
self.view.scene.assets.fonts["small"]:draw(identityString, x + 6, y + 4, -1, "left")
|
||||
end
|
||||
|
||||
function BasicPage:drawLevel(x, y)
|
||||
local levelString = "Level: " .. self.character.level .. "\n"
|
||||
local levelString = levelString .. "Current exp: " .. self.character.exp .. "\n"
|
||||
local levelString = levelString .. "Next level: " .. self.character.exp_next
|
||||
|
||||
love.graphics.draw(self.statBox, x, y)
|
||||
self.view.scene.assets.fonts["small"]:draw(levelString, x + 6, y + 4, -1, "left")
|
||||
end
|
||||
|
||||
function BasicPage:drawStats(x, y)
|
||||
local statString = "ATK " .. self.character.stats.attack .. "0" .. "\n"
|
||||
statString = statString .. "DEF " .. self.character.stats.defense .. "0" .. "\n"
|
||||
|
||||
local statString2 = "POW " .. self.character.stats.power .. "0" .. "\n"
|
||||
statString2 = statString2 .. "MND " .. self.character.stats.mind .. "0" .. "\n"
|
||||
|
||||
local statString3 = "SPD " .. self.character.stats.speed .. "0" .. "\n"
|
||||
statString3 = statString3 .. "TEK " .. self.character.stats.technic .. "0"
|
||||
|
||||
local pos1 = const.CHARPAGESIZE * (1/3)
|
||||
local pos2 = const.CHARPAGESIZE * (2/3)
|
||||
|
||||
love.graphics.draw(self.nameBox, x, y)
|
||||
|
||||
self.view.scene.assets.fonts["small"]:draw(statString, x + 6, y + 4, -1, "left")
|
||||
self.view.scene.assets.fonts["small"]:draw(statString2, x + 6 + pos1, y + 4, -1, "left")
|
||||
self.view.scene.assets.fonts["small"]:draw(statString3, x + 6 + pos2, y + 4, -1, "left")
|
||||
end
|
||||
|
||||
function BasicPage:drawWeakStrong(x, y)
|
||||
local weakString = "Weak to: Earth, Lightning"
|
||||
local strongString = "Resist To: Fire"
|
||||
|
||||
love.graphics.draw(self.nameBox, x, y)
|
||||
self.view.scene.assets.fonts["small"]:draw(weakString .. "\n" .. strongString, x + 6, y + 4, -1, "left")
|
||||
end
|
||||
|
||||
return BasicPage
|
|
@ -5,24 +5,53 @@ local menu = require "game.modules.menus.fancy"
|
|||
local gui = require "game.modules.gui"
|
||||
local const = require "scenes.overworld.screens.mainmenu.const"
|
||||
|
||||
local BasicPage = require "scenes.overworld.screens.mainmenu.character.basicpage"
|
||||
local pageList = {BasicPage}
|
||||
|
||||
local ReturnWidget = menu.BaseWidget:extend()
|
||||
|
||||
function CharacterScreen:new(scene, character)
|
||||
self.character = game.characters.list[character]
|
||||
self.charName = character
|
||||
|
||||
self.statBox = gui.newTextBox("assets/gui/dialogbox.png", 176, 48+8)
|
||||
self.nameBox = gui.newTextBox("assets/gui/dialogbox.png", 176, 40)
|
||||
self.page = BasicPage(self, character)
|
||||
self.pageIndex = 1
|
||||
|
||||
self.artwork = love.graphics.newImage("datas/gamedata/characters/" .. character .. "/artwork.png")
|
||||
self.artworkOrigin = require("datas.gamedata.characters." .. character .. ".artwork")
|
||||
CharacterScreen.super.new(self, scene, self.character.name)
|
||||
end
|
||||
|
||||
function CharacterScreen:update(dt)
|
||||
local keys = self.scene:getKeys(1)
|
||||
if (keys["left"].isPressed) then
|
||||
self:setPage(self.pageIndex - 1)
|
||||
end
|
||||
if (keys["right"].isPressed) then
|
||||
self:setPage(self.pageIndex + 1)
|
||||
end
|
||||
end
|
||||
|
||||
function CharacterScreen:setPage(newPageIndex)
|
||||
local newPageIndex = newPageIndex or 1
|
||||
if (newPageIndex > #pageList) then
|
||||
newPageIndex = 1
|
||||
end
|
||||
if (newPageIndex < 1) then
|
||||
newPageIndex = #pageList
|
||||
end
|
||||
|
||||
self.pageIndex = newPageIndex
|
||||
self.page = pageList[self.pageIndex](self, self.charName)
|
||||
self.scene.menusystem:reset()
|
||||
self:setMenu()
|
||||
end
|
||||
|
||||
function CharacterScreen:setMenu()
|
||||
local itemNumber = 1
|
||||
local y = const.Y2 - (16*itemNumber) + 2
|
||||
menu.FancyMenu(self.scene, "menu", const.X2 - 128 - 14, y, 128, 1, false)
|
||||
self.page:getMenuWidgets()
|
||||
--menu.BaseWidget(self.scene, "equip", "Change talent", ">")
|
||||
--menu.BaseWidget(self.scene, "equip", "Battle skills", ">")
|
||||
--menu.BaseWidget(self.scene, "equip", "Equipement", ">")
|
||||
|
@ -34,33 +63,10 @@ function CharacterScreen:setMenu()
|
|||
end
|
||||
|
||||
function CharacterScreen:draw()
|
||||
love.graphics.draw(self.nameBox, const.X, const.Y)
|
||||
love.graphics.draw(self.statBox, const.X, 100)
|
||||
love.graphics.draw(self.nameBox, const.X, 160)
|
||||
self.scene.assets.fonts["small"]:setLineHeight(16/18)
|
||||
local identityString = self.character.fullname .. "\n"
|
||||
identityString = identityString .. "Class: " .. self.character.data.class
|
||||
self.scene.assets.fonts["small"]:draw(identityString, const.X + 6, const.Y +4, -1, "left")
|
||||
|
||||
local levelString = "Level: " .. self.character.level .. "\n"
|
||||
local levelString = levelString .. "Current exp: " .. self.character.exp .. "\n"
|
||||
local levelString = levelString .. "Next level: " .. self.character.exp_next
|
||||
|
||||
self.scene.assets.fonts["small"]:draw(levelString, const.X + 6, 104, -1, "left")
|
||||
|
||||
local statString = "ATK " .. self.character.stats.attack .. "0" .. "\n"
|
||||
statString = statString .. "DEF " .. self.character.stats.defense .. "0" .. "\n"
|
||||
statString2 = "POW " .. self.character.stats.power .. "0" .. "\n"
|
||||
statString2 = statString2 .. "MND " .. self.character.stats.mind .. "0" .. "\n"
|
||||
statString3 = "SPD " .. self.character.stats.speed .. "0" .. "\n"
|
||||
statString3 = statString3 .. "TEK " .. self.character.stats.technic .. "0"
|
||||
|
||||
local separatorString = ">" .. "\n" .. ">" .. "\n" .. ">" .. "\n" .. ">" .. "\n" .. ">" .. "\n" .. ">"
|
||||
self.scene.assets.fonts["small"]:draw(statString, const.X + 6, 164, -1, "left")
|
||||
self.scene.assets.fonts["small"]:draw(statString2, const.X + 6 + (176/3), 164, -1, "left")
|
||||
self.scene.assets.fonts["small"]:draw(statString3, const.X + 6 + ((176*2)/3), 164, -1, "left")
|
||||
--self.scene.assets.fonts["small"]:draw(separatorString, 88, 120, -1, "left")
|
||||
--self.scene.assets.fonts["small"]:draw("Weak to: Earth, Lightning \nResist To: Fire", 24+76, 181, -1, "left")
|
||||
if (self.page ~= nil) then
|
||||
self.page:draw()
|
||||
end
|
||||
end
|
||||
|
||||
function CharacterScreen:drawBackground()
|
|
@ -6,5 +6,6 @@ ConstMenu.WIDTH = 424 - 56
|
|||
ConstMenu.HEIGHT = 240 - 80
|
||||
ConstMenu.X2 = 424 - 28
|
||||
ConstMenu.Y2 = 240 - 40
|
||||
ConstMenu.CHARPAGESIZE = 176
|
||||
|
||||
return ConstMenu
|
||||
|
|
Loading…
Reference in a new issue