mirror of
https://github.com/xivdev/Penumbra.git
synced 2025-12-12 10:17:22 +01:00
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
Some checks failed
.NET Build / build (push) Has been cancelled
This commit is contained in:
parent
6348c4a639
commit
97c8d82b33
2 changed files with 26 additions and 21 deletions
|
|
@ -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,26 +223,31 @@ public sealed class CollectionPanel(
|
||||||
ImGui.EndGroup();
|
ImGui.EndGroup();
|
||||||
ImGui.SameLine();
|
ImGui.SameLine();
|
||||||
ImGui.BeginGroup();
|
ImGui.BeginGroup();
|
||||||
using var style = ImRaii.PushStyle(ImGuiStyleVar.ButtonTextAlign, new Vector2(0, 0.5f));
|
var width = ImGui.GetContentRegionAvail().X;
|
||||||
var name = _newName ?? collection.Identity.Name;
|
using (ImRaii.Disabled(_collections.DefaultNamed == collection))
|
||||||
var identifier = collection.Identity.Identifier;
|
|
||||||
var width = ImGui.GetContentRegionAvail().X;
|
|
||||||
var fileName = saveService.FileNames.CollectionFile(collection);
|
|
||||||
ImGui.SetNextItemWidth(width);
|
|
||||||
if (ImGui.InputText("##name", ref name, 128))
|
|
||||||
_newName = name;
|
|
||||||
if (ImGui.IsItemDeactivatedAfterEdit() && _newName != null && _newName != collection.Identity.Name)
|
|
||||||
{
|
{
|
||||||
collection.Identity.Name = _newName;
|
using var style = ImRaii.PushStyle(ImGuiStyleVar.ButtonTextAlign, new Vector2(0, 0.5f));
|
||||||
saveService.QueueSave(new ModCollectionSave(mods, collection));
|
var name = _newName ?? collection.Identity.Name;
|
||||||
selector.RestoreCollections();
|
ImGui.SetNextItemWidth(width);
|
||||||
_newName = null;
|
if (ImGui.InputText("##name", ref name, 128))
|
||||||
}
|
_newName = name;
|
||||||
else if (ImGui.IsItemDeactivated())
|
if (ImGui.IsItemDeactivatedAfterEdit() && _newName != null && _newName != collection.Identity.Name)
|
||||||
{
|
{
|
||||||
_newName = null;
|
collection.Identity.Name = _newName;
|
||||||
|
saveService.QueueSave(new ModCollectionSave(mods, collection));
|
||||||
|
selector.RestoreCollections();
|
||||||
|
_newName = null;
|
||||||
|
}
|
||||||
|
else if (ImGui.IsItemDeactivated())
|
||||||
|
{
|
||||||
|
_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;
|
||||||
|
|
|
||||||
|
|
@ -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);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue