Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 51 additions & 32 deletions ReAgent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -189,48 +189,67 @@ public override void DrawSettings()

if (tabSelected)
{
_pendingNames.TryGetValue(profile, out var newProfileName);
newProfileName ??= profileName;
ImGui.InputText("Name", ref newProfileName, 40);
if (!isCurrentProfile)
try
{
using (ImGuiHelpers.UseStyleColor(ImGuiCol.Button, Color.Green.ToImgui()))
if (ImGui.Button("Activate"))
{
Settings.CurrentProfile = profileName;
}

ImGui.SameLine();
}

if (ImGui.Button("Export profile"))
{
ImGui.SetClipboardText(DataExporter.ExportDataBase64(profile, "reagent_profile_v1", new JsonSerializerSettings()));
}

if (profileName != newProfileName)
{
if (Settings.Profiles.ContainsKey(newProfileName))
// Check if there's minimum space available to render UI safely
var availableSpace = ImGui.GetContentRegionAvail();
if (availableSpace.X < 100 || availableSpace.Y < 50)
{
ImGui.SameLine();
ImGui.TextColored(Color.Red.ToImguiVec4(), "This profile name is already used");
_pendingNames.AddOrUpdate(profile, newProfileName);
ImGui.TextColored(Color.Yellow.ToImguiVec4(), "Window too small - expand to view settings");
ImGui.EndTabItem();
}
else
{
Settings.Profiles.Remove(profileName);
Settings.Profiles.Add(newProfileName, profile);
if (isCurrentProfile)
_pendingNames.TryGetValue(profile, out var newProfileName);
newProfileName ??= profileName;
ImGui.InputText("Name", ref newProfileName, 40);
if (!isCurrentProfile)
{
Settings.CurrentProfile = newProfileName;
using (ImGuiHelpers.UseStyleColor(ImGuiCol.Button, Color.Green.ToImgui()))
if (ImGui.Button("Activate"))
{
Settings.CurrentProfile = profileName;
}

ImGui.SameLine();
}

_pendingNames.Clear();
if (ImGui.Button("Export profile"))
{
ImGui.SetClipboardText(DataExporter.ExportDataBase64(profile, "reagent_profile_v1", new JsonSerializerSettings()));
}

if (profileName != newProfileName)
{
if (Settings.Profiles.ContainsKey(newProfileName))
{
ImGui.SameLine();
ImGui.TextColored(Color.Red.ToImguiVec4(), "This profile name is already used");
_pendingNames.AddOrUpdate(profile, newProfileName);
}
else
{
Settings.Profiles.Remove(profileName);
Settings.Profiles.Add(newProfileName, profile);
if (isCurrentProfile)
{
Settings.CurrentProfile = newProfileName;
}

_pendingNames.Clear();
}
}

profile.DrawSettings(_state, Settings);
ImGui.EndTabItem();
}
}

profile.DrawSettings(_state, Settings);
ImGui.EndTabItem();
catch (Exception ex)
{
LogError($"Error rendering profile settings: {ex.Message}");
ImGui.TextColored(Color.Red.ToImguiVec4(), "Error rendering - check logs");
ImGui.EndTabItem();
}
}
else
{
Expand Down