Skip to content

Commit 55bd612

Browse files
author
Lily
committed
update bs
1 parent 8173a4c commit 55bd612

17 files changed

+286
-297
lines changed

source/ClientPrefs.hx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@ import Controls;
99
class ClientPrefs { //default settings if it can't find a save file containing your current settings
1010
#if mobile
1111
public static var screensaver:Bool = false;
12-
#if android
13-
public static var storageType:String = "EXTERNAL_DATA";
14-
#end
1512
#end
1613
public static var mobileCAlpha:Float = FlxG.onMobile ? 0.6 : 0;
1714
public static var mobileCEx:Bool = false;

source/Main.hx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,9 @@ class Main extends Sprite {
117117
super();
118118
#if mobile
119119
#if android
120-
SUtil.doPermissionsShit();
120+
StorageUtil.requestPermissions();
121121
#end
122-
Sys.setCwd(SUtil.getStorageDirectory());
122+
Sys.setCwd(StorageUtil.getStorageDirectory());
123123
#end
124124

125125
CrashHandler.init();

source/editors/ChartingState.hx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4348,7 +4348,7 @@ class ChartingState extends MusicBeatState
43484348
if (difficulty.toLowerCase() != 'normal')
43494349
gamingName = gamingName + '-' + Paths.formatToSongPath(difficulty);
43504350

4351-
SUtil.saveContent('$gamingName.json', data.trim());
4351+
StorageUtil.saveContent('$gamingName.json', data.trim());
43524352
#else
43534353
_file = new FileReference();
43544354
_file.addEventListener(Event.COMPLETE, onSaveComplete);
@@ -4388,7 +4388,7 @@ class ChartingState extends MusicBeatState
43884388
if ((data != null) && (data.length > 0))
43894389
{
43904390
#if mobile
4391-
SUtil.saveContent('events.json', data.trim());
4391+
StorageUtil.saveContent('events.json', data.trim());
43924392
#else
43934393
_file = new FileReference();
43944394
_file.addEventListener(Event.COMPLETE, onSaveComplete);

source/editors/DialogueCharacterEditorState.hx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -796,7 +796,7 @@ class DialogueCharacterEditorState extends MusicBeatState
796796
var characterName:String = splittedImage[0].toLowerCase().replace(' ', '');
797797

798798
#if mobile
799-
SUtil.saveContent('$characterName.json', data); // gacha horror referance
799+
StorageUtil.saveContent('$characterName.json', data); // gacha horror referance
800800
#else
801801
_file = new FileReference();
802802
_file.addEventListener(Event.COMPLETE, onSaveComplete);

source/editors/DialogueEditorState.hx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,7 @@ class DialogueEditorState extends MusicBeatState
532532
if (data.length > 0)
533533
{
534534
#if mobile
535-
SUtil.saveContent("dialogue.json", data);
535+
StorageUtil.saveContent("dialogue.json", data);
536536
#else
537537
_file = new FileReference();
538538
_file.addEventListener(Event.COMPLETE, onSaveComplete);

source/editors/MenuCharacterEditorState.hx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@ class MenuCharacterEditorState extends MusicBeatState
414414
var characterName:String = splittedImage[splittedImage.length-1].toLowerCase().replace(' ', '');
415415

416416
#if mobile
417-
SUtil.saveContent('$characterName.json', data); // gacha horror referance
417+
StorageUtil.saveContent('$characterName.json', data); // gacha horror referance
418418
#else
419419
_file = new FileReference();
420420
_file.addEventListener(Event.COMPLETE, onSaveComplete);

source/editors/WeekEditorState.hx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -552,7 +552,7 @@ class WeekEditorState extends MusicBeatState
552552
if (data.length > 0)
553553
{
554554
#if mobile
555-
SUtil.saveContent('$weekFileName.json', data);
555+
StorageUtil.saveContent('$weekFileName.json', data);
556556
#else
557557
_file = new FileReference();
558558
_file.addEventListener(Event.COMPLETE, onSaveComplete);

source/import.hx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import Paths;
33
import haxe.ds.Vector as HaxeVector; //apparently denpa uses vectors, which is required for camera panning i guess
44

5-
import mobile.SUtil;
5+
import mobile.StorageUtil;
66

77
#if sys
88
import sys.*;

source/mobile/CopyState.hx

Lines changed: 68 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -20,50 +20,49 @@
2020
* DEALINGS IN THE SOFTWARE.
2121
*/
2222

23-
2423
package mobile;
2524

2625
#if mobile
2726
import lime.utils.Assets as LimeAssets;
2827
import openfl.utils.Assets as OpenFLAssets;
29-
import flixel.addons.util.FlxAsyncLoop;
3028
import flixel.FlxG;
3129
import flixel.text.FlxText;
3230
import flixel.FlxSprite;
3331
import flixel.util.FlxColor;
32+
import flixel.util.FlxTimer;
3433
import openfl.utils.ByteArray;
3534
import haxe.io.Path;
35+
import flixel.ui.FlxBar;
36+
import flixel.ui.FlxBar.FlxBarFillDirection;
37+
import lime.system.ThreadPool;
3638
#if sys
3739
import sys.io.File;
3840
import sys.FileSystem;
3941
#end
40-
4142
using StringTools;
4243

43-
#if (android && cpp)
44-
@:headerInclude('sys/utsname.h')
45-
#end
44+
/**
45+
* ...
46+
* @author: Karim Akra
47+
*/
4648
class CopyState extends MusicBeatState
4749
{
50+
private static final textFilesExtensions:Array<String> = ['ini', 'txt', 'xml', 'hxs', 'hx', 'lua', 'json', 'frag', 'vert'];
51+
public static final IGNORE_FOLDER_FILE_NAME:String = "CopyState-Ignore.txt";
52+
private static var directoriesToIgnore:Array<String> = [];
4853
public static var locatedFiles:Array<String> = [];
4954
public static var maxLoopTimes:Int = 0;
50-
public static final IGNORE_FOLDER_FILE_NAME:String = "ignore.txt";
5155

5256
public var loadingImage:FlxSprite;
53-
public var bottomBG:FlxSprite;
57+
public var loadingBar:FlxBar;
5458
public var loadedText:FlxText;
55-
public var copyLoop:FlxAsyncLoop;
59+
public var thread:ThreadPool;
5660

57-
var loopTimes:Int = 0;
58-
var failedFiles:Array<String> = [];
5961
var failedFilesStack:Array<String> = [];
60-
var canUpdate:Bool = true;
62+
var failedFiles:Array<String> = [];
6163
var shouldCopy:Bool = false;
62-
#if android
63-
var archPrefix:String = "";
64-
#end
65-
66-
private static final textFilesExtensions:Array<String> = ['ini', 'txt', 'xml', 'hxs', 'hx', 'lua', 'json', 'frag', 'vert'];
64+
var canUpdate:Bool = true;
65+
var loopTimes:Int = 0;
6766

6867
override function create()
6968
{
@@ -77,41 +76,44 @@ class CopyState extends MusicBeatState
7776
}
7877

7978
CoolUtil.showPopUp("Seems like you have some missing files that are necessary to run the game\nPress OK to begin the copy process", "Notice!");
80-
79+
8180
shouldCopy = true;
8281

8382
add(new FlxSprite(0, 0).makeGraphic(FlxG.width, FlxG.height, 0xffcaff4d));
8483

85-
loadingImage = new FlxSprite(0, 0, Paths.image('funkay'));
84+
loadingImage = new FlxSprite(0, 0, Paths.image('funkay', 'shared'));
8685
loadingImage.setGraphicSize(0, FlxG.height);
8786
loadingImage.updateHitbox();
8887
loadingImage.screenCenter();
8988
add(loadingImage);
9089

91-
bottomBG = new FlxSprite(0, FlxG.height - 26).makeGraphic(FlxG.width, 26, 0xFF000000);
92-
bottomBG.alpha = 0.6;
93-
add(bottomBG);
90+
loadingBar = new FlxBar(0, FlxG.height - 26, FlxBarFillDirection.LEFT_TO_RIGHT, FlxG.width, 26);
91+
loadingBar.setRange(0, maxLoopTimes);
92+
add(loadingBar);
9493

95-
loadedText = new FlxText(bottomBG.x, bottomBG.y + 4, FlxG.width, '', 16);
94+
loadedText = new FlxText(loadingBar.x, loadingBar.y + 4, FlxG.width, '', 16);
9695
loadedText.setFormat(Paths.font("vcr.ttf"), 16, FlxColor.WHITE, CENTER);
9796
add(loadedText);
9897

99-
var ticks:Int = 15;
100-
if (maxLoopTimes <= 15)
101-
ticks = 1;
102-
103-
copyLoop = new FlxAsyncLoop(maxLoopTimes, copyAsset, ticks);
104-
add(copyLoop);
105-
copyLoop.start();
98+
thread = new ThreadPool(0, CoolUtil.getCPUThreadsCount(), MULTI_THREADED);
99+
new FlxTimer().start(0.5, (tmr) -> {
100+
thread.run(function(poop, shit) {
101+
for (file in locatedFiles)
102+
{
103+
loopTimes++;
104+
copyAsset(file);
105+
}
106+
}, null);
107+
});
106108

107109
super.create();
108110
}
109111

110112
override function update(elapsed:Float)
111113
{
112-
if (shouldCopy && copyLoop != null)
114+
if (shouldCopy)
113115
{
114-
if (copyLoop.finished && canUpdate)
116+
if (loopTimes >= maxLoopTimes && canUpdate)
115117
{
116118
if (failedFiles.length > 0)
117119
{
@@ -120,29 +122,32 @@ class CopyState extends MusicBeatState
120122
FileSystem.createDirectory('logs');
121123
File.saveContent('logs/' + Date.now().toString().replace(' ', '-').replace(':', "'") + '-CopyState' + '.txt', failedFilesStack.join('\n'));
122124
}
123-
canUpdate = false;
124-
FlxG.sound.play(Paths.sound('confirmMenu')).onComplete = () -> {
125+
126+
FlxG.sound.play(Paths.sound('confirmMenu')).onComplete = () ->
127+
{
125128
FlxG.switchState(InitState.new);
126129
};
130+
131+
canUpdate = false;
127132
}
128133

129-
if (maxLoopTimes == 0)
134+
if (loopTimes >= maxLoopTimes)
130135
loadedText.text = "Completed!";
131136
else
132137
loadedText.text = '$loopTimes/$maxLoopTimes';
138+
139+
loadingBar.percent = Math.min((loopTimes / maxLoopTimes) * 100, 100);
133140
}
134141
super.update(elapsed);
135142
}
136143

137-
public function copyAsset()
144+
public function copyAsset(file:String)
138145
{
139-
var file = locatedFiles[loopTimes];
140-
loopTimes++;
141146
if (!FileSystem.exists(file))
142147
{
143148
var directory = Path.directory(file);
144149
if (!FileSystem.exists(directory))
145-
SUtil.mkDirs(directory);
150+
FileSystem.createDirectory(directory);
146151
try
147152
{
148153
if (OpenFLAssets.exists(getFile(file)))
@@ -176,7 +181,7 @@ class CopyState extends MusicBeatState
176181
if (fileData == null)
177182
fileData = '';
178183
if (!FileSystem.exists(directory))
179-
SUtil.mkDirs(directory);
184+
FileSystem.createDirectory(directory);
180185
File.saveContent(Path.join([directory, fileName]), fileData);
181186
}
182187
catch (e:haxe.Exception)
@@ -188,7 +193,7 @@ class CopyState extends MusicBeatState
188193

189194
public function getFileBytes(file:String):ByteArray
190195
{
191-
switch (Path.extension(file))
196+
switch (Path.extension(file).toLowerCase())
192197
{
193198
case 'otf' | 'ttf':
194199
return ByteArray.fromFile(file);
@@ -199,11 +204,13 @@ class CopyState extends MusicBeatState
199204

200205
public static function getFile(file:String):String
201206
{
202-
if(OpenFLAssets.exists(file)) return file;
207+
if (OpenFLAssets.exists(file))
208+
return file;
203209

204210
@:privateAccess
205-
for(library in LimeAssets.libraries.keys()){
206-
if(OpenFLAssets.exists('$library:$file') && library != 'default')
211+
for (library in LimeAssets.libraries.keys())
212+
{
213+
if (OpenFLAssets.exists('$library:$file') && library != 'default')
207214
return '$library:$file';
208215
}
209216

@@ -213,28 +220,38 @@ class CopyState extends MusicBeatState
213220
public static function checkExistingFiles():Bool
214221
{
215222
locatedFiles = OpenFLAssets.list();
216-
223+
217224
// removes unwanted assets
218225
var assets = locatedFiles.filter(folder -> folder.startsWith('assets/'));
219226
var mods = locatedFiles.filter(folder -> folder.startsWith('mods/'));
220227
locatedFiles = assets.concat(mods);
228+
locatedFiles = locatedFiles.filter(file -> !FileSystem.exists(file));
221229

222230
var filesToRemove:Array<String> = [];
223231

224232
for (file in locatedFiles)
225233
{
226-
if (FileSystem.exists(file) || OpenFLAssets.exists(getFile(Path.join([Path.directory(getFile(file)), IGNORE_FOLDER_FILE_NAME]))))
234+
if (filesToRemove.contains(file))
235+
continue;
236+
237+
if(file.endsWith(IGNORE_FOLDER_FILE_NAME) && !directoriesToIgnore.contains(Path.directory(file)))
238+
directoriesToIgnore.push(Path.directory(file));
239+
240+
if (directoriesToIgnore.length > 0)
227241
{
228-
filesToRemove.push(file);
242+
for (directory in directoriesToIgnore)
243+
{
244+
if (file.startsWith(directory))
245+
filesToRemove.push(file);
246+
}
229247
}
230248
}
231249

232-
for (file in filesToRemove)
233-
locatedFiles.remove(file);
250+
locatedFiles = locatedFiles.filter(file -> !filesToRemove.contains(file));
234251

235252
maxLoopTimes = locatedFiles.length;
236253

237-
return (maxLoopTimes < 0);
254+
return (maxLoopTimes <= 0);
238255
}
239256
}
240-
#end
257+
#end

source/mobile/MobileControls.hx

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,25 @@
1+
/*
2+
* Copyright (C) 2025 Mobile Porting Team
3+
*
4+
* Permission is hereby granted, free of charge, to any person obtaining a
5+
* copy of this software and associated documentation files (the "Software"),
6+
* to deal in the Software without restriction, including without limitation
7+
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
8+
* and/or sell copies of the Software, and to permit persons to whom the
9+
* Software is furnished to do so, subject to the following conditions:
10+
*
11+
* The above copyright notice and this permission notice shall be included in
12+
* all copies or substantial portions of the Software.
13+
*
14+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19+
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20+
* DEALINGS IN THE SOFTWARE.
21+
*/
22+
123
package mobile;
224

325
import flixel.FlxG;
@@ -9,9 +31,6 @@ import mobile.flixel.FlxButton;
931
import mobile.flixel.FlxHitbox;
1032
import mobile.flixel.FlxVirtualPad;
1133

12-
/**
13-
* @author Mihai Alexandru (M.A. Jigsaw)
14-
*/
1534
class MobileControls extends FlxSpriteGroup
1635
{
1736
public static var customVirtualPad(get, set):FlxVirtualPad;

0 commit comments

Comments
 (0)