Skip to content

Commit

Permalink
squashed commits
Browse files Browse the repository at this point in the history
  • Loading branch information
lemz1 committed Feb 1, 2025
1 parent 6216655 commit 917abce
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 6 deletions.
10 changes: 10 additions & 0 deletions source/Main.hx
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,16 @@ class Main extends Sprite
// TODO: Replace with loadEnabledMods() once the user can configure the mod list.
funkin.modding.PolymodHandler.loadAllMods();

if (funkin.modding.PolymodHandler.outdatedMods.length > 0)
{
var description:String = 'Required Version: ${funkin.modding.PolymodHandler.API_VERSION_RULE}\n';
for (mod in funkin.modding.PolymodHandler.outdatedMods)
{
description += '\n${mod.title} (v${mod.apiVersion}, id: ${mod.id})';
}
funkin.modding.PolymodErrorHandler.showAlert('Outdated Mods', description);
}

if (stage != null)
{
init();
Expand Down
1 change: 1 addition & 0 deletions source/funkin/InitState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import funkin.play.character.CharacterData.CharacterDataParser;
import funkin.play.notes.notekind.NoteKindManager;
import funkin.play.PlayStatePlaylist;
import funkin.ui.debug.charting.ChartEditorState;
import funkin.modding.module.ModuleHandler;
import funkin.ui.title.TitleState;
import funkin.ui.transition.LoadingState;
import funkin.util.CLIUtil;
Expand Down
41 changes: 35 additions & 6 deletions source/funkin/modding/PolymodHandler.hx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import funkin.util.FileUtil;
import funkin.util.macro.ClassMacro;
import polymod.backends.PolymodAssets.PolymodAssetType;
import polymod.format.ParseRules.TextFileFormat;
import polymod.util.VersionUtil;
import polymod.Polymod;

/**
Expand All @@ -38,7 +39,7 @@ class PolymodHandler
* Using more complex rules allows mods from older compatible versions to stay functioning,
* while preventing mods made for future versions from being installed.
*/
static final API_VERSION_RULE:String = ">=0.5.0 <0.6.0";
public static final API_VERSION_RULE:String = ">=0.5.0 <0.6.0";

/**
* Where relative to the executable that mods are located.
Expand All @@ -61,6 +62,8 @@ class PolymodHandler
null
#end;

public static var outdatedMods(default, null):Array<ModMetadata> = [];

public static var loadedModIds:Array<String> = [];

// Use SysZipFileSystem on desktop and MemoryZipFilesystem on web.
Expand Down Expand Up @@ -335,8 +338,19 @@ class PolymodHandler
{
return {
assetLibraryPaths: [
'default' => 'preload', 'shared' => 'shared', 'songs' => 'songs', 'videos' => 'videos', 'tutorial' => 'tutorial', 'week1' => 'week1',
'week2' => 'week2', 'week3' => 'week3', 'week4' => 'week4', 'week5' => 'week5', 'week6' => 'week6', 'week7' => 'week7', 'weekend1' => 'weekend1',
'default' => 'preload',
'shared' => 'shared',
'songs' => 'songs',
'videos' => 'videos',
'tutorial' => 'tutorial',
'week1' => 'week1',
'week2' => 'week2',
'week3' => 'week3',
'week4' => 'week4',
'week5' => 'week5',
'week6' => 'week6',
'week7' => 'week7',
'weekend1' => 'weekend1',
],
coreAssetRedirect: CORE_FOLDER,
}
Expand All @@ -355,12 +369,27 @@ class PolymodHandler
var modMetadata:Array<ModMetadata> = Polymod.scan(
{
modRoot: MOD_FOLDER,
apiVersionRule: API_VERSION_RULE,
apiVersionRule: VersionUtil.DEFAULT_VERSION_RULE,
fileSystem: modFileSystem,
errorCallback: PolymodErrorHandler.onPolymodError
});
trace('Found ${modMetadata.length} mods when scanning.');
return modMetadata;

outdatedMods = [];
var validMods:Array<ModMetadata> = [];

for (data in modMetadata)
{
if (!VersionUtil.match(data.apiVersion, API_VERSION_RULE))
{
outdatedMods.push(data);
}
else
{
validMods.push(data);
}
}

return validMods;
}

/**
Expand Down

0 comments on commit 917abce

Please sign in to comment.