Feature flag cleanup

This commit is contained in:
EliteMasterEric
2025-04-30 00:31:31 -04:00
parent 40f44ece5b
commit 0253df7269
20 changed files with 167 additions and 136 deletions
+2
View File
@@ -3,6 +3,8 @@
.vs/
APIStuff.hx
dump/
temp/
docs/temp/
export/
astc-textures/
RECOVER_*.fla
+2 -3
View File
@@ -5,8 +5,6 @@ Check [COMPILING.md](./COMPILING.md) if you haven’t done that yet.
## Android
### Windows
0. **Create a new folder** – this will store Android tools (remember where you put it!).
1. **Open a terminal as Administrator.**
2. Run this in the terminal (replace the path with your actual folder):
@@ -18,8 +16,9 @@ Check [COMPILING.md](./COMPILING.md) if you haven’t done that yet.
5. (Optional) Close and reopen the terminal if needed.
6. Run:
```
sdkmanager --install "build-tools;32.0.0" "build-tools;32.1.0-rc1" "ndk;28.0.13004108" "platforms;android-29"
sdkmanager --install "build-tools;32.0.0" "build-tools;32.1.0-rc1" "ndk;21.4.7075529" "platforms;android-29"
```
- The latest NDK is not compatible with Lime you have to use the old one.
7. Download and install [JDK 17 (MSI)](https://adoptium.net/temurin/releases/?version=17&os=windows).
8. Run:
```
+94 -70
View File
@@ -28,7 +28,7 @@ class Project extends HXProject {
* 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.6.3";
static final VERSION:String = "0.7.0";
/**
* The game's name. Used as the default window title.
@@ -118,6 +118,17 @@ class Project extends HXProject {
*/
static final ANDROID_MINIMUM_SDK_VERSION:Int = 24;
/**
* The contents of the user's environment config.
* Read from the `.env` file.
*/
static var envConfig:Null<Map<String, Dynamic>> = null;
/**
* A list of asset file globs to exclude from ASTC compression.
*/
static var astcExcludes:Array<String> = [];
//
// FEATURE FLAGS
// Inverse feature flags are automatically populated.
@@ -152,6 +163,12 @@ class Project extends HXProject {
*/
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";
/**
* `-DHARDCODED_CREDITS`
* If this flag is enabled, the credits will be parsed and encoded in the game at compile time,
@@ -159,6 +176,18 @@ class Project extends HXProject {
*/
static final HARDCODED_CREDITS:FeatureFlag = "HARDCODED_CREDITS";
/**
* `-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";
/**
* `-DFEATURE_DEBUG_FUNCTIONS`
* If this flag is enabled, the game will have all playtester-only debugging functionality enabled.
@@ -304,13 +333,20 @@ class Project extends HXProject {
*/
static final FEATURE_HAPTICS:FeatureFlag = "FEATURE_HAPTICS";
/**
/**
* `-DFEATURE_TOUCH_CONTROLS`
* If this flag is enabled, the touch controls for the game is also enabled.
* Works with desktop builds.
*/
static final FEATURE_TOUCH_CONTROLS:FeatureFlag = "FEATURE_TOUCH_CONTROLS";
/**
* `-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 higher files size.
* ASTC textures are GPU Rendered so they have a few cons:
* - Pixel Data cannot be read directly.
* - Some filters specifically the ones in openfl.filters package won't work proprely because they directly modify the bitmap pixels.
* - Some filters specifically the ones in openfl.filters package won't work properly because they directly modify the bitmap pixels.
* - ASync loading for GPU Textures seem bugged and results in a black texture (This is meant to be fixed soon because it's not supposed to happen.).
* 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.
@@ -319,47 +355,17 @@ class Project extends HXProject {
*/
static final FEATURE_COMPRESSED_TEXTURES:FeatureFlag = "FEATURE_COMPRESSED_TEXTURES";
/**
* `-DTOUCH_CONTROLS`
* If this flag is enabled, the touch controls for the game is also enabled.
* Works with desktop builds.
*/
static final TOUCH_CONTROLS:FeatureFlag = "TOUCH_CONTROLS";
/**
* `-DEXCLUDE_ARMV7`
* If this flag is enabled, armv7 won't be compiled when building android.
* `-DFEATURE_MOBILE_ADVERTISEMENTS`
* If this flag is enabled, Google AdMob will be enabled. Banner and interstitial ads will some
*/
static final EXCLUDE_ARMV7:FeatureFlag = "EXCLUDE_ARMV7";
/**
* `-DFEATURE_ADMOB_ADS`
* If this flag is disabled, ADs from AdMob will be disabled.
*/
static final FEATURE_ADMOB_ADS:FeatureFlag = "FEATURE_ADMOB_ADS";
static final FEATURE_MOBILE_ADVERTISEMENTS:FeatureFlag = "FEATURE_MOBILE_ADVERTISEMENTS";
/**
* `-DFEATURE_IAP`
* `-DFEATURE_MOBILE_IAP`
* If this flag is enabled, ADs from AdMob will be disabled.
*/
static final FEATURE_IAP:FeatureFlag = "FEATURE_IAP";
/**
* `-DTESTING_ADS`
* If this flag is enabled, ADs will use testing mode.
*/
static final TESTING_ADS:FeatureFlag = "TESTING_ADS";
/**
* `-DUNLOCK_EVERYTHING`
* If this flag is enabled, all the unlockable features will be unlocked.
*/
static final UNLOCK_EVERYTHING:FeatureFlag = "UNLOCK_EVERYTHING";
static var astcExcludes:Array<String> = [];
static var envConfig:Null<Map<String, Dynamic>> = null;
static final FEATURE_MOBILE_IAP:FeatureFlag = "FEATURE_MOBILE_IAP";
//
// CONFIGURATION FUNCTIONS
@@ -369,7 +375,7 @@ class Project extends HXProject {
super();
envConfig = readEnvironmentFile("./.env");
readASTCExcludsion();
readASTCExclusion();
flair();
configureApp();
@@ -385,7 +391,7 @@ class Project extends HXProject {
configureAssets();
configureIcons();
if (FEATURE_ADMOB_ADS.isEnabled(this))
if (FEATURE_MOBILE_ADVERTISEMENTS.isEnabled(this))
{
configureAdMobKeys();
}
@@ -395,29 +401,7 @@ class Project extends HXProject {
{
if (isRelease())
{
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'));
}
Reflect.setField(config.get('android.manifest'), 'xmlns:tools', 'http://schemas.android.com/tools');
final permissionsConfig:Array<String> = ['<uses-permission android:name="android.permission.READ_PHONE_STATE" tools:node="remove" />', '<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" tools:node="remove" />'];
final xmlChildren:Null<Array<String>> = config.get('android.manifest').xmlChildren;
if (xmlChildren != null)
config.get('android.manifest').xmlChildren = xmlChildren.concat(permissionsConfig);
else
config.get('android.manifest').xmlChildren = permissionsConfig;
if (isBundle())
{
config.set("android.gradle-build-directory", "bin-bundle");
}
configureAndroidRelease();
}
}
@@ -427,6 +411,8 @@ class Project extends HXProject {
launchStoryboard = new LaunchStoryboard();
launchStoryboard.path = "./LaunchScreen.storyboard";
}
info("Done configuring project.");
}
/**
@@ -698,16 +684,16 @@ class Project extends HXProject {
FEATURE_COMPRESSED_TEXTURES.apply(this, false);
// Should be true only on mobile builds.
TOUCH_CONTROLS.apply(this, isMobile());
FEATURE_TOUCH_CONTROLS.apply(this, isMobile());
// Should be true only on mobile builds.
FEATURE_ADMOB_ADS.apply(this, isMobile());
FEATURE_MOBILE_ADVERTISEMENTS.apply(this, isMobile());
// Should be true only on android builds for now.
FEATURE_IAP.apply(this, isAndroid());
FEATURE_MOBILE_IAP.apply(this, isAndroid());
// Should be true only on debug mobile builds.
TESTING_ADS.apply(this, (isTest() || isDebug()) && FEATURE_ADMOB_ADS.isEnabled(this));
TESTING_ADS.apply(this, (isTest() || isDebug()) && FEATURE_MOBILE_ADVERTISEMENTS.isEnabled(this));
// For now needed only on mobile for testing.
UNLOCK_EVERYTHING.apply(this, isMobile());
@@ -817,6 +803,31 @@ class Project extends HXProject {
app.path = buildDir;
}
function configureAndroidRelease() {
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'));
}
Reflect.setField(config.get('android.manifest'), 'xmlns:tools', 'http://schemas.android.com/tools');
final permissionsConfig:Array<String> = ['<uses-permission android:name="android.permission.READ_PHONE_STATE" tools:node="remove" />', '<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" tools:node="remove" />'];
final xmlChildren:Null<Array<String>> = config.get('android.manifest').xmlChildren;
if (xmlChildren != null) {
config.get('android.manifest').xmlChildren = xmlChildren.concat(permissionsConfig);
} else {
config.get('android.manifest').xmlChildren = permissionsConfig;
}
if (isBundle()) {
config.set("android.gradle-build-directory", "bin-bundle");
}
}
function configurePolymod() {
// The file extension to use for script files.
setHaxedef("POLYMOD_SCRIPT_EXT", ".hscript");
@@ -893,7 +904,7 @@ class Project extends HXProject {
addHaxelib('FlxPartialSound'); // Partial sound
}
if (FEATURE_ADMOB_ADS.isEnabled(this)) {
if (FEATURE_MOBILE_ADVERTISEMENTS.isEnabled(this)) {
addHaxelib('extension-admob'); // Ads Extension
}
@@ -901,7 +912,7 @@ class Project extends HXProject {
addHaxelib('extension-haptics'); // Haptic feedback
}
if (FEATURE_IAP.isEnabled(this)) {
if (FEATURE_MOBILE_IAP.isEnabled(this)) {
addHaxelib('extension-iapcore'); // In-app purchases Extension
}
}
@@ -965,6 +976,8 @@ class Project extends HXProject {
addAsset("art/readme.txt", "do NOT readme.txt", "art", shouldEmbedArt);
addAsset("LICENSE.md", "LICENSE.md", "art", shouldEmbedArt);
addAsset("CHANGELOG.md", "CHANGELOG.md", "art", shouldEmbedArt);
info('Done configuring assets.');
}
/**
@@ -972,6 +985,7 @@ class Project extends HXProject {
*/
function configureIcons()
{
info('Configuring application icons...');
if (!isIOS()) {
addIcon("art/icon16.png", 16);
addIcon("art/icon32.png", 32);
@@ -983,6 +997,7 @@ class Project extends HXProject {
addIcon("art/icon64_noalpha.png", 64);
addIcon("art/iconOG_noalpha.png");
}
info('Done configuring icons.');
}
/**
@@ -1336,7 +1351,16 @@ class Project extends HXProject {
if(command != "display") { Log.info('[INFO] ${message}'); }
}
/**
* Read the contents of the `.env` file into a map.
* This is used to store secret keys as environment variables.
*/
public function readEnvironmentFile(file:String):Null<Map<String, Dynamic>> {
if (!FileSystem.exists(file)) {
info('Environment file does not exist: ${file}');
return null;
}
var envFile = File.getContent(file);
if (envFile == null) {
@@ -1357,7 +1381,7 @@ class Project extends HXProject {
return env;
}
public function readASTCExcludsion():Void {
public function readASTCExclusion():Void {
astcExcludes = File.getContent('./compression-excludes.txt').trim().split('\n');
for (i in 0...astcExcludes.length)
+1 -1
View File
@@ -133,7 +133,7 @@ class Main extends Sprite
@:privateAccess
game._customSoundTray = funkin.ui.options.FunkinSoundTray;
#if FEATURE_ADMOB_ADS
#if FEATURE_MOBILE_ADVERTISEMENTS
funkin.mobile.util.AdMobUtil.init();
#end
+3 -3
View File
@@ -96,12 +96,12 @@ class InitState extends FlxState
extension.haptics.Haptic.initialize();
#end
#if FEATURE_ADMOB_ADS
#if FEATURE_MOBILE_ADVERTISEMENTS
// Setup Admob
funkin.mobile.util.AdMobUtil.init();
#end
#if FEATURE_IAP
#if FEATURE_MOBILE_IAP
// Setup In-App purchases
funkin.mobile.util.InAppPurchasesUtil.init();
#end
@@ -126,7 +126,7 @@ class InitState extends FlxState
FlxG.game.focusLostFramerate = 30;
// Makes Flixel use frame times instead of locked movements per frame for things like tweens
FlxG.fixedTimestep = false;
FlxG.fixedTimestep = false;
setupFlixelDebug();
+2 -2
View File
@@ -1,6 +1,6 @@
package funkin.mobile.util;
package funkin.api.mobile;
#if FEATURE_ADMOB_ADS
#if FEATURE_MOBILE_ADVERTISEMENTS
import extension.admob.Admob;
import extension.admob.AdmobBannerAlign;
import extension.admob.AdmobBannerSize;
@@ -1,6 +1,6 @@
package funkin.mobile.util;
#if FEATURE_IAP
#if FEATURE_MOBILE_IAP
import extension.iapcore.android.IAPAndroid;
import extension.iapcore.android.IAPProductDetails;
import extension.iapcore.android.IAPPurchase;
+10 -4
View File
@@ -284,13 +284,20 @@ class PolymodHandler
// Can load and execute compiled binaries.
Polymod.blacklistImport('lime.system.JNI');
#if ("extension-androidtools")
// `android.jni.JNICache`
// Same as `lime.system.JNI`
Polymod.blacklistImport('android.jni.JNICache');
#end
#if FEATURE_ADMOB_ADS
// Disable access to in-app purchases
Polymod.blacklistImport('funkin.mobile.util.InAppPurchasesUtil');
for (cls in ClassMacro.listClassesInPackage('extension.iapcore'))
{
if (cls == null) continue;
var className:String = Type.getClassName(cls);
Polymod.blacklistImport(className);
}
// Disable access to Google AdMob
Polymod.blacklistImport('funkin.mobile.util.AdMobUtil');
for (cls in ClassMacro.listClassesInPackage('extension.admob'))
{
@@ -298,7 +305,6 @@ class PolymodHandler
var className:String = Type.getClassName(cls);
Polymod.blacklistImport(className);
}
#end
// `lime.system.System`
// System.load() can load malicious DLLs
+13 -13
View File
@@ -21,7 +21,7 @@ import funkin.ui.MusicBeatSubState;
import funkin.ui.transition.stickers.StickerSubState;
import funkin.util.SwipeUtil;
import funkin.util.TouchUtil;
#if FEATURE_ADMOB_ADS
#if FEATURE_MOBILE_ADVERTISEMENTS
import funkin.mobile.util.AdMobUtil;
#end
@@ -208,7 +208,7 @@ class PauseSubState extends MusicBeatSubState
public override function create():Void
{
// Add banner ad when game is state is first loaded.
#if FEATURE_ADMOB_ADS
#if FEATURE_MOBILE_ADVERTISEMENTS
AdMobUtil.addBanner(extension.admob.AdmobBannerSize.BANNER, extension.admob.AdmobBannerAlign.TOP_LEFT);
#end
@@ -487,7 +487,7 @@ class PauseSubState extends MusicBeatSubState
var prevEntry:Int = currentEntry;
currentEntry += change;
#if TOUCH_CONTROLS
#if FEATURE_TOUCH_CONTROLS
if (currentEntry < 0) currentEntry = 0;
if (currentEntry >= currentMenuEntries.length) currentEntry = currentMenuEntries.length - 1;
#else
@@ -536,7 +536,7 @@ class PauseSubState extends MusicBeatSubState
clearAndAddMenuEntries();
updateMetadataText();
changeSelection();
#if TOUCH_CONTROLS
#if FEATURE_TOUCH_CONTROLS
SwipeUtil.calculateSwipeThreshold(menuEntryText.members, Y);
#end
}
@@ -669,7 +669,7 @@ class PauseSubState extends MusicBeatSubState
{
// Resume a paused video if it exists.
VideoCutscene.resumeVideo();
#if FEATURE_ADMOB_ADS
#if FEATURE_MOBILE_ADVERTISEMENTS
AdMobUtil.removeBanner();
#end
state.close();
@@ -706,7 +706,7 @@ class PauseSubState extends MusicBeatSubState
PlayState.instance.needsReset = true;
#if FEATURE_ADMOB_ADS
#if FEATURE_MOBILE_ADVERTISEMENTS
AdMobUtil.removeBanner();
#end
state.close();
@@ -719,7 +719,7 @@ class PauseSubState extends MusicBeatSubState
static function restartPlayState(state:PauseSubState):Void
{
PlayState.instance.needsReset = true;
#if FEATURE_ADMOB_ADS
#if FEATURE_MOBILE_ADVERTISEMENTS
AdMobUtil.removeBanner();
#end
state.close();
@@ -744,7 +744,7 @@ class PauseSubState extends MusicBeatSubState
static function restartVideoCutscene(state:PauseSubState):Void
{
VideoCutscene.restartVideo();
#if FEATURE_ADMOB_ADS
#if FEATURE_MOBILE_ADVERTISEMENTS
AdMobUtil.removeBanner();
#end
state.close();
@@ -757,7 +757,7 @@ class PauseSubState extends MusicBeatSubState
static function skipVideoCutscene(state:PauseSubState):Void
{
VideoCutscene.finishVideo();
#if FEATURE_ADMOB_ADS
#if FEATURE_MOBILE_ADVERTISEMENTS
AdMobUtil.removeBanner();
#end
state.close();
@@ -772,7 +772,7 @@ class PauseSubState extends MusicBeatSubState
if (PlayState.instance?.currentConversation == null) return;
PlayState.instance.currentConversation.resetConversation();
#if FEATURE_ADMOB_ADS
#if FEATURE_MOBILE_ADVERTISEMENTS
AdMobUtil.removeBanner();
#end
state.close();
@@ -787,7 +787,7 @@ class PauseSubState extends MusicBeatSubState
if (PlayState.instance?.currentConversation == null) return;
PlayState.instance.currentConversation.skipConversation();
#if FEATURE_ADMOB_ADS
#if FEATURE_MOBILE_ADVERTISEMENTS
AdMobUtil.removeBanner();
#end
state.close();
@@ -828,7 +828,7 @@ class PauseSubState extends MusicBeatSubState
}
}
#if FEATURE_ADMOB_ADS
#if FEATURE_MOBILE_ADVERTISEMENTS
AdMobUtil.removeBanner();
#end
@@ -841,7 +841,7 @@ class PauseSubState extends MusicBeatSubState
*/
static function quitToChartEditor(state:PauseSubState):Void
{
#if FEATURE_ADMOB_ADS
#if FEATURE_MOBILE_ADVERTISEMENTS
AdMobUtil.removeBanner();
#end
state.close();
+2 -2
View File
@@ -61,7 +61,7 @@ import haxe.Int64;
import funkin.util.TouchUtil;
import funkin.mobile.ui.FunkinHitbox;
import funkin.mobile.ui.FunkinHitbox.FunkinHitboxControlSchemes;
#if FEATURE_ADMOB_ADS
#if FEATURE_MOBILE_ADVERTISEMENTS
import funkin.mobile.util.AdMobUtil;
#end
#end
@@ -1215,7 +1215,7 @@ class PlayState extends MusicBeatSubState
function moveToGameOver():Void
{
// Shows an interstital ad on mobile devices each 3 blueballs
#if FEATURE_ADMOB_ADS
#if FEATURE_MOBILE_ADVERTISEMENTS
Constants.GLOBAL_BLUEBALL_COUNTER++;
if (Constants.GLOBAL_BLUEBALL_COUNTER > 0 && Constants.GLOBAL_BLUEBALL_COUNTER % 3 == 0) AdMobUtil.loadInterstitial();
#end
+3 -3
View File
@@ -39,7 +39,7 @@ import funkin.api.newgrounds.Medals;
#end
#if mobile
import funkin.util.TouchUtil;
#if FEATURE_ADMOB_ADS
#if FEATURE_MOBILE_ADVERTISEMENTS
import funkin.mobile.util.AdMobUtil;
#end
#end
@@ -1003,7 +1003,7 @@ class ResultState extends MusicBeatSubState
ease: FlxEase.expoOut,
onComplete: function(_) {
// Shows a interstital ad on mobile devices each week victory.
#if FEATURE_ADMOB_ADS
#if FEATURE_MOBILE_ADVERTISEMENTS
if (PlayStatePlaylist.isStoryMode
|| (Constants.GLOBAL_FREEPLAY_VICTORY_COUNTER > 0 && ++Constants.GLOBAL_FREEPLAY_VICTORY_COUNTER % 3 == 0))
{
@@ -1025,7 +1025,7 @@ class ResultState extends MusicBeatSubState
else
{
// Shows a interstital ad on mobile devices each week victory.
#if FEATURE_ADMOB_ADS
#if FEATURE_MOBILE_ADVERTISEMENTS
if (PlayStatePlaylist.isStoryMode
|| (Constants.GLOBAL_FREEPLAY_VICTORY_COUNTER > 0 && ++Constants.GLOBAL_FREEPLAY_VICTORY_COUNTER % 3 == 0))
{
+1 -1
View File
@@ -125,7 +125,7 @@ class MenuTypedList<T:MenuListItem> extends FlxTypedGroup<T>
case Rows(num): navGrid(num, inputUp, inputDown, wrapY, inputLeft, inputRight, wrapX);
};
#if TOUCH_CONTROLS
#if FEATURE_TOUCH_CONTROLS
// Update touch position
if (TouchUtil.pressed)
{
+8 -8
View File
@@ -153,7 +153,7 @@ class FreeplayState extends MusicBeatSubState
var curPlaying:Bool = false;
var dj:Null<FreeplayDJ> = null;
#if TOUCH_CONTROLS
#if FEATURE_TOUCH_CONTROLS
var djHitbox:FlxSprite = new FlxSprite((FullScreenScaleMode.gameCutoutSize.x * DJ_POS_MULTI) + 58, 358);
#end
@@ -715,7 +715,7 @@ class FreeplayState extends MusicBeatSubState
rankAnimStart(fromResultsParams, grpCapsules.members[curSelected]);
}
#if TOUCH_CONTROLS
#if FEATURE_TOUCH_CONTROLS
SwipeUtil.calculateSwipeThreshold(grpCapsules.members, Y);
FlxG.touches.swipeThreshold.x = 60;
#end
@@ -1429,7 +1429,7 @@ class FreeplayState extends MusicBeatSubState
}
#end // ^<-- FEATURE_DEBUG_FUNCTIONS
if ((controls.FREEPLAY_CHAR_SELECT #if TOUCH_CONTROLS
if ((controls.FREEPLAY_CHAR_SELECT #if FEATURE_TOUCH_CONTROLS
|| (TouchUtil.overlaps(djHitbox, funnyCam) && TouchUtil.justReleased && !SwipeUtil.swipeAny) #end)
&& !busy)
{
@@ -1499,7 +1499,7 @@ class FreeplayState extends MusicBeatSubState
final downP:Bool = controls.UI_DOWN_P;
final accepted:Bool = controls.ACCEPT;
#if TOUCH_CONTROLS
#if FEATURE_TOUCH_CONTROLS
handleTouchCapsuleClick();
handleTouchSelectionScroll(elapsed);
handleTouchFavoritesAndDifficulties();
@@ -1574,7 +1574,7 @@ class FreeplayState extends MusicBeatSubState
function handleDifficultySwitch():Void
{
#if TOUCH_CONTROLS
#if FEATURE_TOUCH_CONTROLS
final leftPressed:Bool = controls.UI_LEFT_P
|| (diffSelLeft != null && TouchUtil.overlaps(diffSelLeft, funnyCam) && TouchUtil.justReleased);
@@ -1600,7 +1600,7 @@ class FreeplayState extends MusicBeatSubState
}
}
#if TOUCH_CONTROLS
#if FEATURE_TOUCH_CONTROLS
private function handleTouchCapsuleClick():Void
{
if (diffSelRight == null) return;
@@ -2600,7 +2600,7 @@ class DifficultySelector extends FlxSprite
var parent:FreeplayState;
#if TOUCH_CONTROLS
#if FEATURE_TOUCH_CONTROLS
public var pressed:Bool = false;
#end
@@ -2630,7 +2630,7 @@ class DifficultySelector extends FlxSprite
super.update(elapsed);
}
#if TOUCH_CONTROLS
#if FEATURE_TOUCH_CONTROLS
public function setPress(press:Bool):Void
{
if (!press)
+1 -1
View File
@@ -100,7 +100,7 @@ class LetterSort extends FlxSpriteGroup
override function update(elapsed:Float):Void
{
super.update(elapsed);
#if TOUCH_CONTROLS
#if FEATURE_TOUCH_CONTROLS
@:privateAccess
if (TouchUtil.justPressed) inputEnabled = instance != null && TouchUtil.overlaps(swipeBounds, instance.funnyCam);
#end
+2 -2
View File
@@ -188,7 +188,7 @@ class MainMenuState extends MusicBeatState
}
#end
#if TOUCH_CONTROLS
#if FEATURE_TOUCH_CONTROLS
SwipeUtil.calculateSwipeThreshold(menuItems.members, Y);
#end
}
@@ -229,7 +229,7 @@ class MainMenuState extends MusicBeatState
override function closeSubState():Void
{
magenta.visible = false;
#if TOUCH_CONTROLS
#if FEATURE_TOUCH_CONTROLS
SwipeUtil.calculateSwipeThreshold(menuItems.members, Y);
#end
super.closeSubState();
+2 -2
View File
@@ -229,7 +229,7 @@ class StoryMenuState extends MusicBeatState
addBackButton(FlxG.width * 0.77, FlxG.height * 0.85, FlxColor.WHITE, goBack);
#end
#if TOUCH_CONTROLS
#if FEATURE_TOUCH_CONTROLS
FlxG.touches.swipeThreshold.y = 100;
#end
}
@@ -431,7 +431,7 @@ class StoryMenuState extends MusicBeatState
currentIndex += change;
#if TOUCH_CONTROLS
#if FEATURE_TOUCH_CONTROLS
// Dont wrap around w/ touch.
if (currentIndex < 0) currentIndex = 0;
if (currentIndex >= levelList.length) currentIndex = levelList.length - 1;
+2 -2
View File
@@ -6,7 +6,7 @@ import funkin.graphics.video.FlxVideo;
#if hxvlc
import funkin.graphics.video.FunkinVideoSprite;
#end
#if TOUCH_CONTROLS
#if FEATURE_TOUCH_CONTROLS
import funkin.util.TouchUtil;
#end
import funkin.ui.MusicBeatState;
@@ -105,7 +105,7 @@ class AttractState extends MusicBeatState
super.update(elapsed);
// If the user presses any button or hold their screen for 1.5 seconds, skip the video.
if ((FlxG.keys.justPressed.ANY && !controls.VOLUME_MUTE && !controls.VOLUME_UP && !controls.VOLUME_DOWN) #if TOUCH_CONTROLS
if ((FlxG.keys.justPressed.ANY && !controls.VOLUME_MUTE && !controls.VOLUME_UP && !controls.VOLUME_DOWN) #if FEATURE_TOUCH_CONTROLS
|| TouchUtil.touch != null
&& TouchUtil.touch.ticksDeltaSincePress >= 1500 #end)
{
+1 -1
View File
@@ -608,7 +608,7 @@ class Constants
*/
public static final DEFAULT_CAMERA_FOLLOW_RATE:Float = 0.04;
#if FEATURE_ADMOB_ADS
#if FEATURE_MOBILE_ADVERTISEMENTS
/**
* A Counter that is increased by 1 each blueball.
* Only used for interstital ads each 3 blueballs on mobile.
+13 -13
View File
@@ -111,7 +111,7 @@ class SwipeUtil
*/
public static function calculateSwipeThreshold(items:Array<Dynamic>, axes:FlxAxes, ?multiplier:Float = 1):Void
{
#if TOUCH_CONTROLS
#if FEATURE_TOUCH_CONTROLS
final itemCount:Int = items.length - 1;
if (itemCount <= 0)
@@ -141,7 +141,7 @@ class SwipeUtil
@:noCompletion
inline static function get_swipeUp():Bool
{
#if TOUCH_CONTROLS
#if FEATURE_TOUCH_CONTROLS
#if mobile
return TouchUtil.touch != null && TouchUtil.touch.justMovedUp;
#else
@@ -155,7 +155,7 @@ class SwipeUtil
@:noCompletion
inline static function get_swipeRight():Bool
{
#if TOUCH_CONTROLS
#if FEATURE_TOUCH_CONTROLS
#if mobile
return TouchUtil.touch != null && TouchUtil.touch.justMovedRight;
#else
@@ -169,7 +169,7 @@ class SwipeUtil
@:noCompletion
inline static function get_swipeLeft():Bool
{
#if TOUCH_CONTROLS
#if FEATURE_TOUCH_CONTROLS
#if mobile
return TouchUtil.touch != null && TouchUtil.touch.justMovedLeft;
#else
@@ -183,7 +183,7 @@ class SwipeUtil
@:noCompletion
inline static function get_swipeDown():Bool
{
#if TOUCH_CONTROLS
#if FEATURE_TOUCH_CONTROLS
#if mobile
return TouchUtil.touch != null && TouchUtil.touch.justMovedDown;
#else
@@ -201,7 +201,7 @@ class SwipeUtil
@:noCompletion
inline static function get_justSwipedUp():Bool
{
#if TOUCH_CONTROLS
#if FEATURE_TOUCH_CONTROLS
final swipe:FlxSwipe = (FlxG.swipes.length > 0) ? FlxG.swipes[0] : null;
return (swipe?.degrees > 45 && swipe?.degrees < 135 && swipe?.distance > 20);
#else
@@ -212,7 +212,7 @@ class SwipeUtil
@:noCompletion
inline static function get_justSwipedRight():Bool
{
#if TOUCH_CONTROLS
#if FEATURE_TOUCH_CONTROLS
final swipe:FlxSwipe = (FlxG.swipes.length > 0) ? FlxG.swipes[0] : null;
return (swipe?.degrees > -45 && swipe?.degrees < 45 && swipe?.distance > 20);
#else
@@ -223,7 +223,7 @@ class SwipeUtil
@:noCompletion
inline static function get_justSwipedLeft():Bool
{
#if TOUCH_CONTROLS
#if FEATURE_TOUCH_CONTROLS
final swipe:FlxSwipe = (FlxG.swipes.length > 0) ? FlxG.swipes[0] : null;
return ((swipe?.degrees > 135 || swipe?.degrees < -135) && swipe?.distance > 20);
#else
@@ -234,7 +234,7 @@ class SwipeUtil
@:noCompletion
inline static function get_justSwipedDown():Bool
{
#if TOUCH_CONTROLS
#if FEATURE_TOUCH_CONTROLS
final swipe:FlxSwipe = (FlxG.swipes.length > 0) ? FlxG.swipes[0] : null;
return (swipe?.degrees > -135 && swipe?.degrees < -45 && swipe?.distance > 20);
#else
@@ -249,7 +249,7 @@ class SwipeUtil
@:noCompletion
inline static function get_flickUp():Bool
{
#if TOUCH_CONTROLS
#if FEATURE_TOUCH_CONTROLS
#if mobile
return FlxG.touches.flickManager.flickUp;
#else
@@ -263,7 +263,7 @@ class SwipeUtil
@:noCompletion
inline static function get_flickRight():Bool
{
#if TOUCH_CONTROLS
#if FEATURE_TOUCH_CONTROLS
#if mobile
return FlxG.touches.flickManager.flickRight;
#else
@@ -277,7 +277,7 @@ class SwipeUtil
@:noCompletion
inline static function get_flickLeft():Bool
{
#if TOUCH_CONTROLS
#if FEATURE_TOUCH_CONTROLS
#if mobile
return FlxG.touches.flickManager.flickLeft;
#else
@@ -291,7 +291,7 @@ class SwipeUtil
@:noCompletion
inline static function get_flickDown():Bool
{
#if TOUCH_CONTROLS
#if FEATURE_TOUCH_CONTROLS
#if mobile
return FlxG.touches.flickManager.flickDown;
#else
+4 -4
View File
@@ -68,7 +68,7 @@ class TouchUtil
*/
public static function overlaps(object:FlxBasic, ?camera:FlxCamera):Bool
{
#if TOUCH_CONTROLS
#if FEATURE_TOUCH_CONTROLS
if (object == null || touch == null) return false;
return touch.overlaps(object, camera ?? object.camera);
@@ -87,7 +87,7 @@ class TouchUtil
*/
public static function overlapsComplex(object:FlxObject, ?camera:FlxCamera):Bool
{
#if TOUCH_CONTROLS
#if FEATURE_TOUCH_CONTROLS
if (object == null || touch == null) return false;
if (camera == null) camera = object.cameras[0];
@@ -111,7 +111,7 @@ class TouchUtil
*/
public static function overlapsComplexPoint(object:FlxObject, point:FlxPoint, ?inScreenSpace:Bool = false, ?camera:FlxCamera):Bool
{
#if TOUCH_CONTROLS
#if FEATURE_TOUCH_CONTROLS
if (object == null || point == null) return false;
if (camera == null) camera = object.cameras[0];
@@ -165,7 +165,7 @@ class TouchUtil
@:noCompletion
inline static function get_touch():FlxMouse
{
#if TOUCH_CONTROLS
#if FEATURE_TOUCH_CONTROLS
FlxG.mouse.visible = true;
return FlxG.mouse;
#end