parent
61639b86d0
commit
9492e2f7ea
4 changed files with 45 additions and 23 deletions
Binary file not shown.
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 3.9 KiB |
|
@ -41,6 +41,9 @@ function BaseWidget:new(menu)
|
|||
self.canvas.texture = nil
|
||||
self.canvas.needRedraw = true
|
||||
|
||||
self.ox = 0
|
||||
self.oy = 0
|
||||
|
||||
self.order = 0
|
||||
self:register()
|
||||
end
|
||||
|
@ -53,7 +56,7 @@ end
|
|||
function BaseWidget:redrawCanvas()
|
||||
self.width, self.height = self.menu:getWidgetSize(self.id)
|
||||
|
||||
local canvas = love.graphics.newCanvas(self.width, self.height)
|
||||
local canvas = love.graphics.newCanvas(self.width * 2, self.height * 2)
|
||||
love.graphics.setCanvas( canvas )
|
||||
|
||||
self:drawCanvas()
|
||||
|
@ -91,7 +94,7 @@ end
|
|||
|
||||
function BaseWidget:draw(x, y)
|
||||
if self.canvas.texture ~= nil then
|
||||
love.graphics.draw(self.canvas.texture, x, y)
|
||||
love.graphics.draw(self.canvas.texture, x - self.ox, y - self.oy)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -45,6 +45,38 @@ function gui.newBorder(width, height, middlePosition)
|
|||
return texture
|
||||
end
|
||||
|
||||
function gui.newChoiceBack(approximateWidth)
|
||||
local asset = love.graphics.newImage("assets/gui/attacklist.png")
|
||||
local sw, sh = asset:getDimensions()
|
||||
local startAsset = love.graphics.newQuad(0, 0, 21, sh, sw, sh)
|
||||
local midAsset = love.graphics.newQuad(21, 0, 12, sh, sw, sh)
|
||||
local endAsset = love.graphics.newQuad(sw-25, 0, 25, sh, sw, sh)
|
||||
|
||||
local iterations = math.floor((approximateWidth / 12) - 4)
|
||||
local width = (iterations * 12)
|
||||
local canvasWidth = width + 21 + 25
|
||||
|
||||
local canvas = love.graphics.newCanvas(canvasWidth, height)
|
||||
|
||||
love.graphics.setCanvas(canvas)
|
||||
|
||||
love.graphics.draw(asset, startAsset, 0, 0)
|
||||
love.graphics.draw(asset, endAsset, 21 + width, 0)
|
||||
|
||||
for i=1, (iterations) do
|
||||
love.graphics.draw(asset, midAsset, 21 + ((i-1)*12), 0)
|
||||
end
|
||||
|
||||
love.graphics.setCanvas( )
|
||||
|
||||
local imagedata = canvas:newImageData()
|
||||
local texture = love.graphics.newImage( imagedata )
|
||||
imagedata:release()
|
||||
canvas:release()
|
||||
|
||||
return texture
|
||||
end
|
||||
|
||||
function gui.drawBar(x, y, width, height)
|
||||
if (width > 0) then
|
||||
local height = height or 7
|
||||
|
|
|
@ -15,6 +15,8 @@ local MENUPOS_X1, MENUPOS_X2, MENUPOS_Y = 88, 32, 72
|
|||
local MENU_WIDTH, MENU_ITEM_HEIGHT = 180, 17
|
||||
local MENU_ITEM_NUMBER = 6
|
||||
|
||||
gui = require "game.modules.gui"
|
||||
|
||||
function MenuConstructor:new( controller )
|
||||
self.scene = controller
|
||||
end
|
||||
|
@ -155,6 +157,8 @@ function BattleWidget:new(character, menu_name, label1, label2, translationdata)
|
|||
|
||||
BattleWidget.super.new(self, menu, font, label1)
|
||||
|
||||
self.back = gui.newChoiceBack( (MENU_WIDTH - 16) )
|
||||
|
||||
self.label2 = label2
|
||||
end
|
||||
|
||||
|
@ -183,32 +187,15 @@ function BattleWidget:selectAction()
|
|||
end
|
||||
|
||||
function BattleWidget:drawCanvas()
|
||||
local h
|
||||
local asset = love.graphics.newImage("assets/gui/attacklist.png")
|
||||
local sw, sh = asset:getDimensions()
|
||||
local startAsset = love.graphics.newQuad(0, 0, 16, sh, sw, sh)
|
||||
local midAsset = love.graphics.newQuad(16, 0, 1, sh, sw, sh)
|
||||
local endAsset = love.graphics.newQuad(sw-16, 0, 16, sh, sw, sh)
|
||||
love.graphics.draw(self.back, 0, 0)
|
||||
|
||||
local trueWidth = self.width - 32
|
||||
|
||||
love.graphics.draw(asset, startAsset, 0, (self.height - 13) / 2)
|
||||
love.graphics.draw(asset, endAsset, trueWidth-16, (self.height - 13) / 2)
|
||||
|
||||
local iterations = trueWidth-32
|
||||
|
||||
for i=0,iterations do
|
||||
love.graphics.draw(asset, midAsset, 16+i, (self.height - 13) / 2)
|
||||
end
|
||||
|
||||
|
||||
h = math.floor(self.height / 2) - (self.font:getHeight() / 2)
|
||||
h = math.floor(self.height / 2) - (self.font:getHeight() / 2) - 1
|
||||
love.graphics.setColor(0, 0, 0, .8)
|
||||
self.font:print(self.label, 17, h, "left")
|
||||
self.font:print(self.label2, trueWidth - 8, h, "right")
|
||||
self.font:print(self.label2, self.width - 48 + 1, h, "right")
|
||||
utils.graphics.resetColor()
|
||||
self.font:print(self.label, 16, h, "left")
|
||||
self.font:print(self.label2, trueWidth - 9, h, "right")
|
||||
self.font:print(self.label2, self.width - 48, h, "right")
|
||||
end
|
||||
|
||||
function BattleWidget:action()
|
||||
|
|
Loading…
Reference in a new issue