Skip to content

Commit

Permalink
Add IpcPending.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ottermandias committed Jun 5, 2024
1 parent 960548f commit eb7cc6f
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 6 deletions.
5 changes: 5 additions & 0 deletions Glamourer/Interop/Material/MaterialManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,11 @@ private void UpdateMaterialValues(ActorState state, ReadOnlySpan<(uint Key, Mate
state.Materials.UpdateValue(idx, new MaterialValueState(newGame, materialValue.Model, drawData, StateSource.Manual),
out _);
break;
case StateSource.IpcPending:
materialValue.Model.Apply(ref row);
state.Materials.UpdateValue(idx, new MaterialValueState(newGame, materialValue.Model, drawData, StateSource.IpcManual),
out _);
break;
case StateSource.IpcManual:
case StateSource.Manual:
deleteList.Add(idx);
Expand Down
6 changes: 6 additions & 0 deletions Glamourer/State/StateListener.cs
Original file line number Diff line number Diff line change
Expand Up @@ -800,6 +800,12 @@ private void ApplyParameters(ActorState state, Model model)
if (_config.UseAdvancedParameters)
model.ApplySingleParameterData(flag, state.ModelData.Parameters);
break;
case StateSource.IpcPending:
state.BaseData.Parameters.Set(flag, newValue);
state.Sources[flag] = StateSource.IpcManual;
if (_config.UseAdvancedParameters)
model.ApplySingleParameterData(flag, state.ModelData.Parameters);
break;
}
}
}
Expand Down
21 changes: 15 additions & 6 deletions Glamourer/State/StateSource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,20 @@ public enum StateSource : byte
IpcFixed,
IpcManual,

// Only used for CustomizeParameters.
// Only used for CustomizeParameters and advanced dyes.
Pending,
IpcPending,
}

public static class StateSourceExtensions
{
public static StateSource Base(this StateSource source)
=> source switch
{
StateSource.Manual or StateSource.IpcManual or StateSource.Pending => StateSource.Manual,
StateSource.Fixed or StateSource.IpcFixed => StateSource.Fixed,
_ => StateSource.Game,
StateSource.Manual or StateSource.Pending => StateSource.Manual,
StateSource.IpcManual or StateSource.IpcPending => StateSource.Manual,
StateSource.Fixed or StateSource.IpcFixed => StateSource.Fixed,
_ => StateSource.Game,
};

public static bool IsGame(this StateSource source)
Expand All @@ -34,7 +36,12 @@ public static bool IsFixed(this StateSource source)
=> source.Base() is StateSource.Fixed;

public static StateSource SetPending(this StateSource source)
=> source is StateSource.Manual ? StateSource.Pending : source;
=> source switch
{
StateSource.Manual => StateSource.Pending,
StateSource.IpcManual => StateSource.IpcPending,
_ => source,
};

public static bool RequiresChange(this StateSource source)
=> source switch
Expand All @@ -46,7 +53,7 @@ public static bool RequiresChange(this StateSource source)
};

public static bool IsIpc(this StateSource source)
=> source is StateSource.IpcManual or StateSource.IpcFixed;
=> source is StateSource.IpcManual or StateSource.IpcFixed or StateSource.IpcPending;
}

public unsafe struct StateSources
Expand Down Expand Up @@ -97,13 +104,15 @@ public void RemoveFixedDesignSources()
case (byte)StateSource.Manual | ((byte)StateSource.Fixed << 4):
case (byte)StateSource.IpcFixed | ((byte)StateSource.Fixed << 4):
case (byte)StateSource.Pending | ((byte)StateSource.Fixed << 4):
case (byte)StateSource.IpcPending | ((byte)StateSource.Fixed << 4):
case (byte)StateSource.IpcManual | ((byte)StateSource.Fixed << 4):
_data[i] = (byte)((value & 0x0F) | ((byte)StateSource.Manual << 4));
break;
case (byte)StateSource.Fixed:
case ((byte)StateSource.Manual << 4) | (byte)StateSource.Fixed:
case ((byte)StateSource.IpcFixed << 4) | (byte)StateSource.Fixed:
case ((byte)StateSource.Pending << 4) | (byte)StateSource.Fixed:
case ((byte)StateSource.IpcPending << 4) | (byte)StateSource.Fixed:
case ((byte)StateSource.IpcManual << 4) | (byte)StateSource.Fixed:
_data[i] = (byte)((value & 0xF0) | (byte)StateSource.Manual);
break;
Expand Down

0 comments on commit eb7cc6f

Please sign in to comment.