forked from FunkinCrew/Funkin
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproject.hxp
More file actions
2609 lines (2186 loc) · 78.4 KB
/
project.hxp
File metadata and controls
2609 lines (2186 loc) · 78.4 KB
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
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
package;
// I don't think we can import `funkin` classes here. Macros? Recursion? IDK.
import hxp.*;
import lime.tools.*;
import sys.FileSystem;
import sys.io.File;
import haxe.io.Bytes;
import haxe.io.Path;
import haxe.ds.Map;
import haxe.xml.Printer;
using StringTools;
using tools.AnsiUtil;
/**
* This HXP performs the functions of a Lime `project.xml` file,
* but it's written in Haxe rather than XML!
*
* This makes it far easier to organize, reuse, and refactor,
* and improves management of feature flag logic.
*/
@:nullSafety
class Project extends HXProject
{
//
// METADATA
//
/**
* The game's version number, as a Semantic Versioning string with no prefix.
* REMEMBER TO CHANGE THIS WHEN THE GAME UPDATES!
* You only have to change it here, the rest of the game will query this value.
*/
static final VERSION:String = "0.8.1";
/**
* The build's number and version code.
* Used when publishing the game to mobile app stores. Should increment with each patch.
*/
static final BUILD_NUMBER:Int = 70;
/**
* The game's name. Used as the default window title.
*/
static final TITLE:String = "Friday Night Funkin'";
/**
* The game's name on mobile. Used as the title for the game on the home screen.
*/
static final TITLE_MOBILE:String = "FNF";
/**
* A package name used for identifying the app on various app stores.
*/
static final PACKAGE_NAME:String = "me.funkin.fnf";
/**
* The name of the generated executable file.
* For example, `"Funkin"` will create a file called `Funkin.exe`.
*/
static final EXECUTABLE_NAME:String = "Funkin";
/**
* The relative location of the source code.
*/
static final SOURCE_DIR:String = "source";
/**
* The relative location of the templates folder.
*/
static final TEMPLATES_DIR:String = "templates";
/**
* The fully qualified class path for the game's preloader.
* Particularly important on HTML5 but we use it on all platforms.
*/
static final PRELOADER:String = "funkin.ui.transition.preload.FunkinPreloader";
/**
* The fully qualified class path for the entry point class to execute when launching the game.
* It's where `public static function main():Void` goes.
*/
static final MAIN_CLASS:String = "Main";
/**
* The company name for the game.
* This appears in metadata in places I think.
*/
static final COMPANY:String = "The Funkin' Crew";
/**
* The app's localization languages.
*/
static final LANGUAGES:Array<String> = ["en"];
/**
* The contents of the user's environment config.
* Read from the local `.env` file. Used for storing API keys.
*/
static var envConfig:Null<Map<String, Dynamic>> = null;
//
// MOBILE METADATA
//
/**
* The app's minimal Android SDK version.
*/
static final ANDROID_MINIMUM_SDK_VERSION:Int = 28;
/**
* The app's target Android SDK version.
*/
static final ANDROID_TARGET_SDK_VERSION:Int = 35;
static final ANDROID_EXTENSIONS:Array<String> = [
"funkin.extensions.CallbackUtil",
"funkin.extensions.FNFCExtension",
"funkin.extensions.AudioSession"
];
/**
* The team ID to use for the iOS app. Configured in XCode.
*/
static var IOS_TEAM_ID:String = "Z7G7AVNGSH";
/**
* A list of asset file globs to exclude from ASTC compression when creating optimized mobile builds.
*/
static var astcExcludes:Array<String> = [];
//
// BUILD SCRIPTS
//
/**
* Path to the Haxe script run before building the game.
*/
static final PREBUILD_HX:String = "source/Prebuild.hx";
/**
* Path to the Haxe script run after building the game.
*/
static final POSTBUILD_HX:String = "source/Postbuild.hx";
//
// ASSET FILTERS
//
/**
* Asset path globs to always exclude from asset libraries.
*/
static final EXCLUDE_ASSETS:Array<String> = [".*", "cvs", "thumbs.db", "desktop.ini", "*.hash", "*.md"];
/**
* Asset path globs to exclude on web platforms.
*/
static final EXCLUDE_ASSETS_WEB:Array<String> = ["*.ogg"];
/**
* Asset path globs to exclude on native platforms.
*/
static final EXCLUDE_ASSETS_NATIVE:Array<String> = ["*.mp3"];
/**
* Asset path globs to exclude on platforms with `CENSOR_EXPLETIVES` enabled.
*/
static final EXCLUDE_ASSETS_CENSORED:Array<String> = ["stressCutscene.mp4", "stressPicoCutscene.mp4", "darnellCutscene.mp4"];
/**
* Asset path globs to exclude on platforms with `CENSOR_EXPLETIVES` disabled.
*/
static final EXCLUDE_ASSETS_UNCENSORED:Array<String> = [
"stressCutscene-censored.mp4",
"stressPicoCutscene-censored.mp4",
"darnellCutscene-censored.mp4"
];
//
// ASSET EMBEDDING
//
/**
* The songs whose audio files should be embedded inside the executable.
*/
static final EMBED_SONGS_AUDIO:Array<String> = [
"spaghetti"
];
//
// BUILD FLAGS
// Inverse build flags are automatically populated.
//
/**
* `-DCENSOR_EXPLETIVES`
* If enabled, specifically disable "sexual explitives" in the game.
* This will forcibly censor these words (even if naughtyness is enabled), while leaving other swears.
*
* NOTE: This is needed because the Android platform specifically hates "fuck" and "cunt",
* but is fine with other naughtyness such as "cock", "asshole", implied sex, cigarettes, etc.
*/
static final CENSOR_EXPLETIVES:FeatureFlag = "CENSOR_EXPLETIVES";
/**
* `-DEMBED_ASSETS`
* Whether to embed all asset libraries into the executable.
* Enabled on web, usually disabled on desktop.
*/
static final EMBED_ASSETS:FeatureFlag = "EMBED_ASSETS";
/**
* `-DEXCLUDE_ARMV7`
* If this flag is enabled, armv7 won't be compiled when building android.
*/
static final EXCLUDE_ARMV7:FeatureFlag = "EXCLUDE_ARMV7";
/**
* `-DGITHUB_BUILD`
* If this flag is enabled, the game will use the configuration used by GitHub Actions
* to generate playtest builds to be pushed to the launcher.
*
* This is generally used to forcibly enable debugging features,
* even when the game is built in release mode for performance.
*/
static final GITHUB_BUILD:FeatureFlag = "GITHUB_BUILD";
/**
* `-DHARDCODED_CREDITS`
* If this flag is enabled, the credits will be parsed and encoded in the game at compile time,
* rather than read from JSON data at runtime.
*/
static final HARDCODED_CREDITS:FeatureFlag = "HARDCODED_CREDITS";
/**
* `-DPRELOAD_ALL`
* Whether to preload all asset libraries.
* Disabled on web, enabled on desktop.
*/
static final PRELOAD_ALL:FeatureFlag = "PRELOAD_ALL";
/**
* `-DREDIRECT_ASSETS_FOLDER`
* If this flag is enabled, the game will redirect the `assets` folder from the `export` folder
* to the `assets` folder at the root of the workspace.
* This is useful for ensuring hot reloaded changes don't get lost when rebuilding the game.
*/
static final REDIRECT_ASSETS_FOLDER:FeatureFlag = "REDIRECT_ASSETS_FOLDER";
/**
* `-DTESTING_ADS`
* If this flag is enabled, mobile advertisements will use testing mode.
*/
static final TESTING_ADS:FeatureFlag = "TESTING_ADS";
/**
* `-DUNLOCK_EVERYTHING`
* If this flag is enabled, the game will assume all songs have been beaten and all content is available.
*/
static final UNLOCK_EVERYTHING:FeatureFlag = "UNLOCK_EVERYTHING";
//
// FEATURE FLAGS
// Inverse build flags are automatically populated.
//
/**
* `-DFEATURE_COMPRESSED_TEXTURES`
* If this flag is enabled, ASTC compressed textures will be used over uncompressed PNGs.
* Compressed ASTC textures provide lower memory usage but at the cost of a slightly higher files size & more GPU usage.
* ASTC textures are GPU Rendered so they have a few cons:
* - Pixel Data of bitmaps cannot be read nor edited directly.
* - Some filters specifically the ones in openfl.filters package won't work properly because they directly modify the bitmap pixels.
* - ASync loading for GPU Compressed Textures doesn't work due to OpenGL being single-threaded. (Looking online there seem to be some workarounds but it's pretty complicated...).
* One thing to note is that ASTC textures aren't available on all platforms:
* - For iOS, it's available starting from phones with A8 chips, so anything from iPhone 6 and beyond has it.
* - For Android, it's sorta mixed, but mostly any mid range phone that came after 2017 does support ASTC.
* - For desktop, it appears to be only supported on Intergrated Graphics from our testing.
*/
static final FEATURE_COMPRESSED_TEXTURES:FeatureFlag = "FEATURE_COMPRESSED_TEXTURES";
/**
* `-DFEATURE_DEBUG_FUNCTIONS`
* If this flag is enabled, the game will have all playtester-only debugging functionality enabled.
* This includes debug hotkeys like time travel in the Play State.
* By default, enabled on debug builds or playtester builds and disabled on release builds.
*/
static final FEATURE_DEBUG_FUNCTIONS:FeatureFlag = "FEATURE_DEBUG_FUNCTIONS";
/**
* `-DFEATURE_RESULTS_DEBUG`
* If this flag is enabled, a debug menu for Results screen will be accessible from the debug menu.
*/
static final FEATURE_RESULTS_DEBUG:FeatureFlag = "FEATURE_RESULTS_DEBUG";
/**
* `-DFEATURE_DEBUG_TRACY`
* If this flag is enabled, the game will have the necessary hooks for the Tracy profiler.
* Only enable this if you're using the correct fork of Haxe to support this.
* @see https://github.com/HaxeFoundation/hxcpp/pull/1153
*/
static final FEATURE_DEBUG_TRACY:FeatureFlag = "FEATURE_DEBUG_TRACY";
/**
* `-DFEATURE_DISCORD_RPC`
* If this flag is enabled, the game will enable the Discord Remote Procedure Call library.
* This is used to provide Discord Rich Presence support.
*/
static final FEATURE_DISCORD_RPC:FeatureFlag = "FEATURE_DISCORD_RPC";
/**
* `-DFEATURE_LOST_FOCUS_VOLUME`
* If this flag is enabled, the game will reduce application volume, when lost focus.
* Allowed only on Desktop targets.
*/
static final FEATURE_LOST_FOCUS_VOLUME:FeatureFlag = "FEATURE_LOST_FOCUS_VOLUME";
/**
* `-DFEATURE_FILE_DROP`
* If this flag is enabled, the game will support dragging and dropping files onto it for various features.
* Disabled on MacOS.
*/
static final FEATURE_FILE_DROP:FeatureFlag = "FEATURE_FILE_DROP";
/**
* `-DFEATURE_FUNKVIS`
* If this flag is enabled, the game will enable the Funkin Visualizer library.
* This is used to provide audio visualization like Nene's speaker.
* Disabling this will make some waveforms inactive.
*/
static final FEATURE_FUNKVIS:FeatureFlag = "FEATURE_FUNKVIS";
/**
* `-DFEATURE_GHOST_TAPPING`
* If this flag is enabled, misses will not be counted when it is not the player's turn.
* Misses are still counted when the player has notes to hit.
*/
static final FEATURE_GHOST_TAPPING:FeatureFlag = "FEATURE_GHOST_TAPPING";
/**
* `-DFEATURE_HAPTICS`
* If this flag is enabled, the game provide haptic feedback vibrations.
* Works for mobile targets (Android and iOS).
*/
static final FEATURE_HAPTICS:FeatureFlag = "FEATURE_HAPTICS";
/**
* `-DFEATURE_LAG_ADJUSTMENT`
* If this flag is enabled, the input offsets menu will be available to configure your audio and visual offsets.
*/
static final FEATURE_LAG_ADJUSTMENT:FeatureFlag = "FEATURE_LAG_ADJUSTMENT";
/**
* `-DFEATURE_LOG_TRACE`
* If this flag is enabled, the game will print debug traces to the console.
* Disable to improve performance a bunch.
*/
static final FEATURE_LOG_TRACE:FeatureFlag = "FEATURE_LOG_TRACE";
/**
* `-DFEATURE_DEBUG_FILE_LOGGING`
* If this flag is enabled, the game will print debug traces to a log file near the game's executable.
* Disable to improve performance a bunch.
*/
static final FEATURE_DEBUG_FILE_LOGGING:FeatureFlag = "FEATURE_DEBUG_FILE_LOGGING";
/**
* `-DFEATURE_MOBILE_ADVERTISEMENTS`
* If this flag is enabled, Google AdMob will be enabled.
* Banner and interstitial ads will sometimes appear.
*/
static final FEATURE_MOBILE_ADVERTISEMENTS:FeatureFlag = "FEATURE_MOBILE_ADVERTISEMENTS";
/**
* `-DFEATURE_MOBILE_IAP`
* If this flag is enabled, in-app purchases will be enabled.
* This includes the in-app purchase to disable mobile advertisements.
*/
static final FEATURE_MOBILE_IAP:FeatureFlag = "FEATURE_MOBILE_IAP";
/**
* `-DFEATURE_MOBILE_IAR`
* If this feature flag is enabled, the user may sometimes be prompted to review the app on their respective store.
*/
static final FEATURE_MOBILE_IAR:FeatureFlag = "FEATURE_MOBILE_IAR";
/**
* `-DFEATURE_MOBILE_WEBVIEW`
* If this feature flag is enabled, the user may sometimes be prompted to review the app on their respective store.
*/
static final FEATURE_MOBILE_WEBVIEW:FeatureFlag = "FEATURE_MOBILE_WEBVIEW";
/**
* `-DFEATURE_NAUGHTYNESS`
* If this feature flag is enabled, naughtyness will be a toggleable option in the Options Menu.
* If disabled, the option will be hidden and the game will always be censored.
*/
static final FEATURE_NAUGHTYNESS:FeatureFlag = "FEATURE_NAUGHTYNESS";
/**
* `-DFEATURE_NEWGROUNDS`
* If this flag is enabled, the game will enable the Newgrounds library.
* This is used to provide Medal and Leaderboard support.
*/
static final FEATURE_NEWGROUNDS:FeatureFlag = "FEATURE_NEWGROUNDS";
/**
* `-DFEATURE_NEWGROUNDS_AUTOLOGIN`
* If this flag is enabled, the game will attempt to automatically login to Newgrounds on startup.
*/
static final FEATURE_NEWGROUNDS_AUTOLOGIN:FeatureFlag = "FEATURE_NEWGROUNDS_AUTOLOGIN";
/**
* `-DFEATURE_NEWGROUNDS_DEBUG`
* If this flag is enabled, the game will enable Newgrounds.io's debug functions.
* This provides additional information in requests, as well as "faking" medal and leaderboard submissions.
*/
static final FEATURE_NEWGROUNDS_DEBUG:FeatureFlag = "FEATURE_NEWGROUNDS_DEBUG";
/**
* `-DFEATURE_NEWGROUNDS_EVENTS`
* If this flag is enabled, the game will attempt to send events to Newgrounds when the user does stuff.
* This lets us see cool anonymized stats! It only works if the user is logged in.
*/
static final FEATURE_NEWGROUNDS_EVENTS:FeatureFlag = "FEATURE_NEWGROUNDS_EVENTS";
/**
* `-DFEATURE_NEWGROUNDS_TESTING_MEDALS`
* If this flag is enabled, use the medal IDs from the debug test bench.
* If disabled, use the actual medal IDs from the release project on Newgrounds.
*/
static final FEATURE_NEWGROUNDS_TESTING_MEDALS:FeatureFlag = "FEATURE_NEWGROUNDS_TESTING_MEDALS";
/**
* `-DFEATURE_OPEN_URL`
* If this flag is enabled, the game will support opening URLs (such as the merch page).
*/
static final FEATURE_OPEN_URL:FeatureFlag = "FEATURE_OPEN_URL";
/**
* `-DFEATURE_PARTIAL_SOUNDS`
* If this flag is enabled, the game will enable the FlxPartialSound library.
* This is used to provide audio previews in Freeplay.
* Disabling this will make those previews not play.
*/
static final FEATURE_PARTIAL_SOUNDS:FeatureFlag = "FEATURE_PARTIAL_SOUNDS";
/**
* `-DFEATURE_POLYMOD_MODS`
* If this flag is enabled, the game will enable the Polymod library's support for atomic mod loading from the `./mods` folder.
* If this flag is disabled, no mods will be loaded.
*/
static final FEATURE_POLYMOD_MODS:FeatureFlag = "FEATURE_POLYMOD_MODS";
/**
* `-DFEATURE_SCREENSHOTS`
* If this flag is enabled, the game will support the screenshots feature.
*/
static final FEATURE_SCREENSHOTS:FeatureFlag = "FEATURE_SCREENSHOTS";
/**
* `-DFEATURE_HAXEUI`
* If this flag is enabled, the game will enable the HaxeUI interface layer.
* This can be used to provide menus, dialogs, and other UI components via HaxeUI.
*/
static final FEATURE_HAXEUI:FeatureFlag = "FEATURE_HAXEUI";
/**
* `-FEATURE_DEBUG_MENU`
* If this flag is enabled, a debug menu will be accessible.
*/
static final FEATURE_DEBUG_MENU:FeatureFlag = "FEATURE_DEBUG_MENU";
/**
* `-FEATURE_ANIMATION_EDITOR`
* If this flag is enabled, the Animation Editor will be accessible from the debug menu.
*/
static final FEATURE_ANIMATION_EDITOR:FeatureFlag = "FEATURE_ANIMATION_EDITOR";
/**
* `-DFEATURE_CHART_EDITOR`
* If this flag is enabled, the Chart Editor will be accessible from the debug menu.
*/
static final FEATURE_CHART_EDITOR:FeatureFlag = "FEATURE_CHART_EDITOR";
/**
* `-DFEATURE_STAGE_EDITOR`
* If this flag is enabled, the Stage Editor will be accessible from the debug menu.
*/
static final FEATURE_STAGE_EDITOR:FeatureFlag = "FEATURE_STAGE_EDITOR";
/**
* `-DFEATURE_TOUCH_CONTROLS`
* If this flag is enabled, the touch controls for the game is also enabled.
* Works with desktop builds I think maybe?
*/
static final FEATURE_TOUCH_CONTROLS:FeatureFlag = "FEATURE_TOUCH_CONTROLS";
/**
* `-DFEATURE_TOUCH_HERE_TO_PLAY`
* If this flag is enabled, the game will display a prompt to the user after the preloader completes,
* requiring them to click anywhere on the screen to start the game.
* This is done to ensure that the audio context can initialize properly on HTML5. Not necessary on desktop.
*/
static final FEATURE_TOUCH_HERE_TO_PLAY:FeatureFlag = "FEATURE_TOUCH_HERE_TO_PLAY";
/**
* `-DFEATURE_VIDEO_PLAYBACK`
* If this flag is enabled, the game will enable support for video playback.
* This requires the hxvlc library on desktop platforms.
*/
static final FEATURE_VIDEO_PLAYBACK:FeatureFlag = "FEATURE_VIDEO_PLAYBACK";
/**
* `-DFEATURE_VIDEO_SUBTITLES`
* If this flag is enabled, the game will be able to show subtitles on video cutscenes.
* This requires the hxvlc library on desktop platforms.
*/
static final FEATURE_VIDEO_SUBTITLES:FeatureFlag = "FEATURE_VIDEO_SUBTITLES";
/**
* `-DFEATURE_DEBUG_DISPLAY`
* If this flag is enabled, the game will be able to show a framerate counter with the memory and current FPS
* This flag is disabled on non debug mobile builds
*/
static final FEATURE_DEBUG_DISPLAY:FeatureFlag = "FEATURE_DEBUG_DISPLAY";
//
// CONFIGURATION FUNCTIONS
//
public function new()
{
super();
envConfig = readEnvironmentFile("./.env");
flair();
configureApp();
displayTarget();
configureFeatureFlags();
configureCompileDefines();
configureIncludeMacros();
configureCustomMacros();
configureOutputDir();
configurePolymod();
configureHaxelibs();
configureASTCTextures();
configureAssets();
if (!isLinux())
{
configureIcons();
}
if (FEATURE_MOBILE_ADVERTISEMENTS.isEnabled(this))
{
configureAdMobKeys();
}
if (isAndroid())
{
configureAndroid();
}
if (isIOS())
{
configureIOS();
}
if (isCPP())
{
buildHxCppTools();
}
if (!isDisplay())
{
checkLibraries();
}
}
/**
* Do something before building, display some ASCII or something IDK
*/
function flair()
{
// TODO: Implement this.
info("Friday Night Funkin' - " + VERSION);
info("Initializing build...");
info("Git Branch: " + getGitBranch());
info("Git Commit: " + getGitCommit());
info("Git Modified? " + getGitModified());
info("Display? " + isDisplay());
}
/**
* Apply basic project metadata, such as the game title and version number,
* as well as info like the package name and company (used by various app stores).
*/
function configureApp()
{
this.meta.title = isMobile() ? TITLE_MOBILE : TITLE;
// ios uses this character code instead of spaces...
// We don't have spaces in our title for mobile anymore
// But keeping incase anybody source-modding ever does add spaces
if (isIOS()) this.meta.title = ~/ /ig.replace(TITLE_MOBILE, "\u2002");
this.meta.version = VERSION;
this.meta.packageName = PACKAGE_NAME;
this.meta.company = COMPANY;
this.app.main = MAIN_CLASS;
this.app.file = EXECUTABLE_NAME;
this.app.preloader = PRELOADER;
// Tell Lime where to look for the game's source code.
// If for some reason we have multiple source directories, we can add more entries here.
this.sources.push(SOURCE_DIR);
// Templates stuff
this.templatePaths.push(TEMPLATES_DIR);
// Tell Lime to run some prebuild and postbuild scripts.
this.preBuildCallbacks.push(buildHaxeCLICommand(PREBUILD_HX));
this.postBuildCallbacks.push(buildHaxeCLICommand(POSTBUILD_HX));
// set the app' local languages.
this.languages = LANGUAGES;
// Set the build number, required for publishing the game to mobile stores.
this.meta.buildNumber = Std.string(BUILD_NUMBER);
// These values are only used by the SWF target I think.
// this.app.path
// this.app.init
// this.app.swfVersion
// this.app.url
// These values are only used by... FIREFOX MARKETPLACE WHAT?
// this.meta.description = "";
// this.meta.companyId = COMPANY;
// this.meta.companyUrl = COMPANY;
// Configure the window.
// Automatically configure FPS.
this.window.fps = 60;
// Set the window size.
this.window.width = 1280;
this.window.height = 720;
// Black background on release builds, magenta on debug builds.
this.window.background = FEATURE_DEBUG_FUNCTIONS.isEnabled(this) ? 0xFFFF00FF : 0xFF000000;
this.window.hardware = true;
this.window.vsync = false;
// force / allow high DPI
this.window.allowHighDPI = true;
if (isWeb())
{
this.window.resizable = true;
}
if (isDesktop())
{
this.window.orientation = Orientation.LANDSCAPE;
this.window.fullscreen = false;
this.window.resizable = true;
this.window.vsync = false;
}
if (isMobile())
{
this.window.orientation = Orientation.LANDSCAPE;
this.window.fullscreen = true;
this.window.resizable = false;
this.window.borderless = true;
this.window.width = 0;
this.window.height = 0;
}
if (isAndroid())
{
if (EXCLUDE_ARMV7.isEnabled(this))
{
this.excludeArchitectures.push(Architecture.ARMV7);
}
config.set("android.minimum-sdk-version", ANDROID_MINIMUM_SDK_VERSION);
config.set("android.target-sdk-version", ANDROID_TARGET_SDK_VERSION);
}
}
/**
* Log information about the configured target platform.
*/
function displayTarget()
{
// Display the target operating system.
switch (this.target)
{
case Platform.WINDOWS:
info('Target Platform: Windows');
case Platform.MAC:
info('Target Platform: MacOS');
case Platform.LINUX:
info('Target Platform: Linux');
case Platform.ANDROID:
info('Target Platform: Android');
case Platform.IOS:
info('Target Platform: IOS');
case Platform.HTML5:
info('Target Platform: HTML5');
// See lime.tools.Platform for a full list.
// case Platform.EMSCRITEN: // A WebAssembly build might be interesting...
// case Platform.AIR:
// case Platform.BLACKBERRY:
// case Platform.CONSOLE_PC:
// case Platform.FIREFOX:
// case Platform.FLASH:
// case Platform.PS3:
// case Platform.PS4:
// case Platform.TIZEN:
// case Platform.TVOS:
// case Platform.VITA:
// case Platform.WEBOS:
// case Platform.WIIU:
// case Platform.XBOX1:
default:
error('Unsupported platform (got ${target})');
}
switch (this.platformType)
{
case PlatformType.DESKTOP:
info('Platform Type: Desktop');
case PlatformType.MOBILE:
info('Platform Type: Mobile');
case PlatformType.WEB:
info('Platform Type: Web');
case PlatformType.CONSOLE:
info('Platform Type: Console');
default:
error('Unknown platform type (got ${platformType})');
}
// Print whether we are using HXCPP, HashLink, or something else.
if (isWeb())
{
info('Target Language: JavaScript (HTML5)');
}
else if (isHashLink())
{
info('Target Language: HashLink');
}
else if (isNeko())
{
info('Target Language: Neko');
}
else if (isJava())
{
info('Target Language: Java');
}
else if (isNodeJS())
{
info('Target Language: JavaScript (NodeJS)');
}
else if (isCSharp())
{
info('Target Language: C#');
}
else if (isCPP())
{
info('Target Language: C++');
}
else
{
error('Unsupported target language!');
}
for (arch in this.architectures)
{
// Display the list of target architectures.
switch (arch)
{
case Architecture.X86:
info('Architecture: x86');
case Architecture.X64:
info('Architecture: x64');
case Architecture.ARMV5:
info('Architecture: ARMv5');
case Architecture.ARMV6:
info('Architecture: ARMv6');
case Architecture.ARMV7:
info('Architecture: ARMv7');
case Architecture.ARMV7S:
info('Architecture: ARMv7S');
case Architecture.ARM64:
info('Architecture: ARMx64');
case Architecture.MIPS:
info('Architecture: MIPS');
case Architecture.MIPSEL:
info('Architecture: MIPSEL');
case null:
if (!isWeb())
{
error('Unsupported architecture (got null on non-web platform)');
}
else
{
info('Architecture: Web');
}
default:
error('Unsupported architecture (got ${arch})');
}
}
}
/**
* Apply various feature flags based on the target platform and the user-provided build flags.
*/
function configureFeatureFlags()
{
// You can explicitly override any of these.
// For example, `-DGITHUB_BUILD` or `-DNO_HARDCODED_CREDITS`
//
// BUILD FLAGS
//
// Should be false unless explicitly requested.
GITHUB_BUILD.apply(this, false);
EXCLUDE_ARMV7.apply(this, false);
// Should be true unless explicitly requested.
HARDCODED_CREDITS.apply(this, true);
UNLOCK_EVERYTHING.apply(this, true);
// Should be true only on web builds.
// Enabling embedding and preloading is required to preload assets properly.
EMBED_ASSETS.apply(this, isWeb());
PRELOAD_ALL.apply(this, !isWeb());
// Should default to true on workspace builds and false on release builds.
REDIRECT_ASSETS_FOLDER.apply(this, isDebug() && isDesktop());
// Should be true only on debug mobile builds.
TESTING_ADS.apply(this, isDebug() && FEATURE_MOBILE_ADVERTISEMENTS.isEnabled(this));
// Should be true on mobile builds.
CENSOR_EXPLETIVES.apply(this, isMobile());
//
// FEATURE FLAGS
//
// Should be true on debug builds or if GITHUB_BUILD is enabled.
FEATURE_DEBUG_FUNCTIONS.apply(this, isDebug() || GITHUB_BUILD.isEnabled(this));
FEATURE_RESULTS_DEBUG.apply(this, isDebug() || GITHUB_BUILD.isEnabled(this));
FEATURE_FUNKVIS.apply(this, true);
FEATURE_LOG_TRACE.apply(this, true);
FEATURE_DEBUG_FILE_LOGGING.apply(this, FEATURE_DEBUG_FUNCTIONS.isEnabled(this));
FEATURE_NAUGHTYNESS.apply(this, true);
FEATURE_OPEN_URL.apply(this, true);
FEATURE_PARTIAL_SOUNDS.apply(this, true);
FEATURE_POLYMOD_MODS.apply(this, true);
// Video playback should be enabled on desktop, web, and mobile.
// HXCPP has trouble with iOS simulator builds though...
FEATURE_VIDEO_PLAYBACK.apply(this, !(isIOSSimulator() || isHashLink()));
// Video subtitles only work via using hxvlc.
FEATURE_VIDEO_SUBTITLES.apply(this, FEATURE_VIDEO_PLAYBACK.isEnabled(this) && !isWeb());
// Should be true on debug builds or if GITHUB_BUILD is enabled.
FEATURE_DEBUG_FUNCTIONS.apply(this, isDebug() || GITHUB_BUILD.isEnabled(this));
FEATURE_RESULTS_DEBUG.apply(this, isDebug() || GITHUB_BUILD.isEnabled(this));
// Should be true on desktop, non-tester builds.
// We don't want testers to accidentally leak songs to their Discord friends!
FEATURE_DISCORD_RPC.apply(this, isDesktop() && !FEATURE_DEBUG_FUNCTIONS.isEnabled(this));
FEATURE_LOST_FOCUS_VOLUME.apply(this, isDesktop());
// Newgrounds features
FEATURE_NEWGROUNDS.apply(this, true);
FEATURE_NEWGROUNDS_DEBUG.apply(this, false);
FEATURE_NEWGROUNDS_TESTING_MEDALS.apply(this, FEATURE_NEWGROUNDS.isEnabled(this) && FEATURE_DEBUG_FUNCTIONS.isEnabled(this));
FEATURE_NEWGROUNDS_AUTOLOGIN.apply(this, FEATURE_NEWGROUNDS.isEnabled(this) && isWeb());
FEATURE_NEWGROUNDS_EVENTS.apply(this, FEATURE_NEWGROUNDS.isEnabled(this));
// Should be true except on web and mobile builds.
// Debug editors aren't built to work on web or mobile right now.
FEATURE_DEBUG_MENU.apply(this, !(isWeb() || isMobile()));
FEATURE_ANIMATION_EDITOR.apply(this, !(isWeb() || isMobile()));
FEATURE_CHART_EDITOR.apply(this, !(isWeb() || isMobile()));
FEATURE_STAGE_EDITOR.apply(this, !(isWeb() || isMobile()));
FEATURE_HAXEUI.apply(this, FEATURE_ANIMATION_EDITOR.isEnabled(this)
|| FEATURE_CHART_EDITOR.isEnabled(this)
|| FEATURE_STAGE_EDITOR.isEnabled(this));
// Should be true except on web builds (some asset stuff breaks it)
FEATURE_LAG_ADJUSTMENT.apply(this, !isWeb());
// Should be true except on web and mobile builds.
// Screenshots doesn't work there, and mobile has its own screenshots anyway.
FEATURE_SCREENSHOTS.apply(this, !(isWeb() || isMobile()));
// Should be true except on MacOS and mobile builds.
// Dragging and dropping files onto the window doesn't work there.
FEATURE_FILE_DROP.apply(this, !(isMac() || isMobile()));
// Audio context issues only exist on web builds.
FEATURE_TOUCH_HERE_TO_PLAY.apply(this, isWeb());
// Should be true only on mobile builds.
FEATURE_HAPTICS.apply(this, isMobile());
FEATURE_TOUCH_CONTROLS.apply(this, isMobile());
// Should be true only on mobile release builds. Remember you can add the flag manually for testing.
FEATURE_MOBILE_ADVERTISEMENTS.apply(this, (isMobile() && isRelease() && !isIOSSimulator()) && envConfig != null);
FEATURE_MOBILE_IAP.apply(this, (isMobile() && isRelease() && !isIOSSimulator()) && envConfig != null);
FEATURE_MOBILE_IAR.apply(this, isMobile() && isRelease() && !isIOSSimulator());
FEATURE_MOBILE_WEBVIEW.apply(this, isMobile() && FEATURE_NEWGROUNDS.isEnabled(this));
// The coveted ghost tapping feature.
// Essential on mobile but delayed on desktop.
// Please send targeted harassment to PhantomArcade about this.
FEATURE_GHOST_TAPPING.apply(this, isMobile());
// Enable ASTC Compressed textures for mobile.
// Since mobile is pretty memory safe (I'm looking at you Apple...) we need them BADLY to have the game run properly.
// It's kept off for desktop due to the low ASTC support on desktop GPUs (which seem to be only among Intergrated Graphics).
FEATURE_COMPRESSED_TEXTURES.apply(this, isMobile() && isRelease() && !isIOSSimulator());
// Turns the debug display off if you are on a non debug mobile build
// Desktop (Native and Web) always has it | Used for mobile debugging purposes
FEATURE_DEBUG_DISPLAY.apply(this, !isMobile() || FEATURE_DEBUG_FUNCTIONS.isEnabled(this));
renderFlagsTable();
}
/**
* Renders a cute little table of which feature flags are enabled and which are disabled
*/
function renderFlagsTable():Void
{
var enabledWidth:Int = 0;
var disabledWidth:Int = 0;
var enabledFlags:Array<String> = [];
var disabledFlags:Array<String> = [];
var unicodeCheck:String = "✓ ";
var unicodeCross:String = "× ";
if (isWindowsHost())
{
#if (!target.unicode)
// lime build tools uses neko (unless compiling with `-eval`), and neko on windows doesn't support UTF8/unicode characters
// so we need to remove our cute emoji!
unicodeCheck = "o ";
unicodeCross = "x ";
#end
}
for (flagStr in this.haxedefs.keys())
{
if (!flagStr.startsWith(FeatureFlag.INVERSE_PREFIX))
{
// we do flagStr.length + 3 to accomodate for adding the "✓ " at the beginning
enabledWidth = Std.int(Math.max(flagStr.length + 3, enabledWidth));
enabledFlags.push(unicodeCheck + flagStr);
}
else
{
disabledWidth = Std.int(Math.max(flagStr.length, disabledWidth));
disabledFlags.push(unicodeCross + flagStr.substring(FeatureFlag.INVERSE_PREFIX.length));
}
}
enabledFlags.sort(function(a, b) return a > b ? 1 : -1);
disabledFlags.sort(function(a, b) return a > b ? 1 : -1);
var horizontalDivider:String = "".rpad("-", enabledWidth + disabledWidth);
info(horizontalDivider);
// Header
info("FEATURE FLAGS");
info('Enabled Flags $unicodeCheck'.rpad(" ", enabledWidth + 5) + 'Disabled Flags $unicodeCross');
info(horizontalDivider);
while (enabledFlags.length > 0 || disabledFlags.length > 0)
{
var outputLine:String = "";