Skip to content

Commit

Permalink
Remove explicit Penumbra IPC
Browse files Browse the repository at this point in the history
- Use the SubstitutionProvider instead
  • Loading branch information
KazWolfe committed Aug 22, 2024
1 parent 85ee7b1 commit 936d60a
Show file tree
Hide file tree
Showing 10 changed files with 26 additions and 190 deletions.
1 change: 1 addition & 0 deletions FFXIVPlugin/Base/Injections.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,5 @@ public class Injections {
[PluginService] public static IToastGui Toasts { get; private set; }
[PluginService] public static IPluginLog PluginLog { get; private set; }
[PluginService] public static IGameInteropProvider GameInteropProvider { get; private set; }
[PluginService] public static ITextureSubstitutionProvider TextureSubstitutionProvider { get; private set; }
}
11 changes: 3 additions & 8 deletions FFXIVPlugin/Base/PluginConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,19 @@ namespace XIVDeck.FFXIVPlugin.Base;
[Serializable]
public class PluginConfig : IPluginConfiguration {
public int Version { get; set; } = 0;

/// <summary>
/// Determines if the plugin is in "safe mode". Disabling this setting allows certain high-risk actions to be taken
/// without any guards.
/// </summary>
public bool SafeMode { get; set; } = true;

/// <summary>
/// Set when a Stream Deck (or other API client) has been linked to this game plugin at least once. Effectively used
/// to track setup state of the application.
/// </summary>
public bool HasLinkedStreamDeckPlugin { get; set; }

/// <summary>
/// Set when the user has requested the Penumbra IPC be enabled to show modded icons on the Stream Deck.
/// </summary>
public bool UsePenumbraIPC { get; set; }

/// <summary>
/// Set when the user has requested that macro icons set through the /micon command are resolved. When not set,
/// XIVDeck will instead use the icon specified in the macro dropdown, regardless of /micon setting.
Expand Down Expand Up @@ -62,4 +57,4 @@ public class PluginConfig : IPluginConfiguration {
public void Save() {
Injections.PluginInterface.SavePluginConfig(this);
}
}
}
23 changes: 10 additions & 13 deletions FFXIVPlugin/Game/Managers/IconManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,35 +5,32 @@
using XIVDeck.FFXIVPlugin.IPC.Subscribers;
using XIVDeck.FFXIVPlugin.Utils;

namespace XIVDeck.FFXIVPlugin.Game.Managers;
namespace XIVDeck.FFXIVPlugin.Game.Managers;

// borrowed from https://github.com/Caraxi/RemindMe/blob/master/IconManager.cs
public static class IconManager {
private const string IconFileFormat = "ui/icon/{0:D3}000/{1}{2:D6}{3}.tex";

private static string GetIconPath(string lang, int iconId, bool highres = false, bool forceOriginal = false) {
var useHqIcon = false;

if (iconId > 1_000_000) {
useHqIcon = true;
iconId -= 1_000_000;
}

var path = string.Format(IconFileFormat,
iconId / 1000, (useHqIcon ? "hq/" : "") + lang, iconId, highres ? "_hr1" : "");

if (PenumbraIPC.Instance is {Enabled: true} && !forceOriginal && XIVDeckPlugin.Instance.Configuration.UsePenumbraIPC)
path = PenumbraIPC.Instance.ResolvePenumbraPath(path);
var path = string.Format(IconFileFormat,
iconId / 1000, (useHqIcon ? "hq/" : "") + lang, iconId, highres ? "_hr1" : "");

return path;
return Injections.TextureSubstitutionProvider.GetSubstitutedPath(path);
}

public static TexFile? GetIcon(string lang, int iconId, bool highres = false) {
TexFile? texFile;
if (lang.Length > 0 && !lang.EndsWith("/"))

if (lang.Length > 0 && !lang.EndsWith('/'))
lang += "/";

var texPath = GetIconPath(lang, iconId, true);

if (Path.IsPathRooted(texPath)) {
Expand Down Expand Up @@ -61,10 +58,10 @@ private static string GetIconPath(string lang, int iconId, bool highres = false,
return texFile;
}
}

public static string GetIconAsPngString(int iconId) {
var icon = GetIcon("", iconId, true) ?? GetIcon("", 0, true)!;

return "data:image/png;base64," + Convert.ToBase64String(icon.GetImage().ConvertToPng());
}
}
}
84 changes: 0 additions & 84 deletions FFXIVPlugin/IPC/Subscribers/PenumbraIPC.cs

This file was deleted.

22 changes: 0 additions & 22 deletions FFXIVPlugin/Resources/Localization/UIStrings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 1 addition & 12 deletions FFXIVPlugin/Resources/Localization/UIStrings.de.resx
Original file line number Diff line number Diff line change
Expand Up @@ -103,18 +103,7 @@
<value>WARNUNG: SICHERER MODUS DEAKTIVIERT! Du kannst möglicherweise verbotene oder ungültige Befehle von deinem Stream Deck an das Spiel senden.</value>
<comment>"Illegal commands" in this case mean commands that normally cannot be sent to the game and may cause damage or harm if proper care is not taken.</comment>
</data>
<data name="SettingsWindow_EnablePenumbraIPC" xml:space="preserve">
<value>Penumbra Integration verwenden</value>
<comment>Setting to enable integration with another app named Penumbra.</comment>
</data>
<data name="SettingsWindow_EnablePenumbraIPC_Help" xml:space="preserve">
<value>Wenn aktiviert, wird versucht, Icons von Penumbra auf dem Stream Deck anzuzeigen. Beachte, dass Penumbra installiert sein muss, damit diese Einstellung eine Wirkung hat.

Wenn deaktiviert, werden stattdessen originale Spielsymbole verwendet.

Standard: Aus</value>
</data>
<data name="SettingsWindow_ExperimentalSettings" xml:space="preserve">
<data name="SettingsWindow_ExperimentalSettings" xml:space="preserve">
<value>Experimentelle Einstellungen</value>
<comment>Header for configuration window section.</comment>
</data>
Expand Down
13 changes: 1 addition & 12 deletions FFXIVPlugin/Resources/Localization/UIStrings.fr.resx
Original file line number Diff line number Diff line change
Expand Up @@ -103,18 +103,7 @@
<value>DANGER : MODE SÉCURISÉ DÉSACTIVÉ ! Vous risquez d'envoyer des commandes illégales depuis votre Stream Deck vers le jeu.</value>
<comment>"Illegal commands" in this case mean commands that normally cannot be sent to the game and may cause damage or harm if proper care is not taken.</comment>
</data>
<data name="SettingsWindow_EnablePenumbraIPC" xml:space="preserve">
<value>Activer l'intégration avec Penumbra</value>
<comment>Setting to enable integration with another app named Penumbra.</comment>
</data>
<data name="SettingsWindow_EnablePenumbraIPC_Help" xml:space="preserve">
<value>Lorsqu'elle est activée, cette fonctionnalité tentera d'afficher les icônes provenant de Penumbra sur le Stream Deck. Notez que Penumbra doit être installé pour que cela fonctionne.

Si désactivé, les icônes par défaut du jeu seront utilisées à la place.

Par défaut : Désactivé</value>
</data>
<data name="SettingsWindow_ExperimentalSettings" xml:space="preserve">
<data name="SettingsWindow_ExperimentalSettings" xml:space="preserve">
<value>Fonctionnalités expérimentales</value>
<comment>Header for configuration window section.</comment>
</data>
Expand Down
13 changes: 1 addition & 12 deletions FFXIVPlugin/Resources/Localization/UIStrings.ja.resx
Original file line number Diff line number Diff line change
Expand Up @@ -103,18 +103,7 @@
<value>危険: セーフモードが無効になりました! Stream Deck からゲームに不正なコマンドを送信できる可能性があります。</value>
<comment>"Illegal commands" in this case mean commands that normally cannot be sent to the game and may cause damage or harm if proper care is not taken.</comment>
</data>
<data name="SettingsWindow_EnablePenumbraIPC" xml:space="preserve">
<value>Penumbra のアイコンを使用する</value>
<comment>Setting to enable integration with another app named Penumbra.</comment>
</data>
<data name="SettingsWindow_EnablePenumbraIPC_Help" xml:space="preserve">
<value>この機能を有効にすると、 Stream Deck にPenumbraのアイコンを表示しようとします。 この設定を有効にするには、Penumbraをインストールする必要があります。

無効にすると、代わりにオリジナルのゲームアイコンが使用されます。

デフォルト: 無効</value>
</data>
<data name="SettingsWindow_ExperimentalSettings" xml:space="preserve">
<data name="SettingsWindow_ExperimentalSettings" xml:space="preserve">
<value>実験的な設定</value>
<comment>Header for configuration window section.</comment>
</data>
Expand Down
11 changes: 0 additions & 11 deletions FFXIVPlugin/Resources/Localization/UIStrings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -104,17 +104,6 @@
<value>DANGER: SAFE MODE DISABLED! You may be able to send illegal commands from your Stream Deck to the game.</value>
<comment>"Illegal commands" in this case mean commands that normally cannot be sent to the game and may cause damage or harm if proper care is not taken.</comment>
</data>
<data name="SettingsWindow_EnablePenumbraIPC" xml:space="preserve">
<value>Enable Penumbra Integration</value>
<comment>Setting to enable integration with another app named Penumbra.</comment>
</data>
<data name="SettingsWindow_EnablePenumbraIPC_Help" xml:space="preserve">
<value>When enabled, this feature will attempt to display icons from Penumbra on the Stream Deck. Note that Penumbra must be installed for this setting to have any effect.

If disabled, original game icons will be used instead.

Default: Off</value>
</data>
<data name="SettingsWindow_ExperimentalSettings" xml:space="preserve">
<value>Experimental Settings</value>
<comment>Header for configuration window section.</comment>
Expand Down
25 changes: 9 additions & 16 deletions FFXIVPlugin/UI/Windows/SettingsWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class SettingsWindow : Window {
public const string WindowKey = "###xivDeckSettingsWindow";

private static SettingsWindow? _instance;

internal static SettingsWindow GetOrCreate() {
if (_instance == null) {
_instance = new SettingsWindow();
Expand All @@ -29,13 +29,12 @@ internal static SettingsWindow GetOrCreate() {
// settings
private int _websocketPort;
private bool _safeMode = true;
private bool _usePenumbraIPC;
private bool _useMIconIcons;
private bool _listenOnAllInterfaces;

public SettingsWindow(bool forceMainWindow = true) :
base(WindowKey, ImGuiWindowFlags.NoScrollbar | ImGuiWindowFlags.NoScrollWithMouse | ImGuiWindowFlags.NoCollapse, forceMainWindow) {

this.SizeCondition = ImGuiCond.FirstUseEver;
this.SizeConstraints = new WindowSizeConstraints {
MinimumSize = new Vector2(350, 250),
Expand All @@ -50,9 +49,6 @@ public override void OnOpen() {
this._safeMode = this._plugin.Configuration.SafeMode;

this._listenOnAllInterfaces = this._plugin.Configuration.ListenOnAllInterfaces;

// setting flags
this._usePenumbraIPC = this._plugin.Configuration.UsePenumbraIPC;

// experimental flags
this._useMIconIcons = this._plugin.Configuration.UseMIconIcons;
Expand All @@ -62,7 +58,7 @@ public override void Draw() {
var windowSize = ImGui.GetContentRegionAvail();

var pbs = ImGuiHelpers.GetButtonSize("placeholder");

ImGui.BeginChild("SettingsPane", windowSize with {Y = windowSize.Y - pbs.Y - 6});

if (!this._safeMode) {
Expand Down Expand Up @@ -97,12 +93,10 @@ public override void Draw() {
}

ImGui.Spacing();
ImGui.Checkbox(UIStrings.SettingsWindow_EnablePenumbraIPC, ref this._usePenumbraIPC);
ImGuiComponents.HelpMarker(UIStrings.SettingsWindow_EnablePenumbraIPC_Help);


ImGui.Checkbox(UIStrings.SettingsWindow_Experiment_MIcon, ref this._useMIconIcons);
ImGuiComponents.HelpMarker(UIStrings.SettingsWindow_UseMIcon_Help);

ImGui.Dummy(new Vector2(0, 10));

ImGui.EndChild();
Expand All @@ -111,7 +105,7 @@ public override void Draw() {
ImGui.Separator();

if (ImGui.Button(UIStrings.SettingsWindow_GitHubLink)) UiUtil.OpenXIVDeckGitHub();

#if DEBUG
ImGui.SameLine();
if (ImGui.Button("Debug")) {
Expand All @@ -133,19 +127,18 @@ private void SaveSettings() {
if (this._websocketPort != this._plugin.Configuration.WebSocketPort) {
this._plugin.Configuration.WebSocketPort = this._websocketPort;
this._plugin.Configuration.HasLinkedStreamDeckPlugin = false;

NagWindow.CloseAllNags();
SetupNag.Show();
}

this._plugin.Configuration.UsePenumbraIPC = this._usePenumbraIPC;
this._plugin.Configuration.UseMIconIcons = this._useMIconIcons;

this._plugin.Configuration.ListenOnAllInterfaces = this._listenOnAllInterfaces;

this._plugin.Configuration.Save();

// initialize regardless of change(s) so that we can easily restart the server when necessary
this._plugin.InitializeWebServer();
}
}
}

0 comments on commit 936d60a

Please sign in to comment.