From 17c4b0de8e1a69fd94edbf431342880c9a9f6b74 Mon Sep 17 00:00:00 2001 From: Kazhnuz Date: Wed, 5 Jan 2022 23:26:09 +0100 Subject: [PATCH] feat: port the main menu to the new gui system --- .../game/modules/gui/overlay.lua | 11 + .../gui/menus/character/charbars.lua | 34 +++ .../gui/menus/character/description.lua | 21 ++ .../overworld/gui/menus/character/init.lua | 175 ++++++++++++ .../gui/menus/character/pageindicator.lua | 27 ++ .../gui/menus/character/subpages.lua | 56 ++++ .../overworld/gui/menus/character/texts.lua | 41 +++ .../overworld/gui/menus/commons/boxedtext.lua | 38 +++ .../overworld/gui/menus/commons/charmenu.lua | 91 ++++++ .../mainmenu => gui/menus/commons}/const.lua | 0 .../gui/menus/commons/screenName.lua | 35 +++ .../scenes/overworld/gui/menus/init.lua | 44 +++ .../scenes/overworld/gui/menus/items/init.lua | 171 ++++++++++++ .../overworld/gui/menus/items/roulette.lua | 40 +++ .../scenes/overworld/gui/menus/mainmenu.lua | 87 ++++++ .../overworld/gui/menus/useItem/equip.lua | 52 ++++ .../overworld/gui/menus/useItem/init.lua | 23 ++ .../overworld/gui/menus/useItem/number.lua | 21 ++ .../overworld/gui/menus/useItem/parent.lua | 91 ++++++ sonic-radiance.love/scenes/overworld/init.lua | 62 +---- .../scenes/overworld/screens/gameover.lua | 89 ------ .../scenes/overworld/screens/init.lua | 4 - .../screens/mainmenu/character/basicpage.lua | 69 ----- .../screens/mainmenu/character/init.lua | 122 --------- .../screens/mainmenu/character/pageparent.lua | 47 ---- .../screens/mainmenu/character/skillpage.lua | 71 ----- .../screens/mainmenu/character/statpage.lua | 88 ------ .../screens/mainmenu/common/charmenu.lua | 12 - .../screens/mainmenu/common/charwidget.lua | 65 ----- .../overworld/screens/mainmenu/equip.lua | 115 -------- .../overworld/screens/mainmenu/init.lua | 7 - .../overworld/screens/mainmenu/items.lua | 258 ------------------ .../overworld/screens/mainmenu/pause.lua | 137 ---------- .../overworld/screens/mainmenu/useitems.lua | 91 ------ .../scenes/overworld/screens/menu.lua | 103 ------- .../scenes/overworld/screens/parent.lua | 49 ---- 36 files changed, 1065 insertions(+), 1382 deletions(-) create mode 100644 sonic-radiance.love/scenes/overworld/gui/menus/character/charbars.lua create mode 100644 sonic-radiance.love/scenes/overworld/gui/menus/character/description.lua create mode 100644 sonic-radiance.love/scenes/overworld/gui/menus/character/init.lua create mode 100644 sonic-radiance.love/scenes/overworld/gui/menus/character/pageindicator.lua create mode 100644 sonic-radiance.love/scenes/overworld/gui/menus/character/subpages.lua create mode 100644 sonic-radiance.love/scenes/overworld/gui/menus/character/texts.lua create mode 100644 sonic-radiance.love/scenes/overworld/gui/menus/commons/boxedtext.lua create mode 100644 sonic-radiance.love/scenes/overworld/gui/menus/commons/charmenu.lua rename sonic-radiance.love/scenes/overworld/{screens/mainmenu => gui/menus/commons}/const.lua (100%) create mode 100644 sonic-radiance.love/scenes/overworld/gui/menus/commons/screenName.lua create mode 100644 sonic-radiance.love/scenes/overworld/gui/menus/init.lua create mode 100644 sonic-radiance.love/scenes/overworld/gui/menus/items/init.lua create mode 100644 sonic-radiance.love/scenes/overworld/gui/menus/items/roulette.lua create mode 100644 sonic-radiance.love/scenes/overworld/gui/menus/mainmenu.lua create mode 100644 sonic-radiance.love/scenes/overworld/gui/menus/useItem/equip.lua create mode 100644 sonic-radiance.love/scenes/overworld/gui/menus/useItem/init.lua create mode 100644 sonic-radiance.love/scenes/overworld/gui/menus/useItem/number.lua create mode 100644 sonic-radiance.love/scenes/overworld/gui/menus/useItem/parent.lua delete mode 100644 sonic-radiance.love/scenes/overworld/screens/gameover.lua delete mode 100644 sonic-radiance.love/scenes/overworld/screens/init.lua delete mode 100644 sonic-radiance.love/scenes/overworld/screens/mainmenu/character/basicpage.lua delete mode 100644 sonic-radiance.love/scenes/overworld/screens/mainmenu/character/init.lua delete mode 100644 sonic-radiance.love/scenes/overworld/screens/mainmenu/character/pageparent.lua delete mode 100644 sonic-radiance.love/scenes/overworld/screens/mainmenu/character/skillpage.lua delete mode 100644 sonic-radiance.love/scenes/overworld/screens/mainmenu/character/statpage.lua delete mode 100644 sonic-radiance.love/scenes/overworld/screens/mainmenu/common/charmenu.lua delete mode 100644 sonic-radiance.love/scenes/overworld/screens/mainmenu/common/charwidget.lua delete mode 100644 sonic-radiance.love/scenes/overworld/screens/mainmenu/equip.lua delete mode 100644 sonic-radiance.love/scenes/overworld/screens/mainmenu/init.lua delete mode 100644 sonic-radiance.love/scenes/overworld/screens/mainmenu/items.lua delete mode 100644 sonic-radiance.love/scenes/overworld/screens/mainmenu/pause.lua delete mode 100644 sonic-radiance.love/scenes/overworld/screens/mainmenu/useitems.lua delete mode 100644 sonic-radiance.love/scenes/overworld/screens/menu.lua delete mode 100644 sonic-radiance.love/scenes/overworld/screens/parent.lua diff --git a/sonic-radiance.love/game/modules/gui/overlay.lua b/sonic-radiance.love/game/modules/gui/overlay.lua index a32337d..4107a9d 100644 --- a/sonic-radiance.love/game/modules/gui/overlay.lua +++ b/sonic-radiance.love/game/modules/gui/overlay.lua @@ -32,6 +32,15 @@ local hideBackground = { {"overlayDarken", "tween", 0.0, 0.6, {opacity = 0}, "outExpo"} } + +local showBackgroundPause = { + {"overlayDarken", "tween", 0.0, 0.2, {opacity = OVERLAY_OPACITY}, "inOutQuart"} +} + +local hideBackgroundPause = { + {"overlayDarken", "tween", 0.0, 0.2, {opacity = 0}, "inOutQuart"} +} + local showVersion = { {"version", "movement", 0.0, 0.5, 380, 220, "inOutQuart"}, } @@ -62,6 +71,8 @@ function OverlayScreen:new(active, doShowVersion) self:addTransform("hide", animateDisappear) self:addTransform("showBackground", showBackground) self:addTransform("hideBackground", hideBackground) + self:addTransform("showBackgroundPause", showBackgroundPause) + self:addTransform("hideBackgroundPause", hideBackgroundPause) self:addTransform("showVersion", showVersion) self:addTransform("hideVersion", hideVersion) diff --git a/sonic-radiance.love/scenes/overworld/gui/menus/character/charbars.lua b/sonic-radiance.love/scenes/overworld/gui/menus/character/charbars.lua new file mode 100644 index 0000000..cd2dd5e --- /dev/null +++ b/sonic-radiance.love/scenes/overworld/gui/menus/character/charbars.lua @@ -0,0 +1,34 @@ +local CharBars = require("birb.modules.gui.elements.canvas"):extend() + +local HPBAR_SIZE = 80 +local W, H = HPBAR_SIZE*2, 32 + +local const = require "scenes.overworld.gui.menus.commons.const" + +local ComplexHPBar = require "game.modules.gui.complexhpbar" + +function CharBars:new(name, x, y, character) + CharBars.super.new(self, name, x, y, W, H) + self.canvas.padding = 24 + self.character = character + + self.hpbar = ComplexHPBar(HPBAR_SIZE) + self.ppbar = ComplexHPBar(HPBAR_SIZE) + self.hpbar:setColorForeground(248/255, 160/255, 0, 1) + self.hpbar:setColorBackground(112/255, 0, 0) + self.ppbar:setColorForeground(0, 248/255, 248/255, 1) + self.ppbar:setColorBackground(0, 54/255, 229/255) + + self.opacity = 0 +end + +function CharBars:drawTexture() + local stats = self.character.stats + local x, y = self.canvas.padding, self.canvas.padding + self.scene.assets.fonts["hudnbrs_small"]:set() + self.hpbar:drawWithLabels(x, y - 4, self.character.hp, stats:get(stats.HPMAX)) + local xx = x + const.CHARPAGESIZE - HPBAR_SIZE - 7 + self.ppbar:drawWithLabels(xx, y - 4, self.character.pp, stats:get(stats.PPMAX)) +end + +return CharBars \ No newline at end of file diff --git a/sonic-radiance.love/scenes/overworld/gui/menus/character/description.lua b/sonic-radiance.love/scenes/overworld/gui/menus/character/description.lua new file mode 100644 index 0000000..d111ae1 --- /dev/null +++ b/sonic-radiance.love/scenes/overworld/gui/menus/character/description.lua @@ -0,0 +1,21 @@ +local Description = require("birb.modules.gui.elements.canvas"):extend() +local PLAYER_MESSAGE = 240 - 24 + +function Description:new(owner, name) + self.owner = owner + Description.super.new(self, name, 0, PLAYER_MESSAGE, 424, 16) + self.canvas.isAnimated = true +end + +function Description:drawTexture() + if (not utils.string.isEmpty(self.owner:getDescription())) then + love.graphics.setColor(0,0,0, 0.66) + love.graphics.rectangle("fill", self.canvas.padding, self.canvas.padding, self.w, self.h) + self.gui.scene.assets.fonts["small"]:setColor(1,1,1, 1) + self.gui.scene.assets.fonts["small"]:draw(self.owner:getDescription(), self.canvas.padding, self.canvas.padding - 1, self.w, "center") + self.gui.scene.assets.fonts["small"]:setColor(1,1,1, 1) + utils.graphics.resetColor() + end +end + +return Description \ No newline at end of file diff --git a/sonic-radiance.love/scenes/overworld/gui/menus/character/init.lua b/sonic-radiance.love/scenes/overworld/gui/menus/character/init.lua new file mode 100644 index 0000000..4402146 --- /dev/null +++ b/sonic-radiance.love/scenes/overworld/gui/menus/character/init.lua @@ -0,0 +1,175 @@ +local CharacterScreen = require("birb.modules.gui.screen"):extend() +local DrawableElement = require("birb.modules.gui.elements.drawable") + +local BoxedText = require "scenes.overworld.gui.menus.commons.boxedtext" +local PageIndicator = require "scenes.overworld.gui.menus.character.pageindicator" +local CharBars = require "scenes.overworld.gui.menus.character.charbars" +local Description = require "scenes.overworld.gui.menus.character.description" + +local FancyMenu = require "game.modules.gui.fancymenu" +local BoxedMenu = require "game.modules.gui.boxedmenu" + +local const = require "scenes.overworld.gui.menus.commons.const" +local subpages = require "scenes.overworld.gui.menus.character.subpages" +local textFunc = require "scenes.overworld.gui.menus.character.texts" + +local MENU_W = 128 +local MENU_X, MENU_Y = const.X2 - MENU_W - 14, const.Y2 - 48 + 2 +local PAGEINDIC_X, PAGEINDIC_Y = const.X2 - 16*5, const.Y - 14 + +function CharacterScreen:new(characterName) + self.characterName = characterName + self.artworkPosition = require("datas.gamedata.characters." .. characterName .. ".artwork") + self.character = game.characters.list[characterName] + CharacterScreen.super.new(self, characterName) + self:setCustomTransforms() + + self.defaultFocus = self.characterName .. "ActMenu" + self.nbr = 1 +end + +function CharacterScreen:setCustomTransforms() + local show = {} + local hide = {} + self:addCustomTween(show, "Artwork", false, 1, nil, self.artworkPosition.x) + self:addCustomTween(hide, "Artwork", true, -1, nil, self.artworkPosition.x) + self:addCustomTween(show, "ActMenu", false, 1, nil, MENU_X) + self:addCustomTween(hide, "ActMenu", true, -1, nil, MENU_X) + self:addCustomTween(show, "Indicator", false, 1, nil, PAGEINDIC_X) + self:addCustomTween(hide, "Indicator", true, -1, nil, PAGEINDIC_X) + self:addTweens(show, "basic", false, -1) + self:addTweens(hide, "", true, 1) + + self:addTransform("show", show) + self:addTransform("hide", hide) + self.desc = "" +end + +function CharacterScreen:createElements() + local elementDatas = subpages.getElements() + local list = {} + + local drawable = love.graphics.newImage("datas/gamedata/characters/" .. self.characterName .. "/artwork.png") + table.insert(list, {DrawableElement(self.characterName .. "Artwork", drawable, self.artworkPosition.x, self.artworkPosition.y,0,1,1,0,0, 0), 0, 1}) + + self.dataMenus = {} + for i, element in ipairs(elementDatas) do + local name = self.characterName .. element.name + local x, y, w, h = const.X - 16, const.Y + element.data.y, const.CHARPAGESIZE, element.data.h + if (element.data.isTextBox) then + local boxedText = BoxedText(name, x, y, w, h, function() return textFunc["get" .. element.name](self.character, const.CHARPAGESIZE) end) + table.insert(list, {boxedText, 0, 1}) + elseif (element.data.isMenu) then + self.dataMenus[element.name] = BoxedMenu(name, x, y + 4, w, h, true, true) + self.dataMenus[element.name].opacity = 0 + self.dataMenus[element.name]:addCancelAction(function () + self.gui.scene.assets.sfx["mBack"]:play() + self.gui:setFocus(self.characterName .. "ActMenu") + self.desc = "" + end) + table.insert(list, {self.dataMenus[element.name], 0, 1}) + else + table.insert(list, {CharBars(name, x, y, self.character), 0, 1}) + end + end + + self:rebuildMenus() + table.insert(list, {self:createGlobalMenu(), 0, 1}) + table.insert(list, {PageIndicator(self, self.characterName .. "Indicator", PAGEINDIC_X, PAGEINDIC_Y, subpages.list), 0, 1}) + table.insert(list, {Description(self, self.characterName .. "Description"), 0, -100}) + + return list +end + +function CharacterScreen:rebuildMenus() + for i, equip in ipairs(subpages.equip) do + local fullname = "No " .. equip + local obj = self.character.equip[equip] + if (not utils.string.isEmpty(obj)) then + fullname = core.datas:get("items", obj).fullname + end + self.dataMenus["EquipMenu"]:addItem(fullname, "left", function () end, "select") + end + + for _, skill in ipairs(self.character.skills) do + local skillData = core.datas:get("skills", skill.name) + local cost = utils.math.numberToString(skillData.cost, 2) + self.dataMenus["SkillsMenu"]:addItem(skillData.fullname, "left", function () end, "select", {{cost, "right"}}, nil, {skillData.description}) + end + + self.dataMenus["SkillsMenu"]:addHoverAction(function (widget) + self.desc = widget.datas[1] + end) +end + +function CharacterScreen:getDescription() + return self.desc or "" +end + +function CharacterScreen:createGlobalMenu() + self.menu = FancyMenu(self.characterName .. "ActMenu", MENU_X, MENU_Y, MENU_W, 3, false) + self.menu.opacity = 0 + + for i, name in ipairs(subpages.list) do + self.menu:addPage(name) + end + + self.menu:switch("skills") + self.menu:addItem("See skill", "left", function() + self.gui:setFocus(self.characterName .. "SkillsMenu") + self.desc = core.datas:get("skills", self.character.skills[1].name).description + end, "navigate") + self.menu:switch("stats") + self.menu:addItem("Remove item", "left", function() self.gui:setFocus(self.characterName .. "EquipMenu") end, "navigate") + + for i, name in ipairs(subpages.list) do + self.menu:switch(name) + self.menu:addItem("Back", "left", function() self.gui:showScreen("mainmenuScreen", "navCharMenu", self.nbr, "main") end, "back") + self.menu:setCancelWidget() + end + self.menu:addLateralAction(function (key) if (key == "left") then self:changePage(-1) else self:changePage(1) end end) + self.menu.packAtEnd = 1 + + self.menu:switch(subpages.list[1]) + return self.menu +end + +function CharacterScreen:changePage(direction) + local currentPage = self.menu:getCurrentPageName() + self.menu:switch(subpages.relativePage(currentPage, direction)) + self:hidePage(currentPage, utils.math.sign(direction)) + self:showPage(self.menu:getCurrentPageName(), utils.math.sign(direction)) + self.gui.scene.assets.sfx["mBeep"]:play() +end + +function CharacterScreen:hidePage(name, direction) + local transform = {} + self:addTweens(transform, name, true, direction) + self.gui:transform(transform, 0) +end + +function CharacterScreen:showPage(name, direction) + local transform = {} + self:addTweens(transform, name, false, direction) + self.gui:transform(transform, 0) +end + +function CharacterScreen:addTweens(list, name, isHiding, direction) + for _, elem in ipairs(subpages.getElements(name)) do + self:addCustomTween(list, elem.name, isHiding, direction) + end +end + +function CharacterScreen:addCustomTween(list, name, isHiding, direction, speed, x) + local begin, duration = utils.math.either(isHiding, 0, 0.1), speed or 0.3 + local trueDirection, opacity = utils.math.either(isHiding, direction, 0), utils.math.either(isHiding, 0, 1) + x = x or const.X + if (not isHiding) then self:addCustomTween(list, name, true, direction * -1, 0.1, x) end + table.insert(list, {self.characterName .. name, "tween", begin, duration, {x = x - 16*trueDirection, opacity = opacity}, "inOutQuad"}) +end + +function CharacterScreen:getCurrentPageName() + return self.menu:getCurrentPageName() +end + +return CharacterScreen \ No newline at end of file diff --git a/sonic-radiance.love/scenes/overworld/gui/menus/character/pageindicator.lua b/sonic-radiance.love/scenes/overworld/gui/menus/character/pageindicator.lua new file mode 100644 index 0000000..1eb4d30 --- /dev/null +++ b/sonic-radiance.love/scenes/overworld/gui/menus/character/pageindicator.lua @@ -0,0 +1,27 @@ +local PageIndicator = require("birb.modules.gui.elements.canvas"):extend() + +local DIST = 16 +local RAD_SMALL, RAD_LARGE = 2, 3 +local OUTLINE_LIGHT = 0.15 + +function PageIndicator:new(owner, name, x, y, pageList) + self.pageList = pageList + self.owner = owner + local w, h = (DIST*(#pageList + 1)), 16 + PageIndicator.super.new(self, name, x, y, w, h) + self.canvas.isAnimated = true + self.opacity = 0 +end + +function PageIndicator:drawTexture() + for i, pageName in ipairs(self.pageList) do + local radius = utils.math.either (pageName == self.owner:getCurrentPageName(), RAD_LARGE, RAD_SMALL) + local x, y = (i+1) * DIST, math.floor(self.h / 2) + love.graphics.circle("fill", x, y, radius, 8) + love.graphics.setColor(OUTLINE_LIGHT, OUTLINE_LIGHT, OUTLINE_LIGHT, 1) + love.graphics.circle("line", x, y, radius, 8) + utils.graphics.resetColor() + end +end + +return PageIndicator \ No newline at end of file diff --git a/sonic-radiance.love/scenes/overworld/gui/menus/character/subpages.lua b/sonic-radiance.love/scenes/overworld/gui/menus/character/subpages.lua new file mode 100644 index 0000000..8616747 --- /dev/null +++ b/sonic-radiance.love/scenes/overworld/gui/menus/character/subpages.lua @@ -0,0 +1,56 @@ +local const = require "scenes.overworld.gui.menus.commons.const" +local subpages = {} + +subpages.list = {"basic", "stats", "skills"} + +subpages.elements = { + ["basic"] = {"IdentityBox", "Bars", "LevelBox", "WeakStrongBox"}, + ["stats"] = {"EquipMenu", "StatsBox"}, + ["skills"] = {"SkillsMenu"} +} + +subpages.equip = {"gloves", "shoes", "accessories"} + +subpages.elementsData = { + IdentityBox = {y = 0, h = 40, isTextBox = true }, + Bars = {y = 48, h = 0, isTextBox = false, isMenu = false}, + LevelBox = {y = 72-13, h = 56, isTextBox = true}, + WeakStrongBox = {y = 132-13, h = 40, isTextBox = true }, + EquipMenu = {y = 0, h = 3, isTextBox = false, isMenu = true}, + StatsBox = {y = 72, h = 72, isTextBox = true }, + SkillsMenu = {y = 0, h = 9, isTextBox = false, isMenu = true}, +} + +function subpages.fromId(id) + return subpages.list[id] +end + +function subpages.fromName(name) + for i, subPageName in ipairs(subpages.list) do + if subPageName == name then + return i + end + end + return -1 +end + +function subpages.relativePage(pageName, direction) + local id = utils.math.wrap(subpages.fromName(pageName) + direction, 1, #subpages.list) + return subpages.fromId(id) +end + +function subpages.getElements(filter) + local list = {} + for i, subpageName in ipairs(subpages.list) do + if (filter == nil or filter == "" or filter == subpageName) then + for j, elementName in ipairs(subpages.elements[subpageName]) do + local data = subpages.elementsData[elementName] + table.insert(list, {name = elementName, page = subpageName, data = data}) + end + end + end + + return list +end + +return subpages \ No newline at end of file diff --git a/sonic-radiance.love/scenes/overworld/gui/menus/character/texts.lua b/sonic-radiance.love/scenes/overworld/gui/menus/character/texts.lua new file mode 100644 index 0000000..ded23bb --- /dev/null +++ b/sonic-radiance.love/scenes/overworld/gui/menus/character/texts.lua @@ -0,0 +1,41 @@ +local TextsFuncs = {} + +local STATS = require "datas.consts.stats" + +function TextsFuncs.getIdentityBox(character) + local identityString = character.fullname .. "\n" + identityString = identityString .. "Class: " .. character.data.class + + return {{1, identityString}} +end + +function TextsFuncs.getLevelBox(character) + local levelString = "Level: " .. character.level .. "\n" + levelString = levelString .. "Current exp: " .. character.exp .. "\n" + levelString = levelString .. "Next level: " .. character.exp_next + + return {{1, levelString}} +end + +function TextsFuncs.getWeakStrongBox(character) + local weakStrongString = "Weak to: Nothing" .. "\n"--"Earth, Lightning" + weakStrongString = weakStrongString .. "Resist To: Nothing" + + return {{1, weakStrongString}} +end + +function TextsFuncs.getStatsBox(character, pageSize) + local char = character + local statStringList = {} + for i, statName in ipairs(STATS.LIST) do + local xStat = (((i - 1) % 2) * (pageSize/2)) + 6 + local line = math.floor((i + 1)/2) + local middle = xStat + 10 + pageSize/4 + local stat = char.stats:get(statName) + table.insert(statStringList, {line, STATS.SIMPLENAME[statName], "left", xStat, 0, {1,1,1,1}, pageSize}) + table.insert(statStringList, {line, stat, "center", middle, 0, {1,1,1,0.9}, -1}) + end + return statStringList +end + +return TextsFuncs \ No newline at end of file diff --git a/sonic-radiance.love/scenes/overworld/gui/menus/commons/boxedtext.lua b/sonic-radiance.love/scenes/overworld/gui/menus/commons/boxedtext.lua new file mode 100644 index 0000000..adeb091 --- /dev/null +++ b/sonic-radiance.love/scenes/overworld/gui/menus/commons/boxedtext.lua @@ -0,0 +1,38 @@ +local BoxedTextElement = require("birb.modules.gui.elements.canvas"):extend() +local gui = require "game.modules.gui" + +local PADDING = 6 +local PADDING_H = 4 +local LINEHEIGHT = 16 + +function BoxedTextElement:new(name, x, y, w, h, linesFunc) + BoxedTextElement.super.new(self, name, x, y, w, h) + self.textwidth = w - (PADDING * 2) + self.opacity = 0 + self.canvas.isAnimated = true + self.linesFunc = linesFunc + + self.box = gui.newTextBox("assets/gui/dialogbox.png", w, h) + self.canvas.padding = 0 +end + +function BoxedTextElement:getLines() + -- return {line, text, align, x, y, color} + return self.linesFunc() +end + +function BoxedTextElement:drawTexture() + love.graphics.draw(self.box, 0, 0) + local lines = self:getLines() + assert(lines ~= nil, "No lines for " .. self.name) + for i, line in ipairs(lines) do + local lineNbr, text, align, x, y = line[1], line[2] or "", line[3] or "left", line[4] or 0, line[5] or 0 + local color, width = line[6] or {1, 1, 1, 1}, line[7] or self.textwidth + self.assets.fonts["small"]:setColor(color[1], color[2], color[3], color[4]) + self.assets.fonts["small"]:draw(text, PADDING + x, PADDING_H + LINEHEIGHT*(lineNbr-1) + y, width, align or "left") + self.assets.fonts["small"]:setColor(1, 1, 1, 1) + utils.graphics.resetColor() + end +end + +return BoxedTextElement \ No newline at end of file diff --git a/sonic-radiance.love/scenes/overworld/gui/menus/commons/charmenu.lua b/sonic-radiance.love/scenes/overworld/gui/menus/commons/charmenu.lua new file mode 100644 index 0000000..3d9667c --- /dev/null +++ b/sonic-radiance.love/scenes/overworld/gui/menus/commons/charmenu.lua @@ -0,0 +1,91 @@ +local CharacterMenu = require("birb.modules.gui.menus.listbox"):extend() +local CharacterWidget = require("birb.modules.gui.menus.widgets.base"):extend() +local const = require "scenes.overworld.gui.menus.commons.const" + +local ComplexHPBar = require "game.modules.gui.complexhpbar" +local Emblem = require "game.modules.gui.emblem" + +function CharacterMenu:new(name, x, func, showEquip) + local w = const.WIDTH - x + 28 + CharacterMenu.super.new(self, name, x, const.Y, w, const.HEIGHT, 4) + self.func = func + self.showEquip = (showEquip == true) + self.opacity = 1 + self:buildFromTeam() + + self.canvas.isAnimated = true +end + +function CharacterMenu:buildFromTeam() + self.charName = game.characters.team[1] + for i, name in ipairs(game.characters.team) do + local widget = CharacterWidget(self.name, name) + widget:setFunc(function () self.func(name, i) end) + end + self:addHoverAction(function(widget) self.charName = widget.charName end) +end + +function CharacterWidget:new(menuName, charName) + CharacterWidget.super.new(self, menuName) + + self.charName = charName + self.emblem = Emblem(game.characters.list[charName], self.scene) + self.font = self.scene.assets.fonts["small"] + self.font2 = self.scene.assets.fonts["hudnbrs_small"] + self.hpbar = ComplexHPBar(88) + self.ppbar = ComplexHPBar(88) + self.hpbar:setColorForeground(248 / 255, 160 / 255, 0, 1) + self.hpbar:setColorBackground(112 / 255, 0, 0) + self.ppbar:setColorForeground(0, 248 / 255, 248 / 255, 1) + self.ppbar:setColorBackground(0, 54 / 255, 229 / 255) + + self.canvas.isAnimated = true + + self.character = game.characters.list[self.charName] +end + +function CharacterWidget:drawCanvas() + local xDebut = 32 + local yDebut = 16 + + self.emblem:draw(0, 6) + + self.font:setFilter("shadow") + self.font:draw(self.character.fullname, xDebut, 0, -1, "left") + + if (self.menu.showEquip ~= nil and self.menu.showEquip ~= false) then + self:drawEquip(xDebut, yDebut) + else + self:drawHPPP(xDebut, yDebut) + self:drawLvlExp(xDebut, yDebut) + end +end + +function CharacterWidget:drawLvlExp(x, y) + self.scene.assets.images["lvl"]:draw(x, y) + self.scene.assets.images["exp"]:draw(x, y + 10) + self.font2:print(self.character.level, x + 19, y, "left") + local expString = self.character.exp .. "/" .. self.character.exp_next + self.font2:print(expString, x + 19, y + 10, "left") +end + +function CharacterWidget:drawEquip(x, y) + local charEquip = self.character.equip[self.menu.showEquip] + local equipString = "None" + if (not utils.string.isEmpty(charEquip)) then + local data = core.datas:get("items", charEquip) + equipString = data.fullname + end + self.font:draw(equipString, x, y, -1, "left") +end + +function CharacterWidget:drawHPPP(x, y) + local xDebut = x + 20 + local yDebut = y - 1 + self.scene.assets.fonts["hudnbrs_small"]:set() + local stats = self.character.stats + self.hpbar:drawWithLabels(xDebut + 53, yDebut, self.character.hp, stats:get(stats.HPMAX)) + self.ppbar:drawWithLabels(xDebut + 64, yDebut + 11, self.character.pp, stats:get(stats.PPMAX)) +end + +return CharacterMenu diff --git a/sonic-radiance.love/scenes/overworld/screens/mainmenu/const.lua b/sonic-radiance.love/scenes/overworld/gui/menus/commons/const.lua similarity index 100% rename from sonic-radiance.love/scenes/overworld/screens/mainmenu/const.lua rename to sonic-radiance.love/scenes/overworld/gui/menus/commons/const.lua diff --git a/sonic-radiance.love/scenes/overworld/gui/menus/commons/screenName.lua b/sonic-radiance.love/scenes/overworld/gui/menus/commons/screenName.lua new file mode 100644 index 0000000..88b33d4 --- /dev/null +++ b/sonic-radiance.love/scenes/overworld/gui/menus/commons/screenName.lua @@ -0,0 +1,35 @@ +local TextElement = require "birb.modules.gui.elements.text" +local ScreenNameElement = TextElement:extend() + +local nameList = { + mainmenuScreen = "Menu", + itemScreen = "Items", + useItemScreen = "Use item", + setEquipScreen = "Equip item" +} + +function ScreenNameElement:new(owner, fontName, x, y, align) + self.owner = owner + ScreenNameElement.super.new(self, "screenName", fontName, "", x, y, align) + self.opacity = 0 + self.currentScreen = "Menu" +end + + +function ScreenNameElement:getText() + if (self.owner.subscreens == nil) then + return "Menu" + end + local newScreen = self.owner.subscreens.currentScreen + if (not utils.string.isEmpty(newScreen)) then + if game.characters.list[newScreen] ~= nil then + local data = core.datas:get("characters", newScreen) + self.currentScreen = data.name + else + self.currentScreen = nameList[newScreen] + end + end + return self.currentScreen or "" +end + +return ScreenNameElement \ No newline at end of file diff --git a/sonic-radiance.love/scenes/overworld/gui/menus/init.lua b/sonic-radiance.love/scenes/overworld/gui/menus/init.lua new file mode 100644 index 0000000..59207f1 --- /dev/null +++ b/sonic-radiance.love/scenes/overworld/gui/menus/init.lua @@ -0,0 +1,44 @@ +local GuiScreen = require "birb.modules.gui.screen" +local MenuScreen = GuiScreen:extend() + +local ScreenNameElement = require "scenes.overworld.gui.menus.commons.screenName" + +local MainMenuScreen = require "scenes.overworld.gui.menus.mainmenu" +local ItemScreen = require "scenes.overworld.gui.menus.items" +local UseItemScreen = require "scenes.overworld.gui.menus.useItem" +local SetEquipScreen = require "scenes.overworld.gui.menus.useItem.equip" +local CharacterScreen = require "scenes.overworld.gui.menus.character" + +local show = { + {"screenName", "movement", 0, 0.5, 160, 12, "inOutQuart"}, + {"screenName", "tween", 0, 0.5, {opacity = 1}, "inOutQuart"}, +} + +local hide = { + {"screenName", "movement", 0, 0.5, 160, -18, "inOutQuart"}, + {"screenName", "tween", 0, 0.5, {opacity = 0}, "inOutQuart"}, +} + +function MenuScreen:new() + MenuScreen.super.new(self, "startmenu") + self:addTransform("show", show) + self:addTransform("hide", hide) + self:addSubscreen(MainMenuScreen()) + self:addSubscreen(ItemScreen()) + self:addSubscreen(UseItemScreen()) + self:addSubscreen(SetEquipScreen()) + for charName, _ in pairs(game.characters.list) do + self:addSubscreen(CharacterScreen(charName)) + end + self.subscreens.delay = -1 +end + +function MenuScreen:createElements() + local list = { + {ScreenNameElement(self, "SA2font", 160, -18, "left"), 0, -100} + } + + return list +end + +return MenuScreen diff --git a/sonic-radiance.love/scenes/overworld/gui/menus/items/init.lua b/sonic-radiance.love/scenes/overworld/gui/menus/items/init.lua new file mode 100644 index 0000000..e3516be --- /dev/null +++ b/sonic-radiance.love/scenes/overworld/gui/menus/items/init.lua @@ -0,0 +1,171 @@ +local ItemsScreen = require("birb.modules.gui.screen"):extend() +local ItemMenu = require("game.modules.gui.boxedmenu") +local BoxedText = require("scenes.overworld.gui.menus.commons.boxedtext") +local ItemRoulette = require("scenes.overworld.gui.menus.items.roulette") + +local POCKET_LIST = require "datas.gamedata.items" +local const = require "scenes.overworld.gui.menus.commons.const" + +local MENU_WIDTH, DESC_SIZE, USE_SIZE = 128+32, 48*4, 96 + +local EFFECT_H, DESC_H = 40, 56 +local HIDE_X, USE_X = 16, 16 - USE_SIZE / 2 +local DESC_Y, USE_Y = (EFFECT_H + 8) + DESC_H, 24 + +local ConfirmDialog = require "game.modules.confirmdialog" + +local show = { + {"itemRoulette", "movement", 0.1, 0.3, const.X, const.Y, "inOutQuart"}, + {"itemRoulette", "tween", 0.1, 0.3, {opacity = 1}, "inOutQuart"}, + {"descText", "movement", 0.1, 0.3, const.X, const.Y2 - DESC_Y, "inOutQuart"}, + {"descText", "tween", 0.1, 0.3, {opacity = 1}, "inOutQuart"}, + {"effectText", "movement", 0.1, 0.3, const.X, const.Y2 - EFFECT_H, "inOutQuart"}, + {"effectText", "tween", 0.1, 0.3, {opacity = 1}, "inOutQuart"}, + {"itemMenu", "movement", 0.1, 0.3, const.X2 - MENU_WIDTH, const.Y + 4, "inOutQuart"}, + {"itemMenu", "tween", 0.1, 0.3, {opacity = 1}, "inOutQuart"}, + {"useMenu", "tween", 0.0, 0.3, {opacity = 0, sx = 1, sy = 1}, "inOutQuart"}, +} + +local hide = { + {"itemRoulette", "movement", 0, 0.3, const.X - HIDE_X, const.Y, "inOutQuart"}, + {"itemRoulette", "tween", 0, 0.3, {opacity = 0}, "inOutQuart"}, + {"descText", "movement", 0, 0.3, const.X - HIDE_X, const.Y2 - DESC_Y, "inOutQuart"}, + {"descText", "tween", 0, 0.3, {opacity = 0}, "inOutQuart"}, + {"effectText", "movement", 0, 0.3, const.X - HIDE_X, const.Y2 - EFFECT_H, "inOutQuart"}, + {"effectText", "tween", 0, 0.3, {opacity = 0}, "inOutQuart"}, + {"itemMenu", "movement", 0, 0.3, const.X2 - MENU_WIDTH + HIDE_X, const.Y + 4, "inOutQuart"}, + {"itemMenu", "tween", 0, 0.3, {opacity = 0}, "inOutQuart"}, + {"useMenu", "tween", 0.0, 0.3, {opacity = 0, sx = 0.8, sy = 0.8}, "inOutQuart"}, +} + +local showUseMenu = { + {"useMenu", "tween", 0.0, 0.3, {opacity = 1, sx = 1, sy = 1}, "inOutQuart"}, + {"useMenu", "delayFocus", 0} +} + +local hideUseMenu = { + {"useMenu", "tween", 0.0, 0.3, {opacity = 0, sx = 0.8, sy = 0.8}, "inOutQuart"}, + {"itemMenu", "delayFocus", 0} +} + +function ItemsScreen:new() + self.desc, self.effect = "", "" + ItemsScreen.super.new(self, "itemScreen") + self:addTransform("show", show) + self:addTransform("hide", hide) + self:addTransform("showUseMenu", showUseMenu) + self:addTransform("hideUseMenu", hideUseMenu) + self.defaultFocus = "itemMenu" +end + +function ItemsScreen:createElements() + self.menu = ItemMenu("itemMenu", const.X2 - MENU_WIDTH, const.Y + 4, MENU_WIDTH, 9, true, true) + self.menu.opacity = 0 + self:rebuildMenu() + + self.use = ItemMenu("useMenu", const.X2 + USE_X, const.Y2 - USE_Y, USE_SIZE, 3, true, false) + self.use.opacity, self.use.ox, self.use.oy = 0, USE_SIZE/2, self.use.h / 2 + + return {{self.menu, 0, 1}, + {BoxedText("descText", const.X, const.Y2 - DESC_Y, DESC_SIZE, DESC_H, function () return {{1, self.desc}} end), 0, 1}, + {BoxedText("effectText", const.X, const.Y2 - EFFECT_H, DESC_SIZE, EFFECT_H, function () return {{1, self.effect}} end), 0, 1}, + {ItemRoulette(self, const.X, const.Y), 0, 1}, + {self.use, 0, 1} + } +end + +function ItemsScreen:rebuildMenu() + self.menu:clear() + for i, pocket in ipairs(POCKET_LIST) do + self.menu:addPage(pocket.name) + self.menu:switch(pocket.name) + local pocketData = game.loot:getPocketById(i) + + for j,item in ipairs(pocketData.list) do + local itemData = core.datas:get("items", item.name) + self.menu:addItem(itemData.fullname, "left", function () self:showUseMenu(item, j) end, "navigate", {{"x" .. utils.math.numberToString(item.number, 2), "right"}}, nil, {item.name}) + end + + self.menu:addItem("Back", "left", function() self.gui:showScreen("mainmenuScreen") end, "back") + self.menu:addHoverAction(function(widget) self:setDescEffectFromWidget(widget) end) + self.menu:setCancelWidget() + self.menu:addLateralAction(function (key) if (key == "left") then self:changePage(-1) else self:changePage(1) end end) + end + self.menu:switch("medicines") +end + +function ItemsScreen:showUseMenu(item, i) + self.dropQuantity = 1 + self.use:clear() + self.use:addItem("Use", "left", function () self:useItem(item.name, i) end, "") + self.use:addItem("Drop", "left", function () self:dropItem(item.name) end, "select", {{"<" .. utils.math.numberToString(self.dropQuantity, 2) .. ">", "right"}}) + self.use:addItem("Back", "left", function () self:playTransform("hideUseMenu") end, "back") + self.use:addLateralAction(function(key, funcWidget, id) + if (key == "left" and id == 2) then + self:modifyDrop(-1, funcWidget, item.number) + elseif (key == "right" and id == 2) then + self:modifyDrop(1, funcWidget, item.number) + end end) + self.use:setCancelWidget() + self:playTransform("showUseMenu") +end + +function ItemsScreen:useItem(itemName, i) + local pocketData = game.loot:getPocketByName(self.menu:getCurrentPageName()) + local itemData = core.datas:get("items", itemName) + if (pocketData.isEquipement) then + self.gui:showScreen("setEquipScreen", nil, nil, nil, {self.menu:getCurrentPageName(), game.loot:getPocketByName(self.menu:getCurrentPageName()).list[i], i}) + self.gui.scene.assets:playSFX("mSelect") + elseif (itemData.usableOnMap) then + self.gui:showScreen("useItemScreen", nil, nil, nil, {self.menu:getCurrentPageName(), game.loot:getPocketByName(self.menu:getCurrentPageName()).list[i], i}) + self.gui.scene.assets:playSFX("mSelect") + else + self.gui.scene.assets:playSFX("mError") + end +end + +function ItemsScreen:dropItem(itemName) + local confirm = ConfirmDialog(self.scene, "Do you want to drop these items ? \nYou won't be able to recover them.", + function() + game.loot:removeItem(self.menu:getCurrentPageName(), itemName, self.dropQuantity) + self:rebuildMenu() + self:playTransform("hideUseMenu") + end) + confirm:setCancelChoice(2) + confirm.autoDismiss = true +end + +function ItemsScreen:modifyDrop(direction, widget, max) + self.dropQuantity = utils.math.wrap(self.dropQuantity + direction, 1, max) + widget:replaceLabel(2, "<" .. utils.math.numberToString(self.dropQuantity, 2) .. ">") + widget.canvas.needRedraw = true + self.use.canvas.needRedraw = true + self.gui.scene.assets.sfx["mBeep"]:play() +end + +function ItemsScreen:setDescEffectFromWidget(widget) + if (widget.datas ~= nil) then + self:setDescEffect(widget.datas[1]) + else + self.desc, self.effect = "", "" + end +end + +function ItemsScreen:changePage(direction) + local id = self:getPocketData() + local newMenuIndex = utils.math.wrap(id + direction, 1, #POCKET_LIST) + self.menu:switch(POCKET_LIST[newMenuIndex].name) + self.gui.scene.assets.sfx["mBeep"]:play() +end + +function ItemsScreen:setDescEffect(name) + local itemData = core.datas:get("items", name) + self.desc, self.effect = itemData.description, game.loot:getEffectStrings("", name) +end + +function ItemsScreen:getPocketData() + local id = game.loot:getPocketIdByName(self.menu:getCurrentPageName()) + return id, self.menu:getCurrentPageName(), POCKET_LIST[id].fullname +end + +return ItemsScreen \ No newline at end of file diff --git a/sonic-radiance.love/scenes/overworld/gui/menus/items/roulette.lua b/sonic-radiance.love/scenes/overworld/gui/menus/items/roulette.lua new file mode 100644 index 0000000..e4374aa --- /dev/null +++ b/sonic-radiance.love/scenes/overworld/gui/menus/items/roulette.lua @@ -0,0 +1,40 @@ +local ItemRoulette = require("birb.modules.gui.elements.canvas"):extend() +local gui = require "game.modules.gui" + +local W, H = 48*4, 48 + 20 + +function ItemRoulette:new(owner, x, y) + ItemRoulette.super.new(self, "itemRoulette", x, y, W, H) + self.choiceBack = gui.newChoiceBack(W) + self.opacity = 0 + self.owner = owner + self.canvas.padding = 0 + self.canvas.isAnimated = true +end + +function ItemRoulette:drawTexture() + love.graphics.draw(self.choiceBack, 0, 0) + + local id, _, fullName = self.owner:getPocketData() + local x2, y2, w2 = 16, -2, (W - 24) + self.scene.assets.fonts["small"]:draw("<", x2, y2, w2, "left") + self.scene.assets.fonts["small"]:draw(">", x2, y2, w2, "right") + self.scene.assets.fonts["small"]:draw(fullName, x2, y2, w2, "center") + + for i, pocket in ipairs(game.loot.inventory) do + local trueIndex = i - id + if (trueIndex > 4) then + trueIndex = trueIndex - 8 + end + if (trueIndex < -4) then + trueIndex = trueIndex + 8 + end + if (trueIndex ~= 0) then + love.graphics.setColor(.3, .3, .3, .6) + end + self.scene.assets.tileset["itembox"]:drawTile(i, W/2 + ((trueIndex)*32), 20, 0, 1, 1, 14, 0) + utils.graphics.resetColor() + end +end + +return ItemRoulette \ No newline at end of file diff --git a/sonic-radiance.love/scenes/overworld/gui/menus/mainmenu.lua b/sonic-radiance.love/scenes/overworld/gui/menus/mainmenu.lua new file mode 100644 index 0000000..6bda72e --- /dev/null +++ b/sonic-radiance.love/scenes/overworld/gui/menus/mainmenu.lua @@ -0,0 +1,87 @@ +local GuiScreen = require "birb.modules.gui.screen" +local MainMenuScreen = GuiScreen:extend() +local FancyMenu = require "game.modules.gui.fancymenu" +local const = require "scenes.overworld.gui.menus.commons.const" + +local NavigationMenu = FancyMenu:extend() +local CharacterMenu = require "scenes.overworld.gui.menus.commons.charmenu" + +local CHARMENU_X = const.X + 136 + +local defTransitions = require "birb.modules.transitions" +local ConfirmDialog = require "game.modules.confirmdialog" + +local show = { + {"navigationMenu", "movement", 0.1, 0.3, const.X, const.Y, "inOutQuart"}, + {"navigationMenu", "tween", 0.1, 0.3, {opacity = 1}, "inOutQuart"}, + {"navCharMenu", "movement", 0.1, 0.3, CHARMENU_X, const.Y, "inOutQuart"}, + {"navCharMenu", "tween", 0.1, 0.3, {opacity = 1}, "inOutQuart"}, +} + +local hide = { + {"navigationMenu", "movement", 0, 0.3, const.X - 16, const.Y, "inOutQuart"}, + {"navigationMenu", "tween", 0, 0.3, {opacity = 0}, "inOutQuart"}, + {"navCharMenu", "movement", 0, 0.3, CHARMENU_X + 16, const.Y, "inOutQuart"}, + {"navCharMenu", "tween", 0, 0.3, {opacity = 0}, "inOutQuart"}, +} + +function MainMenuScreen:new() + MainMenuScreen.super.new(self, "mainmenuScreen") + self:addTransform("show", show) + self:addTransform("hide", hide) + self.defaultFocus = "navigationMenu" +end + +function MainMenuScreen:createElements() + local menu = FancyMenu("navigationMenu", const.X - 16, const.Y, 108, 10, false) + menu:addItem("Team", "left", function() self.gui:setFocus("navCharMenu") end, "navigate", {{">", "right"}}) + menu:addItem("Quest", "left", function() end, "navigate", {{">", "right"}}) + menu:addItem("Items", "left", function() self.gui:showScreen("itemScreen") end, "navigate", {{">", "right"}}) + menu:addItem("Chao", "left", function() end, "navigate", {{">", "right"}}) + menu:addItem("Encylopedia", "left", function() end, "navigate", {{">", "right"}}) + menu:addSubmenu("save", "Save / Exit", "main", true) + menu:addItem("Save game", "left", function() self:save() self.scene:unpause() end, "select") + menu:addItem("Save and exit", "left", function() self:save() self:exitToMenu() end, "navigate") + menu:addItem("Exit game", "left", function() self:exit() end, "select") + menu:switch("main") + menu:addItem("Resume", "left", function() self.scene:unpause() end, "back") + menu:setCancelWidget() + menu.opacity = 0 + + local charMenu = CharacterMenu("navCharMenu", CHARMENU_X + 16, + function (name, i) + self.gui:showScreen(name, nil, 1, "basic") + self.gui:getScreen(name).menu.canvas.needRedraw = true + self.gui:getScreen(name).desc = "" + self.gui:getScreen(name).nbr = i + end, false) + + charMenu:addCancelAction(function () + self.gui:setFocus("navigationMenu") + self.gui.scene.assets:playSFX("mBack") + end) + charMenu.opacity = 0 + return {{menu, 0, 1}, {charMenu, 0, 1}} +end + +function MainMenuScreen:save() + self.scene.world:savePosition() + game:write() +end + +function MainMenuScreen:exit() + local confirm = ConfirmDialog(self.scene, "Do you to exit the game ? \nAll unsaved data will be lost.", + function() self:exitToMenu() end) + confirm:setCancelChoice(2) +end + +function MainMenuScreen:exitToMenu() + core.screen:startTransition(defTransitions.default, defTransitions.circle, function() game:reload() scenes.menus.main() end, 424/2, 240/2) + self.gui:hideScreen("hud") +end + +function NavigationMenu:new() + NavigationMenu.super.new(self) +end + +return MainMenuScreen \ No newline at end of file diff --git a/sonic-radiance.love/scenes/overworld/gui/menus/useItem/equip.lua b/sonic-radiance.love/scenes/overworld/gui/menus/useItem/equip.lua new file mode 100644 index 0000000..3457077 --- /dev/null +++ b/sonic-radiance.love/scenes/overworld/gui/menus/useItem/equip.lua @@ -0,0 +1,52 @@ +local SetEquipScreen = require("scenes.overworld.gui.menus.useItem.parent"):extend() +local STATS = require "datas.consts.stats" + +function SetEquipScreen:new() + SetEquipScreen.super.new(self, "setEquip", 32 * 6, true) +end + +function SetEquipScreen:applyEffect(character) + character:setEquip(self.category, self.item.name) +end + +function SetEquipScreen:getDescription() + local returnData = {} + table.insert(returnData, {1, self.itemData.fullname}) + self.charName = self.gui:getElement("setEquipMenu").charName + if (self.charName ~= "") then + local char = game.characters.list[self.charName] + + for i, statName in ipairs(STATS.LIST) do + local lineNbr = math.floor((i-1)/2) + local isLeft = ((i%2) == 1) + + local stat = char.stats:get(statName) + local newStat = char:predictStat(statName, self.category, self.item.name) + + local sep = ": " + if i > 2 then + sep = ": " + end + + local line = STATS.SIMPLENAME[statName] .. sep .. utils.math.numberToString(stat, 3) .. " > " .. utils.math.numberToString(newStat, 3) + local color = {1, 1, 1, 1} + + if (newStat > stat) then + color = {0.3, 1, 0.3, 0.9} + elseif (newStat < stat) then + color = {1, 0.3, 0.3, 0.9} + end + + table.insert(returnData, {lineNbr + 2, line, utils.math.either(isLeft, "left", "right"), 0, 0, color}) + end + + end + return returnData +end + +function SetEquipScreen:setDatas(datas) + SetEquipScreen.super.setDatas(self, datas) + self.charMenu.showEquip = self.category +end + +return SetEquipScreen \ No newline at end of file diff --git a/sonic-radiance.love/scenes/overworld/gui/menus/useItem/init.lua b/sonic-radiance.love/scenes/overworld/gui/menus/useItem/init.lua new file mode 100644 index 0000000..23ab429 --- /dev/null +++ b/sonic-radiance.love/scenes/overworld/gui/menus/useItem/init.lua @@ -0,0 +1,23 @@ +local UseItemScreen = require("scenes.overworld.gui.menus.useItem.parent"):extend() +local EffectManager = require "game.loot.effectManager" + +function UseItemScreen:new() + self.effectManager = EffectManager() + UseItemScreen.super.new(self, "useItem", 128, false) +end + +function UseItemScreen:applyEffect(character) + self.effectManager:applyEffects(character) + game.loot:removeItem(self.category, self.item.name, 1) +end + +function UseItemScreen:setDatas(datas) + UseItemScreen.super.setDatas(self, datas) + self.effectManager:getItemData(self.category, self.item.name) +end + +function UseItemScreen:getDescription() + return {{1, self.itemData.fullname .. ":\n" .. self.effects}} +end + +return UseItemScreen \ No newline at end of file diff --git a/sonic-radiance.love/scenes/overworld/gui/menus/useItem/number.lua b/sonic-radiance.love/scenes/overworld/gui/menus/useItem/number.lua new file mode 100644 index 0000000..3b5d5b2 --- /dev/null +++ b/sonic-radiance.love/scenes/overworld/gui/menus/useItem/number.lua @@ -0,0 +1,21 @@ +local ItemNumberElement = require("birb.modules.gui.elements.canvas"):extend() + +local W = 48 + 16 +local gui = require "game.modules.gui" + +function ItemNumberElement:new(owner, name, x, y) + ItemNumberElement.super.new(self, name, x, y, W, 18) + + self.choiceBack = gui.newChoiceBack(W) + self.canvas.isAnimated, self.canvas.padding = true, 0 + self.owner = owner + self.opacity = 0 +end + +function ItemNumberElement:drawTexture() + love.graphics.draw(self.choiceBack, 0, 0) + + self.scene.assets.fonts["small"]:draw("x" .. self.owner:getItemNumber(), 16, -2, -1, "left") +end + +return ItemNumberElement \ No newline at end of file diff --git a/sonic-radiance.love/scenes/overworld/gui/menus/useItem/parent.lua b/sonic-radiance.love/scenes/overworld/gui/menus/useItem/parent.lua new file mode 100644 index 0000000..0abeee3 --- /dev/null +++ b/sonic-radiance.love/scenes/overworld/gui/menus/useItem/parent.lua @@ -0,0 +1,91 @@ +local UseScreenParent = require("birb.modules.gui.screen"):extend() +local CharacterMenu = require("scenes.overworld.gui.menus.commons.charmenu") +local BoxedText = require "scenes.overworld.gui.menus.commons.boxedtext" +local ItemNumber = require "scenes.overworld.gui.menus.useItem.number" +local const = require "scenes.overworld.gui.menus.commons.const" + +local DESC_H = 40 + 48 +local NBR_Y = 24 + +function UseScreenParent:new(prefix, descW, showEquip) + self.prefix = prefix + + self.descW = descW + self.showEquip = showEquip + self.nbrX = const.X + self.descW - 48 + self.charMenuX = const.X + self.descW + 8 + + UseScreenParent.super.new(self, prefix .. "Screen") + self:addTransformsWithPrefix() + self.defaultFocus = prefix .. "Menu" +end + +function UseScreenParent:addTransformsWithPrefix() + local show = { + {self.prefix .. "Desc", "movement", 0.1, 0.3, const.X, const.Y, "inOutQuart"}, + {self.prefix .. "Desc", "tween", 0.1, 0.3, {opacity = 1}, "inOutQuart"}, + {self.prefix .. "Nbr", "movement", 0, 0.3, self.nbrX, const.Y2 - NBR_Y, "inOutQuart"}, + {self.prefix .. "Nbr", "tween", 0, 0.3, {opacity = 1}, "inOutQuart"}, + {self.prefix .. "Menu", "movement", 0.1, 0.3, self.charMenuX, const.Y, "inOutQuart"}, + {self.prefix .. "Menu", "tween", 0.1, 0.3, {opacity = 1}, "inOutQuart"}, + } + + local hide = { + {self.prefix .. "Desc", "movement", 0, 0.3, const.X - 16, const.Y, "inOutQuart"}, + {self.prefix .. "Desc", "tween", 0, 0.3, {opacity = 0}, "inOutQuart"}, + {self.prefix .. "Nbr", "movement", 0, 0.3, self.nbrX - 16, const.Y2 - NBR_Y, "inOutQuart"}, + {self.prefix .. "Nbr", "tween", 0, 0.3, {opacity = 0}, "inOutQuart"}, + {self.prefix .. "Menu", "movement", 0, 0.3, self.charMenuX + 16, const.Y, "inOutQuart"}, + {self.prefix .. "Menu", "tween", 0, 0.3, {opacity = 0}, "inOutQuart"}, + } + + self:addTransform("show", show) + self:addTransform("hide", hide) +end + +function UseScreenParent:createElements() + self.charMenu = CharacterMenu(self.prefix .. "Menu", self.charMenuX + 16, function(name) self:useItem(name) end, self.showEquip) + self.charMenu:addCancelAction(function() self:exitScreen() end) + self.charMenu.opacity = 0 + return { + {self.charMenu, 0, 1}, + {BoxedText(self.prefix .. "Desc", const.X - 16, const.Y, self.descW, DESC_H, + function() if (self.itemData ~= nil) then return self:getDescription() else return {{1, ""}} end end), 0, 1}, + {ItemNumber(self, self.prefix .. "Nbr", self.nbrX - 16, const.Y2 - NBR_Y), 0, 1} + } +end + +function UseScreenParent:useItem(charName) + local character = game.characters.list[charName] + self:applyEffect(character) + self.gui:getScreen("itemScreen"):rebuildMenu() + if (self.item.number <= 1) then + self:exitScreen() + end +end + +function UseScreenParent:exitScreen() + self.gui:showScreen("itemScreen", nil, self.nbr, self.category) + self.gui.scene.assets:playSFX("mBack") +end + +function UseScreenParent:setDatas(datas) + --category, item, widgetId) + local category = datas[1] + self.item = datas[2] + self.nbr = datas[3] or 1 + self.itemData = core.datas:get("items", self.item.name) + self.category = category + + self.effects = game.loot:getEffectStrings(self.category, self.item.name) +end + +function UseScreenParent:getItemNumber() + if (self.item ~= nil) then + return self.item.number or 0 + end + return 0 +end + + +return UseScreenParent \ No newline at end of file diff --git a/sonic-radiance.love/scenes/overworld/init.lua b/sonic-radiance.love/scenes/overworld/init.lua index bf9df30..9c199b3 100644 --- a/sonic-radiance.love/scenes/overworld/init.lua +++ b/sonic-radiance.love/scenes/overworld/init.lua @@ -27,14 +27,11 @@ local OverWorld = Scene:extend() local World = require "scenes.overworld.world" local CharsetManager = require "scenes.overworld.charsetmanager" -local screens = require "scenes.overworld.screens" - -local gui = require "game.modules.gui" local TweenManager = require "birb.classes.time" - local EventManager = require "game.events" local OWScreen = require "scenes.overworld.gui.init" +local MenusScreen = require "scenes.overworld.gui.menus" function OverWorld:new(area, playerx, playery) OverWorld.super.new(self, false, false) @@ -42,16 +39,11 @@ function OverWorld:new(area, playerx, playery) self.assets:batchImport("assets.overworld") self.tweens = TweenManager(self) - self.screens = screens World(self, area, playerx, playery) self.world:setPlayerNumber(1) self.world:loadMap() - self.currentScreen = nil - - self.backGroundOpacity = 0 - self.borderPosition = 0 self.isPaused = false self.canPause = false self.gui:hideScreen("overlay") @@ -62,6 +54,7 @@ function OverWorld:new(area, playerx, playery) self.events = EventManager(self) OWScreen() + MenusScreen() end function OverWorld:updateCurrentMap(map) @@ -90,13 +83,6 @@ function OverWorld:endEvent() self.canPause = true end -function OverWorld:registerScreen(screen) - if (self.currentScreen ~= nil) then - self.currentScreen:quit() - end - self.currentScreen = screen -end - function OverWorld:update(dt) local keys = self:getKeys(1) self.tweens:update(dt) @@ -106,10 +92,6 @@ function OverWorld:update(dt) self.charsetManager:update(dt) end - if (self.currentScreen ~= nil) then - self.currentScreen:update(dt) - end - if (keys["start"].isPressed and self.canPause) then if (not self.isPaused) then if (not self.gui.screens["overlay"].isVisible) then @@ -124,20 +106,19 @@ function OverWorld:update(dt) end function OverWorld:pause() - self.tweens:newTween(0,0.2, {backGroundOpacity=0.75}, "inQuad") self.gui:showScreen("overlay") self.gui:playScreenTransform("hud", "pause") + self.gui:playScreenTransform("overlay", "showBackgroundPause") self.isPaused = true self.world.isActive = false - screens.mainmenu.pause(self) + self.gui:showScreen("startmenu") end function OverWorld:gameover() - self.tweens:newTween(0,0.2, {backGroundOpacity=0.75}, "inQuad") self.gui:showScreen("overlay") self.gui:hideScreen("hud") + self.gui:playScreenTransform("overlay", "showBackgroundPause") self.world.isActive = false - screens.gameover(self) end function OverWorld:restored() @@ -152,18 +133,11 @@ function OverWorld:timerResponse(timer) end function OverWorld:unpause() - self.tweens:newTween(0.1, 0.2, {backGroundOpacity=0}, "inQuad") self.tweens:newTimer(0.2, "unPause") + self.gui:playScreenTransform("overlay", "hideBackgroundPause") self.gui:hideScreen("overlay") self.gui:playScreenTransform("hud", "unpause") - - if (self.currentScreen ~= nil) then - self.currentScreen:quit() - end -end - -function OverWorld:quitScreen() - self.currentScreen = nil + self.gui:hideScreen("startmenu") end function OverWorld:getEmblemsPosition() @@ -172,28 +146,6 @@ end function OverWorld:draw() self.events:draw() - self:drawScreenBottomLayer() -end - -function OverWorld:drawOverTransition() - self:drawScreenTopLayer() -end - -function OverWorld:drawScreenBottomLayer() - love.graphics.setColor(0, 0, 0, self.backGroundOpacity) - love.graphics.rectangle("fill", 0, 0, 424, 240) - utils.graphics.resetColor() - - if (self.currentScreen ~= nil) then - self.currentScreen:drawBackground() - self.currentScreen:drawForeground() - end -end - -function OverWorld:drawScreenTopLayer() - if (self.currentScreen ~= nil) then - self.currentScreen:drawOverEverything() - end end return OverWorld diff --git a/sonic-radiance.love/scenes/overworld/screens/gameover.lua b/sonic-radiance.love/scenes/overworld/screens/gameover.lua deleted file mode 100644 index 871db90..0000000 --- a/sonic-radiance.love/scenes/overworld/screens/gameover.lua +++ /dev/null @@ -1,89 +0,0 @@ -local BaseScreen = require "scenes.overworld.screens.parent" -local GameOver = BaseScreen:extend() - -local TweenManager = require "birb.classes.time" - -local gui = require "game.modules.gui" - -local tw, th = 128, 32 - -local defTransitions = require "birb.modules.transitions" -local ConfirmDialog = require "game.modules.confirmdialog" - -function GameOver:new(scene) - GameOver.super.new(self, scene, "") - self.assets = scene.assets - self.turnSystem = scene.turns - - self:setVariables() - - self.continueBox = gui.newTextBox("assets/gui/dialogbox.png", tw, th) - - self.tweens = TweenManager(self) - self:prepareAnimation() -end - -function GameOver:setVariables() - -- Vignette Opacity - self.vignetteOpacity = 0 - - -- Battle FInished Label - self.labelOpacity = 0 - local width, height = core.screen:getDimensions() - self.labelX = width/2 - - -- Infobox - self.tbSize = 0.6 - self.tbOpacity = 0 -end - -function GameOver:prepareAnimation() - -- Label - self.tweens:newTween(0, 0.6, {labelOpacity=1}, 'inExpo') - self.tweens:newTween(0.9, 0.4, {labelX=4}, 'inExpo') - - self.tweens:newTimer(1.8, "continue") -end - -function GameOver:update(dt) - self.tweens:update(dt) -end - -function GameOver:draw() - local width, height = core.screen:getDimensions() - self:drawVignette(width, height) - self:drawLabel(width/2, 48, self.labelX, self.labelOpacity) -end - -function GameOver:timerResponse(timer) - if (timer == "continue") then - local confirm = ConfirmDialog(self.scene, "Do you want to return to title ? \nYou can also reload your latest save.", - function() self:returnToTitle() end, "Return to title", - function() self:loadLastSave() end, "Reload last save") - confirm.darken = false - end -end - -function GameOver:drawVignette(width, height) - love.graphics.setColor(0, 0, 0, self.vignetteOpacity) - - love.graphics.rectangle("fill", 0, 0, width, height) -end - -function GameOver:drawLabel(x, y, x2, opacity) - love.graphics.setColor(1, 1, 1, opacity) - - self.assets.fonts["SA2font"]:print("GAME", x - x2, y, "right") - self.assets.fonts["SA2font"]:print("OVER", x + x2, y, "left") -end - -function GameOver:returnToTitle() - core.screen:startTransition(defTransitions.default, defTransitions.circle, function() scenes.menus.title(true) end, 424/2, 240/2) -end - -function GameOver:loadLastSave() - self.scene.tweens:newTween(0, 0.3, {borderPosition=0}, "inOutQuad") - core.screen:startTransition(defTransitions.default, defTransitions.default, function() game:reload() scenes.overworld() end, 424/2, 240/2) -end - -return GameOver diff --git a/sonic-radiance.love/scenes/overworld/screens/init.lua b/sonic-radiance.love/scenes/overworld/screens/init.lua deleted file mode 100644 index 568e5e9..0000000 --- a/sonic-radiance.love/scenes/overworld/screens/init.lua +++ /dev/null @@ -1,4 +0,0 @@ -return { - mainmenu = require "scenes.overworld.screens.mainmenu", - gameover = require "scenes.overworld.screens.gameover" -} diff --git a/sonic-radiance.love/scenes/overworld/screens/mainmenu/character/basicpage.lua b/sonic-radiance.love/scenes/overworld/screens/mainmenu/character/basicpage.lua deleted file mode 100644 index e639de3..0000000 --- a/sonic-radiance.love/scenes/overworld/screens/mainmenu/character/basicpage.lua +++ /dev/null @@ -1,69 +0,0 @@ -local PageParent = require "scenes.overworld.screens.mainmenu.character.pageparent" -local BasicPage = PageParent:extend() - -local menu = require "game.modules.menus.fancy" -local gui = require "game.modules.gui" -local const = require "scenes.overworld.screens.mainmenu.const" - -local ComplexHPBar = require "game.modules.gui.complexhpbar" - -local HPBAR_SIZE = 80 - -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) - - self.hpbar = ComplexHPBar(HPBAR_SIZE) - self.ppbar = ComplexHPBar(HPBAR_SIZE) - self.hpbar:setColorForeground(248/255, 160/255, 0, 1) - self.hpbar:setColorBackground(112/255, 0, 0) - self.ppbar:setColorForeground(0, 248/255, 248/255, 1) - self.ppbar:setColorBackground(0, 54/255, 229/255) - - BasicPage.super.new(self, view, character, {}) -end - -function BasicPage:draw() - self:drawIdentity(const.X, const.Y) - self:drawHPPP(const.X, const.Y + 48) - self:drawLevel(const.X, 100) - 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:drawHPPP(x, y) - local stats = self.character.stats - self.view.scene.assets.fonts["hudnbrs_small"]:set() - self.hpbar:drawWithLabels(x, y - 4, self.character.hp, stats:get(stats.HPMAX)) - local xx = x + const.CHARPAGESIZE - HPBAR_SIZE - 7 - self.ppbar:drawWithLabels(xx, y - 4, self.character.pp, stats:get(stats.PPMAX)) -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:drawWeakStrong(x, y) - local weakString = "Weak to: Nothing"--"Earth, Lightning" - local strongString = "Resist To: Nothing" - - 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 diff --git a/sonic-radiance.love/scenes/overworld/screens/mainmenu/character/init.lua b/sonic-radiance.love/scenes/overworld/screens/mainmenu/character/init.lua deleted file mode 100644 index e442e9d..0000000 --- a/sonic-radiance.love/scenes/overworld/screens/mainmenu/character/init.lua +++ /dev/null @@ -1,122 +0,0 @@ -local ParentScreen = require "scenes.overworld.screens.parent" -local CharacterScreen = ParentScreen:extend() - -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 StatPage = require "scenes.overworld.screens.mainmenu.character.statpage" -local SkillPage = require "scenes.overworld.screens.mainmenu.character.skillpage" -local pageList = {BasicPage, StatPage, SkillPage} - -local ReturnWidget = menu.BaseWidget:extend() - -function CharacterScreen:new(scene, character) - self.character = game.characters.list[character] - self.charName = character - - 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) - self.scene.assets.sfx["mBeep"]:play() - end - if (keys["right"].isPressed) then - self:setPage(self.pageIndex + 1) - self.scene.assets.sfx["mBeep"]:play() - 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 = self.page:getMenuSize() - local y = const.Y2 - (16*itemNumber) + 2 - menu.FancyMenu(self.scene, "menu", const.X2 - 128 - 14, y, 128, itemNumber, false) - self.page:getMenuWidgets() - ReturnWidget(self.scene, self.charName) - - local customMenu = self.page:getCustomMenus() - - self.scene.menusystem:switchMenu("menu") - self.scene.menusystem.menus["menu"]:getFocus() - self.scene.menusystem.menus["menu"]:setCancelWidget() - self.scene.menusystem.menus["menu"].isLocked = true - if (customMenu ~= nil) then - customMenu.isLocked = true - customMenu.isVisible = true - end - self.scene.menusystem:setSoundFromSceneAssets("mBeep") -end - -function CharacterScreen:draw() - if (self.page ~= nil) then - self.page:draw() - end - - for i = 1, #pageList, 1 do - local radius = 2 - if (i == self.pageIndex) then - radius = 3 - end - local x = (16*i) + 240 + 64 - local y = 17 - local outlineLight = 0.15 - love.graphics.circle("fill", x + 8, y + 8, radius, 8) - love.graphics.setColor(outlineLight, outlineLight, outlineLight, 1) - love.graphics.circle("line", x + 8, y + 8, radius, 8) - utils.graphics.resetColor() - end -end - -function CharacterScreen:drawBackground() - love.graphics.draw(self.artwork, self.artworkOrigin.x, self.artworkOrigin.y) -end - -function CharacterScreen:drawOverEverything() - if (self.page ~= nil) then - self.page:drawOverEverything() - end -end - --- Widgets - -function ReturnWidget:new(scene, charName) - self.charName = charName - ReturnWidget.super.new(self, scene, "menu", "Back", "") -end - -function ReturnWidget:action() - for i, name in ipairs(game.characters.team) do - if (name == self.charName) then - self.widgetSelected = i - end - end - self.scene.assets:playSFX("mBack") - - self.scene.screens.mainmenu["pause"](self.scene, "character", self.widgetSelected) -end - -return CharacterScreen diff --git a/sonic-radiance.love/scenes/overworld/screens/mainmenu/character/pageparent.lua b/sonic-radiance.love/scenes/overworld/screens/mainmenu/character/pageparent.lua deleted file mode 100644 index b91b8cd..0000000 --- a/sonic-radiance.love/scenes/overworld/screens/mainmenu/character/pageparent.lua +++ /dev/null @@ -1,47 +0,0 @@ -local PageParent = Object:extend() -local menu = require "game.modules.menus.fancy" -local Widget = menu.BaseWidget:extend() - -function PageParent:new(view, character, menu) - self.view = view - self.character = game.characters.list[character] - self.menu = menu or {} -end - -function PageParent:update(dt) -end - -function PageParent:getMenuSize() - return #self.menu + 1 -end - -function PageParent:getMenuWidgets() - for index, name in ipairs(self.menu) do - Widget(self, name, index) - end -end - -function PageParent:menuResponses(i) -end - -function PageParent:getCustomMenus() -end - -function PageParent:draw() -end - -function PageParent:drawOverEverything() -end - -function Widget:new(page, name, num) - self.num = num - self.page = page - Widget.super.new(self, self.page.view.scene, "menu", name, ">") -end - -function Widget:action() - self.page:menuResponses(self.num) - self.scene.assets.sfx["mBeep"]:play() -end - -return PageParent diff --git a/sonic-radiance.love/scenes/overworld/screens/mainmenu/character/skillpage.lua b/sonic-radiance.love/scenes/overworld/screens/mainmenu/character/skillpage.lua deleted file mode 100644 index db4681c..0000000 --- a/sonic-radiance.love/scenes/overworld/screens/mainmenu/character/skillpage.lua +++ /dev/null @@ -1,71 +0,0 @@ -local PageParent = require "scenes.overworld.screens.mainmenu.character.pageparent" -local StatPage = PageParent:extend() - -local menu = require "game.modules.menus.list" -local const = require "scenes.overworld.screens.mainmenu.const" - -local SkillMenu = menu.ListMenu:extend() -local SkillWidget = menu.DualTextWidget:extend() -local PLAYER_MESSAGE = 240 - 24 - -function StatPage:new(view, character) - StatPage.super.new(self, view, character, {"See skill"}) - self.message = "" - self.showMessage = false -end - -function StatPage:getCustomMenus() - return SkillMenu(self, self.character) -end - -function StatPage:menuResponses(i) - if (#self.character.skills > 0) then - self.view.scene.menusystem:switchMenu("equip") - self.showMessage = true - end -end - -function StatPage:drawOverEverything() - if (not utils.string.isEmpty(self.message) and self.showMessage) then - love.graphics.setColor(0,0,0, 0.66) - love.graphics.rectangle("fill", 0, PLAYER_MESSAGE, 424, 16) - self.view.scene.assets.fonts["small"]:setColor(1,1,1, 1) - self.view.scene.assets.fonts["small"]:draw(self.message, 424/2, PLAYER_MESSAGE - 1, -1, "center") - self.view.scene.assets.fonts["small"]:setColor(1,1,1, 1) - utils.graphics.resetColor() - end -end - -function StatPage:setMessage(message) - self.message = message -end - -function StatPage:removeEquip(type) - self.character:removeEquip(type) -end - -function SkillMenu:new(page, character) - self.page = page - SkillMenu.super.new(self, page.view.scene, "equip", const.X, const.Y + 4, const.CHARPAGESIZE, 9, true, true) - for _, skill in ipairs(character.skills) do - SkillWidget(page, skill.name) - end -end - -function SkillMenu:cancelAction() - self.scene.menusystem.menus["menu"]:getFocus() - self.page.showMessage = false - self.scene.assets.sfx["mBack"]:play() -end - -function SkillWidget:new(page, skill) - self.page = page - self.skillData = core.datas:get("skills", skill) - SkillWidget.super.new(self, self.page.view.scene, "equip", self.skillData.fullname, utils.math.numberToString(self.skillData.cost, 2)) -end - -function SkillWidget:selectAction() - self.page:setMessage(self.skillData.description) -end - -return StatPage diff --git a/sonic-radiance.love/scenes/overworld/screens/mainmenu/character/statpage.lua b/sonic-radiance.love/scenes/overworld/screens/mainmenu/character/statpage.lua deleted file mode 100644 index 4401ec3..0000000 --- a/sonic-radiance.love/scenes/overworld/screens/mainmenu/character/statpage.lua +++ /dev/null @@ -1,88 +0,0 @@ -local PageParent = require "scenes.overworld.screens.mainmenu.character.pageparent" -local StatPage = PageParent:extend() - -local menu = require "game.modules.menus.list" -local gui = require "game.modules.gui" -local const = require "scenes.overworld.screens.mainmenu.const" - -local EquipMenu = menu.ListMenu:extend() -local EquipWidget = menu.DualTextWidget:extend() - -local STATS = require "datas.consts.stats" - -function StatPage:new(view, character) - self.statBox = gui.newTextBox("assets/gui/dialogbox.png", const.CHARPAGESIZE, 40 + 32) - - StatPage.super.new(self, view, character, {"Remove item"}) -end - -function StatPage:getCustomMenus() - return EquipMenu(self) -end - -function StatPage:menuResponses(i) - self.view.scene.menusystem:switchMenu("equip") -end - -function StatPage:draw() - self:drawStats(const.X, 100) -end - -function StatPage:drawStats(x, y) - love.graphics.draw(self.statBox, x, y) - - local char = self.character - for i, statName in ipairs(STATS.LIST) do - local xStat = x + (((i - 1) % 2) * (const.CHARPAGESIZE/2)) + 6 - local yStat = y + (math.floor((i-1)/2) * 16) + 4 - local middle = xStat + 10 + const.CHARPAGESIZE/4 - local stat = char.stats:get(statName) - self.view.scene.assets.fonts["small"]:draw(STATS.SIMPLENAME[statName], xStat, yStat, const.CHARPAGESIZE, "left") - self.view.scene.assets.fonts["small"]:setColor(1, 1, 1, 0.9) - self.view.scene.assets.fonts["small"]:draw(stat, middle, yStat, -1, "center") - self.view.scene.assets.fonts["small"]:setColor(1, 1, 1, 1) - utils.graphics.resetColor() - end -end - -function StatPage:removeEquip(type) - self.character:removeEquip(type) -end - -function EquipMenu:new(page) - self.page = page - EquipMenu.super.new(self, page.view.scene, "equip", const.X, const.Y + 4, const.CHARPAGESIZE, 3, true, true) - EquipWidget(page, "gloves") - EquipWidget(page, "shoes") - EquipWidget(page, "accessories") -end - -function EquipMenu:cancelAction() - self.scene.menusystem.menus["menu"]:getFocus() - self.scene.assets.sfx["mBack"]:play() -end - -function EquipWidget:new(page, type) - self.page = page - self.type = type - local label = self:getLabel() - EquipWidget.super.new(self, self.page.view.scene, "equip", label, "") -end - -function EquipWidget:getLabel() - local obj = self.page.character.equip[self.type] - if (utils.string.isEmpty(obj)) then - return "No " .. self.type - end - local data = core.datas:get("items", obj) - return data.fullname -end - -function EquipWidget:action() - self.page:removeEquip(self.type) - self.label = self:getLabel() - self:redrawCanvas() - self.scene.assets.sfx["mSelect"]:play() -end - -return StatPage diff --git a/sonic-radiance.love/scenes/overworld/screens/mainmenu/common/charmenu.lua b/sonic-radiance.love/scenes/overworld/screens/mainmenu/common/charmenu.lua deleted file mode 100644 index 6ec5cbc..0000000 --- a/sonic-radiance.love/scenes/overworld/screens/mainmenu/common/charmenu.lua +++ /dev/null @@ -1,12 +0,0 @@ -local baseMenu = require "game.modules.menus.parents.menu" -local CharacterMenu = baseMenu:extend() - -local const = require "scenes.overworld.screens.mainmenu.const" - -function CharacterMenu:new(scene, x) - local x = x or const.X + 136 - local w = const.WIDTH - x + 28 - CharacterMenu.super.new(self, scene, "character", x, const.Y, w, const.HEIGHT, 4) -end - -return CharacterMenu diff --git a/sonic-radiance.love/scenes/overworld/screens/mainmenu/common/charwidget.lua b/sonic-radiance.love/scenes/overworld/screens/mainmenu/common/charwidget.lua deleted file mode 100644 index c4fddf0..0000000 --- a/sonic-radiance.love/scenes/overworld/screens/mainmenu/common/charwidget.lua +++ /dev/null @@ -1,65 +0,0 @@ -local baseWidget = require "game.modules.menus.parents.widget" -local CharacterWidget = baseWidget:extend() - -local ComplexHPBar = require "game.modules.gui.complexhpbar" -local Emblem = require "game.modules.gui.emblem" - --- Hero custom widget --- -function CharacterWidget:new(scene, name, showEquip) - self.charName = name - self.emblem = Emblem(game.characters.list[name], scene) - self.font2 = scene.assets.fonts["hudnbrs_small"] - self.showEquip = showEquip - CharacterWidget.super.new(self, scene, "character") - - self.hpbar = ComplexHPBar(88) - self.ppbar = ComplexHPBar(88) - self.hpbar:setColorForeground(248 / 255, 160 / 255, 0, 1) - self.hpbar:setColorBackground(112 / 255, 0, 0) - self.ppbar:setColorForeground(0, 248 / 255, 248 / 255, 1) - self.ppbar:setColorBackground(0, 54 / 255, 229 / 255) -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") - if (self.showEquip == nil) then - 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") - else - local charEquip = character.equip[self.showEquip] - local equipString = "None" - if (not utils.string.isEmpty(charEquip)) then - local data = core.datas:get("items", charEquip) - equipString = data.fullname - end - self.font:draw(equipString, xDebut, debut + 16, -1, "left") - end -end - -function CharacterWidget:draw(x, y) - local character = game.characters.list[self.charName] - self.emblem:draw(x, y + 6) - if (self.showEquip == nil) then - local xDebut = x + 52 - local yDebut = y + 15 - self.scene.assets.fonts["hudnbrs_small"]:set() - local stats = character.stats - self.hpbar:drawWithLabels(xDebut + 53, yDebut, character.hp, stats:get(stats.HPMAX)) - self.ppbar:drawWithLabels(xDebut + 64, yDebut + 11, character.pp, stats:get(stats.PPMAX)) - end - if self.canvas.texture ~= nil then - love.graphics.draw(self.canvas.texture, x - self.ox, y - self.oy) - end -end - -return CharacterWidget diff --git a/sonic-radiance.love/scenes/overworld/screens/mainmenu/equip.lua b/sonic-radiance.love/scenes/overworld/screens/mainmenu/equip.lua deleted file mode 100644 index 51bd2cb..0000000 --- a/sonic-radiance.love/scenes/overworld/screens/mainmenu/equip.lua +++ /dev/null @@ -1,115 +0,0 @@ -local ParentScreen = require "scenes.overworld.screens.parent" -local EquipScreen = ParentScreen:extend() - -local menu = require "game.modules.menus.list" -local const = require "scenes.overworld.screens.mainmenu.const" -local gui = require "game.modules.gui" - -local baseCharacterMenu = require "scenes.overworld.screens.mainmenu.common.charmenu" -local baseCharacterWidget = require "scenes.overworld.screens.mainmenu.common.charwidget" -local CharacterMenu = baseCharacterMenu:extend() -local CharacterWidget = baseCharacterWidget:extend() - -local STATS = require "datas.consts.stats" - -local DESC_SIZE = 32 * 6 - -function EquipScreen:new(scene, category, item, widgetId) - self.category = category - self.item = item - self.itemData = core.datas:get("items", self.item.name) - self.widgetId = widgetId - - self.choiceBack = gui.newChoiceBack(48 + 16) - self.descBox = gui.newTextBox("assets/gui/dialogbox.png", DESC_SIZE, 40 + 48+16) - - self.desc = self.itemData.description - self.charName = "" - EquipScreen.super.new(self, scene, "Equipement") -end - -function EquipScreen:setMenu() - CharacterMenu(self.scene, 224) - for i, name in ipairs(game.characters.team) do - CharacterWidget(self.scene, name, self.category) - end - self.scene.menusystem:switchMenu("character") -end - -function EquipScreen:draw() - self.scene.assets.fonts["small"]:setLineHeight(16 / 18) - self:drawPocket() - self:drawDescription(const.X, const.Y) -end - -function EquipScreen:drawDescription(x, y) - love.graphics.draw(self.descBox, x, y) - local xx, yy, ww = x + 6, y + 4, DESC_SIZE - 12 - self.scene.assets.fonts["small"]:draw(self.itemData.fullname, xx, yy, ww, "left") - if (self.charName ~= "") then - local char = game.characters.list[self.charName] - for i, statName in ipairs(STATS.LIST) do - local xStat = xx + (((i - 1) % 2) * (ww/2)) - local yStat = yy + (math.floor((i-1)/2) * 16) + 24 - local middle = xStat + 10 + ww/4 - local stat = char.stats:get(statName) - local newStat = char:predictStat(statName, self.category, self.item.name) - self.scene.assets.fonts["small"]:draw(STATS.SIMPLENAME[statName], xStat, yStat, ww, "left") - self.scene.assets.fonts["small"]:setColor(1, 1, 1, 0.9) - self.scene.assets.fonts["small"]:draw(stat .. " ", middle, yStat, -1, "right") - self.scene.assets.fonts["small"]:draw(">", middle, yStat, -1, "center") - if (newStat > stat) then - self.scene.assets.fonts["small"]:setColor(0.3, 1, 0.3, 0.9) - elseif (newStat < stat) then - self.scene.assets.fonts["small"]:setColor(1, 0.3, 0.3, 0.9) - end - - self.scene.assets.fonts["small"]:draw(" " .. newStat, middle, yStat, -1, "left") - self.scene.assets.fonts["small"]:setColor(1, 1, 1, 1) - utils.graphics.resetColor() - end - end -end - -function EquipScreen:drawPocket() - local x = const.X + DESC_SIZE - 48 - local y = const.Y2 - 24 - love.graphics.draw(self.choiceBack, x, y) - - self.scene.assets.fonts["small"]:draw("x" .. self.item.number, x + 16, y - 2, -1, "left") -end - -function EquipScreen:goBack() - self.scene.screens.mainmenu["items"](self.scene, game.loot:getPocketIdByName(self.category), self.widgetId) -end - -function EquipScreen:useItem(charName) - local character = game.characters.list[charName] - if (self.item.number <= 1) then - character:setEquip(self.category, self.item.name) - self:goBack() - else - character:setEquip(self.category, self.item.name) - end -end - --- Character menu -function CharacterMenu:cancelAction() - -- Switch à l'écran précédant - self.scene.assets:playSFX("mBack") - self.scene.currentScreen:goBack() -end - --- Hero custom widget --- -function CharacterWidget:selectAction() - self.scene.currentScreen.charName = self.charName -end - -function CharacterWidget:action() - self.scene.assets:playSFX("mSelect") - self.scene.currentScreen:useItem(self.charName) - self:redrawCanvas() -end - -return EquipScreen diff --git a/sonic-radiance.love/scenes/overworld/screens/mainmenu/init.lua b/sonic-radiance.love/scenes/overworld/screens/mainmenu/init.lua deleted file mode 100644 index 423dc7d..0000000 --- a/sonic-radiance.love/scenes/overworld/screens/mainmenu/init.lua +++ /dev/null @@ -1,7 +0,0 @@ -return { - pause = require "scenes.overworld.screens.mainmenu.pause", - character = require "scenes.overworld.screens.mainmenu.character", - items = require "scenes.overworld.screens.mainmenu.items", - useItems = require "scenes.overworld.screens.mainmenu.useitems", - equip = require "scenes.overworld.screens.mainmenu.equip" -} diff --git a/sonic-radiance.love/scenes/overworld/screens/mainmenu/items.lua b/sonic-radiance.love/scenes/overworld/screens/mainmenu/items.lua deleted file mode 100644 index 65e1308..0000000 --- a/sonic-radiance.love/scenes/overworld/screens/mainmenu/items.lua +++ /dev/null @@ -1,258 +0,0 @@ -local ParentScreen = require "scenes.overworld.screens.parent" -local ItemsScreen = ParentScreen:extend() - -local menu = require "game.modules.menus.list" -local const = require "scenes.overworld.screens.mainmenu.const" -local gui = require "game.modules.gui" - -local ItemWidget = menu.DualTextWidget:extend() -local BackWidget = menu.DualTextWidget:extend() -local ResumeWidget = menu.DualTextWidget:extend() -local DropWidget = menu.DualTextWidget:extend() -local UseWidget = menu.DualTextWidget:extend() - -local DESC_SIZE = 48*4 - -local ConfirmDialog = require "game.modules.confirmdialog" - -function ItemsScreen:new(scene, menuIndex, widgetIndex) - self.menuIndex = menuIndex or 1 - self.widgetIndex = widgetIndex or 1 - self.choiceBack = gui.newChoiceBack(DESC_SIZE) - self.descBox = gui.newTextBox("assets/gui/dialogbox.png", DESC_SIZE, 40+16) - self.effectBox = gui.newTextBox("assets/gui/dialogbox.png", DESC_SIZE, 40) - self.desc = "" - self.effects = "" - ItemsScreen.super.new(self, scene, "Items") -end - -function ItemsScreen:update(dt) - if (self.scene.menusystem.menus["useMenu"] == nil) then - local keys = self.scene:getKeys(1) - if (keys["left"].isPressed) then - self.widgetIndex = 1 - self:getMenu(self.menuIndex - 1) - self.scene.assets.sfx["mBeep"]:play() - end - if (keys["right"].isPressed) then - self.widgetIndex = 1 - self:getMenu(self.menuIndex + 1) - self.scene.assets.sfx["mBeep"]:play() - end - end -end - -function ItemsScreen:getMenu(newMenuIndex) - local newMenuIndex = newMenuIndex or 1 - if (newMenuIndex > #game.loot.inventory) then - newMenuIndex = 1 - end - if (newMenuIndex < 1) then - newMenuIndex = #game.loot.inventory - end - - self.menuIndex = newMenuIndex - self.scene.menusystem:reset() - self:setMenu() -end - -function ItemsScreen:setMenu(widgetId) - self.pocket = game.loot:getPocketById(self.menuIndex) - local w = 128+32 - menu.ListMenu(self.scene, "menu", const.X2 - w, const.Y + 8, w, 9, true) - for i,item in ipairs(self.pocket.list) do - --menu.DualTextWidget(self.scene, "menu", item.name, "x" .. item.number) - ItemWidget(self.scene, self.pocket.name, item, i) - end - BackWidget(self.scene) - self.scene.menusystem.menus["menu"]:setCancelWidget() - self.scene.menusystem:switchMenu("menu") - self.scene.menusystem.menus["menu"].isLocked = true - self.scene.menusystem.menus["menu"].widget.selected = math.max(1, self.widgetIndex) - self.scene.menusystem.menus["menu"].cursorTransition = math.max(0, self.widgetIndex - 1) - self.scene.menusystem:setSoundFromSceneAssets("mBeep") -end - -function ItemsScreen:setUseMenu(item, widgetId) - local w = 96 - menu.ListMenu(self.scene, "useMenu", const.X2 + 16 - w, const.Y2 - 48, w, 3, true) - UseWidget(self.scene, self.pocket.name, item, widgetId) - DropWidget(self.scene, self.pocket.name, item, widgetId) - ResumeWidget(self.scene) - self.scene.menusystem.menus["useMenu"]:setCancelWidget() - self.scene.menusystem:switchMenu("useMenu") - self.scene.menusystem.menus["useMenu"]:setDepth(-1) -end - -function ItemsScreen:removeUseMenu() - self.scene.menusystem.menus["useMenu"]:destroy() - self.scene.menusystem:switchMenu("menu") -end - -function ItemsScreen:draw() - self:drawPocket() - self:drawDescription(const.X, const.Y2 - (88+16)) - self:drawEffects(const.X, const.Y2 - 40) -end - -function ItemsScreen:drawDescription(x, y) - love.graphics.draw(self.descBox, x, y) - local xx, yy, ww = x + 6, y + 4, DESC_SIZE - 12 - self.scene.assets.fonts["small"]:draw(self.desc, xx, yy, ww, "left") -end - -function ItemsScreen:drawEffects(x, y) - love.graphics.draw(self.effectBox, x, y) - local xx, yy, ww = x + 6, y + 4, DESC_SIZE - 12 - self.scene.assets.fonts["small"]:draw(self.effects, xx, yy, ww, "left") -end - -function ItemsScreen:drawPocket() - local middleX = ((16) + (DESC_SIZE - 24)) / 2 - love.graphics.draw(self.choiceBack, const.X, const.Y) - - self.scene.assets.fonts["small"]:draw("<", const.X + 16, const.Y - 2, -1, "left") - self.scene.assets.fonts["small"]:draw(">", const.X + DESC_SIZE - 24, const.Y - 2, -1, "right") - self.scene.assets.fonts["small"]:draw(self.pocket.fullname, const.X + middleX, const.Y - 2, -1, "center") - - self:drawPocketRoll(const.X + 48*2, const.Y + 20) -end - -function ItemsScreen:drawPocketRoll(x, y) - core.screen:setScissor(const.X, const.Y+ 16, 48*4, 48) - - local trueX = x - ((self.menuIndex - 1) * 32) - for i, pocket in ipairs(game.loot.inventory) do - local trueIndex = i - self.menuIndex - if (trueIndex > 4) then - trueIndex = trueIndex - 8 - end - if (trueIndex < -4) then - trueIndex = trueIndex + 8 - end - if (trueIndex ~= 0) then - love.graphics.setColor(.3, .3, .3, .6) - end - self.scene.assets.tileset["itembox"]:drawTile(i, x + ((trueIndex)*32), y, 0, 1, 1, 14, 0) - utils.graphics.resetColor() - end - - core.screen:resetScissor() -end - --- Items Widgets -function ItemWidget:new(scene, pocket, item, widgetId) - self.item = item - self.itemData = core.datas:get("items", self.item.name) - self.pocket = pocket - self.widgetId = widgetId - ItemWidget.super.new(self, scene, "menu", self.itemData.fullname, "x" .. utils.math.numberToString(self.item.number, 2)) -end - -function ItemWidget:selectAction() - self.scene.currentScreen.desc = self.itemData.description - self.scene.currentScreen.effects = game.loot:getEffectStrings(self.pocket, self.item.name) -end - -function ItemWidget:action() - self.scene.assets:playSFX("mSelect") - self.scene.currentScreen:setUseMenu(self.item, self.widgetId) -end - -function BackWidget:new(scene) - ItemWidget.super.new(self, scene, "menu", "Back", "") -end - -function BackWidget:selectAction() - self.scene.currentScreen.desc = "" - self.scene.currentScreen.effects = "" -end - -function BackWidget:action() - self.scene.assets:playSFX("mBack") - self.scene.screens.mainmenu["pause"](self.scene, "main", 3) -end - --- Use Menu Widget - -function UseWidget:new(scene, pocket, item, widgetId) - self.item = item - self.itemData = core.datas:get("items", self.item.name) - self.pocket = pocket - self.pocketData = game.loot:getPocketByName(self.pocket) - self.widgetId = widgetId - UseWidget.super.new(self, scene, "useMenu", "Use", "") - if (not (self.itemData.usableOnMap or self.pocketData.isEquipement)) then - self.color = {0.6, 0.6, 0.6} - end -end - -function UseWidget:action() - if (self.pocketData.isEquipement) then - self.scene.screens.mainmenu["equip"](self.scene, self.pocket, self.item, self.widgetId) - self.scene.assets:playSFX("mSelect") - elseif (self.itemData.usableOnMap) then - self.scene.screens.mainmenu["useItems"](self.scene, self.pocket, self.item, self.widgetId) - self.scene.assets:playSFX("mSelect") - else - self.scene.assets:playSFX("mError") - end -end - -function DropWidget:new(scene, pocket, item, widgetId) - self.item = item - self.itemData = core.datas:get("items", self.item.name) - self.pocket = pocket - self.max = self.item.number - self.widgetId = widgetId - self.number = 1 - DropWidget.super.new(self, scene, "useMenu", "Drop", "<" .. utils.math.numberToString(self.number, 2) .. ">") -end - -function DropWidget:updateSelected() - local keys = self.scene:getKeys(1) - if (keys["left"].isPressed) then - if (self.number > 1) then - self.number = self.number - 1 - else - self.number = self.max - end - self.label2 = "<" .. utils.math.numberToString(self.number, 2) .. ">" - self:invalidateCanvas() - end - if (keys["right"].isPressed) then - if (self.number < self.max) then - self.number = self.number + 1 - else - self.number = 1 - end - self.label2 = "<" .. utils.math.numberToString(self.number, 2) .. ">" - self:invalidateCanvas() - end -end - -function DropWidget:action() - self.scene.assets:playSFX("mSelect") - local confirm = ConfirmDialog(self.scene, "Do you want to drop these items ? \nYou won't be able to recover them.", - function() self:drop() end) - confirm:setCancelChoice(2) - confirm.autoDismiss = true -end - -function DropWidget:drop() - game.loot:removeItem(self.pocket, self.item.name, self.number) - self.scene.currentScreen.widgetIndex = self.widgetId - self.scene.currentScreen:removeUseMenu() - self.scene.currentScreen:setMenu() -end - -function ResumeWidget:new(scene) - ResumeWidget.super.new(self, scene, "useMenu", "Back", "") -end - -function ResumeWidget:action() - self.scene.assets:playSFX("mBack") - self.scene.currentScreen:removeUseMenu() -end - -return ItemsScreen diff --git a/sonic-radiance.love/scenes/overworld/screens/mainmenu/pause.lua b/sonic-radiance.love/scenes/overworld/screens/mainmenu/pause.lua deleted file mode 100644 index c73f79c..0000000 --- a/sonic-radiance.love/scenes/overworld/screens/mainmenu/pause.lua +++ /dev/null @@ -1,137 +0,0 @@ -local ParentScreen = require "scenes.overworld.screens.parent" -local PauseScreen = ParentScreen:extend() - -local menu = require "game.modules.menus.fancy" - -local baseCharacterMenu = require "scenes.overworld.screens.mainmenu.common.charmenu" -local baseCharacterWidget = require "scenes.overworld.screens.mainmenu.common.charwidget" -local CharacterMenu = baseCharacterMenu:extend() -local CharacterWidget = baseCharacterWidget:extend() - -local TeamWidget = menu.BaseWidget:extend() -local ViewWidget = menu.BaseWidget:extend() -local SaveExitWidget = menu.BaseWidget:extend() - -local defTransitions = require "birb.modules.transitions" -local radTransitions = require "game.modules.transitions" -local ConfirmDialog = require "game.modules.confirmdialog" - -local const = require "scenes.overworld.screens.mainmenu.const" - -function PauseScreen:new(scene, menu, widget) - self.menuSelected = menu or "main" - self.widgetSelected = widget - self.widget = widget - PauseScreen.super.new(self, scene, "Menu") -end - -function PauseScreen:setMenu() - menu.FancyMenu(self.scene, "main", const.X, const.Y, 108, 10, false) - TeamWidget(self.scene) - menu.BaseWidget(self.scene, "main", "Quest", ">") - ViewWidget(self.scene, "Items", "items") - menu.BaseWidget(self.scene, "main", "Chao", ">") - menu.BaseWidget(self.scene, "main", "Encylopedia", ">") - --menu.BaseWidget(self.scene, "main", "Options", ">") - self.scene.menusystem.menus["main"]:addSubMenu("save", "Save / Exit") - SaveExitWidget(self.scene, "main", "Resume", false, false) - - SaveExitWidget(self.scene, "save", "Save game", true, false) - SaveExitWidget(self.scene, "save", "Save and exit", true, true) - SaveExitWidget(self.scene, "save", "Exit game", false, true) - - self.scene.menusystem.menus["main"]:finalize() - self.scene.menusystem.menus["main"]:setCancelWidget() - - CharacterMenu(self.scene) - for i, name in ipairs(game.characters.team) do - CharacterWidget(self.scene, name) - end - self.scene.menusystem.menus["character"].isLocked = true - - self.scene.menusystem:switchMenu(self.menuSelected) - self.scene.menusystem.menus["main"].isVisible = true - if (self.widgetSelected ~= nil) then - self.scene.menusystem.menus[self.menuSelected].widget.selected = self.widgetSelected - self.scene.menusystem.menus[self.menuSelected].cursorTransition = self.widgetSelected - 1 - end - self.scene.menusystem:setSoundFromSceneAssets("mBeep") -end - -function PauseScreen:draw() - -end - --- Character menu -function CharacterMenu:cancelAction() - self.scene.assets:playSFX("mBeep") - self.scene.menusystem:switchMenu("main") -end - --- Hero custom widget --- -function CharacterWidget:action() - self.scene.assets:playSFX("mSelect") - self.scene.screens.mainmenu.character(self.scene, self.charName) -end - --- Team Widget --- - -function TeamWidget:new(scene) - TeamWidget.super.new(self, scene, "main", "Team", ">") -end - -function TeamWidget:action() - self.scene.assets:playSFX("mBeep") - self.scene.menusystem.menus["character"]:getFocus() -end - --- View Widget -function ViewWidget:new(scene, name, view) - TeamWidget.super.new(self, scene, "main", name, ">") - self.nextView = view -end - -function ViewWidget:action() - self.scene.assets:playSFX("mSelect") - self.scene.screens.mainmenu[self.nextView](self.scene) -end - --- Save & Exit Widget -function SaveExitWidget:new(scene, menu, name, save, exit) - SaveExitWidget.super.new(self, scene, menu, name, "") - self.exit = exit - self.save = save -end - -function SaveExitWidget:action() - if (self.save or self.exit) then - self.scene.assets:playSFX("mSelect") - else - self.scene.assets:playSFX("mBack") - end - if (self.save) then - self.scene.world:savePosition() - game:write() - end - if (self.exit) then - if (self.save) then - self:exitToMenu() - else - local confirm = ConfirmDialog(self.scene, "Do you to exit the game ? \nAll unsaved data will be lost.", - function() self:exitToMenu() end) - confirm:setCancelChoice(2) - end - else - self.scene:unpause() - end -end - -function SaveExitWidget:exitToMenu() - core.screen:startTransition(defTransitions.default, defTransitions.circle, function() game:reload() scenes.menus.main() end, 424/2, 240/2) - self.scene.tweens:newTween(0, 0.3, {ringBorder=-16}, "inOutQuad") - self.scene.tweens:newTween(0, 0.3, {timeBorder=-20}, "inOutQuad") -end - -return PauseScreen diff --git a/sonic-radiance.love/scenes/overworld/screens/mainmenu/useitems.lua b/sonic-radiance.love/scenes/overworld/screens/mainmenu/useitems.lua deleted file mode 100644 index 795dad2..0000000 --- a/sonic-radiance.love/scenes/overworld/screens/mainmenu/useitems.lua +++ /dev/null @@ -1,91 +0,0 @@ -local ParentScreen = require "scenes.overworld.screens.parent" -local UseItemsScreen = ParentScreen:extend() - -local menu = require "game.modules.menus.list" -local const = require "scenes.overworld.screens.mainmenu.const" -local gui = require "game.modules.gui" - -local baseCharacterMenu = require "scenes.overworld.screens.mainmenu.common.charmenu" -local baseCharacterWidget = require "scenes.overworld.screens.mainmenu.common.charwidget" -local CharacterMenu = baseCharacterMenu:extend() -local CharacterWidget = baseCharacterWidget:extend() - -local EffectManager = require "game.loot.effectManager" - -local DESC_SIZE = 32 * 4 - -function UseItemsScreen:new(scene, category, item, widgetId) - UseItemsScreen.super.new(self, scene, "Use item") - self.category = category - self.item = item - self.itemData = core.datas:get("items", self.item.name) - self.widgetId = widgetId - - self.choiceBack = gui.newChoiceBack(48 + 16) - self.descBox = gui.newTextBox("assets/gui/dialogbox.png", DESC_SIZE, 40 + 48) - - self.desc = self.itemData.description - self.effects = game.loot:getEffectStrings(self.category, self.item.name) - - self.effectManager = EffectManager() - self.effectManager:getItemData(category, self.item.name) -end - -function UseItemsScreen:setMenu() - CharacterMenu(self.scene) - for i, name in ipairs(game.characters.team) do - CharacterWidget(self.scene, name) - end - self.scene.menusystem:switchMenu("character") -end - -function UseItemsScreen:draw() - self.scene.assets.fonts["small"]:setLineHeight(16 / 18) - self:drawPocket() - self:drawDescription(const.X, const.Y) -end - -function UseItemsScreen:drawDescription(x, y) - love.graphics.draw(self.descBox, x, y) - local xx, yy, ww = x + 6, y + 4, DESC_SIZE - 12 - self.scene.assets.fonts["small"]:draw(self.itemData.fullname .. ":\n" .. self.effects, xx, yy, ww, "left") -end - -function UseItemsScreen:drawPocket() - local x = const.X + DESC_SIZE - 48 - local y = const.Y2 - 24 - love.graphics.draw(self.choiceBack, x, y) - - self.scene.assets.fonts["small"]:draw("x" .. self.item.number, x + 16, y - 2, -1, "left") -end - -function UseItemsScreen:goBack() - self.scene.screens.mainmenu["items"](self.scene, game.loot:getPocketIdByName(self.category), self.widgetId) -end - -function UseItemsScreen:useItem(charName) - local character = game.characters.list[charName] - self.effectManager:applyEffects(character) - if (self.item.number <= 1) then - game.loot:removeItem(self.category, self.item.name, 1) - self:goBack() - else - game.loot:removeItem(self.category, self.item.name, 1) - end -end - --- Character menu -function CharacterMenu:cancelAction() - -- Switch à l'écran précédant - self.scene.assets:playSFX("mBack") - self.scene.currentScreen:goBack() -end - --- Hero custom widget --- -function CharacterWidget:action() - self.scene.assets:playSFX("mSelect") - self.scene.currentScreen:useItem(self.charName) -end - -return UseItemsScreen diff --git a/sonic-radiance.love/scenes/overworld/screens/menu.lua b/sonic-radiance.love/scenes/overworld/screens/menu.lua deleted file mode 100644 index 9a46d31..0000000 --- a/sonic-radiance.love/scenes/overworld/screens/menu.lua +++ /dev/null @@ -1,103 +0,0 @@ -local ListBox = require "birb.modules.menusystem.listbox" -local Widget = require "birb.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 = 16 - -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) - - local 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 deleted file mode 100644 index 061077b..0000000 --- a/sonic-radiance.love/scenes/overworld/screens/parent.lua +++ /dev/null @@ -1,49 +0,0 @@ -local MenuScreenParent = Object:extend() - -local menu = require "scenes.overworld.screens.menu" -local const = require "scenes.overworld.screens.mainmenu.const" - -function MenuScreenParent:new(scene, title) - self.scene = scene - self.menusystem = scene.menusystem - - self.menuObj = menu - - self.title = title or "" - - self.scene:registerScreen(self) - self:setMenu() -end - -function MenuScreenParent:update(dt) - -end - -function MenuScreenParent:setMenu() - -end - -function MenuScreenParent:quit() - self.scene.menusystem:reset() - self.scene:quitScreen() -end - -function MenuScreenParent:drawForeground() - self.scene.assets.fonts["SA2font"]:print(self.title, 160, 12) - --love.graphics.rectangle("line", const.X, const.Y, const.WIDTH, const.HEIGHT) - self:draw() -end - - -function MenuScreenParent:draw() - -end - -function MenuScreenParent:drawBackground() - -end - -function MenuScreenParent:drawOverEverything() -end - -return MenuScreenParent