mirror of
https://github.com/Ottermandias/Glamourer.git
synced 2025-12-12 18:27:24 +01:00
Listen to temporary mod changes.
This commit is contained in:
parent
22a8ba3f35
commit
c85598acf4
3 changed files with 11 additions and 44 deletions
|
|
@ -21,7 +21,6 @@ public class SettingsTab(
|
||||||
Configuration config,
|
Configuration config,
|
||||||
DesignFileSystemSelector selector,
|
DesignFileSystemSelector selector,
|
||||||
CodeService codeService,
|
CodeService codeService,
|
||||||
PenumbraAutoRedraw autoRedraw,
|
|
||||||
ContextMenuService contextMenuService,
|
ContextMenuService contextMenuService,
|
||||||
UiBuilder uiBuilder,
|
UiBuilder uiBuilder,
|
||||||
GlamourerChangelog changelog,
|
GlamourerChangelog changelog,
|
||||||
|
|
@ -84,7 +83,7 @@ public class SettingsTab(
|
||||||
config.DisableFestivals == 0, v => config.DisableFestivals = v ? (byte)0 : (byte)2);
|
config.DisableFestivals == 0, v => config.DisableFestivals = v ? (byte)0 : (byte)2);
|
||||||
Checkbox("Auto-Reload Gear",
|
Checkbox("Auto-Reload Gear",
|
||||||
"Automatically reload equipment pieces on your own character when changing any mod options in Penumbra in their associated collection.",
|
"Automatically reload equipment pieces on your own character when changing any mod options in Penumbra in their associated collection.",
|
||||||
config.AutoRedrawEquipOnChanges, autoRedraw.SetState);
|
config.AutoRedrawEquipOnChanges, v => config.AutoRedrawEquipOnChanges = v);
|
||||||
Checkbox("Revert Manual Changes on Zone Change",
|
Checkbox("Revert Manual Changes on Zone Change",
|
||||||
"Restores the old behaviour of reverting your character to its game or automation base whenever you change the zone.",
|
"Restores the old behaviour of reverting your character to its game or automation base whenever you change the zone.",
|
||||||
config.RevertManualChangesOnZoneChange, v => config.RevertManualChangesOnZoneChange = v);
|
config.RevertManualChangesOnZoneChange, v => config.RevertManualChangesOnZoneChange = v);
|
||||||
|
|
|
||||||
|
|
@ -9,58 +9,26 @@ public class PenumbraAutoRedraw : IDisposable
|
||||||
private readonly PenumbraService _penumbra;
|
private readonly PenumbraService _penumbra;
|
||||||
private readonly StateManager _state;
|
private readonly StateManager _state;
|
||||||
private readonly ObjectManager _objects;
|
private readonly ObjectManager _objects;
|
||||||
private bool _enabled;
|
|
||||||
|
|
||||||
public PenumbraAutoRedraw(PenumbraService penumbra, Configuration config, StateManager state, ObjectManager objects)
|
public PenumbraAutoRedraw(PenumbraService penumbra, Configuration config, StateManager state, ObjectManager objects)
|
||||||
{
|
{
|
||||||
_penumbra = penumbra;
|
_penumbra = penumbra;
|
||||||
_config = config;
|
_config = config;
|
||||||
_state = state;
|
_state = state;
|
||||||
_objects = objects;
|
_objects = objects;
|
||||||
if (_config.AutoRedrawEquipOnChanges)
|
|
||||||
Enable();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SetState(bool value)
|
|
||||||
{
|
|
||||||
if (value == _config.AutoRedrawEquipOnChanges)
|
|
||||||
return;
|
|
||||||
|
|
||||||
_config.AutoRedrawEquipOnChanges = value;
|
|
||||||
_config.Save();
|
|
||||||
if (value)
|
|
||||||
Enable();
|
|
||||||
else
|
|
||||||
Disable();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Enable()
|
|
||||||
{
|
|
||||||
if (_enabled)
|
|
||||||
return;
|
|
||||||
|
|
||||||
_penumbra.ModSettingChanged += OnModSettingChange;
|
_penumbra.ModSettingChanged += OnModSettingChange;
|
||||||
_enabled = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Disable()
|
|
||||||
{
|
|
||||||
if (!_enabled)
|
|
||||||
return;
|
|
||||||
|
|
||||||
_penumbra.ModSettingChanged -= OnModSettingChange;
|
|
||||||
_enabled = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
=> _penumbra.ModSettingChanged -= OnModSettingChange;
|
||||||
Disable();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void OnModSettingChange(ModSettingChange type, string name, string mod, bool inherited)
|
private void OnModSettingChange(ModSettingChange type, string name, string mod, bool inherited)
|
||||||
{
|
{
|
||||||
|
if (!_config.AutoRedrawEquipOnChanges && type is not ModSettingChange.TemporaryMod)
|
||||||
|
return;
|
||||||
|
|
||||||
var playerName = _penumbra.GetCurrentPlayerCollection();
|
var playerName = _penumbra.GetCurrentPlayerCollection();
|
||||||
if (playerName == name)
|
if (playerName == name)
|
||||||
_state.ReapplyState(_objects.Player);
|
_state.ReapplyState(_objects.Player, StateSource.IpcManual);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
Subproject commit a28219ac57b53c3be6ca8c252ceb9f76ae0b6c21
|
Subproject commit 2b6bcf338794b34bcba2730c70dcbb73ce97311b
|
||||||
Loading…
Add table
Add a link
Reference in a new issue