Skip to content

Commit

Permalink
Add check for Palette+.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ottermandias committed Jan 17, 2024
1 parent 78a77eb commit 5a30107
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 12 deletions.
5 changes: 3 additions & 2 deletions Glamourer/Gui/Tabs/SettingsTab.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ public class SettingsTab(
FunModule funModule,
IKeyState keys,
DesignColorUi designColorUi,
PaletteImport paletteImport)
PaletteImport paletteImport,
PalettePlusChecker paletteChecker)
: ITab
{
private readonly VirtualKey[] _validKeys = keys.GetValidVirtualKeys().Prepend(VirtualKey.NO_KEY).ToArray();
Expand Down Expand Up @@ -84,7 +85,7 @@ private void DrawBehaviorSettings()
config.RevertManualChangesOnZoneChange, v => config.RevertManualChangesOnZoneChange = v);
Checkbox("Enable Advanced Customization Options",
"Enable the display and editing of advanced customization options like arbitrary colors.",
config.UseAdvancedParameters, v => config.UseAdvancedParameters = v);
config.UseAdvancedParameters, paletteChecker.SetAdvancedParameters);
PaletteImportButton();
ImGui.NewLine();
}
Expand Down
10 changes: 0 additions & 10 deletions Glamourer/Interop/PalettePlus/PaletteImport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -164,14 +164,4 @@ void ParseSingle(string attribute, CustomizeParameterFlag flag, ref float value)
Glamourer.Log.Error($"Could not read Palette+ configuration:\n{ex}");
}
}

public bool TryRead(string name, ref CustomizeParameterData data)
{
if (!Data.TryGetValue(name, out var t))
return false;

foreach (var flag in t.Item2.Iterate())
data[flag] = t.Item1[flag];
return true;
}
}
49 changes: 49 additions & 0 deletions Glamourer/Interop/PalettePlus/PalettePlusChecker.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
using Dalamud.Interface.Internal.Notifications;
using Dalamud.Plugin;
using OtterGui.Classes;
using OtterGui.Services;

namespace Glamourer.Interop.PalettePlus;

public sealed class PalettePlusChecker : IRequiredService, IDisposable
{
private readonly Timer _paletteTimer;
private readonly Configuration _config;
private readonly DalamudPluginInterface _pluginInterface;

public PalettePlusChecker(Configuration config, DalamudPluginInterface pluginInterface)
{
_config = config;
_pluginInterface = pluginInterface;
_paletteTimer = new Timer(_ => PalettePlusCheck(), null, TimeSpan.FromSeconds(30), Timeout.InfiniteTimeSpan);
}

public void Dispose()
=> _paletteTimer.Dispose();

public void SetAdvancedParameters(bool value)
{
_config.UseAdvancedParameters = value;
PalettePlusCheck();
}

private void PalettePlusCheck()
{
if (!_config.UseAdvancedParameters)
return;

try
{
var subscriber = _pluginInterface.GetIpcSubscriber<string>("PalettePlus.ApiVersion");
subscriber.InvokeFunc();
Glamourer.Messager.AddMessage(new Notification(
"You currently have Palette+ installed. This conflicts with Glamourers advanced options and will cause invalid state.\n\n"
+ "Please uninstall Palette+ and restart your game. Palette+ is deprecated and no longer supported by Mare Synchronos.",
NotificationType.Warning, 10000));
}
catch
{
// ignored
}
}
}

0 comments on commit 5a30107

Please sign in to comment.