Compare commits
3 Commits
e7926fab3c
...
a7c4d97aea
Author | SHA1 | Date |
---|---|---|
wan-may | a7c4d97aea | |
wan-may | 0ffba039b6 | |
wan-may | fc0bd44a1c |
Binary file not shown.
|
@ -0,0 +1,92 @@
|
||||||
|
Copyright (c) 2012 Natanael Gama (info@ndiscovered.com), with Reserved Font Name 'Cinzel'
|
||||||
|
This Font Software is licensed under the SIL Open Font License, Version 1.1.
|
||||||
|
This license is copied below, and is also available with a FAQ at:
|
||||||
|
http://scripts.sil.org/OFL
|
||||||
|
|
||||||
|
|
||||||
|
-----------------------------------------------------------
|
||||||
|
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
|
||||||
|
-----------------------------------------------------------
|
||||||
|
|
||||||
|
PREAMBLE
|
||||||
|
The goals of the Open Font License (OFL) are to stimulate worldwide
|
||||||
|
development of collaborative font projects, to support the font creation
|
||||||
|
efforts of academic and linguistic communities, and to provide a free and
|
||||||
|
open framework in which fonts may be shared and improved in partnership
|
||||||
|
with others.
|
||||||
|
|
||||||
|
The OFL allows the licensed fonts to be used, studied, modified and
|
||||||
|
redistributed freely as long as they are not sold by themselves. The
|
||||||
|
fonts, including any derivative works, can be bundled, embedded,
|
||||||
|
redistributed and/or sold with any software provided that any reserved
|
||||||
|
names are not used by derivative works. The fonts and derivatives,
|
||||||
|
however, cannot be released under any other type of license. The
|
||||||
|
requirement for fonts to remain under this license does not apply
|
||||||
|
to any document created using the fonts or their derivatives.
|
||||||
|
|
||||||
|
DEFINITIONS
|
||||||
|
"Font Software" refers to the set of files released by the Copyright
|
||||||
|
Holder(s) under this license and clearly marked as such. This may
|
||||||
|
include source files, build scripts and documentation.
|
||||||
|
|
||||||
|
"Reserved Font Name" refers to any names specified as such after the
|
||||||
|
copyright statement(s).
|
||||||
|
|
||||||
|
"Original Version" refers to the collection of Font Software components as
|
||||||
|
distributed by the Copyright Holder(s).
|
||||||
|
|
||||||
|
"Modified Version" refers to any derivative made by adding to, deleting,
|
||||||
|
or substituting -- in part or in whole -- any of the components of the
|
||||||
|
Original Version, by changing formats or by porting the Font Software to a
|
||||||
|
new environment.
|
||||||
|
|
||||||
|
"Author" refers to any designer, engineer, programmer, technical
|
||||||
|
writer or other person who contributed to the Font Software.
|
||||||
|
|
||||||
|
PERMISSION & CONDITIONS
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
a copy of the Font Software, to use, study, copy, merge, embed, modify,
|
||||||
|
redistribute, and sell modified and unmodified copies of the Font
|
||||||
|
Software, subject to the following conditions:
|
||||||
|
|
||||||
|
1) Neither the Font Software nor any of its individual components,
|
||||||
|
in Original or Modified Versions, may be sold by itself.
|
||||||
|
|
||||||
|
2) Original or Modified Versions of the Font Software may be bundled,
|
||||||
|
redistributed and/or sold with any software, provided that each copy
|
||||||
|
contains the above copyright notice and this license. These can be
|
||||||
|
included either as stand-alone text files, human-readable headers or
|
||||||
|
in the appropriate machine-readable metadata fields within text or
|
||||||
|
binary files as long as those fields can be easily viewed by the user.
|
||||||
|
|
||||||
|
3) No Modified Version of the Font Software may use the Reserved Font
|
||||||
|
Name(s) unless explicit written permission is granted by the corresponding
|
||||||
|
Copyright Holder. This restriction only applies to the primary font name as
|
||||||
|
presented to the users.
|
||||||
|
|
||||||
|
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
|
||||||
|
Software shall not be used to promote, endorse or advertise any
|
||||||
|
Modified Version, except to acknowledge the contribution(s) of the
|
||||||
|
Copyright Holder(s) and the Author(s) or with their explicit written
|
||||||
|
permission.
|
||||||
|
|
||||||
|
5) The Font Software, modified or unmodified, in part or in whole,
|
||||||
|
must be distributed entirely under this license, and must not be
|
||||||
|
distributed under any other license. The requirement for fonts to
|
||||||
|
remain under this license does not apply to any document created
|
||||||
|
using the Font Software.
|
||||||
|
|
||||||
|
TERMINATION
|
||||||
|
This license becomes null and void if any of the above conditions are
|
||||||
|
not met.
|
||||||
|
|
||||||
|
DISCLAIMER
|
||||||
|
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
|
||||||
|
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
||||||
|
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
|
||||||
|
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||||
|
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
|
||||||
|
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
|
||||||
|
OTHER DEALINGS IN THE FONT SOFTWARE.
|
Binary file not shown.
After Width: | Height: | Size: 24 KiB |
|
@ -1,23 +1,36 @@
|
||||||
local scene = {}
|
local scene = {}
|
||||||
local love = assert( love )
|
local love = assert( love )
|
||||||
|
|
||||||
|
local callbacks = {
|
||||||
|
draw = true,
|
||||||
|
mousepressed = true,
|
||||||
|
mousemoved = true,
|
||||||
|
keypressed = true,
|
||||||
|
update = true,
|
||||||
|
resize = true,
|
||||||
|
}
|
||||||
|
|
||||||
local mt = {}
|
local mt = {}
|
||||||
|
|
||||||
local function loadScene( scene, params )
|
print( 'scene', scene )
|
||||||
print( "Loading Scene:", scene.name )
|
|
||||||
for k, v in pairs( scene ) do
|
function scene.loadScene( scen, params )
|
||||||
love[k] = v
|
print( "Loading Scene:", scen.name )
|
||||||
|
for k, v in pairs( callbacks ) do
|
||||||
|
if not scen[k] then print( "Warning: scene missing callback.", scen.name, k ) end
|
||||||
|
love[k] = scen[k] or love[k]
|
||||||
end
|
end
|
||||||
scene.onLoad( params )
|
scen:onLoad( params )
|
||||||
end
|
end
|
||||||
|
|
||||||
local function newScene( scenes, name, t )
|
local function newScene( scenes, name, t )
|
||||||
t.name = t.name or name
|
t.name = t.name or name
|
||||||
print( "Adding Scene:", t.name )
|
print( "Adding Scene:", t.name )
|
||||||
setmetatable( t, { __call = function() return loadScene( t ) end } )
|
setmetatable( t, { __call = function() return scene.loadScene( t ) end } )
|
||||||
rawset( scenes, name, t )
|
rawset( scenes, name, t )
|
||||||
end
|
end
|
||||||
|
|
||||||
return setmetatable( scene,
|
return setmetatable( scene,
|
||||||
{__call = loadScene,
|
{__call = scene.loadScene,
|
||||||
__newindex = newScene
|
__newindex = newScene
|
||||||
} )
|
} )
|
|
@ -1,21 +1,34 @@
|
||||||
local button = {}
|
|
||||||
local lg = assert( love.graphics )
|
|
||||||
|
|
||||||
function button:new( t, x, y, w, h, text, color, callback )
|
local lg = assert( love.graphics )
|
||||||
--print( t.x, t.y, t.w, t.h, t.text, t.color, t.callback )
|
local button = {
|
||||||
return setmetatable( t or
|
h = 60,
|
||||||
{
|
y = 0,
|
||||||
x = 0, y = 0,
|
x = 0,
|
||||||
w = 100, h = 100,
|
w = 100,
|
||||||
text = text, color = color,
|
space = 15,
|
||||||
callback = callback,
|
|
||||||
selected = false
|
|
||||||
},
|
|
||||||
{
|
|
||||||
__index = button,
|
|
||||||
__call = t.callback or callback
|
|
||||||
}
|
}
|
||||||
)
|
local mt = { __index = button }
|
||||||
|
|
||||||
|
function button:new( t )
|
||||||
|
t = t or {}
|
||||||
|
|
||||||
|
if t.y then button.y = t.y end
|
||||||
|
if t.h then button.h = t.h end
|
||||||
|
if t.w then button.w = t.w end
|
||||||
|
if t.x then button.x = t.x end
|
||||||
|
|
||||||
|
t.x = t.x or button.x
|
||||||
|
t.y = t.y or button.y
|
||||||
|
t.w = t.w or button.w
|
||||||
|
t.h = t.h or button.h
|
||||||
|
t.text = t.text or ""
|
||||||
|
t.color = t.color or { 0.5, 0.5, 0.5, 0.5 }
|
||||||
|
t.callback = t.callback or function() print( "Clicked button:", t.text ) end
|
||||||
|
t.selected = t.selected or false
|
||||||
|
|
||||||
|
button.y = button.y + t.h + button.space
|
||||||
|
|
||||||
|
return setmetatable( t, mt )
|
||||||
end
|
end
|
||||||
|
|
||||||
function button:contains( x, y )
|
function button:contains( x, y )
|
||||||
|
@ -33,8 +46,10 @@ function button:draw( )
|
||||||
lg.rectangle( "fill", self.x + 3, self.y + 3, self.w - 6, self.h - 6, 10 )
|
lg.rectangle( "fill", self.x + 3, self.y + 3, self.w - 6, self.h - 6, 10 )
|
||||||
end
|
end
|
||||||
|
|
||||||
lg.setColor( 0, 0, 0, 0.7 )
|
lg.setColor( 0, 0, 0, 0.8 )
|
||||||
lg.print( self.text, self.x + 15, self.y + 10 )
|
lg.print( self.text, self.x + 15, self.y + 6)
|
||||||
|
lg.setColor( 0, 0, 0, 0.2 )
|
||||||
|
lg.print( self.text, self.x + 18, self.y + 8)
|
||||||
end
|
end
|
||||||
|
|
||||||
return setmetatable( button, { __call = button.new } )
|
return setmetatable( button, { __call = button.new } )
|
|
@ -0,0 +1,51 @@
|
||||||
|
local lg = assert( love.graphics )
|
||||||
|
local love = assert( love )
|
||||||
|
local scene = assert( require 'client.scene' )
|
||||||
|
local strings = assert( require 'client.assets.strings' )
|
||||||
|
local button = assert( require 'client.ui.button' )
|
||||||
|
local menu = assert( require 'client.ui.menu' )
|
||||||
|
|
||||||
|
return menu.new(
|
||||||
|
"mainmenu",
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
button{
|
||||||
|
x = 15, w = lg.getWidth(), y = 115, h = 72,
|
||||||
|
text = strings.newgame_button,
|
||||||
|
color = { 0.6, 0.6, 0.6, 0.9 },
|
||||||
|
callback = function() return scene.game() end },
|
||||||
|
|
||||||
|
button{
|
||||||
|
text = strings.join_button,
|
||||||
|
color = { 0.6, 0.6, 0.6, 0.9 },
|
||||||
|
callback = function() return scene.browser() end },
|
||||||
|
|
||||||
|
button{
|
||||||
|
text = strings.option_button,
|
||||||
|
color = { 0.6, 0.6, 0.6, 0.9 },
|
||||||
|
callback = function() return scene.options() end },
|
||||||
|
|
||||||
|
button{
|
||||||
|
text = strings.quit_button,
|
||||||
|
color = { 0.6, 0.6, 0.6, 0.9 },
|
||||||
|
callback = love.event.quit },
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
lg.newMesh{
|
||||||
|
{ 0, 0, 0, 0, 0.4, 0.1, 0.05, 0.0 },
|
||||||
|
{ 1, 0, 1, 0, 0.8, 0.3, 0.1, 0.8 },
|
||||||
|
{ 1, 1, 1, 1, 0.7, 0.4, 0.1, 0.8 },
|
||||||
|
{ 0, 1, 0, 1, 0.4, 0.1, 0.03, 0.0 },
|
||||||
|
},
|
||||||
|
|
||||||
|
lg.newMesh{
|
||||||
|
{ 0, 0, 0, 0, 0.4, 0.05, 0.0, 0.1 },
|
||||||
|
{ 1, 0, 1, 0, 0.8, 0.3, 0.1, 0.8 },
|
||||||
|
{ 1, 1, 1, 1, 0.7, 0.4, 0.1, 0.8 },
|
||||||
|
{ 0, 1, 0, 1, 0.4, 0.05, 0.05, 0.1 },
|
||||||
|
},
|
||||||
|
|
||||||
|
lg.newFont( "client/assets/Montserrat-Bold.ttf", 48 )
|
||||||
|
)
|
|
@ -1,74 +1,37 @@
|
||||||
local lg = assert( love.graphics )
|
|
||||||
local love = assert( love )
|
local love = assert( love )
|
||||||
|
local lg = assert( love.graphics )
|
||||||
local scene = assert( require 'client.scene' )
|
local scene = assert( require 'client.scene' )
|
||||||
local strings = assert( require 'client.assets.strings' )
|
print( 'scene', scene )
|
||||||
local button = assert( require 'client.ui.button' )
|
|
||||||
local menu = {}
|
local menu = {}
|
||||||
|
|
||||||
local t = 0
|
--Static variables.
|
||||||
local wWidth = 800
|
local selectedButtonIdx
|
||||||
local wHeight = 600
|
local canvas
|
||||||
|
local wWidth, wHeight
|
||||||
|
local currentMenu
|
||||||
|
|
||||||
local selectedButtonIdx = nil
|
function menu.new( name, buttons, fg, bg, font )
|
||||||
|
local t = { buttons = buttons, fg = fg, bg = bg, font = font or lg.getFont() }
|
||||||
|
scene[name] = t
|
||||||
|
print( 'scene', scene )
|
||||||
|
getmetatable( t ).__index = menu
|
||||||
|
return t
|
||||||
|
end
|
||||||
|
|
||||||
local canvas = lg.newCanvas()
|
function menu:onLoad()
|
||||||
local buttons =
|
print( 'loading:', self.name )
|
||||||
{
|
currentMenu = self
|
||||||
button{
|
lg.setFont( self.font )
|
||||||
x = 15, w = 400, h = 50,
|
return menu.resize( lg.getDimensions() )
|
||||||
y = 115,
|
end
|
||||||
text = strings.newgame_button,
|
|
||||||
color = { 0.3, 0.2, 0.9, 0.5 },
|
|
||||||
callback = function() return scene.game() end },
|
|
||||||
|
|
||||||
button{
|
function menu.update( dt ) end
|
||||||
x = 15, w = 400, h = 50,
|
|
||||||
y = 115 + 55,
|
|
||||||
text = strings.join_button,
|
|
||||||
color = { 0.3, 0.2, 0.8, 0.5 },
|
|
||||||
callback = function() return scene.browser() end },
|
|
||||||
|
|
||||||
button{
|
function menu.resize( w, h )
|
||||||
x = 15, w = 400, h = 50,
|
wWidth, wHeight = w, h
|
||||||
y = 115 + 55 * 2,
|
canvas = lg.newCanvas()
|
||||||
text = strings.option_button,
|
return currentMenu:paint()
|
||||||
color = { 0.3, 0.2, 0.9, 0.5 },
|
end
|
||||||
callback = function() return scene.options() end },
|
|
||||||
|
|
||||||
button{
|
|
||||||
x = 15, w = 400, h = 50,
|
|
||||||
y = 115 + 55 * 3,
|
|
||||||
text = strings.quit_button,
|
|
||||||
color = { 0.3, 0.2, 1.0, 0.5 },
|
|
||||||
callback = love.event.quit },
|
|
||||||
}
|
|
||||||
|
|
||||||
local gradientQuad = lg.newMesh{
|
|
||||||
{
|
|
||||||
-- top-left corner (red-tinted)
|
|
||||||
0, 0, -- position of the vertex
|
|
||||||
0, 0, -- texture coordinate at the vertex position
|
|
||||||
0.4, 0.1, 0.4, 0.0 -- color of the vertex
|
|
||||||
},
|
|
||||||
{
|
|
||||||
-- top-right corner (green-tinted)
|
|
||||||
1, 0,
|
|
||||||
1, 0, -- texture coordinates are in the range of [0, 1]
|
|
||||||
0.8, 0.3, 0.1, 1.0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
-- bottom-right corner (blue-tinted)
|
|
||||||
1, 1,
|
|
||||||
1, 1,
|
|
||||||
0.7, 0.4, 0.1, 1.0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
-- bottom-left corner (yellow-tinted)
|
|
||||||
0, 1,
|
|
||||||
0, 1,
|
|
||||||
0.4, 0.15, 0.3, 0.0
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
function menu.draw()
|
function menu.draw()
|
||||||
lg.setCanvas()
|
lg.setCanvas()
|
||||||
|
@ -76,69 +39,59 @@ function menu.draw()
|
||||||
lg.draw( canvas )
|
lg.draw( canvas )
|
||||||
end
|
end
|
||||||
|
|
||||||
function menu.paint()
|
|
||||||
lg.setCanvas( canvas )
|
|
||||||
|
|
||||||
--bg
|
|
||||||
lg.setColor( 0.8, 0.6, 0.3, 1 )
|
|
||||||
lg.rectangle( "fill", 0, 0, wWidth, wHeight )
|
|
||||||
|
|
||||||
--buttons
|
|
||||||
for id, button in pairs( buttons ) do button:draw( ) end
|
|
||||||
|
|
||||||
--gradient
|
|
||||||
lg.setColor( 1, 1, 1, 1 )
|
|
||||||
lg.draw( gradientQuad, 0, 0, 0, wWidth, wHeight )
|
|
||||||
lg.setCanvas()
|
|
||||||
end
|
|
||||||
|
|
||||||
function menu.onLoad()
|
|
||||||
lg.setNewFont( 28 )
|
|
||||||
return menu.resize( lg.getDimensions() )
|
|
||||||
end
|
|
||||||
|
|
||||||
function menu.update( dt )
|
|
||||||
t = t + dt
|
|
||||||
end
|
|
||||||
|
|
||||||
function menu.resize( w, h )
|
|
||||||
wWidth, wHeight = w, h
|
|
||||||
canvas = lg.newCanvas()
|
|
||||||
for id, uiButton in pairs( buttons ) do
|
|
||||||
uiButton.w = wWidth
|
|
||||||
end
|
|
||||||
menu.paint()
|
|
||||||
end
|
|
||||||
|
|
||||||
function menu.mousemoved( x, y, dx, dy, istouch )
|
function menu.mousemoved( x, y, dx, dy, istouch )
|
||||||
if selectedButtonIdx then
|
if not currentMenu then return end
|
||||||
buttons[selectedButtonIdx].selected = false
|
local buttons = currentMenu.buttons
|
||||||
selectedButtonIdx = nil
|
|
||||||
end
|
local selectedButton = buttons[selectedButtonIdx or 0]
|
||||||
for id, menuButton in ipairs( buttons ) do
|
for id, menuButton in ipairs( buttons ) do
|
||||||
if menuButton:contains( x, y ) then
|
if menuButton:contains( x, y ) then
|
||||||
|
if selectedButton then selectedButton.selected = false end
|
||||||
menuButton.selected = true
|
menuButton.selected = true
|
||||||
selectedButtonIdx = id
|
selectedButtonIdx = id
|
||||||
return menu.paint()
|
if menuButton ~= selectedButton then
|
||||||
end
|
return currentMenu:paint()
|
||||||
|
else return end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--deselect button
|
||||||
|
if selectedButton then
|
||||||
|
selectedButtonIdx = nil
|
||||||
|
selectedButton.selected = false
|
||||||
|
return currentMenu:paint()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
function menu.mousepressed( x, y, button, istouch, presses )
|
function menu.mousepressed( x, y, button, istouch, presses )
|
||||||
if not selectedButtonIdx then return end
|
|
||||||
local uiButton = buttons[selectedButtonIdx]
|
if not selectedButtonIdx and currentMenu then return end
|
||||||
if uiButton:contains( x, y ) then return uiButton() end
|
local uiButton = currentMenu.buttons[selectedButtonIdx]
|
||||||
return menu.paint()
|
if uiButton:contains( x, y ) then
|
||||||
|
selectedButtonIdx = nil
|
||||||
|
uiButton.selected = false
|
||||||
|
return uiButton:callback()
|
||||||
|
end
|
||||||
|
return currentMenu:paint()
|
||||||
end
|
end
|
||||||
|
|
||||||
function menu.keypressed( key, code, isrepeat )
|
function menu.keypressed( key, code, isrepeat )
|
||||||
|
|
||||||
|
assert( currentMenu )
|
||||||
|
|
||||||
if code == "escape" then
|
if code == "escape" then
|
||||||
return love.event.quit()
|
return love.event.quit()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local buttons = currentMenu.buttons
|
||||||
|
|
||||||
if code == "return" and selectedButtonIdx then
|
if code == "return" and selectedButtonIdx then
|
||||||
return buttons[selectedButtonIdx]()
|
local button = buttons[selectedButtonIdx]
|
||||||
|
selectedButtonIdx = nil
|
||||||
|
button.selected = false
|
||||||
|
currentMenu:paint()
|
||||||
|
return button:callback()
|
||||||
end
|
end
|
||||||
|
|
||||||
if code == "down" or code == "tab" or code == "up" then
|
if code == "down" or code == "tab" or code == "up" then
|
||||||
|
@ -151,14 +104,37 @@ function menu.keypressed( key, code, isrepeat )
|
||||||
if sbi < 1 then sbi = #buttons end
|
if sbi < 1 then sbi = #buttons end
|
||||||
|
|
||||||
--Assign
|
--Assign
|
||||||
print( "selecting button: ", sbi )
|
|
||||||
selectedButtonIdx = sbi
|
selectedButtonIdx = sbi
|
||||||
buttons[selectedButtonIdx].selected = true
|
buttons[selectedButtonIdx].selected = true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
return menu.paint()
|
return currentMenu:paint()
|
||||||
end
|
end
|
||||||
|
|
||||||
scene.mainmenu = menu
|
function menu:paint()
|
||||||
|
lg.setCanvas( canvas )
|
||||||
|
|
||||||
|
--bg
|
||||||
|
lg.setColor( 1, 1, 1, 1 )
|
||||||
|
lg.draw( self.bg, 0, 0, 0, wWidth, wHeight )
|
||||||
|
|
||||||
|
--buttons
|
||||||
|
for i = #self.buttons, 1, -1 do self.buttons[i]:draw( ) end
|
||||||
|
|
||||||
|
--gradient
|
||||||
|
lg.setColor( 1, 1, 1, 1 )
|
||||||
|
local r = math.random
|
||||||
|
local v = r() * 0.4 + 0.6
|
||||||
|
|
||||||
|
local fg = self.fg
|
||||||
|
fg:setVertexAttribute( 2, 3, v * (0.7 + 0.2 * r()), v * (0.1 + 0.4 * r()), v * (0.1 * r()), 1 )
|
||||||
|
fg:setVertexAttribute( 1, 3, 0.3 * ( 1 - v ), 0, 0, 0.4 * (1 - v) )
|
||||||
|
fg:setVertexAttribute( 4, 3, 0.3 * ( 1 - v ), 0, 0, 0.4 * (1 - v) )
|
||||||
|
fg:setVertexAttribute( 3, 3, v * (0.7 + 0.2 * r()), v * (0.1 + 0.4 * r()), v * (0.1 * r()), 1 )
|
||||||
|
lg.draw( fg, 0, 0, 0, wWidth, wHeight )
|
||||||
|
lg.setCanvas()
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
return menu
|
return menu
|
|
@ -3,179 +3,60 @@ local love = assert( love )
|
||||||
local scene = assert( require 'client.scene' )
|
local scene = assert( require 'client.scene' )
|
||||||
local strings = assert( require 'client.assets.strings' )
|
local strings = assert( require 'client.assets.strings' )
|
||||||
local button = assert( require 'client.ui.button' )
|
local button = assert( require 'client.ui.button' )
|
||||||
local textinput = assert( require 'client.ui.textinput' )
|
local menu = assert( require 'client.ui.menu' )
|
||||||
local menu = {}
|
|
||||||
|
|
||||||
local t = 0
|
return menu.new(
|
||||||
local wWidth = 800
|
"options",
|
||||||
local wHeight = 600
|
|
||||||
local canvas = lg.newCanvas()
|
|
||||||
|
|
||||||
local selectedButtonIdx = nil
|
|
||||||
|
|
||||||
local gradientQuad = lg.newMesh{
|
|
||||||
{ 0, 0, 0, 0, 0.4, 0.1, 0.4, 0.0 },
|
|
||||||
{ 1, 0, 1, 0, 0.8, 0.3, 0.1, 1.0 },
|
|
||||||
{ 1, 1, 1, 1, 0.7, 0.4, 0.1, 1.0 },
|
|
||||||
{ 0, 1, 0, 1, 0.4, 0.1, 0.3, 0.0 },
|
|
||||||
}
|
|
||||||
|
|
||||||
local buttons =
|
|
||||||
{
|
{
|
||||||
|
|
||||||
button{
|
button{
|
||||||
x = 15, w = 400, h = 50,
|
x = 15, y = 115, w = 800, h = 30,
|
||||||
y = 115,
|
|
||||||
text = strings.mainmenu_button,
|
text = strings.mainmenu_button,
|
||||||
color = { 0.5, 0.2, 0.8, 0.6 },
|
color = { 0.6, 0.6, 0.6, 0.8 },
|
||||||
callback = function() return scene.mainmenu() end },
|
callback = function() return scene.mainmenu() end },
|
||||||
|
|
||||||
button{
|
button{
|
||||||
x = 15, w = 400, h = 50,
|
|
||||||
y = 115 + 55,
|
|
||||||
option = 'name',
|
option = 'name',
|
||||||
text = strings.option_name,
|
text = strings.option_name,
|
||||||
color = { 0.5, 0.2, 0.2, 0.6 },
|
color = { 0.6, 0.6, 0.6, 0.8 },
|
||||||
callback = menu.textOption },
|
callback = menu.textOption },
|
||||||
|
|
||||||
button{
|
button{
|
||||||
x = 15, w = 400, h = 50,
|
|
||||||
y = 115 + 55 * 2,
|
|
||||||
option = 'pronoun',
|
option = 'pronoun',
|
||||||
text = strings.option_pron,
|
text = strings.option_pron,
|
||||||
color = { 0.5, 0.2, 0.4, 0.6 },
|
color = { 0.6, 0.6, 0.6, 0.8 },
|
||||||
callback = menu.textOption },
|
callback = menu.textOption },
|
||||||
|
|
||||||
button{
|
button{
|
||||||
x = 15, w = 400, h = 50,
|
|
||||||
y = 115 + 55 * 3,
|
|
||||||
option = 'colour',
|
option = 'colour',
|
||||||
text = strings.option_tint,
|
text = strings.option_tint,
|
||||||
color = { 0.5, 0.2, 0.6, 0.6 },
|
color = { 0.6, 0.6, 0.6, 0.8 },
|
||||||
callback = menu.colourOption },
|
callback = menu.colourOption },
|
||||||
|
|
||||||
|
|
||||||
button{
|
button{
|
||||||
x = 15, w = 400, h = 50,
|
|
||||||
y = 115 + 55 * 4,
|
|
||||||
option = 'keybinds',
|
option = 'keybinds',
|
||||||
text = strings.keybinding_button,
|
text = strings.option_keybinds,
|
||||||
color = { 0.8, 0.0, 0.4, 0.8 },
|
color = { 0.6, 0.6, 0.6, 0.8 },
|
||||||
callback = menu.editKeybinds,
|
callback = menu.editKeybinds,
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
--[[local keybindButtons = {
|
|
||||||
button{
|
|
||||||
x = wWidth / 2, w = 400, h = 50
|
|
||||||
y = 115,
|
|
||||||
text = options:get( 'forward_key' ),
|
|
||||||
color = { 0.8, 0.0, 0.4, 0.8 },
|
|
||||||
callback = function() options:set( 'forward_key' ) end,
|
|
||||||
},
|
},
|
||||||
|
|
||||||
button{
|
lg.newMesh{
|
||||||
x = wWidth / 2, w = 400, h = 50
|
{ 0, 0, 0, 0, 0.4, 0.1, 0.05, 0.0 },
|
||||||
y = 115,
|
{ 1, 0, 1, 0, 0.8, 0.3, 0.1, 0.8 },
|
||||||
text = strings.backward_key,
|
{ 1, 1, 1, 1, 0.7, 0.4, 0.1, 0.8 },
|
||||||
color = { 0.8, 0.0, 0.4, 0.8 },
|
{ 0, 1, 0, 1, 0.4, 0.1, 0.03, 0.0 },
|
||||||
callback = function() return setOption( 'backward_key' ) end,
|
},
|
||||||
}
|
|
||||||
|
|
||||||
}]]
|
|
||||||
|
|
||||||
function menu.onLoad()
|
lg.newMesh{
|
||||||
lg.setNewFont( 28 )
|
{ 0, 0, 0, 0, 1, 1, 1, 0.01 },
|
||||||
return menu.resize( lg.getDimensions() )
|
{ 1, 0, 1, 0, 1, 1, 1, 0.1 },
|
||||||
end
|
{ 1, 1, 1, 1, 0, 0, 0, 0.1 },
|
||||||
|
{ 0, 1, 0, 1, 0, 0, 0, 0.01 },
|
||||||
|
},
|
||||||
|
|
||||||
function menu.draw()
|
lg.newFont( "client/assets/Montserrat-Bold.ttf", 18 )
|
||||||
lg.setCanvas()
|
)
|
||||||
lg.setColor( 1,1,1,1 )
|
|
||||||
lg.draw( canvas )
|
|
||||||
end
|
|
||||||
|
|
||||||
function menu.paint()
|
|
||||||
|
|
||||||
lg.setCanvas( canvas )
|
|
||||||
|
|
||||||
--bg
|
|
||||||
lg.setColor( 0.8, 0.6, 0.3, 1 )
|
|
||||||
lg.rectangle( "fill", 0, 0, wWidth, wHeight )
|
|
||||||
|
|
||||||
--buttons
|
|
||||||
for id, button in pairs( buttons ) do button:draw( ) end
|
|
||||||
|
|
||||||
--gradient
|
|
||||||
lg.setColor( 1, 1, 1, 1 )
|
|
||||||
lg.draw( gradientQuad, 0, 0, 0, wWidth, wHeight )
|
|
||||||
lg.setCanvas()
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
function menu.update( dt )
|
|
||||||
t = t + dt
|
|
||||||
end
|
|
||||||
|
|
||||||
function menu.resize( w, h )
|
|
||||||
wWidth, wHeight = w, h
|
|
||||||
canvas = lg.newCanvas()
|
|
||||||
for id, uiButton in pairs( buttons ) do
|
|
||||||
uiButton.w = wWidth
|
|
||||||
end
|
|
||||||
return menu.paint()
|
|
||||||
end
|
|
||||||
|
|
||||||
function menu.mousemoved( x, y, dx, dy, istouch )
|
|
||||||
if selectedButtonIdx then
|
|
||||||
buttons[selectedButtonIdx].selected = false
|
|
||||||
selectedButtonIdx = nil
|
|
||||||
end
|
|
||||||
for id, menuButton in ipairs( buttons ) do
|
|
||||||
if menuButton:contains( x, y ) then
|
|
||||||
menuButton.selected = true
|
|
||||||
selectedButtonIdx = id
|
|
||||||
return menu.paint()
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
function menu.mousepressed( x, y, button, istouch, presses )
|
|
||||||
if not selectedButtonIdx then return end
|
|
||||||
local uiButton = buttons[selectedButtonIdx]
|
|
||||||
if uiButton:contains( x, y ) then return uiButton( ) end
|
|
||||||
|
|
||||||
return menu.paint()
|
|
||||||
end
|
|
||||||
|
|
||||||
function menu.keypressed( key, code, isrepeat )
|
|
||||||
|
|
||||||
if code == "escape" then
|
|
||||||
return scene.mainmenu()
|
|
||||||
end
|
|
||||||
|
|
||||||
if code == "return" and selectedButtonIdx then
|
|
||||||
return buttons[selectedButtonIdx].callback()
|
|
||||||
end
|
|
||||||
|
|
||||||
if code == "down" or code == "tab" or code == "up" then
|
|
||||||
local sbi = (selectedButtonIdx or 1)
|
|
||||||
buttons[sbi].selected = false
|
|
||||||
|
|
||||||
--Increment / decrement
|
|
||||||
sbi = sbi + ((code == "up") and -1 or 1)
|
|
||||||
if sbi > #buttons then sbi = 1 end
|
|
||||||
if sbi < 1 then sbi = #buttons end
|
|
||||||
|
|
||||||
--Assign
|
|
||||||
print( "selecting button: ", sbi )
|
|
||||||
selectedButtonIdx = sbi
|
|
||||||
buttons[selectedButtonIdx].selected = true
|
|
||||||
end
|
|
||||||
|
|
||||||
return menu.paint()
|
|
||||||
end
|
|
||||||
|
|
||||||
scene.options = menu
|
|
||||||
return menu
|
|
|
@ -11,7 +11,7 @@ function love.conf(t)
|
||||||
t.audio.mixwithsystem = true -- Keep background music playing when opening LOVE (boolean, iOS and Android only)
|
t.audio.mixwithsystem = true -- Keep background music playing when opening LOVE (boolean, iOS and Android only)
|
||||||
|
|
||||||
t.window.title = "vision-dajjal" -- The window title (string)
|
t.window.title = "vision-dajjal" -- The window title (string)
|
||||||
t.window.icon = nil -- Filepath to an image to use as the window's icon (string)
|
t.window.icon = "client/assets/client-icon.png" -- Filepath to an image to use as the window's icon (string)
|
||||||
t.window.width = 800 -- The window width (number)
|
t.window.width = 800 -- The window width (number)
|
||||||
t.window.height = 600 -- The window height (number)
|
t.window.height = 600 -- The window height (number)
|
||||||
t.window.borderless = false -- Remove all border visuals from the window (boolean)
|
t.window.borderless = false -- Remove all border visuals from the window (boolean)
|
||||||
|
|
|
@ -3,10 +3,13 @@ local shared = assert( require 'shared' )
|
||||||
local love = assert( love )
|
local love = assert( love )
|
||||||
|
|
||||||
function love.load()
|
function love.load()
|
||||||
|
love.window.setIcon( assert( love.image.newImageData( "client/assets/client-icon.png" ) ) )
|
||||||
|
love.graphics.setNewFont( "client/assets/Montserrat-Bold.ttf", 48 )
|
||||||
local scenes = assert( require 'client.scene' )
|
local scenes = assert( require 'client.scene' )
|
||||||
assert( require 'client.ui.menu' )
|
|
||||||
|
assert( require 'client.ui.options' )
|
||||||
assert( require 'client.ui.browser' )
|
assert( require 'client.ui.browser' )
|
||||||
assert( require 'client.game' )
|
assert( require 'client.game' )
|
||||||
assert( require 'client.ui.options' )
|
assert( require 'client.ui.mainmenu' )
|
||||||
scenes.mainmenu()
|
scenes.loadScene( scenes.mainmenu )
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue