mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-22 08:29:18 +01:00
feat: add DALAMUD_API_LEVEL
This commit is contained in:
parent
ebce8ab05f
commit
ad93b6324f
5 changed files with 57 additions and 51 deletions
|
|
@ -318,6 +318,10 @@ namespace Dalamud {
|
||||||
{
|
{
|
||||||
OnPluginReloadCommand(string.Empty, string.Empty);
|
OnPluginReloadCommand(string.Empty, string.Empty);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ImGui.Separator();
|
||||||
|
ImGui.MenuItem("API Level:" + PluginManager.DALAMUD_API_LEVEL, false);
|
||||||
|
ImGui.MenuItem("Loaded plugins:" + PluginManager?.Plugins.Count, false);
|
||||||
ImGui.EndMenu();
|
ImGui.EndMenu();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,5 +16,6 @@ namespace Dalamud.Plugin
|
||||||
public string ApplicableVersion { get; set; }
|
public string ApplicableVersion { get; set; }
|
||||||
public string RepoUrl { get; set; }
|
public string RepoUrl { get; set; }
|
||||||
public bool IsHide { get; set; }
|
public bool IsHide { get; set; }
|
||||||
|
public int DalamudApiLevel { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -66,8 +66,9 @@ namespace Dalamud.Plugin
|
||||||
} else if (this.dalamud.PluginRepository.State == PluginRepository.InitializationState.Fail) {
|
} else if (this.dalamud.PluginRepository.State == PluginRepository.InitializationState.Fail) {
|
||||||
ImGui.Text(Loc.Localize("InstallerDownloadFailed", "Download failed."));
|
ImGui.Text(Loc.Localize("InstallerDownloadFailed", "Download failed."));
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
var didAny = false;
|
||||||
|
|
||||||
foreach (var pluginDefinition in this.dalamud.PluginRepository.PluginMaster) {
|
foreach (var pluginDefinition in this.dalamud.PluginRepository.PluginMaster) {
|
||||||
if (pluginDefinition.ApplicableVersion != this.gameVersion &&
|
if (pluginDefinition.ApplicableVersion != this.gameVersion &&
|
||||||
pluginDefinition.ApplicableVersion != "any")
|
pluginDefinition.ApplicableVersion != "any")
|
||||||
|
|
@ -76,6 +77,11 @@ namespace Dalamud.Plugin
|
||||||
if (pluginDefinition.IsHide)
|
if (pluginDefinition.IsHide)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
if (pluginDefinition.DalamudApiLevel != PluginManager.DALAMUD_API_LEVEL)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
didAny = true;
|
||||||
|
|
||||||
ImGui.PushID(pluginDefinition.InternalName + pluginDefinition.AssemblyVersion);
|
ImGui.PushID(pluginDefinition.InternalName + pluginDefinition.AssemblyVersion);
|
||||||
|
|
||||||
var isInstalled = this.dalamud.PluginManager.Plugins.Where(x => x.Definition != null).Any(
|
var isInstalled = this.dalamud.PluginManager.Plugins.Where(x => x.Definition != null).Any(
|
||||||
|
|
@ -159,6 +165,9 @@ namespace Dalamud.Plugin
|
||||||
|
|
||||||
ImGui.PopID();
|
ImGui.PopID();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!didAny)
|
||||||
|
ImGui.TextColored(new Vector4(0.70f, 0.70f, 0.70f, 1.00f), Loc.Localize("InstallerNoCompatible", "No compatible plugins were found :( Please restart your game and try again."));
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui.PopStyleVar();
|
ImGui.PopStyleVar();
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,8 @@ using Serilog;
|
||||||
namespace Dalamud.Plugin
|
namespace Dalamud.Plugin
|
||||||
{
|
{
|
||||||
internal class PluginManager {
|
internal class PluginManager {
|
||||||
|
public const int DALAMUD_API_LEVEL = 1;
|
||||||
|
|
||||||
private readonly Dalamud dalamud;
|
private readonly Dalamud dalamud;
|
||||||
private readonly string pluginDirectory;
|
private readonly string pluginDirectory;
|
||||||
private readonly string devPluginDirectory;
|
private readonly string devPluginDirectory;
|
||||||
|
|
@ -132,25 +134,6 @@ namespace Dalamud.Plugin
|
||||||
// Assembly.Load() by name here will not load multiple versions with the same name, in the case of updates
|
// Assembly.Load() by name here will not load multiple versions with the same name, in the case of updates
|
||||||
var pluginAssembly = Assembly.LoadFile(dllFile.FullName);
|
var pluginAssembly = Assembly.LoadFile(dllFile.FullName);
|
||||||
|
|
||||||
// Don't wanna fuck this up
|
|
||||||
// This is a fix for earlier Chat Extender versions, since they break command handlers
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var ver = int.Parse(pluginAssembly.GetName().Version.ToString().Replace(".", ""));
|
|
||||||
if (dllFile.Name.Contains("ChatExtender") &&
|
|
||||||
ver < 1410)
|
|
||||||
{
|
|
||||||
Log.Information($"Found banned v{ver} ChatExtender, skipping...");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception)
|
|
||||||
{
|
|
||||||
// ignored
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pluginAssembly != null)
|
|
||||||
{
|
|
||||||
Log.Information("Loading types for {0}", pluginAssembly.FullName);
|
Log.Information("Loading types for {0}", pluginAssembly.FullName);
|
||||||
var types = pluginAssembly.GetTypes();
|
var types = pluginAssembly.GetTypes();
|
||||||
foreach (var type in types)
|
foreach (var type in types)
|
||||||
|
|
@ -162,7 +145,8 @@ namespace Dalamud.Plugin
|
||||||
|
|
||||||
if (type.GetInterface(interfaceType.FullName) != null)
|
if (type.GetInterface(interfaceType.FullName) != null)
|
||||||
{
|
{
|
||||||
if (this.Plugins.Any(x => x.Plugin.GetType().Assembly.GetName().Name == type.Assembly.GetName().Name)) {
|
if (this.Plugins.Any(x => x.Plugin.GetType().Assembly.GetName().Name == type.Assembly.GetName().Name))
|
||||||
|
{
|
||||||
Log.Error("Duplicate plugin found: {0}", dllFile.FullName);
|
Log.Error("Duplicate plugin found: {0}", dllFile.FullName);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
@ -170,29 +154,31 @@ namespace Dalamud.Plugin
|
||||||
var plugin = (IDalamudPlugin)Activator.CreateInstance(type);
|
var plugin = (IDalamudPlugin)Activator.CreateInstance(type);
|
||||||
|
|
||||||
// this happens for raw plugins that don't specify a PluginDefinition - just generate a dummy one to avoid crashes anywhere
|
// this happens for raw plugins that don't specify a PluginDefinition - just generate a dummy one to avoid crashes anywhere
|
||||||
if (pluginDef == null)
|
pluginDef ??= new PluginDefinition{
|
||||||
{
|
|
||||||
pluginDef = new PluginDefinition
|
|
||||||
{
|
|
||||||
Author = "developer",
|
Author = "developer",
|
||||||
Name = plugin.Name,
|
Name = plugin.Name,
|
||||||
InternalName = Path.GetFileNameWithoutExtension(dllFile.Name),
|
InternalName = Path.GetFileNameWithoutExtension(dllFile.Name),
|
||||||
AssemblyVersion = plugin.GetType().Assembly.GetName().Version.ToString(),
|
AssemblyVersion = plugin.GetType().Assembly.GetName().Version.ToString(),
|
||||||
Description = "",
|
Description = "",
|
||||||
ApplicableVersion = "any",
|
ApplicableVersion = "any",
|
||||||
IsHide = false
|
IsHide = false,
|
||||||
|
DalamudApiLevel = DALAMUD_API_LEVEL
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (pluginDef.DalamudApiLevel != DALAMUD_API_LEVEL) {
|
||||||
|
Log.Error("Incompatible API level: {0}", dllFile.FullName);
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
var dalamudInterface = new DalamudPluginInterface(this.dalamud, type.Assembly.GetName().Name, this.pluginConfigs);
|
var dalamudInterface = new DalamudPluginInterface(this.dalamud, type.Assembly.GetName().Name, this.pluginConfigs);
|
||||||
plugin.Initialize(dalamudInterface);
|
plugin.Initialize(dalamudInterface);
|
||||||
|
|
||||||
Log.Information("Loaded plugin: {0}", plugin.Name);
|
Log.Information("Loaded plugin: {0}", plugin.Name);
|
||||||
this.Plugins.Add((plugin, pluginDef, dalamudInterface));
|
this.Plugins.Add((plugin, pluginDef, dalamudInterface));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
Log.Information("Plugin DLL {0} has no plugin interface.", dllFile.FullName);
|
Log.Information("Plugin DLL {0} has no plugin interface.", dllFile.FullName);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -160,6 +160,12 @@ namespace Dalamud.Plugin
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (remoteInfo.DalamudApiLevel != PluginManager.DALAMUD_API_LEVEL)
|
||||||
|
{
|
||||||
|
Log.Information("Has not applicable API level: {0}", info.Name);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (remoteInfo.AssemblyVersion != info.AssemblyVersion)
|
if (remoteInfo.AssemblyVersion != info.AssemblyVersion)
|
||||||
{
|
{
|
||||||
Log.Information("Eligible for update: {0}", remoteInfo.InternalName);
|
Log.Information("Eligible for update: {0}", remoteInfo.InternalName);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue