跳转到内容

变更

【2023-09-21】

删除 imgFileReplaceList ,现在使用新的ImageHookLoader直接拦截图像请求来实现图像替换,因此,与原始图像文件重名的图像会被覆盖

【2023-09-23】

添加 addonPlugin ,添加 dependenceInfo

现在可以使用 dependenceInfo 来声明依赖的mod,不满足的声明会在加载日志中显示警告

可以使用 addonPlugin 来声明依赖的插件,会在 EarlyLoad 之后 PatchModToGame 之前将所有需要依赖插件的Mod注册给插件,
故所有提供插件的插件Mod(或者说lib mod)需要最迟在 EarlyLoad 阶段(喜欢的话也可以在InjectEarlyLoad阶段) 调用 window.modAddonPluginManager.registerAddonPlugin() 将自己提供的插件注册到 AddonPluginManager

【2023-10-14】

BreakChange :破坏性变更:为了支持 “安全模式” 和 “Mod禁用功能” ,调整了 InjectEarlyLoad 的加载实现以及Mod加载行为。

调整了 AddonPluginHook 的触发顺序, afterModLoad 会在 afterInjectEarlyLoad LifeTimeCircleHook.afterModLoad 执行后触发。
所以,如果一个Mod需要等待其他Mod对自己修改后再执行操作(例如Mod对Mod的i18n),可以在afterInjectEarlyLoad中或EarlyLoad时再执行自己的任务。

现在 ModLoader 会读取所有Mod,然后在 InjectEarlyLoad 每一个Mod后立即使用剩余未InjectEarlyLoad的Mod列表调用所有已加载Mod的canLoadThisMod来过滤接下来要加载的Mod。
即,先加载的Mod可以决定剩下还未加载的Mod是否需要继续加载,但对于已经加载的Mod没有过滤能力。

【2023-10-08】

v1.6.0 使用 HtmlTagSrcHook 支持替换游戏中由 SC2 引擎创建的所有 html img 标签引用的图片。在此之前只有canvas绘图引用的图片才会被替换。

通过对 SC2 引擎的 Wikifier.Parser.add 'htmlTag' 添加如下的代码来在创建<IMG>标签前拦截图片请求并交由ModLoader进行处理,来实现拦截并替换图片的功能。

if (typeof window.modSC2DataManager !== 'undefined' &&
typeof window.modSC2DataManager.getHtmlTagSrcHook?.()?.doHook !== 'undefined') {
if (tagName === 'img' && !el.getAttribute('src')?.startsWith('data:')) {
// need check the src is not "data:" URI
el.setAttribute('ML-src', el.getAttribute('src'));
el.removeAttribute('src');
// call img loader on there
window.modSC2DataManager.getHtmlTagSrcHook().doHook(el).catch(E => console.error(E));
}
}
// 以下这行是SC2原始代码,上面添加的代码需要插入在这一行之前
output.appendChild(tagName === 'track' ? el.cloneNode(true) : el);

ModLoader DoL ImageLoaderHook 已经添加了这个功能的支持,只需要像之前那样正常使用即可。

使用此功能可以通过自行注册 HtmlTagSrcHook 钩子,或者使用 v2.3.0 以上版本的 ModLoader DoL ImageLoaderHook

注:游戏 DoL 仍然存在部分没有拦截到的图片,这些图片由 DoL 自行添加了 Macro.add("icon", icon 标签来实现的。这些代码几乎全是在 link 前使用的标签。

【2023-10-23】

BreakChange : 破坏性变更: v2.0.0 修正mod排序问题; 为Mod加密功能添加 SideLazyLoad API 。

modOrder 数据结构发生重大变化。
为了保证向后(未来)兼容性,现在开始不允许直接访问modOrder。请使用以下两个API

  • ModLoader.getModByNameOne('mod name') 使用modName查询Mod
  • ModLoader.getModZip('mod name') 使用modName查询ModZip
  • ModLoader.getModEarlyLoadCache()EarlyLoad阶段安全地读取已经加载的mod快照

以下是ModCache的低级查询/遍历方法,请注意以下方法不能在EarlyLoad阶段使用

  • ModLoader.getModCacheMap() 以Map的方式使用modName查询,返回ReadOnlyMap
  • ModLoader.getModCacheOneArray() 以Array的方式遍历,对返回的Array的修改不会应用到ModLoader内部数据
  • ModLoader.getModCacheArray()
  • ModLoader.getModCacheByNameOne() 以modName查询
  • ModLoader.checkModCacheUniq() 检查数据是否唯一,请在手动修改后调用此API验证数据
  • ModLoader.checkModCacheData() 检查内部数据是否一致,请在手动修改后调用此API验证数据

【2023-09-21】

Delete imgFileReplaceList. Now, use the new ImageHookLoader to intercept image requests directly for image replacement. Therefore, images with the same name as the original image files will be overwritten.

【2023-09-23】

Add addonPlugin. Add dependenceInfo.

You can now use dependenceInfo to declare dependencies on mods. Declarations that are not met will display warnings in the loading log.
You can use addonPlugin to declare dependencies on plugins. All mods that need to depend on plugins will be registered with the plugin after EarlyLoad but before PatchModToGame. Therefore, all mods that provide plugins (or “lib mods”) should call window.modAddonPluginManager.registerAddonPlugin() to register their provided plugins with the AddonPluginManager no later than in the EarlyLoad phase (or optionally in the InjectEarlyLoad phase).