mirror of
https://github.com/xivdev/Penumbra.git
synced 2026-01-03 06:13:45 +01:00
tmp
This commit is contained in:
parent
196ca2ce39
commit
361082813b
16 changed files with 1008 additions and 660 deletions
|
|
@ -162,12 +162,9 @@ public class ModMerger : IDisposable
|
|||
|
||||
foreach (var originalOption in mergeOptions)
|
||||
{
|
||||
foreach (var manip in originalOption.Manipulations)
|
||||
{
|
||||
if (!manips.Add(manip))
|
||||
throw new Exception(
|
||||
$"Could not add meta manipulation {manip} from {originalOption.GetFullName()} to {option.GetFullName()} because another manipulation of the same data already exists in this option.");
|
||||
}
|
||||
if (!manips.MergeForced(originalOption.Manipulations, out var failed))
|
||||
throw new Exception(
|
||||
$"Could not add meta manipulation {failed} from {originalOption.GetFullName()} to {option.GetFullName()} because another manipulation of the same data already exists in this option.");
|
||||
|
||||
foreach (var (swapA, swapB) in originalOption.FileSwaps)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,24 +1,24 @@
|
|||
using System.Collections.Frozen;
|
||||
using OtterGui.Services;
|
||||
using Penumbra.Meta.Manipulations;
|
||||
using Penumbra.Mods.Manager;
|
||||
using Penumbra.Mods.SubMods;
|
||||
|
||||
namespace Penumbra.Mods.Editor;
|
||||
|
||||
public class ModMetaEditor(ModManager modManager)
|
||||
public class ModMetaEditor(ModManager modManager) : MetaDictionary, IService
|
||||
{
|
||||
private readonly HashSet<ImcManipulation> _imc = [];
|
||||
private readonly HashSet<EqpManipulation> _eqp = [];
|
||||
private readonly HashSet<EqdpManipulation> _eqdp = [];
|
||||
private readonly HashSet<GmpManipulation> _gmp = [];
|
||||
private readonly HashSet<EstManipulation> _est = [];
|
||||
private readonly HashSet<RspManipulation> _rsp = [];
|
||||
private readonly HashSet<GlobalEqpManipulation> _globalEqp = [];
|
||||
|
||||
public sealed class OtherOptionData : HashSet<string>
|
||||
{
|
||||
public int TotalCount;
|
||||
|
||||
public void Add(string name, int count)
|
||||
{
|
||||
if (count > 0)
|
||||
Add(name);
|
||||
TotalCount += count;
|
||||
}
|
||||
|
||||
public new void Clear()
|
||||
{
|
||||
TotalCount = 0;
|
||||
|
|
@ -31,91 +31,9 @@ public class ModMetaEditor(ModManager modManager)
|
|||
|
||||
public bool Changes { get; private set; }
|
||||
|
||||
public IReadOnlySet<ImcManipulation> Imc
|
||||
=> _imc;
|
||||
|
||||
public IReadOnlySet<EqpManipulation> Eqp
|
||||
=> _eqp;
|
||||
|
||||
public IReadOnlySet<EqdpManipulation> Eqdp
|
||||
=> _eqdp;
|
||||
|
||||
public IReadOnlySet<GmpManipulation> Gmp
|
||||
=> _gmp;
|
||||
|
||||
public IReadOnlySet<EstManipulation> Est
|
||||
=> _est;
|
||||
|
||||
public IReadOnlySet<RspManipulation> Rsp
|
||||
=> _rsp;
|
||||
|
||||
public IReadOnlySet<GlobalEqpManipulation> GlobalEqp
|
||||
=> _globalEqp;
|
||||
|
||||
public bool CanAdd(MetaManipulation m)
|
||||
public new void Clear()
|
||||
{
|
||||
return m.ManipulationType switch
|
||||
{
|
||||
MetaManipulation.Type.Imc => !_imc.Contains(m.Imc),
|
||||
MetaManipulation.Type.Eqdp => !_eqdp.Contains(m.Eqdp),
|
||||
MetaManipulation.Type.Eqp => !_eqp.Contains(m.Eqp),
|
||||
MetaManipulation.Type.Est => !_est.Contains(m.Est),
|
||||
MetaManipulation.Type.Gmp => !_gmp.Contains(m.Gmp),
|
||||
MetaManipulation.Type.Rsp => !_rsp.Contains(m.Rsp),
|
||||
MetaManipulation.Type.GlobalEqp => !_globalEqp.Contains(m.GlobalEqp),
|
||||
_ => false,
|
||||
};
|
||||
}
|
||||
|
||||
public bool Add(MetaManipulation m)
|
||||
{
|
||||
var added = m.ManipulationType switch
|
||||
{
|
||||
MetaManipulation.Type.Imc => _imc.Add(m.Imc),
|
||||
MetaManipulation.Type.Eqdp => _eqdp.Add(m.Eqdp),
|
||||
MetaManipulation.Type.Eqp => _eqp.Add(m.Eqp),
|
||||
MetaManipulation.Type.Est => _est.Add(m.Est),
|
||||
MetaManipulation.Type.Gmp => _gmp.Add(m.Gmp),
|
||||
MetaManipulation.Type.Rsp => _rsp.Add(m.Rsp),
|
||||
MetaManipulation.Type.GlobalEqp => _globalEqp.Add(m.GlobalEqp),
|
||||
_ => false,
|
||||
};
|
||||
Changes |= added;
|
||||
return added;
|
||||
}
|
||||
|
||||
public bool Delete(MetaManipulation m)
|
||||
{
|
||||
var deleted = m.ManipulationType switch
|
||||
{
|
||||
MetaManipulation.Type.Imc => _imc.Remove(m.Imc),
|
||||
MetaManipulation.Type.Eqdp => _eqdp.Remove(m.Eqdp),
|
||||
MetaManipulation.Type.Eqp => _eqp.Remove(m.Eqp),
|
||||
MetaManipulation.Type.Est => _est.Remove(m.Est),
|
||||
MetaManipulation.Type.Gmp => _gmp.Remove(m.Gmp),
|
||||
MetaManipulation.Type.Rsp => _rsp.Remove(m.Rsp),
|
||||
MetaManipulation.Type.GlobalEqp => _globalEqp.Remove(m.GlobalEqp),
|
||||
_ => false,
|
||||
};
|
||||
Changes |= deleted;
|
||||
return deleted;
|
||||
}
|
||||
|
||||
public bool Change(MetaManipulation m)
|
||||
=> Delete(m) && Add(m);
|
||||
|
||||
public bool Set(MetaManipulation m)
|
||||
=> Delete(m) | Add(m);
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
_imc.Clear();
|
||||
_eqp.Clear();
|
||||
_eqdp.Clear();
|
||||
_gmp.Clear();
|
||||
_est.Clear();
|
||||
_rsp.Clear();
|
||||
_globalEqp.Clear();
|
||||
base.Clear();
|
||||
Changes = true;
|
||||
}
|
||||
|
||||
|
|
@ -129,15 +47,19 @@ public class ModMetaEditor(ModManager modManager)
|
|||
if (option == currentOption)
|
||||
continue;
|
||||
|
||||
foreach (var manip in option.Manipulations)
|
||||
{
|
||||
var data = OtherData[manip.ManipulationType];
|
||||
++data.TotalCount;
|
||||
data.Add(option.GetFullName());
|
||||
}
|
||||
var name = option.GetFullName();
|
||||
OtherData[MetaManipulation.Type.Imc].Add(name, option.Manipulations.GetCount(MetaManipulation.Type.Imc));
|
||||
OtherData[MetaManipulation.Type.Eqp].Add(name, option.Manipulations.GetCount(MetaManipulation.Type.Eqp));
|
||||
OtherData[MetaManipulation.Type.Eqdp].Add(name, option.Manipulations.GetCount(MetaManipulation.Type.Eqdp));
|
||||
OtherData[MetaManipulation.Type.Gmp].Add(name, option.Manipulations.GetCount(MetaManipulation.Type.Gmp));
|
||||
OtherData[MetaManipulation.Type.Est].Add(name, option.Manipulations.GetCount(MetaManipulation.Type.Est));
|
||||
OtherData[MetaManipulation.Type.Rsp].Add(name, option.Manipulations.GetCount(MetaManipulation.Type.Rsp));
|
||||
OtherData[MetaManipulation.Type.GlobalEqp].Add(name, option.Manipulations.GetCount(MetaManipulation.Type.GlobalEqp));
|
||||
}
|
||||
|
||||
Split(currentOption.Manipulations);
|
||||
Clear();
|
||||
UnionWith(currentOption.Manipulations);
|
||||
Changes = false;
|
||||
}
|
||||
|
||||
public void Apply(IModDataContainer container)
|
||||
|
|
@ -145,50 +67,7 @@ public class ModMetaEditor(ModManager modManager)
|
|||
if (!Changes)
|
||||
return;
|
||||
|
||||
modManager.OptionEditor.SetManipulations(container, [..Recombine()]);
|
||||
modManager.OptionEditor.SetManipulations(container, this);
|
||||
Changes = false;
|
||||
}
|
||||
|
||||
private void Split(IEnumerable<MetaManipulation> manips)
|
||||
{
|
||||
Clear();
|
||||
foreach (var manip in manips)
|
||||
{
|
||||
switch (manip.ManipulationType)
|
||||
{
|
||||
case MetaManipulation.Type.Imc:
|
||||
_imc.Add(manip.Imc);
|
||||
break;
|
||||
case MetaManipulation.Type.Eqdp:
|
||||
_eqdp.Add(manip.Eqdp);
|
||||
break;
|
||||
case MetaManipulation.Type.Eqp:
|
||||
_eqp.Add(manip.Eqp);
|
||||
break;
|
||||
case MetaManipulation.Type.Est:
|
||||
_est.Add(manip.Est);
|
||||
break;
|
||||
case MetaManipulation.Type.Gmp:
|
||||
_gmp.Add(manip.Gmp);
|
||||
break;
|
||||
case MetaManipulation.Type.Rsp:
|
||||
_rsp.Add(manip.Rsp);
|
||||
break;
|
||||
case MetaManipulation.Type.GlobalEqp:
|
||||
_globalEqp.Add(manip.GlobalEqp);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Changes = false;
|
||||
}
|
||||
|
||||
public IEnumerable<MetaManipulation> Recombine()
|
||||
=> _imc.Select(m => (MetaManipulation)m)
|
||||
.Concat(_eqdp.Select(m => (MetaManipulation)m))
|
||||
.Concat(_eqp.Select(m => (MetaManipulation)m))
|
||||
.Concat(_est.Select(m => (MetaManipulation)m))
|
||||
.Concat(_gmp.Select(m => (MetaManipulation)m))
|
||||
.Concat(_rsp.Select(m => (MetaManipulation)m))
|
||||
.Concat(_globalEqp.Select(m => (MetaManipulation)m));
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue