From c4aeb98126e73d111b2272e7ec7726f169e638c4 Mon Sep 17 00:00:00 2001 From: rootdarkarchon Date: Mon, 30 Jan 2023 13:42:04 +0100 Subject: [PATCH] CustomizePlus+ -> Customize+, make characters collapsible in Character Management --- .../MareConfiguration/Authentication.cs | 2 +- MareSynchronos/UI/SettingsUi.cs | 80 ++++++++++--------- MareSynchronos/UI/UIShared.cs | 2 +- 3 files changed, 45 insertions(+), 39 deletions(-) diff --git a/MareSynchronos/MareConfiguration/Authentication.cs b/MareSynchronos/MareConfiguration/Authentication.cs index 24c4a5e..af6492a 100644 --- a/MareSynchronos/MareConfiguration/Authentication.cs +++ b/MareSynchronos/MareConfiguration/Authentication.cs @@ -1,7 +1,7 @@ namespace MareSynchronos.MareConfiguration; [Serializable] -public class Authentication +public record Authentication { public string CharacterName { get; set; } = string.Empty; public uint WorldId { get; set; } = 0; diff --git a/MareSynchronos/UI/SettingsUi.cs b/MareSynchronos/UI/SettingsUi.cs index 06ad907..f8015ae 100644 --- a/MareSynchronos/UI/SettingsUi.cs +++ b/MareSynchronos/UI/SettingsUi.cs @@ -252,31 +252,13 @@ public class SettingsUi : Window, IDisposable { UiShared.DrawWithID("selectedChara" + i, () => { - var charaName = item.CharacterName; - if (ImGui.InputText("Character Name", ref charaName, 64)) - { - item.CharacterName = charaName; - _serverConfigurationManager.Save(); - } var worldIdx = (ushort)item.WorldId; var data = _uiShared.WorldData.OrderBy(u => u.Value, StringComparer.Ordinal).ToDictionary(k => k.Key, k => k.Value); if (!data.TryGetValue(worldIdx, out string? worldPreview)) { worldPreview = data.First().Value; } - if (ImGui.BeginCombo("World", worldPreview)) - { - foreach (var world in data) - { - bool isSelected = worldIdx == world.Key; - if (ImGui.Selectable(world.Value, isSelected)) - { - item.WorldId = world.Key; - _serverConfigurationManager.Save(); - } - } - ImGui.EndCombo(); - } + var secretKeyIdx = item.SecretKeyIdx; var keys = selectedServer.SecretKeys; if (!keys.TryGetValue(secretKeyIdx, out var secretKey)) @@ -284,29 +266,53 @@ public class SettingsUi : Window, IDisposable secretKey = new(); } var friendlyName = secretKey.FriendlyName; - if (ImGui.BeginCombo("Secret Key", friendlyName)) + + if (ImGui.TreeNode($"chara", $"Character: {item.CharacterName}, World: {worldPreview}, Secret Key: {friendlyName}")) { - foreach (var kvp in keys) + var charaName = item.CharacterName; + if (ImGui.InputText("Character Name", ref charaName, 64)) { - bool isSelected = kvp.Key == secretKeyIdx; - if (ImGui.Selectable(kvp.Value.FriendlyName, isSelected)) - { - item.SecretKeyIdx = kvp.Key; - _serverConfigurationManager.Save(); - } + item.CharacterName = charaName; + _serverConfigurationManager.Save(); } - ImGui.EndCombo(); - } - if (UiShared.IconTextButton(FontAwesomeIcon.Trash, "Delete Character")) - { - if (UiShared.CtrlPressed()) - _serverConfigurationManager.RemoveCharacterFromServer(idx, item); - } - UiShared.AttachToolTip("Hold CTRL to delete this entry."); + if (ImGui.BeginCombo("World", worldPreview)) + { + foreach (var world in data) + { + bool isSelected = worldIdx == world.Key; + if (ImGui.Selectable(world.Value, isSelected)) + { + item.WorldId = world.Key; + _serverConfigurationManager.Save(); + } + } + ImGui.EndCombo(); + } - if (item != selectedServer.Authentications.LastOrDefault()) - ImGui.Separator(); + if (ImGui.BeginCombo("Secret Key", friendlyName)) + { + foreach (var kvp in keys) + { + bool isSelected = kvp.Key == secretKeyIdx; + if (ImGui.Selectable(kvp.Value.FriendlyName, isSelected)) + { + item.SecretKeyIdx = kvp.Key; + _serverConfigurationManager.Save(); + } + } + ImGui.EndCombo(); + } + + if (UiShared.IconTextButton(FontAwesomeIcon.Trash, "Delete Character")) + { + if (UiShared.CtrlPressed()) + _serverConfigurationManager.RemoveCharacterFromServer(idx, item); + } + UiShared.AttachToolTip("Hold CTRL to delete this entry."); + + ImGui.TreePop(); + } }); i++; diff --git a/MareSynchronos/UI/UIShared.cs b/MareSynchronos/UI/UIShared.cs index 74f5f8d..44388e0 100644 --- a/MareSynchronos/UI/UIShared.cs +++ b/MareSynchronos/UI/UIShared.cs @@ -205,7 +205,7 @@ public partial class UiShared : IDisposable ImGui.SameLine(); ImGui.TextColored(customizeColor, customizeExists ? "Available" : "Unavailable"); ImGui.SameLine(); - ImGui.Text("PalettePlus+:"); + ImGui.Text("Palette+:"); ImGui.SameLine(); ImGui.TextColored(paletteColor, paletteExists ? "Available" : "Unavailable");