Skip to content

Commit 20b5079

Browse files
authored
Merge branch 'develop' into album-stickers-metadata
2 parents 3d67196 + 2ad5933 commit 20b5079

23 files changed

+335
-120
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ shitAudio/
1313
.swp
1414
NewgroundsCredentials.hx
1515

16+
# Exclude IntelliJ IDEA stuff
17+
.idea/
18+
*.iml
19+
1620
# Mobile signing stuff
1721
.apple/
1822
.env

hmm.json

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -123,10 +123,8 @@
123123
},
124124
{
125125
"name": "hxdiscord_rpc",
126-
"type": "git",
127-
"dir": null,
128-
"ref": "82c47ecc1a454b7dd644e4fcac7e91155f176dec",
129-
"url": "https://github.com/FunkinCrew/hxdiscord_rpc"
126+
"type": "haxelib",
127+
"version": "1.3.0"
130128
},
131129
{
132130
"name": "hxjsonast",
@@ -154,7 +152,7 @@
154152
"name": "json2object",
155153
"type": "git",
156154
"dir": null,
157-
"ref": "589cad78fe2ff91eb3253a673071293ba0233c2c",
155+
"ref": "a7e4cef3d444bea8d8244d6e59ab82f5a593f597",
158156
"url": "https://github.com/FunkinCrew/json2object"
159157
},
160158
{

project.hxp

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -493,6 +493,13 @@ class Project extends HXProject
493493
*/
494494
static final FEATURE_VIDEO_SUBTITLES:FeatureFlag = "FEATURE_VIDEO_SUBTITLES";
495495

496+
/**
497+
* `-DFEATURE_DEBUG_DISPLAY`
498+
* If this flag is enabled, the game will be able to show a framerate counter with the memory and current FPS
499+
* This flag is disabled on non debug mobile builds
500+
*/
501+
static final FEATURE_DEBUG_DISPLAY:FeatureFlag = "FEATURE_DEBUG_DISPLAY";
502+
496503
//
497504
// CONFIGURATION FUNCTIONS
498505
//
@@ -892,6 +899,10 @@ class Project extends HXProject
892899
// It's kept off for desktop due to the low ASTC support on desktop GPUs (which seem to be only among Intergrated Graphics).
893900
FEATURE_COMPRESSED_TEXTURES.apply(this, isMobile() && isRelease() && !isIOSSimulator());
894901

902+
// Turns the debug display off if you are on a non debug mobile build
903+
// Desktop (Native and Web) always has it | Used for mobile debugging purposes
904+
FEATURE_DEBUG_DISPLAY.apply(this, !isMobile() || FEATURE_DEBUG_FUNCTIONS.isEnabled(this));
905+
895906
renderFlagsTable();
896907
}
897908

@@ -1385,6 +1396,11 @@ class Project extends HXProject
13851396
addAssetLibrary("default", shouldEmbed, shouldPreloadDefault);
13861397
addAssetPath("assets/preload", "assets", "default", ["*"], exclude, shouldEmbed, "assets");
13871398

1399+
if (!HARDCODED_CREDITS.isEnabled(this))
1400+
{
1401+
addAsset("assets/exclude/data/credits.json", "assets/data/credits.json", "default", shouldEmbed);
1402+
}
1403+
13881404
if (!FEATURE_ANIMATION_EDITOR.isEnabled(this))
13891405
removeAssetPath('assets/preload/data/ui/animation-editor', "default");
13901406

@@ -1457,13 +1473,21 @@ class Project extends HXProject
14571473
var basePath:String = Path.join([exportPath, platform, "bin"]);
14581474
var assetsPath:String = "";
14591475

1460-
if (isMacHost())
1476+
switch(platformType)
14611477
{
1462-
assetsPath = Path.join([basePath, '${this.app.file}.app', "Contents", "Resources", "assets"]);
1463-
}
1464-
else
1465-
{
1466-
assetsPath = Path.join([basePath, "assets"]);
1478+
case PlatformType.DESKTOP:
1479+
if (isMacHost())
1480+
{
1481+
assetsPath = Path.join([basePath, '${this.app.file}.app', "Contents", "Resources", "assets"]);
1482+
}
1483+
else
1484+
{
1485+
assetsPath = Path.join([basePath, "assets"]);
1486+
}
1487+
1488+
default:
1489+
// Don't do this for other platform types yet.
1490+
return;
14671491
}
14681492

14691493
if (sys.FileSystem.exists(assetsPath))

source/funkin/InitState.hx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,11 @@ class InitState extends FlxState
402402
}
403403
else if (params.song.shouldLoadSong && params.song.songPath != null)
404404
{
405+
#if sys
405406
FlxG.switchState(() -> new ChartPlaytestMenu(params.song.songPath));
407+
#else
408+
FlxG.switchState(() -> new TitleState());
409+
#end
406410
}
407411
else
408412
{

source/funkin/Preferences.hx

Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -137,14 +137,14 @@ class Preferences
137137

138138
/**
139139
* If enabled, an FPS and memory counter will be displayed even if this is not a debug build.
140-
* Always disabled on mobile.
140+
* Always disabled on release mobile builds.
141141
* @default `Off`
142142
*/
143143
public static var debugDisplay(get, set):DebugDisplayMode;
144144

145145
static function get_debugDisplay():DebugDisplayMode
146146
{
147-
#if mobile
147+
#if NO_FEATURE_DEBUG_DISPLAY
148148
return DebugDisplayMode.Off;
149149
#end
150150

@@ -267,27 +267,6 @@ class Preferences
267267
return value;
268268
}
269269

270-
#if FEATURE_VIDEO_SUBTITLES
271-
/**
272-
* If enabled, subtitles will be shown on video cutscenes.
273-
* @default `true`
274-
*/
275-
public static var videoSubtitles(get, set):Bool;
276-
277-
static function get_videoSubtitles():Bool
278-
{
279-
return Save?.instance?.options?.videoSubtitles ?? true;
280-
}
281-
282-
static function set_videoSubtitles(value:Bool):Bool
283-
{
284-
var save:Save = Save.instance;
285-
save.options.videoSubtitles = value;
286-
save.flush();
287-
return value;
288-
}
289-
#end
290-
291270
/**
292271
* If enabled, the game will automatically launch in fullscreen on startup.
293272
* @default `true`
@@ -541,6 +520,25 @@ class Preferences
541520
Main.debugDisplay.backgroundOpacity = value;
542521
}
543522

523+
/**
524+
* If enabled, subtitles will appear during some songs and cutscenes.
525+
* @default `true`
526+
*/
527+
public static var subtitles(get, set):Bool;
528+
529+
static function get_subtitles():Bool
530+
{
531+
return Save?.instance?.options?.subtitles ?? true;
532+
}
533+
534+
static function set_subtitles(value:Bool):Bool
535+
{
536+
var save:Save = Save.instance;
537+
save.options.subtitles = value;
538+
save.flush();
539+
return value;
540+
}
541+
544542
#if mobile
545543
/**
546544
* If enabled, device will be able to sleep on its own.

source/funkin/api/discord/DiscordClient.hx

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class DiscordClient
3131
{
3232
trace('[DISCORD] Initializing event handlers...');
3333

34-
handlers = DiscordEventHandlers.create();
34+
handlers = new DiscordEventHandlers();
3535

3636
handlers.ready = cpp.Function.fromStaticFunction(onReady);
3737
handlers.disconnected = cpp.Function.fromStaticFunction(onDisconnected);
@@ -50,7 +50,7 @@ class DiscordClient
5050

5151
@:nullSafety(Off)
5252
{
53-
Discord.Initialize(DISCORD_CLIENT_ID, cpp.RawPointer.addressOf(handlers), 1, "");
53+
Discord.Initialize(DISCORD_CLIENT_ID, cpp.RawPointer.addressOf(handlers), false, "");
5454
}
5555

5656
createDaemon();
@@ -79,7 +79,7 @@ class DiscordClient
7979
Discord.updateConnection();
8080
#end
8181

82-
Discord.runCallbacks();
82+
Discord.RunCallbacks();
8383
Sys.sleep(2);
8484
}
8585
}
@@ -88,17 +88,12 @@ class DiscordClient
8888
{
8989
trace('[DISCORD] Shutting down...');
9090

91-
Discord.shutdown();
91+
Discord.Shutdown();
9292
}
9393

9494
public function setPresence(params:DiscordClientPresenceParams):Void
9595
{
96-
Discord.updatePresence(buildPresence(params));
97-
}
98-
99-
function buildPresence(params:DiscordClientPresenceParams):DiscordRichPresence
100-
{
101-
var presence = DiscordRichPresence.create();
96+
var presence:DiscordRichPresence = new DiscordRichPresence();
10297

10398
// Presence should always be playing the game.
10499
presence.type = DiscordActivityType_Playing;
@@ -129,17 +124,17 @@ class DiscordClient
129124
// presence.startTimestamp = time - 10;
130125
// presence.endTimestamp = time + 30;
131126

132-
final button1:DiscordButton = DiscordButton.create();
127+
final button1:DiscordButton = new DiscordButton();
133128
button1.label = "Play on Web";
134129
button1.url = Constants.URL_NEWGROUNDS;
135130
presence.buttons[0] = button1;
136131

137-
final button2:DiscordButton = DiscordButton.create();
132+
final button2:DiscordButton = new DiscordButton();
138133
button2.label = "Download";
139134
button2.url = Constants.URL_ITCH;
140135
presence.buttons[1] = button2;
141136

142-
return presence;
137+
Discord.UpdatePresence(cpp.RawConstPointer.addressOf(presence));
143138
}
144139

145140
// TODO: WHAT THE FUCK get this pointer bullfuckery out of here

source/funkin/play/GameOverSubState.hx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -499,9 +499,9 @@ class GameOverSubState extends MusicBeatSubState
499499
else
500500
{
501501
onComplete = function() {
502-
isStarting = true;
502+
isStarting = false;
503503
// We need to force to ensure that the non-starting music plays.
504-
startDeathMusic(0.0, true);
504+
startDeathMusic(1.0, true);
505505
};
506506
}
507507
}

source/funkin/play/PlayState.hx

Lines changed: 44 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ import funkin.play.character.BaseCharacter;
3838
import funkin.data.character.CharacterData.CharacterDataParser;
3939
import funkin.play.components.HealthIcon;
4040
import funkin.play.components.PopUpStuff;
41+
import funkin.play.components.Subtitles;
4142
import funkin.play.cutscene.dialogue.Conversation;
4243
import funkin.play.cutscene.VanillaCutscenes;
4344
import funkin.play.cutscene.VideoCutscene;
@@ -512,6 +513,11 @@ class PlayState extends MusicBeatSubState
512513
*/
513514
public var healthBarBG:FunkinSprite;
514515

516+
/**
517+
* A sprite group for subtitle display.
518+
*/
519+
public var subtitles:Null<Subtitles>;
520+
515521
/**
516522
* The health icon representing the player.
517523
*/
@@ -558,6 +564,11 @@ class PlayState extends MusicBeatSubState
558564
*/
559565
public var camCutouts:FlxCamera;
560566

567+
/**
568+
* The camera which contains, and controls visibility of, the subtitles.
569+
*/
570+
public var camSubtitles:FlxCamera;
571+
561572
/**
562573
* The camera which contains, and controls visibility of, pause menu.
563574
*/
@@ -724,6 +735,7 @@ class PlayState extends MusicBeatSubState
724735
camHUD = new FlxCamera();
725736
camCutscene = new FlxCamera();
726737
camCutouts = new FlxCamera();
738+
camSubtitles = new FlxCamera();
727739
camPause = new FlxCamera();
728740

729741
var currentChart = currentSong.getDifficulty(currentDifficulty, currentVariation);
@@ -1856,12 +1868,14 @@ class PlayState extends MusicBeatSubState
18561868
camCutouts.setPosition((FlxG.width - FlxG.initialWidth) / 2, (FlxG.height - FlxG.initialHeight) / 2);
18571869
camCutouts.setSize(FlxG.initialWidth, FlxG.initialHeight);
18581870
camCutouts.bgColor.alpha = 0; // Show the game scene behind the camera.
1871+
if (Preferences.subtitles) camSubtitles.bgColor.alpha = 0; // Show the game scene behind the camera.
18591872
camPause.bgColor.alpha = 0; // Show the game scene behind the camera.
18601873

18611874
FlxG.cameras.reset(camGame);
18621875
FlxG.cameras.add(camHUD, false);
18631876
FlxG.cameras.add(camCutscene, false);
18641877
FlxG.cameras.add(camCutouts, false);
1878+
if (Preferences.subtitles) FlxG.cameras.add(camSubtitles, false);
18651879
FlxG.cameras.add(camPause, false);
18661880

18671881
// Configure camera follow point.
@@ -1878,11 +1892,11 @@ class PlayState extends MusicBeatSubState
18781892
*/
18791893
function initHealthBar():Void
18801894
{
1881-
var healthBarYPos:Float = Preferences.downscroll ? FlxG.height * 0.1 : FlxG.height * 0.9;
1882-
#if mobile
1883-
if (Preferences.controlsScheme == FunkinHitboxControlSchemes.Arrows
1884-
&& !ControlsHandler.usingExternalInputDevice) healthBarYPos = FlxG.height * 0.1;
1885-
#end
1895+
final isDownscroll:Bool = #if mobile (Preferences.controlsScheme == FunkinHitboxControlSchemes.Arrows
1896+
&& !ControlsHandler.usingExternalInputDevice)
1897+
|| #end Preferences.downscroll;
1898+
1899+
var healthBarYPos:Float = isDownscroll ? FlxG.height * 0.1 : FlxG.height * 0.9;
18861900

18871901
healthBarBG.y = healthBarYPos;
18881902
healthBarBG.screenCenter(X);
@@ -1911,6 +1925,21 @@ class PlayState extends MusicBeatSubState
19111925
healthBar.cameras = [camHUD];
19121926
healthBarBG.cameras = [camHUD];
19131927
scoreText.cameras = [camHUD];
1928+
1929+
// Create subtitles if they are enabled.
1930+
if (Preferences.subtitles)
1931+
{
1932+
final isDownscroll:Bool = #if mobile (Preferences.controlsScheme == FunkinHitboxControlSchemes.Arrows
1933+
&& !ControlsHandler.usingExternalInputDevice)
1934+
|| #end Preferences.downscroll;
1935+
1936+
final subtitlesAlignment:SubtitlesAlignment = isDownscroll ? SubtitlesAlignment.SUBTITLES_TOP : SubtitlesAlignment.SUBTITLES_BOTTOM;
1937+
subtitles = new Subtitles(0, 139, subtitlesAlignment);
1938+
subtitles.zIndex = 10000;
1939+
add(subtitles);
1940+
1941+
subtitles.cameras = [camSubtitles];
1942+
}
19141943
}
19151944

19161945
/**
@@ -2472,6 +2501,16 @@ class PlayState extends MusicBeatSubState
24722501
FlxG.sound.music.time = startTimestamp;
24732502
FlxG.sound.music.pitch = playbackRate;
24742503

2504+
if (Preferences.subtitles)
2505+
{
2506+
var subtitlesFile:String = 'songs/${currentSong.id}/subtitles/song-lyrics';
2507+
if (currentVariation != Constants.DEFAULT_VARIATION)
2508+
{
2509+
subtitlesFile += '-${currentVariation}';
2510+
}
2511+
if (subtitles != null) subtitles.assignSubtitles(subtitlesFile, FlxG.sound.music);
2512+
}
2513+
24752514
// Prevent the volume from being wrong.
24762515
FlxG.sound.music.volume = 1.0;
24772516
if (FlxG.sound.music.fadeTween != null) FlxG.sound.music.fadeTween.cancel();

source/funkin/play/cutscene/VideoCutscene.hx

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -73,13 +73,10 @@ class VideoCutscene
7373
if (!openfl.Assets.exists(filePath))
7474
{
7575
// Display a popup.
76-
// funkin.util.WindowUtil.showError('Error playing video', 'Video file does not exist: ${filePath}');
77-
// return;
78-
79-
// TODO: After moving videos to their own library,
80-
// this function ALWAYS FAILS on web, but the video still plays.
81-
// I think that's due to a weird quirk with how OpenFL libraries work.
76+
funkin.util.WindowUtil.showError('Error playing video', 'Video file does not exist: ${filePath}');
8277
trace('Video file does not exist: ${filePath}');
78+
79+
return;
8380
}
8481

8582
var rawFilePath = Paths.stripLibrary(filePath);
@@ -186,7 +183,7 @@ class VideoCutscene
186183
final fileOptions:Array<String> = [];
187184

188185
#if FEATURE_VIDEO_SUBTITLES
189-
if (Preferences.videoSubtitles)
186+
if (Preferences.subtitles)
190187
{
191188
fileOptions.push(':sub-language=$DEFAULT_LANGUAGE');
192189
}

0 commit comments

Comments
 (0)