Skip to content

Commit 42d3eda

Browse files
committed
wwwwww
1 parent 898313e commit 42d3eda

File tree

2 files changed

+38
-4
lines changed

2 files changed

+38
-4
lines changed

source/archipelago/APEntryState.hx

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,10 @@ class APEntryState extends MusicBeatState
102102
static final wsCheck = ~/^wss?:\/\//;
103103

104104
static final APWorld:String = "apworld/fridaynightfunkin.apworld";
105+
static var currentAPLocation:String = new yutautil.save.MixSaveWrapper(null, "save/apLocation.json", true).getItem("apLocation") != null
106+
? new yutautil.save.MixSaveWrapper(null, "save/apLocation.json", true).getItem("apLocation")
107+
: "C:/ProgramData/Archipelago";
108+
105109
// #if embed
106110
// @:embed(APWorld) static var apWorldBytes:ByteArray;
107111
// #end
@@ -248,11 +252,41 @@ class APEntryState extends MusicBeatState
248252

249253
super.create();
250254

255+
251256
#if sys
252-
var apWorldButtonText = FileSystem.exists("C:/ProgramData/Archipelago/custom_worlds/fridaynightfunkin.apworld") ? "Update APWorld" : "Install APWorld";
257+
var changeAPLocationButton = new PsychUIButton(0, 0, "Change AP Location", function() {
258+
var before = currentAPLocation;
259+
currentAPLocation = yutautil.ImprovedFileHandling.selectFolder("Select Archipelago Folder", true);
260+
if (currentAPLocation != null && currentAPLocation.trim() != "") {
261+
var save = new yutautil.save.MixSaveWrapper(null, "save/apLocation.json", true).setItem("apLocation", currentAPLocation);
262+
Application.current.window.alert("Archipelago location changed to: " + currentAPLocation, "Archipelago Location Changed");
263+
save.save();
264+
}
265+
else {
266+
Application.current.window.alert("Archipelago location not changed.", "Archipelago Location Not Changed");
267+
currentAPLocation = before;
268+
}
269+
});
270+
changeAPLocationButton.x = (FlxG.width / 2) - 10 - changeAPLocationButton.width;
271+
changeAPLocationButton.y = FlxG.height - changeAPLocationButton.height - 100;
272+
add(changeAPLocationButton);
273+
274+
var apWorldButtonText = FileSystem.exists(currentAPLocation + "/custom_worlds/fridaynightfunkin.apworld") ? "Update APWorld" : "Install APWorld";
253275
var apWorldButton = new PsychUIButton(0, 0, apWorldButtonText, installAPWorld);
254276
apWorldButton.x = (FlxG.width / 2) - 10 - apWorldButton.width;
255277
apWorldButton.y = FlxG.height - apWorldButton.height - 50;
278+
279+
if (!FileSystem.exists(currentAPLocation)) {
280+
apWorldButton.normalStyle.bgColor = FlxColor.DARK_GRAY;
281+
apWorldButton.normalStyle.textColor = FlxColor.LIGHT_GRAY;
282+
apWorldButton.hoverStyle.bgColor = FlxColor.DARK_GRAY;
283+
apWorldButton.hoverStyle.textColor = FlxColor.LIGHT_GRAY;
284+
apWorldButton.clickStyle.bgColor = FlxColor.DARK_GRAY;
285+
apWorldButton.clickStyle.textColor = FlxColor.LIGHT_GRAY;
286+
apWorldButton.onClick = function() {
287+
Application.current.window.alert("Archipelago not found.\nPlease install Archipelago to use this feature.", "APWorld Installation");
288+
};
289+
}
256290
add(apWorldButton);
257291
#end
258292

@@ -467,7 +501,7 @@ class APEntryState extends MusicBeatState
467501
public static function checkAPWorld():{status:String, message:String}
468502
{
469503
#if sys
470-
var programDataPath = "C:/ProgramData/Archipelago/";
504+
var programDataPath = currentAPLocation + "/";
471505
var customWorldsPath = programDataPath + "custom_worlds/";
472506
var apWorldFile = customWorldsPath + "fridaynightfunkin.apworld";
473507

@@ -524,7 +558,7 @@ class APEntryState extends MusicBeatState
524558
public static function installAPWorld():Void
525559
{
526560
#if sys
527-
var programDataPath = "C:/ProgramData/Archipelago/";
561+
var programDataPath = currentAPLocation + "/";
528562
var launcherPath = programDataPath + "ArchipelagoLauncher.exe";
529563
var customWorldsPath = programDataPath + "custom_worlds/";
530564
var apWorldFile = customWorldsPath + "fridaynightfunkin.apworld";

source/yutautil/ImprovedFileHandling.hx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class ImprovedFileHandling {
4444
}
4545

4646
public static function selectFolder(title:String, ?preserve_cwd:Bool=true):String {
47-
return FilePopup.folder(title, preserve_cwd);
47+
return FilePopup.folder(title, preserve_cwd).trim();
4848
}
4949

5050
public static function loadFile(title:String, ?filters:Array<FileFilter>, readType:ReadType, ?operation:Dynamic->Dynamic, ?preserve_cwd:Bool=true):Dynamic {

0 commit comments

Comments
 (0)