feat: style main menu

This commit is contained in:
Kazhnuz 2021-04-04 13:17:12 +02:00
parent 801e332b69
commit 262a46be82
8 changed files with 56 additions and 20 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1 KiB

After

Width:  |  Height:  |  Size: 5.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

View file

@ -1,5 +1,17 @@
local MenuBack = Object:extend()
local fancyBackShader = love.graphics.newShader[[
uniform number screenWidth;
uniform number screenHeight;
vec4 effect( vec4 color, Image texture, vec2 texture_coords, vec2 screen_coords ){
vec4 pixel = Texel(texture, texture_coords); //This is the current pixel color
number value = (screen_coords.x / screenWidth) * (screen_coords.y / screenHeight) * 0.5;
number lighten = 0.25;
return vec4(0.5 + value + lighten,0.0 + lighten,0.5 - value + lighten, 1 - pixel.r);
//return vec4(1,1,1, pixel.r);
}
]]
function MenuBack:new()
self.backx = 0
self.bordery = 0
@ -7,8 +19,12 @@ function MenuBack:new()
self.back = love.graphics.newImage("assets/gui/back/background.png")
self.border = love.graphics.newImage("assets/gui/back/border.png")
self.emblem = love.graphics.newImage("assets/gui/back/emblem.png")
self.star = love.graphics.newImage("assets/gui/back/star.png")
self.canvas = nil
local w, h = love.graphics.getDimensions()
fancyBackShader:send("screenWidth",w)
fancyBackShader:send("screenHeight",h)
end
@ -28,9 +44,8 @@ function MenuBack:update(dt)
for j = 0, (math.ceil(240/160)), 1 do
love.graphics.draw(self.border, 0, self.bordery + ((j - 1) * 160))
end
love.graphics.draw(self.emblem, 424, 240 - 32, self.turn, 0.8, 0.8, 200, 200)
love.graphics.setColor(1, 1, 1, 0.85)
love.graphics.rectangle("fill", 0, 0, 424, 240)
love.graphics.draw(self.emblem, 424, 240 - 32, 0, 0.8, 0.8, 200, 200)
love.graphics.draw(self.star, 424, 240 - 32, self.turn, 0.8, 0.8, 200, 200)
love.graphics.setColor(1, 1, 1, 1)
love.graphics.setCanvas()
@ -39,13 +54,11 @@ end
function MenuBack:draw()
love.graphics.setColor(1, 1, 1, 1)
love.graphics.setBlendMode("multiply", "premultiplied")
love.graphics.setShader(fancyBackShader)
if (self.canvas ~= nil) then
love.graphics.draw(self.canvas, 0, 0)
end
love.graphics.setBlendMode("alpha")
love.graphics.setColor(1, 1, 1, 1)
love.graphics.setShader()
end
return MenuBack

View file

@ -1,10 +1,11 @@
local menu = {}
local RadianceListMenu = require "game.modules.menus.list"
local RadianceListMenu = require "game.modules.menus.fancy"
local Widget = require "core.modules.menusystem.widgets"
menu.DebugMenu = RadianceListMenu.ListMenu:extend()
menu.SceneWidget = RadianceListMenu.DualTextWidget:extend()
menu.MainMenu = RadianceListMenu.FancyMenu:extend()
menu.DebugMenu = RadianceListMenu.FancyMenu:extend()
menu.SceneWidget = RadianceListMenu.BaseWidget:extend()
local CONST = {}
CONST.MENU = {}
@ -14,6 +15,13 @@ CONST.MENU.W = 424/2
CONST.MENU.ITEM_NUMBER = 8
-- Basic menu structure
function menu.MainMenu:new(scene, name)
local x, y = CONST.MENU.X, CONST.MENU.Y
local w = CONST.MENU.W / 1.5
local itemNumber = CONST.MENU.ITEM_NUMBER
menu.MainMenu.super.new(self, scene, name, x, y, w, itemNumber, false)
end
function menu.DebugMenu:new(scene, name)
local x, y = CONST.MENU.X, CONST.MENU.Y
local w = CONST.MENU.W

View file

@ -7,11 +7,12 @@ local battleutils = require "game.utils.battle"
local itemutils = require "game.utils.items"
local gui = require "game.modules.gui"
local MenuBack = require "game.modules.gui.menuback"
function DebugMenu:new()
DebugMenu.super.new(self)
self.assets:batchImport("scenes.debug.commons.assets")
menu.commons.DebugMenu(self, "BaseMenu")
menu.commons.MainMenu(self, "BaseMenu")
menu.commons.SceneWidget(self, "BaseMenu", scenes.overworld, "Start playing")
menu.commons.SceneWidget(self, "BaseMenu", scenes.options, "Options")
self:buildDebugMenu()
@ -23,6 +24,12 @@ function DebugMenu:new()
self.menusystem:switchMenu("BaseMenu")
self.panel = panels.Gamedata()
self.borderY = 30
self.borders = gui.newBorder(424, 30, 8)
self.backImage = love.graphics.newImage("assets/artworks/back.png")
self.back = MenuBack()
end
function DebugMenu:buildDebugMenu()
@ -115,6 +122,7 @@ function DebugMenu:update(dt)
if (love.keyboard.isDown("space") and (not self.menusystem.isActive)) then
self.menusystem:activate()
end
self.back:update(dt)
end
function DebugMenu:addSubMenu(submenu, parent, name, panel, panelArgument)
@ -126,8 +134,15 @@ function DebugMenu:addSubMenu(submenu, parent, name, panel, panelArgument)
end
function DebugMenu:draw()
love.graphics.setColor(1, 1, 1, 1)
love.graphics.rectangle("fill", 0, 0, 424, 240)
self.back:draw()
utils.graphics.resetColor()
love.graphics.draw(self.backImage, 0, 0)
if (self.menusystem.isActive) then
self.assets.fonts["small"]:print("## SONIC RADIANCE - MAIN MENU ##", 424/2, 8, "center")
love.graphics.draw(self.borders, 0, self.borderY, 0, 1, -1)
love.graphics.draw(self.borders, 424, 240 - self.borderY, 0, -1, 1)
self.assets.fonts["small"]:print("v" .. game.version, 424 - 8, 240 - 20, "right")
self.panel:draw(240, 48)

View file

@ -1,15 +1,15 @@
local commons = require "scenes.debug.commons.menu"
local listMenu = require "game.modules.menus.list"
local listMenu = require "game.modules.menus.fancy"
local menu = {}
menu.commons = commons
menu.ExitWidget = listMenu.DualTextWidget:extend()
menu.SaveWidget = listMenu.DualTextWidget:extend()
menu.LoadWidget = listMenu.DualTextWidget:extend()
menu.LevelUpWidget = listMenu.DualTextWidget:extend()
menu.AddRemoveWidget = listMenu.DualTextWidget:extend()
menu.ChangeLeaderWidget = listMenu.DualTextWidget:extend()
menu.ItemWidget = listMenu.DualTextWidget:extend()
menu.ExitWidget = listMenu.BaseWidget:extend()
menu.SaveWidget = listMenu.BaseWidget:extend()
menu.LoadWidget = listMenu.BaseWidget:extend()
menu.LevelUpWidget = listMenu.BaseWidget:extend()
menu.AddRemoveWidget = listMenu.BaseWidget:extend()
menu.ChangeLeaderWidget = listMenu.BaseWidget:extend()
menu.ItemWidget = listMenu.BaseWidget:extend()
-- ExitWidget
function menu.ExitWidget:new(scene, menuName)