-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstartup.lua
More file actions
63 lines (55 loc) · 2.07 KB
/
startup.lua
File metadata and controls
63 lines (55 loc) · 2.07 KB
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
----
-- startup.lua
--
-- This file contains numerous routines used when starting the game. This is
-- to help prevent main.lua from becoming too confusing.
----
local Keymap = require "xl.Keymap"
local Gamestate = require "hump.gamestate"
local DebugMenu = require "state.DebugMenu"
local ObjChar = require "objects.ObjChar"
local InventoryMenu = require "state.InventoryMenu"
local startup = { window = {} }
----
-- Perform basic checks to ensure the graphics card has support for everything we need.
-- Fail with asserts if it doesn't.
----
function startup.sanityCheck()
-- local function sancheck(s,m) assert(love.graphics.isSupported(s), "Your graphics card doesn't support " .. m) end
-- sancheck("canvas", "Framebuffers.")
-- sancheck("shader", "shaders")
-- sancheck("subtractive", "the subtractive blend mode.")
-- sancheck("npot", "non-power-of-two textures.")
end
function startup.takeScreenshot()
local fname = string.format("%s/Screenshot %s.png", love.filesystem.getUserDirectory(), os.date("%Y-%m-%d_%H.%M.%S"))
love.graphics.newScreenshot():encode("temp.png")
util.moveFile("temp.png", fname)
xl.AddMessage(string.format("Screenshot saved to '%s'",fname))
end
function startup.GotoDebugMenu( )
Gamestate.push( DebugMenu )
end
function startup.ToggleFullscreen( )
local fs = not love.window.getFullscreen()
love.window.setFullscreen( fs, "normal" )
end
function startup.dothings()
-- print out graphics card information
local _, version, vendor, device = love.graphics.getRendererInfo()
print( "OpenGL Version: " .. version .. "\nGPU: " .. device )
-- otherwise sprites look weird
love.graphics.setDefaultFilter("nearest", "nearest")
-- default log level
Log.setLevel("debug")
xl.DScreen.toggle()
-- screenshot function
Keymap.pressed("screenshot", startup.takeScreenshot)
-- debug menu
Keymap.pressed("debug", startup.GotoDebugMenu)
Keymap.pressed("fullscreen", startup.ToggleFullscreen)
love.physics.setMeter(32)
-- register Gamestate functions
Gamestate.registerEvents({"focus", "mousefocus", "quit", "textinput", "threaderror", "visible"})
end
return startup