From e221a36e74f1322229e096d36e44167fc37d3f76 Mon Sep 17 00:00:00 2001 From: Kazhnuz Date: Thu, 20 Aug 2020 15:39:02 +0200 Subject: [PATCH] feat: first try of a start menu --- .../assets/gui/strings/exp.png | Bin 0 -> 648 bytes .../assets/gui/strings/lvl.png | Bin 0 -> 3546 bytes .../scenes/overworld/actors/player.lua | 6 +- .../scenes/overworld/assets.lua | 6 +- sonic-radiance.love/scenes/overworld/init.lua | 94 +++++++++++++++- .../scenes/overworld/screens/init.lua | 3 + .../overworld/screens/mainmenu/init.lua | 3 + .../overworld/screens/mainmenu/pause.lua | 75 +++++++++++++ .../scenes/overworld/screens/menu.lua | 103 ++++++++++++++++++ .../scenes/overworld/screens/parent.lua | 32 ++++++ 10 files changed, 315 insertions(+), 7 deletions(-) create mode 100644 sonic-radiance.love/assets/gui/strings/exp.png create mode 100644 sonic-radiance.love/assets/gui/strings/lvl.png create mode 100644 sonic-radiance.love/scenes/overworld/screens/init.lua create mode 100644 sonic-radiance.love/scenes/overworld/screens/mainmenu/init.lua create mode 100644 sonic-radiance.love/scenes/overworld/screens/mainmenu/pause.lua create mode 100644 sonic-radiance.love/scenes/overworld/screens/menu.lua create mode 100644 sonic-radiance.love/scenes/overworld/screens/parent.lua diff --git a/sonic-radiance.love/assets/gui/strings/exp.png b/sonic-radiance.love/assets/gui/strings/exp.png new file mode 100644 index 0000000000000000000000000000000000000000..e95a6b2401b52bc0f5de1859da1beaa0abb66c76 GIT binary patch literal 648 zcmV;30(bq1P)EX>4Tx04R}tkv&MmKpe$iQ>8^JBF!M;kfAzR5G&%SRVYG*P%E_RU_SZ@4|zbb@Y5yl{*NPw3V%a{|zGt~4AUmwAfDc| z4aWP#yi%4_;&bA0lP*a7$aLA`H^wEGIhM(r*~~mKPb`$WSngt_Y-+?)#4%OVDWA)E ztTNtWtX1nu`=0EDk%GRm%ygO~NMR965FtQD9TikzBTlPMiiHgACw=_Gu3sdVOs)zP zax9<*4U+2z`-9)zTE)bqmlR0?y)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BDzdUAJ} z*1b(Vxdu&)11aKkcO7>}GNkmo{C`Q9JFff}gt?b$UlUf%Q!Gt}@@20H@?>`FU8ajW zx7^mIWh=mTYO00OK{>yaGHS1g=|Xp+Zbtpd1Tejrk9OVNMEeduDqX0Ex8C1g6tPDl z-$G1s4I|e;XhNc8y~H=asFaV2?mHd-RK;g@a-W7MW+np+&Cq$hQ8yhzn)ISH2R-Ko zNSVmsGe)WGQMPMF{~Ahi3~rImDKDIS50%H^44HG?p@kjR{X#>YR~{5BCXa!=QmwnK zzN^js%s^G{S2)uK=YJ&7y(IpvK=-YRKNEOf#YHN9;qgU6F3q~K^#+DCq4mp!%hTe? zoRm@|&6}S&ZQ;iC%f|A<(S7yCzY}CH9Z=ByA2B<2BVavO2mk;9glR)VP)S2WAaHVT zW@&6?004NLeUUv#!$2IxUsI(;Dk9Aw;*g;_Sr9AYs8uLJg-|QB>R>+l1x*@~6c5Z%%qY+ zF25>-UJ=G1qDX+36w8)XFrEF@%Q^YY<(KpOAsMIMjaJYVIxkfPKt#L?I(Tw!>(T>mrSk-6ml$} z1`U$y2m6EH-CD)Oq?Z&)0=+Me^Dzp9c7ayIalVfor*#4ZpMfjA_C zX>@2HM@dakSAh-}00010Nkl") + menu.BaseWidget(self.scene, "main", "Items", ">") + --self.menuObj.BoxedWidget(self.scene, "main", "Equipments", ">") + menu.BaseWidget(self.scene, "main", "Chao", ">") + menu.BaseWidget(self.scene, "main", "Encylopedia", ">") + menu.BaseWidget(self.scene, "main", "Save", ">") + menu.BaseWidget(self.scene, "main", "Options", ">") + menu.BaseWidget(self.scene, "main", "Exit game", ">") + + baseMenu(self.scene, "character", 168, 40, 248, 168, 4) + CharacterWidget(self.scene, "sonic") + CharacterWidget(self.scene, "tails") + CharacterWidget(self.scene, "amy") + CharacterWidget(self.scene, "sonic") +end + +function PauseScreen:draw() + self.scene.assets.fonts["SA2font"]:print("MAIN MENU", 158, 16) +end + +-- Hero custom widget +-- +function CharacterWidget:new(scene, name) + self.charName = name + self.emblem = Emblem(game.characters.list[name], scene) + self.font2 = scene.assets.fonts["hudnbrs_small"] + CharacterWidget.super.new(self, scene, "character") +end + +function CharacterWidget:drawCanvas() + local character = game.characters.list[self.charName] + self.font:setFilter("shadow") + local debut = 0 + local xDebut = 32 + self.font:draw(character.fullname, xDebut, debut, -1, "left") + local yLvl = debut + 16 + local xLvl = xDebut + self.scene.assets.images["lvl"]:draw(xLvl, yLvl) + self.scene.assets.images["exp"]:draw(xLvl, yLvl + 10) + self.font2:print(character.level, xLvl + 19, yLvl, "left") + local expString = character.exp .. "/" .. character.exp_next + self.font2:print(expString, xLvl + 19, yLvl + 10, "left") + --text, x, y, limit, align +end + +function CharacterWidget:draw(x, y) + self.emblem:draw(x, y+6) + if self.canvas.texture ~= nil then + love.graphics.draw(self.canvas.texture, x - self.ox, y - self.oy) + end +end + +return PauseScreen diff --git a/sonic-radiance.love/scenes/overworld/screens/menu.lua b/sonic-radiance.love/scenes/overworld/screens/menu.lua new file mode 100644 index 0000000..a661ca8 --- /dev/null +++ b/sonic-radiance.love/scenes/overworld/screens/menu.lua @@ -0,0 +1,103 @@ +local ListBox = require "core.modules.menusystem.listbox" +local Widget = require "core.modules.menusystem.widgets" + +local menu = {} +menu.CustomMenu = ListBox:extend() +menu.BasicMenu = ListBox:extend() +menu.BoxedMenu = menu.BasicMenu:extend() +menu.BasicWidget = Widget.Text:extend() +menu.BoxedWidget = menu.BasicWidget:extend() + +local CONST = {} +CONST.MENU = {} +CONST.MENU.ITEM_HEIGHT = 17 + +local gui = require "game.modules.gui" + +-- Custom Menu +function menu.CustomMenu:new(scene, name, x, y, w, h, itemNumber) + self.scene = scene + menu.CustomMenu.super.new(self, scene.menusystem, name, x, y, w, h, itemNumber) +end + +-- Basic menu +function menu.BasicMenu:new(scene, name, itemNumber, x, y, w) + self.scene = scene + local h = itemNumber * CONST.MENU.ITEM_HEIGHT + menu.BasicMenu.super.new(self, scene.menusystem, name, x, y, w, h, itemNumber) + self.cursorTexture = love.graphics.newImage("assets/gui/cursor-menulist.png") + self.cursorTransition = 0 +end + +function menu.BasicMenu:update(dt) + menu.BasicMenu.super.update(self, dt) + + local relativecursor = self.widget.selected - self.view.firstSlot + + local transition = self.cursorTransition - relativecursor + + if math.abs(transition) < 0.1 then + self.cursorTransition = relativecursor + else + self.cursorTransition = (self.cursorTransition) + ((relativecursor) - (self.cursorTransition)) * dt*45 + end + +end + +function menu.BasicMenu:drawCursor() + local addition = 17 + local x = self.x - 1 + local y = self.y + ((self.cursorTransition) * addition) + 1 + love.graphics.draw(self.cursorTexture, x, y) +end + +-- Boxed menu +function menu.BoxedMenu:new(scene, name, itemNumber, x, y, w) + menu.BoxedMenu.super.new(self, scene, name, itemNumber, x, y, w) + self.box = gui.newTextBox("assets/gui/dialogbox.png", self.w+16, self.h+16) +end + +function menu.BoxedMenu:draw() + love.graphics.draw(self.box, self.x-8, self.y-8) + menu.BoxedMenu.super.draw(self) +end + +-- Basic Widget +function menu.BasicWidget:new(scene, menu_name, label, label2) + local font = scene.assets.fonts["small"] + self.scene = scene + local widgetMenu = scene.menusystem.menus[menu_name] + self.label2 = label2 or "" + menu.BasicWidget.super.new(self, widgetMenu, font, label) +end + +function menu.BasicWidget:drawCanvas() + local h = math.floor(self.height / 2) - (self.font:getHeight() / 2) + love.graphics.setColor(0, 0, 0, 1) + self.font:print(self.label, 9, h, "left") + self.font:print(self.label2, self.width - 7, h, "right") + utils.graphics.resetColor() + self.font:print(self.label, 8, h, "left") + self.font:print(self.label2, self.width - 8, h, "right") +end + +-- Basic Widget +function menu.BoxedWidget:new(scene, menu_name, label, label2) + menu.BoxedWidget.super.new(self, scene, menu_name, label, label2) + self.box = gui.newChoiceBack(self.menu.w + 24) +end + +function menu.BoxedWidget:drawCanvas() + love.graphics.draw(self.box, 0, 0) + + 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, self.width - 8, h, "right") + utils.graphics.resetColor() + self.font:print(self.label, 16, h, "left") + self.font:print(self.label2, self.width - 9, h, "right") +end + + +return menu diff --git a/sonic-radiance.love/scenes/overworld/screens/parent.lua b/sonic-radiance.love/scenes/overworld/screens/parent.lua new file mode 100644 index 0000000..36236dd --- /dev/null +++ b/sonic-radiance.love/scenes/overworld/screens/parent.lua @@ -0,0 +1,32 @@ +local MenuScreenParent = Object:extend() + +local menu = require "scenes.overworld.screens.menu" + +function MenuScreenParent:new(scene) + self.scene = scene + self.menusystem = scene.menusystem + + self.menuObj = menu + + self:setMenu() + self.scene:registerScreen(self) +end + +function MenuScreenParent:update(dt) + +end + +function MenuScreenParent:setMenu() + +end + +function MenuScreenParent:quit() + self.scene.menusystem:reset() + self.scene:quitScreen() +end + +function MenuScreenParent:draw() + +end + +return MenuScreenParent