Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show Outdated Mods #3447

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
26 changes: 22 additions & 4 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 @@ -366,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