Skip to content

Commit

Permalink
Add gui buttons for screen resolutions and fullscreen/windowed mode
Browse files Browse the repository at this point in the history
  • Loading branch information
TomK32 committed Dec 14, 2012
1 parent 488d39c commit a384735
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion views/start_menu_view.lua
@@ -1,14 +1,16 @@

StartMenuView = class("StartMenuView", View)

StartMenuView.mode = {fullscreen = false }

gui.core.style.color.normal.bg = {80,180,80}

function StartMenuView:draw()
gui.core.draw()
end

function StartMenuView:update(dt)
gui.group.push{grow = "down", pos = {love.graphics.getWidth() / 2 - 150, love.graphics.getHeight() / 2 - 100}}
gui.group.push({grow = "down", pos = {100, 150}})
if gui.Button{text = "1 Player"} then
game_state:start()
game_state:addPlayer('Player')
Expand All @@ -18,4 +20,26 @@ function StartMenuView:update(dt)
game_state:addPlayer('Player WASD', 'wasd')
game_state:addPlayer('Player LRDU', 'arrows')
end
local i = 0
while i < 16 do
i = i + 1
love.graphics.rectangle('fill', i * math.random(100), i * math.random(100), 16, 16)
end
gui.group.push({grow = "down", pos = { 150, -50}})
modes = love.graphics.getModes()
table.sort(modes, function(a, b) return a.width*a.height < b.width*b.height end) -- sort from smallest to largest
for i, mode in ipairs(modes) do
if gui.Button({text = mode.width .. 'x' .. mode.height}) then
love.graphics.setMode(mode.width, mode.height)
end
end
if self.mode.fullscreen then
text = 'Windowed'
else
text = 'Fullscreen'
end
if gui.Button({text = text}) then
self.mode.fullscreen = not self.mode.fullscreen
love.graphics.setMode(love.graphics.getWidth(), love.graphics.getHeight(), self.mode.fullscreen)
end
end

0 comments on commit a384735

Please sign in to comment.