mirror of
https://github.com/Ottermandias/Glamourer.git
synced 2026-02-18 05:27:43 +01:00
Change mousewheel to ctrl, current material state.
This commit is contained in:
parent
42ac507b86
commit
b5b9289dc2
20 changed files with 537 additions and 296 deletions
|
|
@ -222,7 +222,7 @@ public class InternalStateEditor(
|
|||
}
|
||||
|
||||
/// <summary> Change the value of a single material color table entry. </summary>
|
||||
public bool ChangeMaterialValue(ActorState state, MaterialValueIndex index, Vector3 value, Vector3 gameValue, StateSource source, out Vector3 oldValue,
|
||||
public bool ChangeMaterialValue(ActorState state, MaterialValueIndex index, in MaterialValueState newValue, StateSource source, out ColorRow? oldValue,
|
||||
uint key = 0)
|
||||
{
|
||||
// We already have an existing value.
|
||||
|
|
@ -240,18 +240,18 @@ public class InternalStateEditor(
|
|||
}
|
||||
|
||||
// Update if edited.
|
||||
state.Materials.UpdateValue(index, new MaterialValueState(gameValue, value, source), out _);
|
||||
state.Materials.UpdateValue(index, newValue, out _);
|
||||
return true;
|
||||
}
|
||||
|
||||
// We do not have an existing value.
|
||||
oldValue = gameValue;
|
||||
oldValue = null;
|
||||
// Do not do anything if locked or if the game value updates, because then we do not need to add an entry.
|
||||
if (!state.CanUnlock(key) || source is StateSource.Game)
|
||||
return false;
|
||||
|
||||
// Only add an entry if it is sufficiently different from the game value.
|
||||
return !value.NearEqual(gameValue) && state.Materials.TryAddValue(index, new MaterialValueState(gameValue, value, source));
|
||||
// Only add an entry if it is different from the game value.
|
||||
return state.Materials.TryAddValue(index, newValue);
|
||||
}
|
||||
|
||||
public bool ChangeMetaState(ActorState state, MetaIndex index, bool value, StateSource source, out bool oldValue,
|
||||
|
|
|
|||
|
|
@ -276,7 +276,7 @@ public class StateApplier(
|
|||
return data;
|
||||
}
|
||||
|
||||
public unsafe void ChangeMaterialValue(ActorData data, MaterialValueIndex index, Vector3? value, bool force)
|
||||
public unsafe void ChangeMaterialValue(ActorData data, MaterialValueIndex index, ColorRow? value, bool force)
|
||||
{
|
||||
if (!force && !_config.UseAdvancedParameters)
|
||||
return;
|
||||
|
|
@ -289,14 +289,11 @@ public class StateApplier(
|
|||
if (!index.TryGetColorTable(texture, out var table))
|
||||
continue;
|
||||
|
||||
Vector3 actualValue;
|
||||
if (value.HasValue)
|
||||
actualValue = value.Value;
|
||||
else if (!PrepareColorSet.TryGetColorTable(actor, index, out var baseTable)
|
||||
|| !index.DataIndex.TryGetValue(baseTable[index.RowIndex], out actualValue))
|
||||
continue;
|
||||
|
||||
if (!index.DataIndex.SetValue(ref table[index.RowIndex], actualValue))
|
||||
value.Value.Apply(ref table[index.RowIndex]);
|
||||
else if (PrepareColorSet.TryGetColorTable(actor, index, out var baseTable))
|
||||
table[index.RowIndex] = baseTable[index.RowIndex];
|
||||
else
|
||||
continue;
|
||||
|
||||
MaterialService.ReplaceColorTable(texture, table);
|
||||
|
|
|
|||
|
|
@ -165,15 +165,15 @@ public class StateEditor(
|
|||
StateChanged.Invoke(StateChanged.Type.Parameter, settings.Source, state, actors, (old, @new, flag));
|
||||
}
|
||||
|
||||
public void ChangeMaterialValue(object data, MaterialValueIndex index, Vector3 value, Vector3 gameValue, ApplySettings settings)
|
||||
public void ChangeMaterialValue(object data, MaterialValueIndex index, in MaterialValueState newValue, ApplySettings settings)
|
||||
{
|
||||
var state = (ActorState)data;
|
||||
if (!Editor.ChangeMaterialValue(state, index, value, gameValue, settings.Source, out var oldValue, settings.Key))
|
||||
if (!Editor.ChangeMaterialValue(state, index, newValue, settings.Source, out var oldValue, settings.Key))
|
||||
return;
|
||||
|
||||
var actors = Applier.ChangeMaterialValue(state, index, settings.Source.RequiresChange());
|
||||
Glamourer.Log.Verbose($"Set material value in state {state.Identifier.Incognito(null)} from {oldValue} to {value}. [Affecting {actors.ToLazyString("nothing")}.]");
|
||||
StateChanged.Invoke(StateChanged.Type.MaterialValue, settings.Source, state, actors, (oldValue, value, index));
|
||||
Glamourer.Log.Verbose($"Set material value in state {state.Identifier.Incognito(null)} from {oldValue} to {newValue.Game}. [Affecting {actors.ToLazyString("nothing")}.]");
|
||||
StateChanged.Invoke(StateChanged.Type.MaterialValue, settings.Source, state, actors, (oldValue, newValue.Game, index));
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
|
|
@ -282,6 +282,20 @@ public class StateEditor(
|
|||
if (!settings.RespectManual || !state.Sources[meta].IsManual())
|
||||
Editor.ChangeMetaState(state, meta, mergedDesign.Design.DesignData.GetMeta(meta), Source(meta), out _, settings.Key);
|
||||
}
|
||||
|
||||
foreach (var (key, value) in mergedDesign.Design.Materials)
|
||||
{
|
||||
if (!value.Enabled)
|
||||
continue;
|
||||
|
||||
var idx = MaterialValueIndex.FromKey(key);
|
||||
// TODO
|
||||
//if (state.Materials.TryGetValue(idx, out var materialState))
|
||||
//{
|
||||
// if (!settings.RespectManual || materialState.Source.IsManual())
|
||||
// Editor.ChangeMaterialValue(state, idx, new MaterialValueState(materialState.Game, value.Value, materialState.DrawData));
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
||||
var actors = settings.Source.RequiresChange()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue