Skip to content

Commit

Permalink
replace using manual path with PolyHandler getModIDs instead
Browse files Browse the repository at this point in the history
  • Loading branch information
khuonghoanghuy committed Jan 11, 2025
1 parent f08ade4 commit 2d12b1c
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 5 deletions.
4 changes: 3 additions & 1 deletion gameConfig.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
{
"playSplashesScreen": true
"playSplashesScreen": true,
"loadgameInstant": "template",
"willLoadgameInstant": false
}
2 changes: 2 additions & 0 deletions source/GameSelectionState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ class GameSelectionState extends FlxState
versionDisplay.cameras = [camHUD];
add(versionDisplay);

// trace(PolyHandler.getModIDs());

changeSelection();
FlxG.camera.follow(camFollow, null, 0.15);
}
Expand Down
4 changes: 3 additions & 1 deletion source/HScript.hx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ class HScript extends Iris
set("importScript", function(source:String)
{
var name:String = StringTools.replace(source, ".", "/");
var filePath = "mods/" + PolyHandler.trackedMods[PlayState.trackerFolder].id + "/data/" + name + ".hxs";
var filePath:String = null;
for (mod in PolyHandler.getModIDs())
filePath = "mods/" + mod + "/data/" + name + ".hxs";
var script:HScript = new HScript(filePath);
script.execute();
return script.getAll();
Expand Down
2 changes: 2 additions & 0 deletions source/InitialState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import tjson.TJSON;
typedef InitialData =
{
playSplashesScreen:Bool,
loadgameInstant:String,
willLoadgameInstant:Bool,
}

class InitialState extends FlxState
Expand Down
4 changes: 3 additions & 1 deletion source/PlayState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@ class PlayState extends FlxState

public static var trackerFolder:Int = 0;
public static var instance:PlayState = null;
var path(default, null):String;

override public function create()
{
instance = this;

var foldersToCheck:Array<String> = [];
foldersToCheck.push('mods/' + PolyHandler.trackedMods[trackerFolder].id + '/data/');
for (mod in PolyHandler.getModIDs())
foldersToCheck.push("mods/" + mod + "/data/" + path + ".hxs");
for (folder in foldersToCheck)
{
if (FileSystem.exists(folder) && FileSystem.isDirectory(folder))
Expand Down
5 changes: 4 additions & 1 deletion source/ScriptedClass.hx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ class ScriptedClass extends FlxUIState
trackerFolder = PlayState.trackerFolder;
try
{
var filePath = "mods/" + PolyHandler.trackedMods[trackerFolder].id + "/data/classes/" + path + ".hxs";
var filePath:String = null;

for (mod in PolyHandler.getModIDs())
filePath = "mods/" + mod + "/data/classes/" + path + ".hxs";

if (FileSystem.exists(filePath))
path = filePath;
Expand Down
5 changes: 4 additions & 1 deletion source/ScriptedSubClass.hx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ class ScriptedSubClass extends FlxUISubState
trackerFolder = PlayState.trackerFolder;
try
{
var filePath = "mods/" + PolyHandler.trackedMods[trackerFolder].id + "/data/classes/" + path + ".hxs";
var filePath:String = null;

for (mod in PolyHandler.getModIDs())
filePath = "mods/" + mod + "/data/classes/" + path + ".hxs";

if (FileSystem.exists(filePath))
path = filePath;
Expand Down

0 comments on commit 2d12b1c

Please sign in to comment.