Compare commits

..

No commits in common. "a7c4d97aeabbf2e846118abbae1640efedbf26b4" and "e7926fab3cefb97f681743c3644c676993e2434d" have entirely different histories.

10 changed files with 308 additions and 339 deletions

View File

@ -1,92 +0,0 @@
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.

Before

Width:  |  Height:  |  Size: 24 KiB

View File

@ -1,36 +1,23 @@
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 = {}
print( 'scene', scene ) local function loadScene( scene, params )
print( "Loading Scene:", scene.name )
function scene.loadScene( scen, params ) for k, v in pairs( scene ) do
print( "Loading Scene:", scen.name ) love[k] = v
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
scen:onLoad( params ) scene.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 scene.loadScene( t ) end } ) setmetatable( t, { __call = function() return loadScene( t ) end } )
rawset( scenes, name, t ) rawset( scenes, name, t )
end end
return setmetatable( scene, return setmetatable( scene,
{__call = scene.loadScene, {__call = loadScene,
__newindex = newScene __newindex = newScene
} ) } )

View File

@ -1,34 +1,21 @@
local button = {}
local lg = assert( love.graphics ) local lg = assert( love.graphics )
local button = {
h = 60,
y = 0,
x = 0,
w = 100,
space = 15,
}
local mt = { __index = button }
function button:new( t ) function button:new( t, x, y, w, h, text, color, callback )
t = t or {} --print( t.x, t.y, t.w, t.h, t.text, t.color, t.callback )
return setmetatable( t or
if t.y then button.y = t.y end {
if t.h then button.h = t.h end x = 0, y = 0,
if t.w then button.w = t.w end w = 100, h = 100,
if t.x then button.x = t.x end text = text, color = color,
callback = callback,
t.x = t.x or button.x selected = false
t.y = t.y or button.y },
t.w = t.w or button.w {
t.h = t.h or button.h __index = button,
t.text = t.text or "" __call = t.callback or callback
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 )
@ -46,10 +33,8 @@ 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.8 ) lg.setColor( 0, 0, 0, 0.7 )
lg.print( self.text, self.x + 15, self.y + 6) lg.print( self.text, self.x + 15, self.y + 10 )
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 } )

View File

@ -1,51 +0,0 @@
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 )
)

View File

@ -1,37 +1,74 @@
local love = assert( love )
local lg = assert( love.graphics ) local lg = assert( love.graphics )
local love = assert( love )
local scene = assert( require 'client.scene' ) local scene = assert( require 'client.scene' )
print( 'scene', scene ) local strings = assert( require 'client.assets.strings' )
local button = assert( require 'client.ui.button' )
local menu = {} local menu = {}
--Static variables. local t = 0
local selectedButtonIdx local wWidth = 800
local canvas local wHeight = 600
local wWidth, wHeight
local currentMenu
function menu.new( name, buttons, fg, bg, font ) local selectedButtonIdx = nil
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
function menu:onLoad() local canvas = lg.newCanvas()
print( 'loading:', self.name ) local buttons =
currentMenu = self {
lg.setFont( self.font ) button{
return menu.resize( lg.getDimensions() ) x = 15, w = 400, h = 50,
end y = 115,
text = strings.newgame_button,
color = { 0.3, 0.2, 0.9, 0.5 },
callback = function() return scene.game() end },
function menu.update( dt ) end button{
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 },
function menu.resize( w, h ) button{
wWidth, wHeight = w, h x = 15, w = 400, h = 50,
canvas = lg.newCanvas() y = 115 + 55 * 2,
return currentMenu:paint() text = strings.option_button,
end color = { 0.3, 0.2, 0.9, 0.5 },
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()
@ -39,59 +76,69 @@ function menu.draw()
lg.draw( canvas ) lg.draw( canvas )
end end
function menu.mousemoved( x, y, dx, dy, istouch ) function menu.paint()
if not currentMenu then return end lg.setCanvas( canvas )
local buttons = currentMenu.buttons
local selectedButton = buttons[selectedButtonIdx or 0] --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 )
if selectedButtonIdx then
buttons[selectedButtonIdx].selected = false
selectedButtonIdx = nil
end
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
if menuButton ~= selectedButton then return menu.paint()
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 end
function menu.mousepressed( x, y, button, istouch, presses ) function menu.mousepressed( x, y, button, istouch, presses )
if not selectedButtonIdx then return end
if not selectedButtonIdx and currentMenu then return end local uiButton = buttons[selectedButtonIdx]
local uiButton = currentMenu.buttons[selectedButtonIdx] if uiButton:contains( x, y ) then return uiButton() end
if uiButton:contains( x, y ) then return menu.paint()
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
local button = buttons[selectedButtonIdx] return 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
@ -104,37 +151,14 @@ 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 currentMenu:paint() return menu.paint()
end end
function menu:paint() scene.mainmenu = menu
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

View File

@ -3,60 +3,179 @@ 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 menu = assert( require 'client.ui.menu' ) local textinput = assert( require 'client.ui.textinput' )
local menu = {}
return menu.new( local t = 0
"options", local wWidth = 800
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, y = 115, w = 800, h = 30, x = 15, w = 400, h = 50,
y = 115,
text = strings.mainmenu_button, text = strings.mainmenu_button,
color = { 0.6, 0.6, 0.6, 0.8 }, color = { 0.5, 0.2, 0.8, 0.6 },
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.6, 0.6, 0.6, 0.8 }, color = { 0.5, 0.2, 0.2, 0.6 },
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.6, 0.6, 0.6, 0.8 }, color = { 0.5, 0.2, 0.4, 0.6 },
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.6, 0.6, 0.6, 0.8 }, color = { 0.5, 0.2, 0.6, 0.6 },
callback = menu.colourOption }, callback = menu.colourOption },
button{ button{
x = 15, w = 400, h = 50,
y = 115 + 55 * 4,
option = 'keybinds', option = 'keybinds',
text = strings.option_keybinds, text = strings.keybinding_button,
color = { 0.6, 0.6, 0.6, 0.8 }, color = { 0.8, 0.0, 0.4, 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,
}, },
lg.newMesh{ button{
{ 0, 0, 0, 0, 0.4, 0.1, 0.05, 0.0 }, x = wWidth / 2, w = 400, h = 50
{ 1, 0, 1, 0, 0.8, 0.3, 0.1, 0.8 }, y = 115,
{ 1, 1, 1, 1, 0.7, 0.4, 0.1, 0.8 }, text = strings.backward_key,
{ 0, 1, 0, 1, 0.4, 0.1, 0.03, 0.0 }, color = { 0.8, 0.0, 0.4, 0.8 },
}, callback = function() return setOption( 'backward_key' ) end,
}
}]]
lg.newMesh{ function menu.onLoad()
{ 0, 0, 0, 0, 1, 1, 1, 0.01 }, lg.setNewFont( 28 )
{ 1, 0, 1, 0, 1, 1, 1, 0.1 }, return menu.resize( lg.getDimensions() )
{ 1, 1, 1, 1, 0, 0, 0, 0.1 }, end
{ 0, 1, 0, 1, 0, 0, 0, 0.01 },
},
lg.newFont( "client/assets/Montserrat-Bold.ttf", 18 ) function menu.draw()
) 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

View File

@ -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 = "client/assets/client-icon.png" -- Filepath to an image to use as the window's icon (string) t.window.icon = nil -- 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)

View File

@ -3,13 +3,10 @@ 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.mainmenu' ) assert( require 'client.ui.options' )
scenes.loadScene( scenes.mainmenu ) scenes.mainmenu()
end end