Fix some issues with UI actors.

This commit is contained in:
Ottermandias 2023-08-28 12:17:36 +02:00
parent abcb1a6222
commit 68e85a640c
4 changed files with 18 additions and 3 deletions

View file

@ -41,6 +41,7 @@ public class ActorPanel
private Actor _actor = Actor.Null;
private ActorData _data;
private ActorState? _state;
private bool _lockedRedraw;
public ActorPanel(ActorSelector selector, StateManager stateManager, CustomizationDrawer customizationDrawer,
EquipmentDrawer equipmentDrawer, IdentifierService identification, AutoDesignApplier autoDesignApplier,
@ -59,10 +60,14 @@ public class ActorPanel
_datFileService = datFileService;
}
private CustomizeFlag CustomizeApplicationFlags
=> _lockedRedraw ? CustomizeFlagExtensions.AllRelevant & ~CustomizeFlagExtensions.RedrawRequired : CustomizeFlagExtensions.AllRelevant;
public void Draw()
{
using var group = ImRaii.Group();
(_identifier, _data) = _selector.Selection;
_lockedRedraw = _identifier.Type is IdentifierType.Special;
(_actorName, _actor) = GetHeaderName();
DrawHeader();
DrawPanel();
@ -71,7 +76,7 @@ public class ActorPanel
return;
if (_datFileService.CreateImGuiTarget(out var dat))
_stateManager.ChangeCustomize(_state!, dat.Customize, CustomizeFlagExtensions.AllRelevant, StateChanged.Source.Manual);
_stateManager.ChangeCustomize(_state!, dat.Customize, CustomizeApplicationFlags, StateChanged.Source.Manual);
_datFileService.CreateSource();
}

View file

@ -22,6 +22,9 @@ public class ActorState
public readonly ActorIdentifier Identifier;
public bool AllowsRedraw
=> Identifier.Type is not IdentifierType.Special;
/// <summary> This should always represent the unmodified state of the draw object. </summary>
public DesignData BaseData;

View file

@ -177,8 +177,14 @@ public class StateListener : IDisposable
{
case UpdateState.Transformed: break;
case UpdateState.Change:
var set = _customizations.AwaitedService.GetList(state.ModelData.Customize.Clan, state.ModelData.Customize.Gender);
var model = state.ModelData.Customize;
if (customize.Gender != model.Gender || customize.Clan != model.Clan)
{
_manager.ChangeCustomize(state, in customize, CustomizeFlagExtensions.AllRelevant, StateChanged.Source.Game);
return;
}
var set = _customizations.AwaitedService.GetList(model.Clan, model.Gender);
foreach (var index in CustomizationExtensions.AllBasic)
{
if (state[index] is not StateChanged.Source.Fixed)

View file

@ -378,7 +378,8 @@ public class StateManager : IReadOnlyDictionary<ActorIdentifier, ActorState>
if (design.DoApplyVisorToggle())
_editor.ChangeMetaState(state, ActorState.MetaIndex.VisorState, design.DesignData.IsVisorToggled(), source, out _, key);
_editor.ChangeHumanCustomize(state, design.DesignData.Customize, design.ApplyCustomize, source, out _, out var applied, key);
var flags = state.AllowsRedraw ? design.ApplyCustomize : design.ApplyCustomize & ~CustomizeFlagExtensions.RedrawRequired;
_editor.ChangeHumanCustomize(state, design.DesignData.Customize, flags, source, out _, out var applied, key);
redraw |= applied.RequiresRedraw();
foreach (var slot in EquipSlotExtensions.FullSlots)