mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-12 10:17:22 +01:00
add icon for dev plugins
This commit is contained in:
parent
b3740d0539
commit
d827151ee5
5 changed files with 55 additions and 23 deletions
|
|
@ -63,41 +63,48 @@ public enum DalamudAsset
|
|||
[DalamudAsset(DalamudAssetPurpose.TextureFromPng)]
|
||||
[DalamudAssetPath("UIRes", "troubleIcon.png")]
|
||||
TroubleIcon = 1006,
|
||||
|
||||
/// <summary>
|
||||
/// <see cref="DalamudAssetPurpose.TextureFromPng"/>: The plugin trouble icon overlay.
|
||||
/// </summary>
|
||||
[DalamudAsset(DalamudAssetPurpose.TextureFromPng)]
|
||||
[DalamudAssetPath("UIRes", "devPluginIcon.png")]
|
||||
DevPluginIcon = 1007,
|
||||
|
||||
/// <summary>
|
||||
/// <see cref="DalamudAssetPurpose.TextureFromPng"/>: The plugin update icon overlay.
|
||||
/// </summary>
|
||||
[DalamudAsset(DalamudAssetPurpose.TextureFromPng)]
|
||||
[DalamudAssetPath("UIRes", "updateIcon.png")]
|
||||
UpdateIcon = 1007,
|
||||
UpdateIcon = 1008,
|
||||
|
||||
/// <summary>
|
||||
/// <see cref="DalamudAssetPurpose.TextureFromPng"/>: The plugin installed icon overlay.
|
||||
/// </summary>
|
||||
[DalamudAsset(DalamudAssetPurpose.TextureFromPng)]
|
||||
[DalamudAssetPath("UIRes", "installedIcon.png")]
|
||||
InstalledIcon = 1008,
|
||||
InstalledIcon = 1009,
|
||||
|
||||
/// <summary>
|
||||
/// <see cref="DalamudAssetPurpose.TextureFromPng"/>: The third party plugin icon overlay.
|
||||
/// </summary>
|
||||
[DalamudAsset(DalamudAssetPurpose.TextureFromPng)]
|
||||
[DalamudAssetPath("UIRes", "thirdIcon.png")]
|
||||
ThirdIcon = 1009,
|
||||
ThirdIcon = 1010,
|
||||
|
||||
/// <summary>
|
||||
/// <see cref="DalamudAssetPurpose.TextureFromPng"/>: The installed third party plugin icon overlay.
|
||||
/// </summary>
|
||||
[DalamudAsset(DalamudAssetPurpose.TextureFromPng)]
|
||||
[DalamudAssetPath("UIRes", "thirdInstalledIcon.png")]
|
||||
ThirdInstalledIcon = 1010,
|
||||
ThirdInstalledIcon = 1011,
|
||||
|
||||
/// <summary>
|
||||
/// <see cref="DalamudAssetPurpose.TextureFromPng"/>: The API bump explainer icon.
|
||||
/// </summary>
|
||||
[DalamudAsset(DalamudAssetPurpose.TextureFromPng)]
|
||||
[DalamudAssetPath("UIRes", "changelogApiBump.png")]
|
||||
ChangelogApiBumpIcon = 1011,
|
||||
ChangelogApiBumpIcon = 1012,
|
||||
|
||||
/// <summary>
|
||||
/// <see cref="DalamudAssetPurpose.TextureFromPng"/>: The background shade for
|
||||
|
|
@ -105,7 +112,7 @@ public enum DalamudAsset
|
|||
/// </summary>
|
||||
[DalamudAsset(DalamudAssetPurpose.TextureFromPng)]
|
||||
[DalamudAssetPath("UIRes", "tsmShade.png")]
|
||||
TitleScreenMenuShade = 1012,
|
||||
TitleScreenMenuShade = 1013,
|
||||
|
||||
/// <summary>
|
||||
/// <see cref="DalamudAssetPurpose.Font"/>: Noto Sans CJK JP Medium.
|
||||
|
|
|
|||
|
|
@ -98,6 +98,12 @@ internal class PluginImageCache : IDisposable, IServiceType
|
|||
/// </summary>
|
||||
public IDalamudTextureWrap TroubleIcon =>
|
||||
this.dalamudAssetManager.GetDalamudTextureWrap(DalamudAsset.TroubleIcon, this.EmptyTexture);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the devPlugin icon overlay.
|
||||
/// </summary>
|
||||
public IDalamudTextureWrap DevPluginIcon =>
|
||||
this.dalamudAssetManager.GetDalamudTextureWrap(DalamudAsset.DevPluginIcon, this.EmptyTexture);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the plugin update icon overlay.
|
||||
|
|
|
|||
|
|
@ -1800,6 +1800,14 @@ internal class PluginInstallerWindow : Window, IDisposable
|
|||
|
||||
var isLoaded = plugin is { IsLoaded: true };
|
||||
|
||||
if (plugin is LocalDevPlugin)
|
||||
{
|
||||
ImGui.PushStyleVar(ImGuiStyleVar.Alpha, 0.4f);
|
||||
ImGui.Image(this.imageCache.DevPluginIcon.ImGuiHandle, iconSize);
|
||||
ImGui.PopStyleVar();
|
||||
ImGui.SetCursorPos(cursorBeforeImage);
|
||||
}
|
||||
|
||||
if (updateAvailable)
|
||||
ImGui.Image(this.imageCache.UpdateIcon.ImGuiHandle, iconSize);
|
||||
else if ((trouble && !pluginDisabled) || isOrphan)
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ using Dalamud.Interface.Utility;
|
|||
using Dalamud.Interface.Utility.Raii;
|
||||
using Dalamud.Plugin.Internal;
|
||||
using Dalamud.Plugin.Internal.Profiles;
|
||||
using Dalamud.Plugin.Internal.Types;
|
||||
using Dalamud.Utility;
|
||||
using ImGuiNET;
|
||||
using Serilog;
|
||||
|
|
@ -315,13 +316,13 @@ internal class ProfileManagerWidget
|
|||
if (ImGui.BeginListBox("###pluginPicker", new Vector2(width, width - 80)))
|
||||
{
|
||||
// TODO: Plugin searching should be abstracted... installer and this should use the same search
|
||||
foreach (var plugin in pm.InstalledPlugins.Where(x => x.Manifest.SupportsProfiles && !x.IsDev &&
|
||||
foreach (var plugin in pm.InstalledPlugins.Where(x => x.Manifest.SupportsProfiles &&
|
||||
(this.pickerSearch.IsNullOrWhitespace() || x.Manifest.Name.ToLowerInvariant().Contains(this.pickerSearch.ToLowerInvariant()))))
|
||||
{
|
||||
using var disabled2 =
|
||||
ImRaii.Disabled(profile.Plugins.Any(y => y.InternalName == plugin.Manifest.InternalName));
|
||||
|
||||
if (ImGui.Selectable($"{plugin.Manifest.Name}###selector{plugin.Manifest.InternalName}"))
|
||||
if (ImGui.Selectable($"{plugin.Manifest.Name}{(plugin is LocalDevPlugin ? "(dev plugin)" : string.Empty)}###selector{plugin.Manifest.InternalName}"))
|
||||
{
|
||||
Task.Run(() => profile.AddOrUpdateAsync(plugin.Manifest.WorkingPluginId, true, false))
|
||||
.ContinueWith(this.installer.DisplayErrorContinuation, Locs.ErrorCouldNotChangeState);
|
||||
|
|
@ -426,18 +427,28 @@ internal class ProfileManagerWidget
|
|||
Guid? wantRemovePluginGuid = null;
|
||||
|
||||
using var syncScope = profile.GetSyncScope();
|
||||
foreach (var plugin in profile.Plugins.ToArray())
|
||||
foreach (var profileEntry in profile.Plugins.ToArray())
|
||||
{
|
||||
didAny = true;
|
||||
var pmPlugin = pm.InstalledPlugins.FirstOrDefault(x => x.Manifest.WorkingPluginId == plugin.WorkingPluginId);
|
||||
var pmPlugin = pm.InstalledPlugins.FirstOrDefault(x => x.Manifest.WorkingPluginId == profileEntry.WorkingPluginId);
|
||||
var btnOffset = 2;
|
||||
|
||||
if (pmPlugin != null)
|
||||
{
|
||||
var cursorBeforeIcon = ImGui.GetCursorPos();
|
||||
pic.TryGetIcon(pmPlugin, pmPlugin.Manifest, pmPlugin.IsThirdParty, out var icon);
|
||||
icon ??= pic.DefaultIcon;
|
||||
|
||||
ImGui.Image(icon.ImGuiHandle, new Vector2(pluginLineHeight));
|
||||
|
||||
if (pmPlugin is LocalDevPlugin)
|
||||
{
|
||||
ImGui.SetCursorPos(cursorBeforeIcon);
|
||||
ImGui.PushStyleVar(ImGuiStyleVar.Alpha, 0.4f);
|
||||
ImGui.Image(pic.DevPluginIcon.ImGuiHandle, new Vector2(pluginLineHeight));
|
||||
ImGui.PopStyleVar();
|
||||
}
|
||||
|
||||
ImGui.SameLine();
|
||||
|
||||
var text = $"{pmPlugin.Name}";
|
||||
|
|
@ -454,17 +465,17 @@ internal class ProfileManagerWidget
|
|||
ImGui.Image(pic.DefaultIcon.ImGuiHandle, new Vector2(pluginLineHeight));
|
||||
ImGui.SameLine();
|
||||
|
||||
var text = Locs.NotInstalled(plugin.InternalName);
|
||||
var text = Locs.NotInstalled(profileEntry.InternalName);
|
||||
var textHeight = ImGui.CalcTextSize(text);
|
||||
var before = ImGui.GetCursorPos();
|
||||
|
||||
ImGui.SetCursorPosY(ImGui.GetCursorPosY() + (pluginLineHeight / 2) - (textHeight.Y / 2));
|
||||
ImGui.TextUnformatted(text);
|
||||
|
||||
var firstAvailableInstalled = pm.InstalledPlugins.FirstOrDefault(x => x.InternalName == plugin.InternalName);
|
||||
var firstAvailableInstalled = pm.InstalledPlugins.FirstOrDefault(x => x.InternalName == profileEntry.InternalName);
|
||||
var installable =
|
||||
pm.AvailablePlugins.FirstOrDefault(
|
||||
x => x.InternalName == plugin.InternalName && !x.SourceRepo.IsThirdParty);
|
||||
x => x.InternalName == profileEntry.InternalName && !x.SourceRepo.IsThirdParty);
|
||||
|
||||
if (firstAvailableInstalled != null)
|
||||
{
|
||||
|
|
@ -494,10 +505,10 @@ internal class ProfileManagerWidget
|
|||
ImGui.SetCursorPosX(windowSize.X - (ImGuiHelpers.GlobalScale * 30));
|
||||
ImGui.SetCursorPosY(ImGui.GetCursorPosY() + (pluginLineHeight / 2) - (ImGui.GetFrameHeight() / 2));
|
||||
|
||||
var enabled = plugin.IsEnabled;
|
||||
if (ImGui.Checkbox($"###{this.editingProfileGuid}-{plugin.InternalName}", ref enabled))
|
||||
var enabled = profileEntry.IsEnabled;
|
||||
if (ImGui.Checkbox($"###{this.editingProfileGuid}-{profileEntry.InternalName}", ref enabled))
|
||||
{
|
||||
Task.Run(() => profile.AddOrUpdateAsync(plugin.WorkingPluginId, enabled))
|
||||
Task.Run(() => profile.AddOrUpdateAsync(profileEntry.WorkingPluginId, enabled))
|
||||
.ContinueWith(this.installer.DisplayErrorContinuation, Locs.ErrorCouldNotChangeState);
|
||||
}
|
||||
|
||||
|
|
@ -505,9 +516,9 @@ internal class ProfileManagerWidget
|
|||
ImGui.SetCursorPosX(windowSize.X - (ImGuiHelpers.GlobalScale * 30 * btnOffset) - 5);
|
||||
ImGui.SetCursorPosY(ImGui.GetCursorPosY() + (pluginLineHeight / 2) - (ImGui.GetFrameHeight() / 2));
|
||||
|
||||
if (ImGuiComponents.IconButton($"###removePlugin{plugin.InternalName}", FontAwesomeIcon.Trash))
|
||||
if (ImGuiComponents.IconButton($"###removePlugin{profileEntry.InternalName}", FontAwesomeIcon.Trash))
|
||||
{
|
||||
wantRemovePluginGuid = plugin.WorkingPluginId;
|
||||
wantRemovePluginGuid = profileEntry.WorkingPluginId;
|
||||
}
|
||||
|
||||
if (ImGui.IsItemHovered())
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ public class ModuleLog
|
|||
/// <param name="messageTemplate">The message template.</param>
|
||||
/// <param name="values">Values to log.</param>
|
||||
[MessageTemplateFormatMethod("messageTemplate")]
|
||||
public void Verbose(Exception exception, string messageTemplate, params object?[] values)
|
||||
public void Verbose(Exception? exception, string messageTemplate, params object?[] values)
|
||||
=> this.WriteLog(LogEventLevel.Verbose, messageTemplate, exception, values);
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -62,7 +62,7 @@ public class ModuleLog
|
|||
/// <param name="messageTemplate">The message template.</param>
|
||||
/// <param name="values">Values to log.</param>
|
||||
[MessageTemplateFormatMethod("messageTemplate")]
|
||||
public void Debug(Exception exception, string messageTemplate, params object?[] values)
|
||||
public void Debug(Exception? exception, string messageTemplate, params object?[] values)
|
||||
=> this.WriteLog(LogEventLevel.Debug, messageTemplate, exception, values);
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -81,7 +81,7 @@ public class ModuleLog
|
|||
/// <param name="messageTemplate">The message template.</param>
|
||||
/// <param name="values">Values to log.</param>
|
||||
[MessageTemplateFormatMethod("messageTemplate")]
|
||||
public void Information(Exception exception, string messageTemplate, params object?[] values)
|
||||
public void Information(Exception? exception, string messageTemplate, params object?[] values)
|
||||
=> this.WriteLog(LogEventLevel.Information, messageTemplate, exception, values);
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -100,7 +100,7 @@ public class ModuleLog
|
|||
/// <param name="messageTemplate">The message template.</param>
|
||||
/// <param name="values">Values to log.</param>
|
||||
[MessageTemplateFormatMethod("messageTemplate")]
|
||||
public void Warning(Exception exception, string messageTemplate, params object?[] values)
|
||||
public void Warning(Exception? exception, string messageTemplate, params object?[] values)
|
||||
=> this.WriteLog(LogEventLevel.Warning, messageTemplate, exception, values);
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -138,7 +138,7 @@ public class ModuleLog
|
|||
/// <param name="messageTemplate">The message template.</param>
|
||||
/// <param name="values">Values to log.</param>
|
||||
[MessageTemplateFormatMethod("messageTemplate")]
|
||||
public void Fatal(Exception exception, string messageTemplate, params object?[] values)
|
||||
public void Fatal(Exception? exception, string messageTemplate, params object?[] values)
|
||||
=> this.WriteLog(LogEventLevel.Fatal, messageTemplate, exception, values);
|
||||
|
||||
[MessageTemplateFormatMethod("messageTemplate")]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue