-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
no_rom.lua
108 lines (92 loc) · 3.52 KB
/
no_rom.lua
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
-- Overrides for the LÖVE callback functions if no ROM is loaded
local path_separator = "/"
if love.system.getOS() == "Windows" then
path_separator = "\\"
end
local root_dir = ""
local local_assets
if love.filesystem.isFused() and love.filesystem.mount(love.filesystem.getSourceBaseDirectory(), "fused_dir") then
root_dir = "fused_dir/"
local_assets =
string.gsub(love.filesystem.getSourceBaseDirectory(), "/", path_separator) .. path_separator .. "assets"
else
local_assets = string.gsub(love.filesystem.getSource(), "/", path_separator) .. path_separator .. "assets"
end
local font = love.graphics.newFont(20)
local dot = "• "
local dot_width = font:getWidth(dot)
local local_assets_width = font:getWidth(local_assets)
local local_assets_height = font:getHeight(local_assets)
local save_assets = string.gsub(love.filesystem.getSaveDirectory(), "/", path_separator) .. path_separator .. "assets"
local save_assets_width = font:getWidth(save_assets)
local save_assets_height = font:getHeight(save_assets)
function love.draw()
if love.filesystem.getInfo(root_dir .. "assets/background.png") then
local background = love.graphics.newImage(root_dir .. "assets/background.png")
if background then
love.graphics.setColor(1, 1, 1, .5)
love.graphics.draw(
background,
0,
0,
0,
-- Resize it to fill the screen
love.graphics.getWidth() / background:getWidth(),
love.graphics.getHeight() / background:getHeight()
)
love.graphics.setColor(1, 1, 1)
end
end
love.graphics.setFont(font)
love.graphics.printf(
"Unable to locate Space Invaders ROM files\n" .. "Please put them in one of the following locations:",
20,
150,
love.graphics.getWidth(),
"left"
)
love.graphics.printf("• " .. local_assets, 40, 220, love.graphics.getWidth(), "left")
love.graphics.line(
40 + dot_width,
220 + local_assets_height,
40 + dot_width + local_assets_width,
222 + local_assets_height
)
love.graphics.printf("• " .. save_assets, 40, 250, love.graphics.getWidth(), "left")
love.graphics.line(
40 + dot_width,
250 + save_assets_height,
40 + dot_width + save_assets_width,
252 + save_assets_height
)
end
function love.mousepressed(x, y)
local link_local_assets = root_dir .. "assets"
if x >= 45 and x <= 45 + local_assets_width and y >= 220 and y <= 220 + local_assets_height then
love.system.openURL(link_local_assets)
end
if x >= 45 and y >= 250 and y <= 250 + save_assets_height then
if not love.filesystem.getInfo(love.filesystem.getSaveDirectory() .. "/assets") then
love.filesystem.createDirectory(love.filesystem.getSaveDirectory() .. "/assets")
end
love.system.openURL(love.filesystem.getSaveDirectory() .. "/assets")
end
end
function love.mousemoved(x, y)
local hand = love.mouse.getSystemCursor("hand")
if x >= 40 + dot_width and x <= 40 + dot_width + local_assets_width and y >= 220 and y <= 220 + local_assets_height then
love.mouse.setCursor(hand)
elseif
x >= 40 + dot_width and x <= 40 + dot_width + save_assets_width and y >= 250 and y <= 250 + local_assets_height
then
love.mouse.setCursor(hand)
else
love.mouse.setCursor()
end
end
-- Stub out love.update
function love.update()
end
function love.quit()
return false
end