Skip to content

Commit e5556a2

Browse files
Mobile Update
1 parent b015ed1 commit e5556a2

File tree

5 files changed

+49
-69
lines changed

5 files changed

+49
-69
lines changed

source/core/Main.hx

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,34 @@ class Main extends Sprite
8686
{
8787
super();
8888

89+
var shouldStop:Bool = false;
90+
91+
if (AndroidVersion.SDK_INT >= AndroidVersionCode.M)
92+
{
93+
if (AndroidVersion.SDK_INT < AndroidVersionCode.TIRAMISU)
94+
{
95+
AndroidPermissions.requestPermissions(['READ_EXTERNAL_STORAGE', 'WRITE_EXTERNAL_STORAGE']);
96+
97+
shouldStop = true;
98+
}
99+
100+
if (!AndroidEnvironment.isExternalStorageManager())
101+
{
102+
AndroidSettings.requestSetting('MANAGE_APP_ALL_FILES_ACCESS_PERMISSION');
103+
104+
shouldStop = true;
105+
}
106+
}
107+
108+
if (shouldStop)
109+
{
110+
CoolUtil.showPopUp('Notice', 'The game starts automatically when requesting permissions without them having been granted yet\n\nPlease start the game again once the permissions have been granted');
111+
112+
Sys.exit(0);
113+
114+
return;
115+
}
116+
89117
preOnceConfig();
90118

91119
addChild(new ALEGame(MainState));
@@ -100,17 +128,6 @@ class Main extends Sprite
100128
#end
101129

102130
#if android
103-
if (AndroidVersion.SDK_INT >= AndroidVersionCode.M)
104-
{
105-
if (AndroidVersion.SDK_INT < AndroidVersionCode.TIRAMISU)
106-
AndroidPermissions.requestPermissions(['READ_EXTERNAL_STORAGE', 'WRITE_EXTERNAL_STORAGE']);
107-
108-
if (!AndroidEnvironment.isExternalStorageManager())
109-
AndroidSettings.requestSetting('MANAGE_APP_ALL_FILES_ACCESS_PERMISSION');
110-
}
111-
112-
Sys.sleep(1);
113-
114131
final androidPath:String = AndroidEnvironment.getExternalStorageDirectory() + '/.' + Lib.application?.meta?.get('file');
115132

116133
if (!FileSystem.exists(androidPath))

source/scripting/lua/callbacks/LuaCoolUtil.hx

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -134,11 +134,6 @@ class LuaCoolUtil extends LuaPresetBase
134134
return CoolUtil.capitalize(str);
135135
});
136136

137-
set('listFromString', function(str:String):Array<String>
138-
{
139-
return CoolUtil.listFromString(str);
140-
});
141-
142137

143138
set('browserLoad', function(site:String)
144139
{

source/utils/cool/FileUtil.hx

Lines changed: 19 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,11 @@ import sys.io.File;
55

66
class FileUtil
77
{
8-
inline public static function coolTextFile(path:String):Array<String>
9-
{
10-
var daList:String = null;
11-
12-
var formatted:Array<String> = path.split(':');
13-
14-
path = formatted[formatted.length-1];
15-
16-
if (FileSystem.exists(path))
17-
daList = File.getContent(path);
18-
19-
return daList != null ? StringUtil.listFromString(daList) : [];
20-
}
21-
228
public static function searchComplexFile(path:String, missingPrint:Bool = true)
239
{
2410
var parts = path.split('/');
2511

26-
var parent = "";
12+
var parent = '';
2713

2814
var result:String = null;
2915

@@ -47,11 +33,8 @@ class FileUtil
4733

4834
public static function searchFile(parent:String, file:String)
4935
{
50-
for (folder in [Paths.mod == null ? '' : Paths.mods + '/' + Paths.mod, 'assets'])
36+
for (folder in Paths.library.roots)
5137
{
52-
if (folder == null)
53-
continue;
54-
5538
var path:String = folder + '/' + parent;
5639

5740
if (FileSystem.exists(path) && FileSystem.isDirectory(path))
@@ -63,22 +46,23 @@ class FileUtil
6346
return null;
6447
}
6548

66-
inline public static function openFolder(folder:String, absolute:Bool = false) {
67-
#if sys
68-
if(!absolute) folder = Sys.getCwd() + '$folder';
69-
70-
folder = folder.replace('/', '\\');
71-
if(folder.endsWith('/')) folder.substr(0, folder.length - 1);
72-
73-
#if linux
74-
var command:String = '/usr/bin/xdg-open';
75-
#else
76-
var command:String = 'explorer.exe';
77-
#end
78-
Sys.command(command, [folder]);
79-
#else
80-
FlxG.error("Platform is not supported for CoolUtil.openFolder");
81-
#end
49+
inline public static function openFolder(folder:String, absolute:Bool = false)
50+
{
51+
if (!absolute)
52+
folder = Sys.getCwd() + '$folder';
53+
54+
folder = folder.replace('/', '\\');
55+
56+
if (folder.endsWith('/'))
57+
folder.substr(0, folder.length - 1);
58+
59+
#if linux
60+
var command:String = '/usr/bin/xdg-open';
61+
#else
62+
var command:String = 'explorer.exe';
63+
#end
64+
65+
Sys.command(command, [folder]);
8266
}
8367

8468
public static function formatToSongPath(string:String):String

source/utils/cool/LogUtil.hx

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,18 @@ class LogUtil
1010
{
1111
public static function debugTrace(text:Dynamic, ?type:PrintType = TRACE, ?customType:String = '', ?customColor:FlxColor = FlxColor.GRAY, ?canTrace:Bool = true, ?canPrint:Bool = true, ?pos:haxe.PosInfos)
1212
{
13-
if ((type.unnecessary() && !CoolVars.data.verbose))
13+
if (CoolVars.data == null || (type.unnecessary() && !CoolVars.data.verbose))
1414
return;
1515

1616
if (canTrace)
1717
Sys.println(ansiColorString(type == CUSTOM ? customType : type.toString(), type == CUSTOM ? customColor : type.toColor()) + ansiColorString(' | ' + Date.now().toString().split(' ')[1] + ' | ', 0xFF505050) + (pos == null ? '' : ansiColorString(pos.fileName + ':' + pos.lineNumber + ': ', 0xFF888888)) + text);
1818

19-
if (CoolVars.data == null || !CoolVars.data.developerMode)
20-
return;
21-
22-
if (CoolVars.data.allowDebugPrint && type.printable() && canPrint)
19+
if (CoolVars.data.developerMode && CoolVars.data.allowDebugPrint && type.printable() && canPrint)
2320
debugPrint(text, type, customType, customColor);
2421
}
2522

2623
public static function debugPrint(text:Dynamic, ?type:PrintType = TRACE, ?customType:String = '', ?customColor:FlxColor = FlxColor.GRAY)
27-
{
2824
Main.debugPrintPlugin?.print(text, type == CUSTOM ? customType : type.toString(), type == CUSTOM ? customColor : type.toColor());
29-
}
3025

3126
public static function ansiColorString(text:String, color:FlxColor):String
3227
return '\x1b[38;2;' + color.red + ';' + color.green + ';' + color.blue + 'm' + text + '\x1b[0m';

source/utils/cool/StringUtil.hx

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,6 @@ class StringUtil
77
public static function capitalize(text:String)
88
return text.charAt(0).toUpperCase() + text.substr(1).toLowerCase();
99

10-
public static function listFromString(string:String):Array<String>
11-
{
12-
var daList:Array<String> = [];
13-
daList = string.trim().split('\n');
14-
15-
for (i in 0...daList.length)
16-
daList[i] = daList[i].trim();
17-
18-
return daList;
19-
}
20-
2110
public static function easeFromString(?ease:String = ''):EaseFunction
2211
{
2312
return switch(ease.toLowerCase().trim())

0 commit comments

Comments
 (0)