diff --git a/project.hxp b/project.hxp index f7bf4c8be..189529e3d 100644 --- a/project.hxp +++ b/project.hxp @@ -291,6 +291,13 @@ class Project extends HXProject { */ static final FEATURE_GHOST_TAPPING:FeatureFlag = "FEATURE_GHOST_TAPPING"; + /** + * `-DFEATURE_HAPTIC_FEEDBACK` + * If this flag is enabled, The game provide rich haptic feedback vibrations. + * Works for mobile targets (Android and iOS). + */ + static final FEATURE_HAPTIC_FEEDBACK:FeatureFlag = "FEATURE_HAPTIC_FEEDBACK"; + /** * `-DTOUCH_CONTROLS` * If this flag is enabled, the touch controls for the game is also enabled. @@ -353,10 +360,10 @@ class Project extends HXProject { { if (envConfig != null) { - keystore = new Keystore(); - keystore.path = Std.string(envConfig.get('ANDROID_KEYSTORE_PATH')); - keystore.alias = Std.string(envConfig.get('ANDROID_KEYSTORE_ALIAS')); - keystore.password = Std.string(envConfig.get('ANDROID_KEYSTORE_PASSWORD')); + keystore = new Keystore(); + keystore.path = Std.string(envConfig.get('ANDROID_KEYSTORE_PATH')); + keystore.alias = Std.string(envConfig.get('ANDROID_KEYSTORE_ALIAS')); + keystore.password = Std.string(envConfig.get('ANDROID_KEYSTORE_PASSWORD')); } Reflect.setField(config.get('android.manifest'), 'xmlns:tools', 'http://schemas.android.com/tools'); @@ -638,6 +645,9 @@ class Project extends HXProject { // Screenshots doesn't work there. FEATURE_SCREENSHOTS.apply(this, !(isWeb() || isMobile())); + // Should be true only on mobile builds. + FEATURE_HAPTIC_FEEDBACK.apply(this, isMobile()); + // Should be true only on mobile builds. TOUCH_CONTROLS.apply(this, isMobile()); @@ -825,21 +835,21 @@ class Project extends HXProject { addHaxelib('grig.audio'); // Audio data utilities } - addHaxelib('funkin.haptic'); // Haptic feedback - - addHaxelib('extension-haptics'); // Haptic feedback - - if (FEATURE_PARTIAL_SOUNDS.isEnabled(this)) - { + if (FEATURE_PARTIAL_SOUNDS.isEnabled(this)) { addHaxelib('FlxPartialSound'); // Partial sound } - if (FEATURE_ADMOB_ADS.isEnabled(this)) - { + if (FEATURE_ADMOB_ADS.isEnabled(this)) { addHaxelib('extension-admob'); // Ads Extension } - addHaxelib('extension-iap'); // In-app purchases Extension + if (FEATURE_HAPTIC_FEEDBACK.isEnabled(this)) { + addHaxelib('extension-haptics'); // Haptic feedback + } + + if (isMobile()) { + addHaxelib('extension-iap'); // In-app purchases Extension + } } function configureAssets() { diff --git a/source/Main.hx b/source/Main.hx index 931889c60..0d1d2935f 100644 --- a/source/Main.hx +++ b/source/Main.hx @@ -122,10 +122,6 @@ class Main extends Sprite // George recommends binding the save before FlxGame is created. Save.load(); - #if mobile - FlxG.signals.gameResized.add(resizeGame); - #end - var game:FlxGame = new FlxGame(gameWidth, gameHeight, initialState, Preferences.framerate, Preferences.framerate, skipSplash, startFullscreen); // FlxG.game._customSoundTray wants just the class, it calls new from @@ -220,4 +216,5 @@ class Main extends Sprite } } } - } + #end +} diff --git a/source/funkin/FunkinMemory.hx b/source/funkin/FunkinMemory.hx index 96dc16684..a7d865aa1 100644 --- a/source/funkin/FunkinMemory.hx +++ b/source/funkin/FunkinMemory.hx @@ -327,7 +327,7 @@ class FunkinMemory trace('Queued $key to clean up'); new Future(function() { - new FlxTimer().start(1 / 24, function(_) { + new flixel.util.FlxTimer().start(1 / 24, function(_) { FlxG.bitmap.removeKey(key); if (currentCachedTextures.exists(key)) currentCachedTextures.remove(key); obj.destroy(); diff --git a/source/funkin/mobile/util/AdMobUtil.hx b/source/funkin/mobile/util/AdMobUtil.hx index f78720890..ecad83c37 100644 --- a/source/funkin/mobile/util/AdMobUtil.hx +++ b/source/funkin/mobile/util/AdMobUtil.hx @@ -1,10 +1,10 @@ package funkin.mobile.util; #if FEATURE_ADMOB_ADS -import admob.Admob; -import admob.AdmobBannerAlign; -import admob.AdmobBannerSize; -import admob.AdmobEvent; +import extension.admob.Admob; +import extension.admob.AdmobBannerAlign; +import extension.admob.AdmobBannerSize; +import extension.admob.AdmobEvent; import funkin.util.macro.EnvironmentConfigMacro; /** diff --git a/source/funkin/play/GameOverSubState.hx b/source/funkin/play/GameOverSubState.hx index d4f1a95ec..79d42f650 100644 --- a/source/funkin/play/GameOverSubState.hx +++ b/source/funkin/play/GameOverSubState.hx @@ -505,6 +505,14 @@ class GameOverSubState extends MusicBeatSubState // PlayState.seenCutscene = false; // old thing... if (gameOverMusic != null) gameOverMusic.stop(); + // Stop death quotes immediately. + hasPlayedDeathQuote = true; + if (deathQuoteSound != null) + { + deathQuoteSound.stop(); + deathQuoteSound = null; + } + if (isChartingMode) { this.close(); @@ -512,13 +520,26 @@ class GameOverSubState extends MusicBeatSubState PlayState.instance.close(); // This only works because PlayState is a substate! return; } - else if (PlayStatePlaylist.isStoryMode) - { - openSubState(new funkin.ui.transition.StickerSubState(null, (sticker) -> new StoryMenuState(sticker))); - } else { - openSubState(new funkin.ui.transition.StickerSubState(null, (sticker) -> FreeplayState.build(sticker))); + var targetState:funkin.ui.transition.StickerSubState->FlxState = (PlayStatePlaylist.isStoryMode) ? (sticker) -> + new StoryMenuState(sticker) : (sticker) -> FreeplayState.build(sticker); + + if (PlayStatePlaylist.isStoryMode) + { + PlayStatePlaylist.reset(); + } + + var playerCharacterId = PlayerRegistry.instance.getCharacterOwnerId(PlayState.instance.currentChart.characters.player); + var stickerSet = (playerCharacterId == "pico") ? "stickers-set-2" : "stickers-set-1"; + var stickerPack = switch (PlayState.instance.currentChart.song.id) + { + case "tutorial": "tutorial"; + case "darnell" | "lit-up" | "2hot": "weekend"; + default: "all"; + }; + + openSubState(new funkin.ui.transition.StickerSubState({targetState: targetState, stickerSet: stickerSet, stickerPack: stickerPack})); } } diff --git a/source/funkin/save/Save.hx b/source/funkin/save/Save.hx index 090f0166e..5685473f2 100644 --- a/source/funkin/save/Save.hx +++ b/source/funkin/save/Save.hx @@ -11,6 +11,7 @@ import funkin.ui.debug.charting.ChartEditorState.ChartEditorTheme; import funkin.ui.debug.stageeditor.StageEditorState.StageEditorTheme; import funkin.util.FileUtil; import funkin.util.SerializerUtil; +import funkin.mobile.ui.FunkinHitbox; import thx.semver.Version; #if FEATURE_NEWGROUNDS import funkin.api.newgrounds.Medals; diff --git a/source/funkin/ui/freeplay/FreeplayState.hx b/source/funkin/ui/freeplay/FreeplayState.hx index 9ade934fe..f14a820cf 100644 --- a/source/funkin/ui/freeplay/FreeplayState.hx +++ b/source/funkin/ui/freeplay/FreeplayState.hx @@ -53,7 +53,6 @@ import funkin.api.discord.DiscordClient; #end import funkin.util.TouchUtil; import funkin.util.SwipeUtil; -import flixel.system.scaleModes.FullScreenScaleMode; /** * The state for the freeplay menu, allowing the player to select any song to play. @@ -448,7 +447,7 @@ class FreeplayState extends MusicBeatSubState if (fromCharSelect) { - blackOverlayBullshitLOLXD.x = bgDad.x; + blackOverlayBullshitLOLXD.x = backingImage.x; overhangStuff.y = -100; backingCard?.skipIntroTween(); } @@ -456,7 +455,7 @@ class FreeplayState extends MusicBeatSubState { albumRoll.applyExitMovers(exitMovers, exitMoversCharSel); FlxTween.tween(overhangStuff, {y: -100}, 0.3, {ease: FlxEase.quartOut}); - FlxTween.tween(blackOverlayBullshitLOLXD, {x: bgDad.x}, 0.7, {ease: FlxEase.quintOut}); + FlxTween.tween(blackOverlayBullshitLOLXD, {x: backingImage.x}, 0.7, {ease: FlxEase.quintOut}); } fnfFreeplay = new FlxText(FullScreenScaleMode.gameNotchSize.x + 8, 8, 0, 'FREEPLAY', 48); diff --git a/source/funkin/util/WindowUtil.hx b/source/funkin/util/WindowUtil.hx index 647c521a0..c4ffcfe54 100644 --- a/source/funkin/util/WindowUtil.hx +++ b/source/funkin/util/WindowUtil.hx @@ -115,6 +115,7 @@ class WindowUtil windowExit.dispatch(exitCode); }); + #if desktop openfl.Lib.current.stage.addEventListener(openfl.events.KeyboardEvent.KEY_DOWN, (e:openfl.events.KeyboardEvent) -> { for (key in PlayerSettings.player1.controls.getKeysForAction(WINDOW_FULLSCREEN)) { diff --git a/source/funkin/util/macro/EnvironmentConfigMacro.hx b/source/funkin/util/macro/EnvironmentConfigMacro.hx index 55be514da..351af622a 100644 --- a/source/funkin/util/macro/EnvironmentConfigMacro.hx +++ b/source/funkin/util/macro/EnvironmentConfigMacro.hx @@ -1,6 +1,5 @@ package funkin.util.macro; -import haxe.ds.Map; #if sys import sys.io.File; import sys.FileSystem; @@ -9,11 +8,14 @@ import sys.FileSystem; import haxe.macro.Context; import haxe.macro.Expr; #end +import haxe.ds.Map; + +using StringTools; /** * A macro that reads an environment file during the build process for you to access in runtime without exposing the value. */ -#if (!macro) +#if !macro @:build(funkin.util.macro.EnvironmentConfigMacro.setupEnvConfig(".env")) #end class EnvironmentConfigMacro @@ -34,7 +36,7 @@ class EnvironmentConfigMacro var fields = Context.getBuildFields(); var pos = Context.currentPos(); - var envFile = File.getConsent(file); + var envFile:String = File.getContent(file); if (envFile == null) { @@ -64,7 +66,7 @@ class EnvironmentConfigMacro var typePath:TypePath = { name: 'EnvironmentConfigMacro', - pack: ['funkin', 'utl', 'macro'], + pack: ['funkin', 'util', 'macro'], sub: 'EnvironmentConfig' };