mirror of
https://github.com/Ottermandias/Glamourer.git
synced 2025-12-30 20:33:44 +01:00
Use new functionality.
This commit is contained in:
parent
a4de13f228
commit
2219d9293f
9 changed files with 163 additions and 136 deletions
|
|
@ -4,74 +4,109 @@ using Penumbra.GameData.Enums;
|
|||
|
||||
namespace Glamourer.Gui;
|
||||
|
||||
public ref struct ToggleDrawData
|
||||
public struct ToggleDrawData
|
||||
{
|
||||
private IDesignEditor _editor = null!;
|
||||
private object _data = null!;
|
||||
private StateIndex _index;
|
||||
|
||||
public bool Locked;
|
||||
public bool DisplayApplication;
|
||||
|
||||
public bool CurrentValue;
|
||||
public bool CurrentApply;
|
||||
|
||||
public Action<bool> SetValue = null!;
|
||||
public Action<bool> SetApply = null!;
|
||||
|
||||
public string Label = string.Empty;
|
||||
public string Tooltip = string.Empty;
|
||||
|
||||
|
||||
public ToggleDrawData()
|
||||
{ }
|
||||
|
||||
public readonly void SetValue(bool value)
|
||||
{
|
||||
switch (_index.GetFlag())
|
||||
{
|
||||
case MetaIndex index:
|
||||
_editor.ChangeMetaState(_data, index, value, ApplySettings.Manual);
|
||||
break;
|
||||
case CrestFlag flag:
|
||||
_editor.ChangeCrest(_data, flag, value, ApplySettings.Manual);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public readonly void SetApply(bool value)
|
||||
{
|
||||
var manager = (DesignManager)_editor;
|
||||
var design = (Design)_data;
|
||||
switch (_index.GetFlag())
|
||||
{
|
||||
case MetaIndex index:
|
||||
manager.ChangeApplyMeta(design, index, value);
|
||||
break;
|
||||
case CrestFlag flag:
|
||||
manager.ChangeApplyCrest(design, flag, value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public static ToggleDrawData FromDesign(MetaIndex index, DesignManager manager, Design design)
|
||||
=> new()
|
||||
{
|
||||
_index = index,
|
||||
_editor = manager,
|
||||
_data = design,
|
||||
Label = index.ToName(),
|
||||
Tooltip = string.Empty,
|
||||
Locked = design.WriteProtected(),
|
||||
DisplayApplication = true,
|
||||
CurrentValue = design.DesignData.GetMeta(index),
|
||||
CurrentApply = design.DoApplyMeta(index),
|
||||
SetValue = b => manager.ChangeMetaState(design, index, b),
|
||||
SetApply = b => manager.ChangeApplyMeta(design, index, b),
|
||||
};
|
||||
|
||||
public static ToggleDrawData FromState(MetaIndex index, StateManager manager, ActorState state)
|
||||
=> new()
|
||||
{
|
||||
_index = index,
|
||||
_editor = manager,
|
||||
_data = state,
|
||||
Label = index.ToName(),
|
||||
Tooltip = index.ToTooltip(),
|
||||
Locked = state.IsLocked,
|
||||
CurrentValue = state.ModelData.GetMeta(index),
|
||||
};
|
||||
|
||||
public static ToggleDrawData CrestFromDesign(CrestFlag slot, DesignManager manager, Design design)
|
||||
=> new()
|
||||
{
|
||||
_index = slot,
|
||||
_editor = manager,
|
||||
_data = design,
|
||||
Label = $"{slot.ToLabel()} Crest",
|
||||
Tooltip = string.Empty,
|
||||
Locked = design.WriteProtected(),
|
||||
DisplayApplication = true,
|
||||
CurrentValue = design.DesignData.Crest(slot),
|
||||
CurrentApply = design.DoApplyCrest(slot),
|
||||
SetValue = v => manager.ChangeCrest(design, slot, v),
|
||||
SetApply = v => manager.ChangeApplyCrest(design, slot, v),
|
||||
};
|
||||
|
||||
public static ToggleDrawData CrestFromState(CrestFlag slot, StateManager manager, ActorState state)
|
||||
=> new()
|
||||
{
|
||||
_index = slot,
|
||||
_editor = manager,
|
||||
_data = state,
|
||||
Label = $"{slot.ToLabel()} Crest",
|
||||
Tooltip = "Hide or show your free company crest on this piece of gear.",
|
||||
Locked = state.IsLocked,
|
||||
CurrentValue = state.ModelData.Crest(slot),
|
||||
SetValue = v => manager.ChangeCrest(state, slot, v, ApplySettings.Manual),
|
||||
};
|
||||
|
||||
public static ToggleDrawData FromState(MetaIndex index, StateManager manager, ActorState state)
|
||||
{
|
||||
return new ToggleDrawData
|
||||
{
|
||||
Label = index.ToName(),
|
||||
Tooltip = index.ToTooltip(),
|
||||
Locked = state.IsLocked,
|
||||
CurrentValue = state.ModelData.GetMeta(index),
|
||||
SetValue = b => manager.ChangeMetaState(state, index, b, ApplySettings.Manual),
|
||||
};
|
||||
}
|
||||
|
||||
public static ToggleDrawData FromValue(MetaIndex index, bool value)
|
||||
=> new()
|
||||
{
|
||||
_index = index,
|
||||
Label = index.ToName(),
|
||||
Tooltip = index.ToTooltip(),
|
||||
Locked = true,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue