♻️ ConfigWindow: move tab logic into separate methods

rendering
Liza 2022-12-10 20:53:07 +01:00
parent aa4f28b4fd
commit 976bfcbe2c
1 changed files with 130 additions and 117 deletions

View File

@ -64,6 +64,35 @@ namespace Pal.Client.Windows
bool save = false;
bool saveAndClose = false;
if (ImGui.BeginTabBar("PalTabs"))
{
DrawTrapCofferTab(ref save, ref saveAndClose);
DrawCommunityTab(ref saveAndClose);
DrawDebugTab();
ImGui.EndTabBar();
}
if (save || saveAndClose)
{
var config = Service.Configuration;
config.Mode = (Configuration.EMode)_mode;
config.ShowTraps = _showTraps;
config.TrapColor = _trapColor;
config.OnlyVisibleTrapsAfterPomander = _onlyVisibleTrapsAfterPomander;
config.ShowHoard = _showHoard;
config.HoardColor = _hoardColor;
config.OnlyVisibleHoardAfterPomander = _onlyVisibleHoardAfterPomander;
config.ShowSilverCoffers = _showSilverCoffers;
config.SilverCofferColor = _silverCofferColor;
config.FillSilverCoffers = _fillSilverCoffers;
config.Save();
if (saveAndClose)
IsOpen = false;
}
}
private void DrawTrapCofferTab(ref bool save, ref bool saveAndClose)
{
if (ImGui.BeginTabItem("PotD/HoH"))
{
@ -111,7 +140,10 @@ namespace Pal.Client.Windows
ImGui.EndTabItem();
}
}
private void DrawCommunityTab(ref bool saveAndClose)
{
if (BeginTabItemEx("Community", _switchToCommunityTab ? ImGuiTabItemFlags.SetSelected : ImGuiTabItemFlags.None))
{
_switchToCommunityTab = false;
@ -135,7 +167,10 @@ namespace Pal.Client.Windows
ImGui.EndDisabled();
ImGui.EndTabItem();
}
}
private void DrawDebugTab()
{
if (ImGui.BeginTabItem("Debug"))
{
var plugin = Service.Plugin;
@ -182,28 +217,6 @@ namespace Pal.Client.Windows
ImGui.EndTabItem();
}
ImGui.EndTabBar();
}
if (save || saveAndClose)
{
var config = Service.Configuration;
config.Mode = (Configuration.EMode)_mode;
config.ShowTraps = _showTraps;
config.TrapColor = _trapColor;
config.OnlyVisibleTrapsAfterPomander = _onlyVisibleTrapsAfterPomander;
config.ShowHoard = _showHoard;
config.HoardColor = _hoardColor;
config.OnlyVisibleHoardAfterPomander = _onlyVisibleHoardAfterPomander;
config.ShowSilverCoffers = _showSilverCoffers;
config.SilverCofferColor = _silverCofferColor;
config.FillSilverCoffers = _fillSilverCoffers;
config.Save();
if (saveAndClose)
IsOpen = false;
}
}
private void DrawDebugItems()