From 9492e2f7ea60d1e0311f60d41873e065b2426bd6 Mon Sep 17 00:00:00 2001 From: Kazhnuz Date: Tue, 18 Aug 2020 23:46:11 +0200 Subject: [PATCH] feat: new battlesystem choice boxe Fix #35 --- sonic-radiance.love/assets/gui/attacklist.png | Bin 1899 -> 4028 bytes .../core/modules/menusystem/widgets/init.lua | 7 ++-- sonic-radiance.love/game/modules/gui/init.lua | 32 ++++++++++++++++++ .../scenes/battlesystem/menu.lua | 29 +++++----------- 4 files changed, 45 insertions(+), 23 deletions(-) diff --git a/sonic-radiance.love/assets/gui/attacklist.png b/sonic-radiance.love/assets/gui/attacklist.png index 9234aaf351893112c92781222d3b0cb7fd9e9785..c2b2f96d0d3a8f4f459d6f1ef0e69f22b0579a8b 100644 GIT binary patch delta 4008 zcmV;Z4_EN(4!j?b7k>^21^@s6_sE#~000ajdQ@0+Qek%>aB^>EX>4U6ba`-PAZ2)I zW&i+q+NGFjaxA$Gg#YstJ_1P)T#myv!Z+~o{ee}|lQeI}GvV&&trjlGL?Y2{|L5Pw z{fmc$R$bCkbIaNDNG-M4`BMG!==VMNbl>lzyr=m6?YQ&%J%157Bz(&Av*!2s=6K}# z_#U6{IGyAAWuW#B6vp=x{T(RQcY^o$$3zmI3H*8o>hC}j-!`23TH`#alu>F^Ei&u=dc+{cONe@}zF z-z($?dinG79(O-a1pPhS7t^oAOz*e&9RD>?^5fg4>#x^2tDdu;-Sw2&a(*}UvBlsn zlxGbi!M!c>EWDKOkrE&ucB{?0{z^*qON zDTJFM@d+5~ipBz#VaVA#mw`w)Z&39H_~ZGVkT0+TYI?(5*~vn zV~#xcDZY1I>lC7w@}4Ej-ZC^#J;zEo_mx4=^UOqlG^wl3g>HFip}D=w$Yp5pizGS1 zQc0|KM7vZ3?TBYSiDOjC|CU})?nnJ78Gm`4pif|fbn2RBj;9jzC?Oo&-#XilwU50B zo2`fam$qu%hR5i+NL)Sbwu*F?+^f32MyT7Td?YI6akX4IJz6TUu>39U%sf(*vck#z6bP~R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MFZKulQ;9tSY6yUgO z!-g$u?)`9VZ({@@QOPRr-G0#ti=Nb`g63!pZhPXLc)A;NOo0c-7)4Tc2@MpsTJl%< zm-zY-gVzv@mXzQuKYR_J<);^4kri9=AAEflAHECmldtcD({tFvBkng>AD)60zJCa> z@56rl3@?s;0rlsYhVMcBIi}%zP`|~rM_6Mcp~z+os~QLpRfxs1@<;}saeQ&Cn^K!BT}s)s=_moUh3Z#s2MWXARvtpJ+HEL^lOn(j5dX zWi3Cp7X-&_R)^4_+1mt(yRDKO)_)^RT~n$(VQQ18ZQ|U=hRp~{8fZ$ef;^{M;4Byd zymZT>GH^yKPmmkeyg-FzS;RqI;4Y}Uk?hFwIH(RwDc>U1^$z3;s16#Xt}zO^#LLXKX-ExT*0gn~y?ab75q z4i84qZqmGE@oe}%$P?&^8apSH(*k!2IuSJTW{zHm(b9qIK?i1#Ay^R1n_;qti3aSD z168}ZBQ_5kfO~LW5ZEA&mLr-MqMC)!)uSUpXS6#EDPXP0Ra;#CVJl4rIQ#ACw~B=Nkl#F5JYDQ4u?5c3_&5oH}RMRxl=kwZmx!TL5{EyW=f$?>wF{34*aM#M*&de6fM99J2%{*DOxCRZZ_eTIfLsZcNROU8tx7 bqk8xQKV}~_w-QVe00000NkvXXu0mjfZX#lb diff --git a/sonic-radiance.love/core/modules/menusystem/widgets/init.lua b/sonic-radiance.love/core/modules/menusystem/widgets/init.lua index 15ab5b2..8e90d03 100644 --- a/sonic-radiance.love/core/modules/menusystem/widgets/init.lua +++ b/sonic-radiance.love/core/modules/menusystem/widgets/init.lua @@ -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 diff --git a/sonic-radiance.love/game/modules/gui/init.lua b/sonic-radiance.love/game/modules/gui/init.lua index 5baa59a..fde1473 100644 --- a/sonic-radiance.love/game/modules/gui/init.lua +++ b/sonic-radiance.love/game/modules/gui/init.lua @@ -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 diff --git a/sonic-radiance.love/scenes/battlesystem/menu.lua b/sonic-radiance.love/scenes/battlesystem/menu.lua index e64033a..78aca25 100644 --- a/sonic-radiance.love/scenes/battlesystem/menu.lua +++ b/sonic-radiance.love/scenes/battlesystem/menu.lua @@ -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()