-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbutton_func.lua
90 lines (76 loc) · 2.15 KB
/
button_func.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
local button_func = {}
button_func.overwrite = function()
if love.filesystem.exists("save.lua") then
menu.push({{txt = "Yes", color = "dark_blue", img = 11, func = menu.get_button().func},
{txt = "No", color = "red", img = 7, insta_func = "back"}},
{name = "Overwrite Current Save?", color = "red"}, true)
else
button_func.off()
end
end
button_func.off = function()
menu.off()
end
button_func.new_game = function()
map.new()
state = "map"
character.load()
end
button_func.load_game = function()
manage.load_file()
end
button_func.tutorial = function()
tutorial.start()
state = "game"
end
button_func.check_save = function()
if love.filesystem.exists("save.lua") then
button_func.off()
end
end
button_func.quit_game = function()
love.event.quit()
end
button_func.resume = function()
state = oldstate
oldstate = ""
freeze = false
end
button_func.main_menu = function()
if save then
manage.save_game()
end
freeze = false
state = "main"
menu.start_main()
end
button_func.back = function()
menu.pop()
end
button_func.toggle_fullscreen = function()
local current_type = love.window.getFullscreen()
love.window.setMode(screen.w, screen.h, {fullscreen = not current_type, resizable = true})
if not current_type then
screen.type = "Fullscreen"
else
screen.type = "Windowed"
end
window.scale_screen()
end
button_func.up_res = function()
if not love.window.getFullscreen() then
screen.res = screen.res + 1
local w, h = love.window.getDesktopDimensions()
if screen.res*screen.w > w or screen.res*screen.h > h then
screen.res = 1
end
love.window.setMode(screen.res*screen.w, screen.res*screen.h, {fullscreen = false, resizable = true})
end
end
button_func.settings = function()
menu.push({{txt = {table = screen, index = "type"}, color = "dark_blue", img = 9, insta_func = "toggle_fullscreen"},
{txt = {table = screen, index = "res_txt"}, color = "dark_blue", img = 10, insta_func = "up_res"},
{txt = "Back", color = "red", img = 7, insta_func = "back"}},
{name = "Settings", color = "blue"}, false)
end
return button_func