-
Notifications
You must be signed in to change notification settings - Fork 14
/
main.lua
757 lines (710 loc) · 25.9 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
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
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
-- . , + - ` , . ` _ ^ + * . . --
-- ` . * , `. * * , . - ` --
-- - * - ______ . __ . * _ ` . * + * ` z ^ , * --
-- . /_ __/__ _____/ /_ ____ ___ (_)___ ____ ` . * ` * --
-- + . / / / _ \/ ___/ __ \/ __ `__ \/ / __ \/ __ \ _ ______ . __ . . _ --
-- ` / / / __/ /__/ / / / / / / / / / / / / /_/ / * (_) / ____/___ _/ /___ __ ____ __ ` . --
-- + , . , . /_/ \___/\___/_/ /_/_/ /_/ /_/_/_/ /_/\____/ _ / / __/ __ `/ / __ `/ |/_/ / / / * * --
-- + ^ * (_) ` / /_/ / /_/ / / /_/ /> </ /_/ / * --
-- * ^ ` ` ` ` \____/\__,_/_/\__,_/_/|_|\__, / ` --
-- ^ , * ` . ` + * * . . /____/ . , * --
-- * . + . * ` t * , . . ^ ` ^ ` --
-- . _ ` - , ^ * ` ` + * - . + . --
-- Techmino: Galaxy is an ultra-improved version of Techmino.
-- Creating issues on GitHub is welcomed if you also love stacking/matching game
-- Developer's note
-- 1. I made a framework called Zenitha, the code in Zenitha are not directly relevant to the game;
-- 2. This project use Emmylua for better IDE support, recommend to use it if you can;
-- 3. Check file ".editorconfig" for detailed formatting rule (but not exactly, don't change large amount of code with it);
-- 4. "xxx" are texts for reading by the player/developer, 'xxx' are string values used only in code;
-- 5. Most codes are focusing on efficiency, then maintainability and readability, excuse me for some mess;
-- 6. 26
-------------------------------------------------------------
-- Load Zenitha
require'Zenitha'
DEBUG.checkLoadTime("Load Zenitha")
-- DEBUG.runVarMonitor()
-- DEBUG.setCollectGarvageVisible()
-- if os.getenv("LOCAL_LUA_DEBUGGER_VSCODE") == "1" then require("lldebugger").start() end
--------------------------------------------------------------
-- System setting
STRING.install()
math.randomseed(os.time()*626)
love.setDeprecationOutput(false)
love.keyboard.setTextInput(false)
VERSION=require'version'
--------------------------------------------------------------
-- Create directories
for _,v in next,{'conf','progress','replay','cache','lib','soundbank'} do
local info=love.filesystem.getInfo(v)
if not info then
love.filesystem.createDirectory(v)
elseif info.type~='directory' and info.type~='symlink' then
love.filesystem.remove(v)
love.filesystem.createDirectory(v)
end
end
--------------------------------------------------------------
-- Misc modules
require'assets.gamefunc'
GAME=require'assets.game'
AI=require'assets.ai'
PROGRESS=require'assets.progress'
VCTRL=require'assets.vctrl'
KEYMAP=require'assets.keymap'
SKIN=require'assets.skin'
CHAR=require'assets.char'
SETTINGS=require'assets.settings'
SONGBOOK=require'assets.songbook'
FMOD=require'assets.fmod20221'
DEBUG.checkLoadTime("Load game modules")
--------------------------------------------------------------
-- Config Zenitha and Fmod
ZENITHA.setAppName('Techmino')
ZENITHA.setVersionText(VERSION.appVer)
ZENITHA.setFirstScene('hello')
ZENITHA.setMaxFPS(260)
ZENITHA.setDebugInfo{
{"Cache",gcinfo},
{"Tasks",TASK.getCount},
{"Mouse",function() return ("%d, %d"):format(SCR.xOy:inverseTransformPoint(love.mouse.getPosition())) end},
-- {"FMOD", function() local a,b,c=FMOD.studio:getMemoryUsage() return a..","..b..","..c end}, -- Only available in logging builds Fmod
}
ZENITHA.addConsoleCommand('regurl',{
code=function(bool)
if bool~="on" and bool~="off" then
_CL{COLOR.I,"Usage: regurl <on|off>"}
elseif not love.filesystem.isFused() then
_CL{COLOR.Y,"Only available when running in fused mode"}
elseif SYSTEM=='Windows' then
if bool=="on" then
local f
f=io.popen('dir /b *.exe')
if not f then
_CL{COLOR.R,"Error: Failed to get .exe file in working directory"}
return
end
local exeN=f:read('*a'); f:close()
exeN=exeN:gsub('\r',''):split('\n')
if #exeN==0 then
_CL{COLOR.R,"Error: No .exe file found in working directory"}
return
elseif #exeN>=2 then
_CL{COLOR.R,"Error: Multiple .exe files found in working directory:"}
for i=1,#exeN do _CL{COLOR.R,exeN[i]} end
return
end
f=io.popen('cd')
if not f then
_CL{COLOR.R,"Error: Failed to get working directory"}
return
end
local path=f:read('*l'); f:close()
path=(path..'\\'..exeN[1]):gsub('\\','\\\\')
local regCode=STRING.trimIndent[=[
Windows Registry Editor Version 5.00,
[HKEY_CLASSES_ROOT\techmino],
@="Techmino: Block Stacking Protocol",
"URL Protocol"="",
[HKEY_CLASSES_ROOT\techmino\shell],
[HKEY_CLASSES_ROOT\techmino\shell\open],
[HKEY_CLASSES_ROOT\techmino\shell\open\command],
@="\"EXEPATH\" %1",
]=]:gsub('EXEPATH',path)
love.filesystem.write('RegisterURL.reg',regCode)
_CL{COLOR.G,".reg script generated, check it carefully then run it"}
_CL("Check the file with command 'explorer'.")
elseif bool=="off" then
love.filesystem.write('UnregisterURL.reg',[=[Windows Registry Editor Version 5.00\n[-HKEY_CLASSES_ROOT\techmino]]=])
_CL{COLOR.G,".reg script generated, check it carefully then run it"}
_CL("Check the file with command 'explorer'.")
end
else
_CL{COLOR.lR,"Only",COLOR.lS,"available",COLOR.lY,"on",COLOR.lG,"Windows"}
end
end,
description="Register/Unregister \"Techmino://...\" link",
details={
"Register/Unregister \"Techmino://...\" link for your system.",
"Windows: will generate a .reg file, run it manually",
"Other systems: not supported yet",
"",
"Usage: regurl <on|off>",
},
})
ZENITHA.addConsoleCommand('supernova',{
code=function()
if not PROGRESS.getStyleUnlock('acry') then
PROGRESS.setStyleUnlock('acry')
PROGRESS.setExteriorUnlock('action')
end
_CL("Extraordinary!")
end,
},true)
ZENITHA.addConsoleCommand('chain',{
code=function()
if not PROGRESS.getStyleUnlock('gela') then
PROGRESS.setStyleUnlock('gela')
PROGRESS.setExteriorUnlock('chain')
end
_CL("Fever!")
end,
},true)
local _keyDown_orig=ZENITHA.globalEvent.keyDown
function ZENITHA.globalEvent.keyDown(key,isRep)
if _keyDown_orig(key,isRep) then return true end
if key=='f11' then
SETTINGS.system.fullscreen=not SETTINGS.system.fullscreen
saveSettings()
return true
end
end
function ZENITHA.globalEvent.focus(f)
if SETTINGS.system.autoMute then
if f then
FMOD.setMainVolume(SETTINGS.system.mainVol)
elseif SCN.cur~='musicroom' then
FMOD.setMainVolume(0)
end
end
end
local autoGCcount=0
function ZENITHA.globalEvent.lowMemory()
collectgarbage()
if autoGCcount<6 then
autoGCcount=autoGCcount+1
MSG.new('check',Text.autoGC..('.'):rep(4-autoGCcount))
end
end
function ZENITHA.globalEvent.quit()
PROGRESS.save('save')
FMOD.destroy()
end
FONT.load{
norm='assets/fonts/RHDisplayGalaxy-Medium.otf',
bold='assets/fonts/RHDisplayGalaxy-ExtraBold.otf',
number='assets/fonts/RHTextInktrap-Regular.otf',
codepixel='assets/fonts/codePixel_cjk-Regular.ttf',
symbols='assets/fonts/symbols.otf',
galaxy_bold="assets/fonts/26FGalaxySans-Bold.otf",
galaxy_norm="assets/fonts/26FGalaxySans-Regular.otf",
galaxy_thin="assets/fonts/26FGalaxySans-Thin.otf",
}
FONT.setDefaultFallback('symbols')
FONT.setDefaultFont('norm')
SCR.setSize(1600,1000)
WIDGET.setDefaultOption{
base={
lineWidth=2,
},
button_fill={
textColor='L',
},
button={
sound_trigger='button_norm',
},
slider={
sound_drag='slider_drag',
soundInterval=.042,
soundPitchRange=7.02,
},
slider_fill={
sound_drag='slider_fill_drag',
soundInterval=.042,
soundPitchRange=7.02,
},
checkBox={
w=40,
sound_on='check_on',
sound_off='check_off',
},
selector={
sound_press='selector',
},
listBox={
sound_select='listbox_select',
sound_click='listbox_click',
},
inputBox={
sound_input='inputbox_input',
sound_bksp='inputbox_bksp',
sound_clear='inputbox_clear',
},
}
MSG.addCategory('collect',
{COLOR.HEX'90FFC7'},
{COLOR.HEX'262626'},
GC.load{w=40,h=40,
{'setCL',COLOR.HEX'262626'},
{'setLW',3},
{'fRect',17,6,6,28},
{'fRect',6,17,28,6},
}
)
MSG.addCategory('achievement',
{COLOR.HEX'FFF0C2'},
{COLOR.HEX'262626'},
GC.load{w=40,h=40,
{'setCL',COLOR.HEX'262626'},
{'setLW',3},
{'dRect',1,1,38,38},
{'fRect',17,6,6,28},
{'fRect',6,17,28,6},
}
)
IMG.init{
actionIcons={
texture='assets/image/action_icon.png',
brik=(function()
local t={}
local w=180
for i,name in next,{
'moveLeft','moveRight','','softDrop','hardDrop',
'rotateCW','rotateCCW','rotate180','holdPiece','skip',
'','','','','',
'func1','func2','func3','func4','func5',
} do if #name>0 then t[name]=GC.newQuad((i-1)%5*w,math.floor((i-1)/5)*w,w,w,5*w,7*w) end end
return t
end)(),
gela=(function()
local t={}
local w=180
for i,name in next,{
'moveLeft','moveRight','','softDrop','hardDrop',
'rotateCW','rotateCCW','rotate180','holdPiece','skip',
'','','','','',
'func1','func2','func3','func4','func5',
} do if #name>0 then t[name]=GC.newQuad((i-1)%5*w,math.floor((i-1)/5)*w,w,w,5*w,7*w) end end
return t
end)(),
acry=(function()
local t={}
local w=180
for i,name in next,{
'swapLeft','swapRight','swapUp','swapDown','',
'twistCW','twistCCW','twist180','','skip',
'moveLeft','moveRight','moveUp','moveDown','',
'func1','func2','func3','func4','func5',
} do if #name>0 then t[name]=GC.newQuad((i-1)%5*w,math.floor((i-1)/5)*w,w,w,5*w,7*w) end end
return t
end)(),
sys=(function()
local t={}
local w=180
for i,name in next,{
'','','','','',
'','','','','',
'','','','','',
'','','','','',
'view','restart','back','quit','',
'setting','help','chat','','',
'left','right','up','down','select',
} do if #name>0 then t[name]=GC.newQuad((i-1)%5*w,math.floor((i-1)/5)*w,w,w,5*w,7*w) end end
return t
end)(),
},
title_techmino='assets/image/title_techmino.png',
logo_fmod='assets/image/logo_fmod.png',
-- touhou=(function()
-- local path='assets/image/touhou/'
-- local L={}
-- for _,v in next,love.filesystem.getDirectoryItems(path) do
-- if FILE.isSafe(path..v) then
-- L[tonumber(v:match("%d+"))]=path..v
-- end
-- end
-- return L
-- end)(),
touhou={
orb='assets/image/touhou/orb.png',
},
}
Text=nil ---@type Techmino.I18N
LANG.add{
en='assets/language/lang_en.lua',
it='assets/language/lang_it.lua',
zh='assets/language/lang_zh.lua',
eo='assets/language/lang_eo.lua',
}
LANG.setDefault('en')
function FMODLoadFunc() -- Will be called again when applying advanced options
local memLoad=SETTINGS.system.fmod_loadMemory
local function loadBank(path)
if memLoad then
local bank=FMOD.loadBank2(path)
if bank then return bank end
memLoad=false
SETTINGS.system.fmod_loadMemory=false
MSG.new('other',"Switched to another bank loading mode")
end
return FMOD.loadBank(love.filesystem.getSaveDirectory()..'/'..path)
end
if not (FMOD.C and FMOD.C2) then
MSG.new('error',"FMOD library loaded failed")
return
end
FMOD.init{
maxChannel=math.min(SETTINGS.system.fmod_maxChannel,256),
DSPBufferCount=math.min(SETTINGS.system.fmod_DSPBufferCount,16),
DSPBufferLength=math.min(SETTINGS.system.fmod_DSPBufferLength,65536),
studioFlag=bit.bxor(FMOD.FMOD_STUDIO_INIT_SYNCHRONOUS_UPDATE,FMOD.FMOD_INIT_STREAM_FROM_UPDATE,FMOD.FMOD_INIT_MIX_FROM_UPDATE),
coreFlag=FMOD.FMOD_INIT_NORMAL,
}
local noFile
if not loadBank('soundbank/Master.strings.bank') then
MSG.new('warn',"Strings bank file load failed")
noFile=true
end
if not loadBank('soundbank/Master.bank') then
MSG.new('warn',"Master bank file load failed")
noFile=true
end
FMOD.registerMusic((function()
if not love.filesystem.getInfo('soundbank/Master.bank') then
MSG.new('warn',"Music bank not found")
return {}
end
local L={}
for _,bankName in next,{'Music_Beepbox','Music_FL','Music_Community','Music_Extra'} do
if not love.filesystem.getInfo('soundbank/'..bankName..'.bank') then
MSG.new('warn',bankName.." bank file not found")
noFile=true
else
local bankMusic=loadBank('soundbank/'..bankName..'.bank')
if not bankMusic then
MSG.new('warn',"bank "..bankName.." load failed")
else
local l,c=bankMusic:getEventList()
for i=1,c do
local path=l[i-1]:getPath()
if path then
local name=path:match('/([^/]+)$'):lower()
L[name]=path
if not SONGBOOK[name] then SONGBOOK(name) end
-- print(name,path)
end
end
end
end
end
if noFile then _getLatestBank(2.6) end
-- print("--------------------------")
-- print("Musics")
-- for k,v in next,L do print(k,v)end
-- Music check
local regMore={}
for name in next,SONGBOOK do
if not L[name] then
table.insert(regMore,name)
end
end
if #regMore>0 then
MSG.new('warn',"Music not found in Bank:")
for i=1,#regMore do MSG.new('info',regMore[i]) end
end
return L
end)())
FMOD.registerEffect((function()
if not love.filesystem.getInfo('soundbank/Effect.bank') then
MSG.new('warn',"Effect bank not found")
return {}
end
local bankEffect=loadBank('soundbank/Effect.bank')
if not bankEffect then
MSG.new('warn',"Effect bank file load failed")
return {}
end
local L={}
local nameList={}
local l,c=bankEffect:getEventList()
for i=1,c do
local path=l[i-1]:getPath()
if path then
local name=path:match('/([^/]+)$'):lower()
L[name]=path
if path:find('event:') then
table.insert(nameList,name)
end
-- print(name,path)
end
end
-- print("--------------------------")
-- print("Effects")
-- for k,v in next,L do print(k,v)end
-- SE check
local regList=require'datatable.se_names'
local existMore,regMore=TABLE.copy(nameList),TABLE.copy(regList)
TABLE.subtract(existMore,regList)
TABLE.subtract(regMore,nameList)
if #existMore>0 then
MSG.new('warn',"SE not registered:")
for i=1,#existMore do MSG.new('info',existMore[i]) end
end
if #regMore>0 then
MSG.new('warn',"SE not found in Bank:")
for i=1,#regMore do MSG.new('info',regMore[i]) end
end
return L
end)())
end
-- Hijack the original SFX module, use FMOD instead
SFX[('play')]=function(name,vol,pos,tune)
FMOD.effect(name,{
volume=vol,
tune=tune,
})
end
DEBUG.checkLoadTime("Config Zenitha and Fmod")
--------------------------------------------------------------
-- Load saving data
TABLE.update(SETTINGS,FILE.load('conf/settings','-json -canskip') or {})
for k,v in next,SETTINGS._system do
-- Gurantee triggering all setting-triggers
SETTINGS._system[k]=nil
SETTINGS.system[k]=v
end
if SETTINGS.system.portrait then -- Brute fullscreen config for mobile device
SCR.setSize(1600,2560)
SCR._resize(love.graphics.getWidth(),love.graphics.getHeight())
end
PROGRESS.load()
PROGRESS.fix()
VCTRL.importSettings(FILE.load('conf/touch','-json -canskip'))
KEYMAP.brik=KEYMAP.new{
{act='moveLeft', keys={'left'}},
{act='moveRight',keys={'right'}},
{act='rotateCW', keys={'up'}},
{act='rotateCCW',keys={'down'}},
{act='rotate180',keys={'c'}},
{act='softDrop', keys={'x'}},
{act='hardDrop', keys={'z'}},
{act='holdPiece',keys={'space'}},
{act='skip', keys={'q'}},
{act='func1', keys={'a'}},
{act='func2', keys={'s'}},
{act='func3', keys={'d'}},
{act='func4', keys={'w'}},
{act='func5', keys={'e'}},
}
KEYMAP.gela=KEYMAP.new{
{act='moveLeft', keys={'left'}},
{act='moveRight',keys={'right'}},
{act='rotateCW', keys={'up'}},
{act='rotateCCW',keys={'down'}},
{act='rotate180',keys={'c'}},
{act='softDrop', keys={'x'}},
{act='hardDrop', keys={'z'}},
{act='skip', keys={'q'}},
{act='func1', keys={'a'}},
{act='func2', keys={'s'}},
{act='func3', keys={'d'}},
{act='func4', keys={'w'}},
{act='func5', keys={'e'}},
}
KEYMAP.acry=KEYMAP.new{
{act='swapLeft', keys={'a'}},
{act='swapRight',keys={'d'}},
{act='swapUp', keys={'w'}},
{act='swapDown', keys={'s'}},
{act='twistCW', keys={'e'}},
{act='twistCCW', keys={'q'}},
{act='twist180', keys={'z'}},
{act='moveLeft', keys={'left'}},
{act='moveRight',keys={'right'}},
{act='moveUp', keys={'up'}},
{act='moveDown', keys={'down'}},
{act='skip', keys={'space'}},
{act='func1', keys={'r'}},
{act='func2', keys={'f'}},
{act='func3', keys={'c'}},
{act='func4', keys={'x'}},
{act='func5', keys={'v'}},
}
KEYMAP.sys=KEYMAP.new{
{act='view', keys={'lshift'}},
{act='restart',keys={'r','`'}},
{act='chat', keys={'t'}},
{act='back', keys={'escape'}},
{act='quit', keys={'q'}},
{act='setting',keys={'s'}},
{act='help', keys={'h'}},
{act='left', keys={'left'}},
{act='right', keys={'right'}},
{act='up', keys={'up'}},
{act='down', keys={'down'}},
{act='select', keys={'return'}},
}
local keys=FILE.load('conf/keymap','-json -canskip')
if keys then
KEYMAP.brik:import(keys['brik'])
KEYMAP.gela:import(keys['gela'])
KEYMAP.acry:import(keys['acry'])
KEYMAP.sys:import(keys['sys'])
end
DEBUG.checkLoadTime("Load settings & data")
--------------------------------------------------------------
-- Load SOURCE ONLY resources
---@type table<string, love.Shader>
SHADER={}
for _,v in next,love.filesystem.getDirectoryItems('assets/shader') do
if FILE.isSafe('assets/shader/'..v) then
local name=v:sub(1,-6)
local suc,res=pcall(love.graphics.newShader,'assets/shader/'..name..'.hlsl')
SHADER[name]=suc and res or error("Error in Shader '"..name.."': "..res)
end
end
-- Initialize shader parameters
for k,v in next,{
aura={{'alpha',1.0}},
gaussianBlur={
{'smpCount',10}, -- min(400 * radius, 40)
{'radius',0.026},
},
gaussianSharp={
{'smpCount',10}, -- min(400 * radius, 40)
{'radius',0.026},
{'intensity',1},
},
pixelize={{'size',{100,100}}},
rgb={{'alpha',1.0}},
ripple={
{'wave',{0.01,0.01}},
{'freq',{12,16}},
{'phase',{0,0}},
},
slowPixelize={{'tileSize',0.01}},
} do for i=1,#v do SHADER[k]:send(unpack(v[i])) end end
for _,v in next,love.filesystem.getDirectoryItems('assets/background') do
if FILE.isSafe('assets/background/'..v) and v:sub(-3)=='lua' then
local name=v:sub(1,-5)
BG.add(name,FILE.load('assets/background/'..v,'-lua'))
end
end
for _,v in next,love.filesystem.getDirectoryItems('assets/scene') do
if FILE.isSafe('assets/scene/'..v) then
local sceneName=v:sub(1,-5)
SCN.add(sceneName,FILE.load('assets/scene/'..v,'-lua'))
end
end
for _,v in next,love.filesystem.getDirectoryItems('assets/scene_app') do
if FILE.isSafe('assets/scene_app/'..v) then
local sceneName=v:sub(1,-5)
SCN.add(sceneName,FILE.load('assets/scene_app/'..v,'-lua'))
end
end
for _,v in next,{
'brik_template', -- Shouldn't be used
'brik_plastic',
'brik_interior',
'gela_template', -- Shouldn't be used
'gela_jelly',
'acry_template',
'touhou/brik_reimu',
} do
if FILE.isSafe('assets/skin/'..v..'.lua') then
SKIN.add(v,FILE.load('assets/skin/'..v..'.lua','-lua'))
end
end
SCN.addSwapStyle('fadeHeader',{
duration=.5,
timeChange=.25,
draw=function(t)
local a=t>.25 and 2-t*4 or t*4
local h=120*SCR.k
GC.setColor(.26,.26,.26,a)
GC.rectangle('fill',0,0,SCR.w,h)
GC.setColor(1,1,1,a)
GC.rectangle('fill',0,h,SCR.w,1)
GC.setColor(.1,.1,.1,a)
GC.rectangle('fill',0,h+1,SCR.w,SCR.h-h)
end,
})
SCN.addSwapStyle('fastFadeHeader',{
duration=.2,
timeChange=.1,
draw=function(t)
local a=t>.1 and 2-t*10 or t*10
local h=120*SCR.k
GC.setColor(.26,.26,.26,a)
GC.rectangle('fill',0,0,SCR.w,h)
GC.setColor(1,1,1,a)
GC.rectangle('fill',0,h,SCR.w,1)
GC.setColor(.1,.1,.1,a)
GC.rectangle('fill',0,h+1,SCR.w,SCR.h-h)
end,
})
local _oldLoad=SCN.scenes._console.load
function SCN.scenes._console.load(...)
_oldLoad(...)
local l=SCN.scenes._console.widgetList
l[5].fontType='codepixel'
l[6].fontType='codepixel'
l[5]:reset()
l[6]:reset()
end
do -- Power Manager
local warnThres={-1,2.6,6.26,14.2,26}
local warnCheck=5
TASK.new(function()
while true do
local state,pow=love.system.getPowerInfo()
if not pow then return end
if state=='charging' or state=='charged' then
while warnCheck<5 and pow>warnThres[warnCheck] do
warnCheck=warnCheck+1
end
else
if pow<=warnThres[warnCheck] then
repeat
warnCheck=warnCheck-1
until warnCheck==1 or pow>warnThres[warnCheck]
MSG.new(({'check','error','warn','info'})[warnCheck],Text.batteryWarn[warnCheck])
end
end
TASK.yieldT(6.26)
end
end)
end
FMODLoadFunc()
if tostring(FMOD.studio):find('NULL') then
MSG.new('error',"FMOD initialization failed")
elseif TABLE.getSize(FMOD.banks)==0 then
MSG.new('error',"no FMOD bank files found")
else
FMOD.setMainVolume(SETTINGS.system.mainVol,true)
for name,data in next,SONGBOOK do
local ED=FMOD.music.getDesc(name)
if ED then
if select(2,ED:getParameterDescriptionByName('fade'))~=FMOD.FMOD_OK then
MSG.new('warn',"Missing 'fade' parameter in music '"..name.."'")
end
data.intensity=select(2,ED:getParameterDescriptionByName('intensity'))==FMOD.FMOD_OK
data.section=select(2,ED:getParameterDescriptionByName('section'))==FMOD.FMOD_OK
data.multitrack=select(2,ED:getUserProperty('multitrack'))==FMOD.FMOD_OK
data.looppoint=select(2,ED:getUserProperty('looppoint'))==FMOD.FMOD_OK
if data.section then
local param,res=ED:getUserProperty('maxsection')
if res==FMOD.FMOD_OK then
---@cast param FMOD.Studio.UserProperty
data.maxsection=param.intvalue
else
MSG.new('warn',"Missing 'maxsection' property in music '"..name.."'")
end
end
-- print(name..":")
-- print('itst',data.intensity)
-- print('sect',data.section)
-- print('mult',data.multitrack)
-- print('loop',data.looppoint)
else
data.notFound=true
MSG.new('warn',"Music '"..name.."' not found in FMOD",0)
end
end
end
love.joystick.loadGamepadMappings('datatable/gamecontrollerdb.txt')
DiscordRPC=require'assets.discordRPC'
DiscordRPC.update("Online")
DEBUG.checkLoadTime("Load shaders/BGs/SCNs/skins/FMOD/Managers")
--------------------------------------------------------------
DEBUG.logLoadTime()