-
Notifications
You must be signed in to change notification settings - Fork 0
/
Menu.lua
357 lines (301 loc) · 12.5 KB
/
Menu.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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
local st = Gamestate:new('Menu')
st:setInit(function(self)
entities = {}
shuv.resetPal()
self.panEase = nil
self.x = 1
self.tutorialPopup = false
self.mainMenu = em.init('OptionsList',{allowInput = true})
self.mainMenu:addOption('playdemolevels',function()
cs = bs.load('SongSelect')
self.menuMusicManager:clearOnBeatHooks()
cs.menuMusicManager = self.menuMusicManager
cs.topDirectory = 'levels/Demo/'
cs.allowEditor = false
cs:init()
end, 0)
self.mainMenu:addOption('customs',function()
local playedLevelsJson = dpf.loadJson("savedata/playedlevels.json",{})
if playedLevelsJson['Tutorial_CV35W_DPS2004'] then
if not love.filesystem.getInfo('Custom Levels','directory') then
love.filesystem.createDirectory('Custom Levels')
end
cs = bs.load('SongSelect')
self.menuMusicManager:clearOnBeatHooks()
cs.menuMusicManager = self.menuMusicManager
cs.topDirectory = 'Custom Levels/'
cs.allowEditor = true
cs:init()
else
print('didnt play the tutorial lol')
self.tutorialPopup = true
end
end, 17)
self.mainMenu:addOption('settings',function()
self.mainMenu.allowInput = false
self.optionsMenu.allowInput = true
self.panEase = flux.to(self,60,{x = -1}):ease('outExpo')
end, 34)
self.mainMenu:addOption('credits',function()
cs = bs.load('Credits')
self.menuMusicManager:stop()
--cs.menuMusicManager = self.menuMusicManager
--cs.topDirectory = 'levels/'
cs:init()
end, 17*3)
self.mainMenu:addOption('exitgame',function()
love.event.quit()
end, 17*4)
if not project.release then
self.mainMenu:addOption('devLevelSelect',function()
cs = bs.load('SongSelect')
self.menuMusicManager:clearOnBeatHooks()
cs.menuMusicManager = self.menuMusicManager
cs.topDirectory = 'levels/'
cs:init()
end, 17*5)
else
self.mainMenu:addOption('discordLink',function()
love.system.openURL('https://discord.gg/MAXGRYPMSw')
end, 17*6)
end
self.mainMenu:setSelection(1)
local optionsHeight = 17
self.optionsMenu = em.init('OptionsList',{allowInput = false})
self.optionsMenu:addOption('optionsLanguage','language',optionsHeight*1)
self.optionsMenu:defineSubmenu('language')
local langOption = self.optionsMenu:addCustom('language',optionsHeight*1,30)
langOption.languages = {'en','jp','ko','owo'}
langOption.languageIndex = 0
for i,v in ipairs(langOption.languages) do
if v == loc.lang then
langOption.languageIndex = i
end
end
langOption.onInput = function(langSelf,x)
langSelf.languageIndex = (langSelf.languageIndex + x - 1) % #langSelf.languages + 1
te.play(sounds.hold,"static",'sfx',0.5)
end
langOption.getText = function(langSelf)
return '[-] ' .. loc.get('lang_'..langSelf.languages[langSelf.languageIndex]) .. ' [+]'
end
self.optionsMenu:addOption('back',function()
local newLanguage = langOption.languages[langOption.languageIndex]
if loc.lang == newLanguage then
self.optionsMenu:setSubmenu('main')
else
savedata.options.language = newLanguage
sdfunc.save()
love.event.quit('restart')
end
end,optionsHeight*3)
self.optionsMenu:defineSubmenu()
self.optionsMenu:addOption('optionsAccessibility','accessibility',optionsHeight*2)
self.optionsMenu:defineSubmenu('accessibility')
self.optionsMenu:addEnum('optionsVFX',{
{'full','optionsVFXFull'},
{'decreased','optionsVFXDecreased'},
{'none','optionsVFXNone'}
},savedata.options.accessibility,'vfx',optionsHeight*1)
self.optionsMenu:addEnum('optionsTaps',{
{'default','optionsNotesDefault'},
{'lenient','optionsNotesLenient'},
{'auto','optionsNotesAuto'}
},savedata.options.accessibility,'taps',optionsHeight*2)
self.optionsMenu:addEnum('optionsSides',{
{'default','optionsNotesDefault'},
{'lenient','optionsNotesLenient'},
{'auto','optionsNotesAuto'}
},savedata.options.accessibility,'sides',optionsHeight*3)
self.optionsMenu:addOption('back','main',optionsHeight*5)
self.optionsMenu:defineSubmenu()
self.optionsMenu:addOption('optionsGraphics','graphics',optionsHeight*3)
self.optionsMenu:defineSubmenu('graphics')
--self.optionsMenu:addBoolean({'optionsFullscreen','optionsEnabled','optionsDisabled'},savedata.options.graphics,'fullscreen',optionsHeight*1,sdfunc.updateWindow)
self.optionsMenu:addEnum('optionsDisplayMode',{
{'windowed','enumWindowed'},
{'fullscreen','enumFullscreen'},
{'borderless','enumBorderless'}
},savedata.options.graphics,'displayMode',optionsHeight*1, sdfunc.updateWindow)
self.optionsMenu:addNumber('optionsWindowScale',savedata.options.graphics,'windowScale',optionsHeight*2,1,{1,5},sdfunc.updateWindow)
self.optionsMenu:addEnum('optionsHUD', {
{'default', 'enumHUDDefault'},
{'expanded', 'enumHUDExpanded'},
{'expandedPlus', 'enumHUDExpandedPlus'},
{'none', 'enumHUDNone'}
}, savedata.options.graphics, 'hudStyle', optionsHeight*3)
self.optionsMenu:addBoolean({'optionsVSync', 'optionsEnabled', 'optionsDisabled'}, savedata.options.graphics, 'vsync', optionsHeight*4, function()
if savedata.options.graphics.vsync then
love.window.setVSync(-1)
else
love.window.setVSync(0)
end
end)
self.optionsMenu:addOption('back','main',optionsHeight*6)
self.optionsMenu:defineSubmenu()
self.optionsMenu:addOption('optionsAudio','audio',optionsHeight*4)
self.optionsMenu:defineSubmenu('audio')
self.optionsMenu:addNumber('optionsMusicVolume',savedata.options.audio,'musicvolume',optionsHeight*1,1,{0,10},sdfunc.updateVol)
self.optionsMenu:addNumber('optionsSfxVolume',savedata.options.audio,'sfxvolume',optionsHeight*2,1,{0,10},sdfunc.updateVol)
self.optionsMenu:addBoolean({'optionsHitsounds','optionsEnabled','optionsDisabled'},savedata.options.audio,'hitsounds',optionsHeight*3,sdfunc.updateVol)
self.optionsMenu:addBoolean({'optionsPlayMenuMusic','optionsEnabled','optionsDisabled'}, savedata.options.audio, 'playMenuMusic', optionsHeight*4,function()
if savedata.options.audio.playMenuMusic then
self.menuMusicManager:play()
else
self.menuMusicManager:stop()
end
end)
self.optionsMenu:addBoolean({'optionsMuteOnFocusLoss','optionsEnabled','optionsDisabled'}, savedata.options.audio, 'muteOnFocusLoss', optionsHeight*5)
self.optionsMenu:addOption('back','main',optionsHeight*7)
self.optionsMenu:defineSubmenu()
self.optionsMenu:addOption('optionsGameplay','gameplay',optionsHeight*5)
self.optionsMenu:defineSubmenu('gameplay')
self.optionsMenu:addNumber('optionsInputOffset',savedata.options.game,'inputOffset',optionsHeight*1)
self.optionsMenu:addOption('optionsCalibrate',function()
self.menuMusicManager:stop()
cLevel = 'levels/Other/calibration/'
returnData = {state = 'Menu', vars = {}}
cs = bs.load('Game')
cs:init()
end,optionsHeight*2)
self.optionsMenu:addOption('back','main',optionsHeight*6)
self.optionsMenu:defineSubmenu()
self.optionsMenu:addOption('optionsKeybinds', 'keybinds', optionsHeight*6)
self.optionsMenu:defineSubmenu('keybinds')
self.optionsMenu:addOption('optionsKeybindsKeyboardGameplay',function()
local ps = cs
cs = bs.load('Keybinds')
cs.ps = ps
self.menuMusicManager:clearOnBeatHooks()
cs.menuMusicManager = self.menuMusicManager
cs.type = 'keyboardGameplay'
cs.keybinds = savedata.options.bindings.keyboardGameplay
cs:init()
end, optionsHeight*1)
self.optionsMenu:addOption('optionsKeybindsKeyboardMenu',function()
local ps = cs
cs = bs.load('Keybinds')
cs.ps = ps
self.menuMusicManager:clearOnBeatHooks()
cs.menuMusicManager = self.menuMusicManager
cs.type = 'keyboardMenu'
cs.keybinds = savedata.options.bindings.keyboardMenu
cs:init()
end, optionsHeight*2)
self.optionsMenu:addOption('optionsKeybindsKeyboardEditor',function()
local ps = cs
cs = bs.load('Keybinds')
cs.ps = ps
self.menuMusicManager:clearOnBeatHooks()
cs.menuMusicManager = self.menuMusicManager
cs.type = 'keyboardEditor'
cs.keybinds = savedata.options.bindings.keyboardEditor
cs:init()
end, optionsHeight*3)
self.optionsMenu:addOption('optionsKeybindsControllerBinds',function()
local ps = cs
cs = bs.load('Keybinds')
cs.ps = ps
self.menuMusicManager:clearOnBeatHooks()
cs.menuMusicManager = self.menuMusicManager
cs.type = 'controllerBinds'
cs.keybinds = savedata.options.bindings.controllerBinds
cs:init()
end, optionsHeight*4)
self.optionsMenu:addOption('optionsMouseSettings', 'mouseSettings', optionsHeight * 5)
self.optionsMenu:addOption('back', 'main', optionsHeight * 7)
self.optionsMenu:defineSubmenu()
self.optionsMenu:defineSubmenu('mouseSettings', 'keybinds')
self.optionsMenu:addBoolean({ 'optionsCircleSnap', 'optionsEnabled', 'optionsDisabled' }, savedata.options.game,
'circleSnap', optionsHeight * 1)
self.optionsMenu:addBoolean({ 'optionsForceMouseKeyboard', 'optionsEnabled', 'optionsDisabled' }, savedata.options
.game, 'forceMouseKeyboard', optionsHeight * 2)
self.optionsMenu:addBoolean({ 'optionsLockToWindow', 'optionsEnabled', 'optionsDisabled' }, savedata.options.game,
'lockMouseToWindow', optionsHeight * 3)
self.optionsMenu:addEnum('optionsCursorMode', {
{ 'default', 'enumCursorDefault' },
{ 'large', 'enumCursorLarge' },
{ 'invert', 'enumCursorInvert' }
}, savedata.options.game, 'cursorMode', optionsHeight * 4)
self.optionsMenu:addBoolean({'optionsDisableClick', 'optionsEnabled', 'optionsDisabled'}, savedata.options.game, 'disableClick', optionsHeight*5)
self.optionsMenu:addOption('back','keybinds',optionsHeight*7)
self.optionsMenu:defineSubmenu('main')
self.optionsMenu:setSelection(1)
--[[
enumTestValue = enumTestValue or 'enumOne'
self.optionsMenu:addEnum('optionsTestEnum',{'enumOne','enumTwo','enumThree'},_G,'enumTestValue',optionsHeight*4)
]]--
local returnToMainMenu = function()
sdfunc.save()
self.mainMenu.allowInput = true
self.optionsMenu.allowInput = false
self.panEase = flux.to(self,60,{x = 1}):ease('outExpo')
end
self.optionsMenu:addOption('back',returnToMainMenu,optionsHeight*8)
self.optionsMenu.returnLoc['main'] = returnToMainMenu
self.optionsMenu:setSubmenu('main')
--[[
if #te.findTag('music') == 0 then
te.playLooping('assets/music/menuloop.ogg','stream','music')
end
]]
if not self.menuMusicManager then
self.menuMusicManager = em.init('MenuMusicManager')
self.menuMusicManager:play()
end
self.logoEase = nil
self.logoZoom = 1
self.menuMusicManager:addOnBeatHook(function(b)
if b % 2 == 0 then
--self.logoZoom = 1.03
else
self.logoZoom = 1.1
end
self.logoEase = flux.to(self,60,{logoZoom=1}):ease("outExpo")
end)
end)
st:setUpdate(function(self,dt)
self.menuMusicManager:update()
if not self.tutorialPopup then
local ranFunction = self.mainMenu:update()
if not ranFunction then
self.optionsMenu:update()
end
if maininput:pressed('back') then
self.optionsMenu:callReturn()
end
else
if maininput:pressed('back') or maininput:pressed('accept') or mouse.pressed == 1 then
self.tutorialPopup = false
te.play(sounds.hold,"static",'sfx',0.5)
end
end
end)
st:setBgDraw(function(self)
love.graphics.setFont(fonts.digitalDisco)
color()
love.graphics.rectangle('fill',0,0,project.res.x,project.res.y)
self.mainMenu:draw(0 + self.x * project.res.cx, 200)
self.optionsMenu:draw(project.res.x + self.x * project.res.cx, 180)
love.graphics.printf(loc.get('optionsHint'),project.res.cx + self.x * project.res.cx, 160,project.res.x,'center')
love.graphics.print(loc.get('twitterPlug'),project.res.cx * -1 + 10 + self.x * project.res.cx,336)
color()
love.graphics.draw(sprites.title.logo,project.res.cx,100,0,self.logoZoom, self.logoZoom,170,32)
if self.tutorialPopup then
local w,h = 330,130
love.graphics.rectangle('fill',project.res.cx - w*0.5,project.res.cy - h*0.5,w,h)
love.graphics.setLineWidth(2)
color(1)
love.graphics.rectangle('line',project.res.cx - w*0.5,project.res.cy - h*0.5,w,h)
love.graphics.printf(loc.get('tutorialNag'),project.res.cx - w*0.5,150,w,'center')
local locString = 'pressToContinue_mouse'
if helpers.usingController() then
locString = 'pressToContinue_controller'
end
love.graphics.printf(loc.get(locString),project.res.cx - w*0.5,200,w,'center')
end
color('black')
love.graphics.print(version, project.res.cx * 2 - fonts.digitalDisco:getWidth(version) - 10 ,336)
color()
end)
return st