-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.lua
115 lines (95 loc) · 2.7 KB
/
main.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
109
110
111
112
113
114
115
require 'lib/simpleScale'
require 'globals'
require 'colors'
require 'managers/statemanager'
require 'managers/savemanager'
local discordRPC = require 'lib/discordRPC'
local appId = require 'applicationId'
function love.load()
savemanager:load()
volumeValue = savemanager.settings.volume or 100
resolutionIndex = savemanager.settings.resolutionIndex or 8
statemanager:load()
math.randomseed(os.time())
if resolutionList[resolutionIndex][1] == 0 and resolutionList[resolutionIndex][2] == 0 then
isFullScreen = true
else
isFullScreen = false
end
simpleScale.setWindow(gw, gh, resolutionList[resolutionIndex][1], resolutionList[resolutionIndex][2], {fullscreen = isFullScreen})
love.window.setVSync(0)
cursor:load()
love.graphics.setBackgroundColor(0.1, 0.1, 0.1, 1)
love.mouse.setVisible(false)
joystick = nil
isJoystickMove = false
joystickNoticeTextOpacity = 0
discordRPC.initialize(appId, true)
now = os.time(os.date("*t"))
nextPresenceUpdate = 0
end
function discordApplyPresence()
if statemanager:getState() == "game" then
detailsNow = "Playing " .. maingame:getSong()
stateNow = "By " .. maingame:getArtist()
else
detailsNow = "In Mainmenu"
stateNow = ""
end
presence = {
largeImageKey = "icon",
largeImageText = "upo",
details = detailsNow,
state = stateNow,
startTimestamp = now,
}
return presence
end
function love.update(dt)
collectgarbage()
mx = love.mouse.getX() / simpleScale.getScale()
my = love.mouse.getY() / simpleScale.getScale()
statemanager:update(dt)
if nextPresenceUpdate < love.timer.getTime() then
discordRPC.updatePresence(discordApplyPresence())
nextPresenceUpdate = love.timer.getTime() + 2.0
end
discordRPC.runCallbacks()
end
function love.draw()
simpleScale.set()
statemanager:draw()
simpleScale.unSet()
end
function love.mousepressed(x, y, button)
statemanager:mousepressed(x, y, button)
end
function love.gamepadpressed(joystick, button)
statemanager:gamepadpressed(joystick, button)
if (button == "y" and statemanager:getState() == "menu" and joystick ~= nil) then
isJoystickMove = not isJoystickMove
joystickNoticeTextOpacity = 1
end
end
function love.keypressed(key)
statemanager:keypressed(key)
if (key == "y" and statemanager:getState() == "menu" and joystick ~= nil) then
isJoystickMove = not isJoystickMove
joystickNoticeTextOpacity = 1
end
end
function love.joystickadded(jstick)
joystick = jstick
end
function love.joystickremoved(jstick)
if (joystick == jstick) then
joystick = nil
if (isJoystickMove) then
isJoystickMove = false
joystickNoticeTextOpacity = 1
end
end
end
function love.quit()
discordRPC.shutdown()
end