Fix enabling / disabling

This commit is contained in:
Jade Macho 2024-02-18 23:01:45 +01:00
parent e2fafa4f60
commit 3d192964d3
Signed by: 0x0ade
GPG Key ID: E1960710FE4FBEEF
2 changed files with 21 additions and 31 deletions

View File

@ -5,7 +5,7 @@ using System;
namespace CustomResolution.Cmds; namespace CustomResolution.Cmds;
public sealed class OpenSettingsCmd : Cmd public sealed class MainCmd : Cmd
{ {
public override string Name => "cres"; public override string Name => "cres";
@ -20,7 +20,7 @@ public sealed class OpenSettingsCmd : Cmd
{ {
if (string.IsNullOrEmpty(arguments)) if (string.IsNullOrEmpty(arguments))
{ {
ToggleOpen(); Service.PluginUI.SettingsVisible = !Service.PluginUI.SettingsVisible;
return; return;
} }
@ -78,9 +78,4 @@ public sealed class OpenSettingsCmd : Cmd
Service.PrintChat("Updated custom resolution scale."); Service.PrintChat("Updated custom resolution scale.");
} }
private void ToggleOpen()
{
Service.PluginUI.SettingsVisible = !Service.PluginUI.SettingsVisible;
}
} }

View File

@ -164,9 +164,11 @@ public sealed unsafe class Plugin : IDalamudPlugin
uint width, height; uint width, height;
if (Service.Config.IsScale || _unloading) bool disabled = _unloading || !Service.Config.IsEnabled;
if (Service.Config.IsScale || disabled)
{ {
var scale = _unloading ? 1f : Service.Config.Scale; var scale = disabled ? 1f : Service.Config.Scale;
width = (uint) Math.Round(rectWidth * scale); width = (uint) Math.Round(rectWidth * scale);
height = (uint) Math.Round(rectHeight * scale); height = (uint) Math.Round(rectHeight * scale);
@ -177,8 +179,6 @@ public sealed unsafe class Plugin : IDalamudPlugin
height = Service.Config.Height; height = Service.Config.Height;
} }
if (Service.Config.IsEnabled)
{
if (width != dev->Width || height != dev->Height) if (width != dev->Width || height != dev->Height)
{ {
Service.PluginLog.Info($"Changing resolution to {width} x {height}"); Service.PluginLog.Info($"Changing resolution to {width} x {height}");
@ -197,12 +197,7 @@ public sealed unsafe class Plugin : IDalamudPlugin
dev->NewHeight = height; dev->NewHeight = height;
dev->RequestResolutionChange = 1; dev->RequestResolutionChange = 1;
} }
}
else
{
width = dev->Width;
height = dev->Height;
}
CurrentWidth = width; CurrentWidth = width;
CurrentHeight = height; CurrentHeight = height;