Prevent default-named collection from being renamed and always put it at the top of the selector.
Some checks failed
.NET Build / build (push) Has been cancelled

This commit is contained in:
Ottermandias 2025-09-07 10:45:28 +02:00
parent 6348c4a639
commit 97c8d82b33
2 changed files with 26 additions and 21 deletions

View file

@ -11,6 +11,7 @@ using OtterGui;
using OtterGui.Classes; using OtterGui.Classes;
using OtterGui.Extensions; using OtterGui.Extensions;
using OtterGui.Raii; using OtterGui.Raii;
using OtterGui.Text;
using Penumbra.Collections; using Penumbra.Collections;
using Penumbra.Collections.Manager; using Penumbra.Collections.Manager;
using Penumbra.GameData.Actors; using Penumbra.GameData.Actors;
@ -222,11 +223,11 @@ public sealed class CollectionPanel(
ImGui.EndGroup(); ImGui.EndGroup();
ImGui.SameLine(); ImGui.SameLine();
ImGui.BeginGroup(); ImGui.BeginGroup();
var width = ImGui.GetContentRegionAvail().X;
using (ImRaii.Disabled(_collections.DefaultNamed == collection))
{
using var style = ImRaii.PushStyle(ImGuiStyleVar.ButtonTextAlign, new Vector2(0, 0.5f)); using var style = ImRaii.PushStyle(ImGuiStyleVar.ButtonTextAlign, new Vector2(0, 0.5f));
var name = _newName ?? collection.Identity.Name; var name = _newName ?? collection.Identity.Name;
var identifier = collection.Identity.Identifier;
var width = ImGui.GetContentRegionAvail().X;
var fileName = saveService.FileNames.CollectionFile(collection);
ImGui.SetNextItemWidth(width); ImGui.SetNextItemWidth(width);
if (ImGui.InputText("##name", ref name, 128)) if (ImGui.InputText("##name", ref name, 128))
_newName = name; _newName = name;
@ -241,7 +242,12 @@ public sealed class CollectionPanel(
{ {
_newName = null; _newName = null;
} }
}
if (_collections.DefaultNamed == collection)
ImUtf8.HoverTooltip(ImGuiHoveredFlags.AllowWhenDisabled, "The Default collection can not be renamed."u8);
var identifier = collection.Identity.Identifier;
var fileName = saveService.FileNames.CollectionFile(collection);
using (ImRaii.PushFont(UiBuilder.MonoFont)) using (ImRaii.PushFont(UiBuilder.MonoFont))
{ {
if (ImGui.Button(collection.Identity.Identifier, new Vector2(width, 0))) if (ImGui.Button(collection.Identity.Identifier, new Vector2(width, 0)))
@ -375,9 +381,7 @@ public sealed class CollectionPanel(
ImGuiUtil.TextWrapped(type.ToDescription()); ImGuiUtil.TextWrapped(type.ToDescription());
switch (type) switch (type)
{ {
case CollectionType.Default: case CollectionType.Default: ImGui.TextUnformatted("Overruled by any other Assignment."); break;
ImGui.TextUnformatted("Overruled by any other Assignment.");
break;
case CollectionType.Yourself: case CollectionType.Yourself:
ImGuiUtil.DrawColoredText(("Overruled by ", 0), ("Individual ", ColorId.NewMod.Value()), ("Assignments.", 0)); ImGuiUtil.DrawColoredText(("Overruled by ", 0), ("Individual ", ColorId.NewMod.Value()), ("Assignments.", 0));
break; break;

View file

@ -116,7 +116,8 @@ public sealed class CollectionSelector : ItemSelector<ModCollection>, IDisposabl
public void RestoreCollections() public void RestoreCollections()
{ {
Items.Clear(); Items.Clear();
foreach (var c in _storage.OrderBy(c => c.Identity.Name)) Items.Add(_storage.DefaultNamed);
foreach (var c in _storage.OrderBy(c => c.Identity.Name).Where(c => c != _storage.DefaultNamed))
Items.Add(c); Items.Add(c);
SetFilterDirty(); SetFilterDirty();
SetCurrent(_active.Current); SetCurrent(_active.Current);