aboutsummaryrefslogtreecommitdiffstats
path: root/Gamestates/Menu.lua
blob: 37e69a4f9f1087c2e61b5d7ad9dbad8a0cf2f921 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
--[[
	Gamestates/Menu.lua
	Main menu
	by piernov

	Comment: might not be a good idea to immediately load both Solo and Multiplayer mode.
]]--

local Menu = {}
local Gui = require "Quickie"
local Utils = require "Utils"
local GUI = { Menu = require("GUI/Menu")}
local Gamestates = {
	Solo = require("Gamestates/Solo"),
	Multiplayer = require("Gamestates/Multiplayer"),
	About = require("Gamestates/About")
}
Gamestates.Options = Config


function Menu:enter()
	Previous = nil -- Menu's root

-- Redefine Quickie's colors
	Gui.core.style.color.normal.fg[1] = 0
	Gui.core.style.color.normal.fg[2] = 0
	Gui.core.style.color.normal.fg[3] = 255

	Gui.core.style.color.normal.bg[1] = 0
	Gui.core.style.color.normal.bg[2] = 0
	Gui.core.style.color.normal.bg[3] = 0

	Gui.core.style.color.hot.fg[1] = 0
	Gui.core.style.color.hot.fg[2] = 0
	Gui.core.style.color.hot.fg[3] = 255

	Gui.core.style.color.hot.bg[1] = 48
	Gui.core.style.color.hot.bg[2] = 48
	Gui.core.style.color.hot.bg[3] = 48

	Gui.core.style.color.active.fg[1] = 0
	Gui.core.style.color.active.fg[2] = 0
	Gui.core.style.color.active.fg[3] = 255

	Gui.core.style.color.active.bg[1] = 24
	Gui.core.style.color.active.bg[2] = 24
	Gui.core.style.color.active.bg[3] = 24
-- End
end

function Menu:update(dt)
	Gui.group{grow = "down", pos = {Utils.percentCoordinates(10, 10)}, function()
		for _, name in ipairs(GUI.Menu.Buttons) do
			if Gui.Button{text = name, size = {Utils.percentCoordinates(80, 20)}} then -- Display main menu buttons and switch gamestate if clicked
				Gamestate.switch(Gamestates[name])
			end
		end
	end}
end

function Menu:draw()
	Gui.core.draw()
end

return Menu