mirror of
https://github.com/xivdev/Penumbra.git
synced 2025-12-15 21:24:18 +01:00
Remove OptionPriority from general option groups.
This commit is contained in:
parent
f86f29b44a
commit
b99a809eba
5 changed files with 25 additions and 14 deletions
|
|
@ -16,7 +16,7 @@ public interface IModGroup : IReadOnlyCollection<SubMod>
|
|||
public ModPriority Priority { get; }
|
||||
public Setting DefaultSettings { get; set; }
|
||||
|
||||
public ModPriority OptionPriority(Index optionIdx);
|
||||
public FullPath? FindBestMatch(Utf8GamePath gamePath);
|
||||
|
||||
public SubMod this[Index idx] { get; }
|
||||
|
||||
|
|
@ -37,7 +37,7 @@ public readonly struct ModSaveGroup : ISavable
|
|||
private readonly DirectoryInfo _basePath;
|
||||
private readonly IModGroup? _group;
|
||||
private readonly int _groupIdx;
|
||||
private readonly SubMod? _defaultMod;
|
||||
private readonly SubMod? _defaultMod;
|
||||
private readonly bool _onlyAscii;
|
||||
|
||||
public ModSaveGroup(Mod mod, int groupIdx, bool onlyAscii)
|
||||
|
|
|
|||
|
|
@ -21,8 +21,10 @@ public sealed class MultiModGroup : IModGroup
|
|||
public ModPriority Priority { get; set; }
|
||||
public Setting DefaultSettings { get; set; }
|
||||
|
||||
public ModPriority OptionPriority(Index idx)
|
||||
=> PrioritizedOptions[idx].Priority;
|
||||
public FullPath? FindBestMatch(Utf8GamePath gamePath)
|
||||
=> PrioritizedOptions.OrderByDescending(o => o.Priority)
|
||||
.SelectWhere(o => (o.Mod.FileData.TryGetValue(gamePath, out var file) || o.Mod.FileSwapData.TryGetValue(gamePath, out file), file))
|
||||
.FirstOrDefault();
|
||||
|
||||
public SubMod this[Index idx]
|
||||
=> PrioritizedOptions[idx].Mod;
|
||||
|
|
|
|||
|
|
@ -21,8 +21,10 @@ public sealed class SingleModGroup : IModGroup
|
|||
|
||||
public readonly List<SubMod> OptionData = [];
|
||||
|
||||
public ModPriority OptionPriority(Index _)
|
||||
=> Priority;
|
||||
public FullPath? FindBestMatch(Utf8GamePath gamePath)
|
||||
=> OptionData
|
||||
.SelectWhere(m => (m.FileData.TryGetValue(gamePath, out var file) || m.FileSwapData.TryGetValue(gamePath, out file), file))
|
||||
.FirstOrDefault();
|
||||
|
||||
public SubMod this[Index idx]
|
||||
=> OptionData[idx];
|
||||
|
|
|
|||
|
|
@ -540,14 +540,17 @@ public partial class ModEditWindow : Window, IDisposable
|
|||
return currentFile.Value;
|
||||
|
||||
if (Mod != null)
|
||||
foreach (var option in Mod.Groups.OrderByDescending(g => g.Priority)
|
||||
.SelectMany(g => g.WithIndex().OrderByDescending(o => g.OptionPriority(o.Index)).Select(g => g.Value))
|
||||
.Append(Mod.Default))
|
||||
{
|
||||
foreach (var option in Mod.Groups.OrderByDescending(g => g.Priority))
|
||||
{
|
||||
if (option.Files.TryGetValue(path, out var value) || option.FileSwaps.TryGetValue(path, out value))
|
||||
return value;
|
||||
if (option.FindBestMatch(path) is { } fullPath)
|
||||
return fullPath;
|
||||
}
|
||||
|
||||
if (Mod.Default.Files.TryGetValue(path, out var value) || Mod.Default.FileSwaps.TryGetValue(path, out value))
|
||||
return value;
|
||||
}
|
||||
|
||||
return new FullPath(path);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -532,10 +532,10 @@ public class ModPanelEditTab(
|
|||
panel._delayedActions.Enqueue(() => panel._modManager.OptionEditor.DeleteOption(panel._mod, groupIdx, optionIdx));
|
||||
|
||||
ImGui.TableNextColumn();
|
||||
if (group.Type != GroupType.Multi)
|
||||
if (group is not MultiModGroup multi)
|
||||
return;
|
||||
|
||||
if (Input.Priority("##Priority", groupIdx, optionIdx, group.OptionPriority(optionIdx), out var priority,
|
||||
if (Input.Priority("##Priority", groupIdx, optionIdx, multi.PrioritizedOptions[optionIdx].Priority, out var priority,
|
||||
50 * UiHelpers.Scale))
|
||||
panel._modManager.OptionEditor.ChangeOptionPriority(panel._mod, groupIdx, optionIdx, priority);
|
||||
|
||||
|
|
@ -613,7 +613,11 @@ public class ModPanelEditTab(
|
|||
var sourceGroup = panel._mod.Groups[sourceGroupIdx];
|
||||
var currentCount = group.Count;
|
||||
var option = sourceGroup[sourceOption];
|
||||
var priority = sourceGroup.OptionPriority(_dragDropOptionIdx);
|
||||
var priority = sourceGroup switch
|
||||
{
|
||||
MultiModGroup multi => multi.PrioritizedOptions[_dragDropOptionIdx].Priority,
|
||||
_ => ModPriority.Default,
|
||||
};
|
||||
panel._delayedActions.Enqueue(() =>
|
||||
{
|
||||
panel._modManager.OptionEditor.DeleteOption(panel._mod, sourceGroupIdx, sourceOption);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue