CustomizePlus+ -> Customize+, make characters collapsible in Character Management

This commit is contained in:
rootdarkarchon
2023-01-30 13:42:04 +01:00
parent 56242c0e7a
commit c4aeb98126
3 changed files with 45 additions and 39 deletions

View File

@@ -1,7 +1,7 @@
namespace MareSynchronos.MareConfiguration; namespace MareSynchronos.MareConfiguration;
[Serializable] [Serializable]
public class Authentication public record Authentication
{ {
public string CharacterName { get; set; } = string.Empty; public string CharacterName { get; set; } = string.Empty;
public uint WorldId { get; set; } = 0; public uint WorldId { get; set; } = 0;

View File

@@ -252,18 +252,30 @@ public class SettingsUi : Window, IDisposable
{ {
UiShared.DrawWithID("selectedChara" + i, () => 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 worldIdx = (ushort)item.WorldId;
var data = _uiShared.WorldData.OrderBy(u => u.Value, StringComparer.Ordinal).ToDictionary(k => k.Key, k => k.Value); var data = _uiShared.WorldData.OrderBy(u => u.Value, StringComparer.Ordinal).ToDictionary(k => k.Key, k => k.Value);
if (!data.TryGetValue(worldIdx, out string? worldPreview)) if (!data.TryGetValue(worldIdx, out string? worldPreview))
{ {
worldPreview = data.First().Value; worldPreview = data.First().Value;
} }
var secretKeyIdx = item.SecretKeyIdx;
var keys = selectedServer.SecretKeys;
if (!keys.TryGetValue(secretKeyIdx, out var secretKey))
{
secretKey = new();
}
var friendlyName = secretKey.FriendlyName;
if (ImGui.TreeNode($"chara", $"Character: {item.CharacterName}, World: {worldPreview}, Secret Key: {friendlyName}"))
{
var charaName = item.CharacterName;
if (ImGui.InputText("Character Name", ref charaName, 64))
{
item.CharacterName = charaName;
_serverConfigurationManager.Save();
}
if (ImGui.BeginCombo("World", worldPreview)) if (ImGui.BeginCombo("World", worldPreview))
{ {
foreach (var world in data) foreach (var world in data)
@@ -277,13 +289,7 @@ public class SettingsUi : Window, IDisposable
} }
ImGui.EndCombo(); ImGui.EndCombo();
} }
var secretKeyIdx = item.SecretKeyIdx;
var keys = selectedServer.SecretKeys;
if (!keys.TryGetValue(secretKeyIdx, out var secretKey))
{
secretKey = new();
}
var friendlyName = secretKey.FriendlyName;
if (ImGui.BeginCombo("Secret Key", friendlyName)) if (ImGui.BeginCombo("Secret Key", friendlyName))
{ {
foreach (var kvp in keys) foreach (var kvp in keys)
@@ -305,8 +311,8 @@ public class SettingsUi : Window, IDisposable
} }
UiShared.AttachToolTip("Hold CTRL to delete this entry."); UiShared.AttachToolTip("Hold CTRL to delete this entry.");
if (item != selectedServer.Authentications.LastOrDefault()) ImGui.TreePop();
ImGui.Separator(); }
}); });
i++; i++;

View File

@@ -205,7 +205,7 @@ public partial class UiShared : IDisposable
ImGui.SameLine(); ImGui.SameLine();
ImGui.TextColored(customizeColor, customizeExists ? "Available" : "Unavailable"); ImGui.TextColored(customizeColor, customizeExists ? "Available" : "Unavailable");
ImGui.SameLine(); ImGui.SameLine();
ImGui.Text("PalettePlus+:"); ImGui.Text("Palette+:");
ImGui.SameLine(); ImGui.SameLine();
ImGui.TextColored(paletteColor, paletteExists ? "Available" : "Unavailable"); ImGui.TextColored(paletteColor, paletteExists ? "Available" : "Unavailable");