Skip to content

Commit 7da5d73

Browse files
committed
Keep enabled and priority at the top of settings, add button to turn temporary.
1 parent a2258e6 commit 7da5d73

File tree

1 file changed

+44
-17
lines changed

1 file changed

+44
-17
lines changed

Penumbra/UI/ModsTab/ModPanelSettingsTab.cs

Lines changed: 44 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,19 @@ public void Reset()
3838

3939
public void DrawContent()
4040
{
41-
using var child = ImUtf8.Child("##settings"u8, default);
42-
if (!child)
41+
using var table = ImUtf8.Table("##settings"u8, 1, ImGuiTableFlags.ScrollY, ImGui.GetContentRegionAvail());
42+
if (!table)
4343
return;
4444

4545
_inherited = selection.Collection != collectionManager.Active.Current;
4646
_temporary = selection.TemporarySettings != null;
4747
_locked = (selection.TemporarySettings?.Lock ?? 0) > 0;
48+
49+
ImGui.TableSetupScrollFreeze(0, 1);
50+
ImGui.TableNextColumn();
4851
DrawTemporaryWarning();
4952
DrawInheritedWarning();
50-
UiHelpers.DefaultLineSpace();
53+
ImGui.Dummy(Vector2.Zero);
5154
communicator.PreSettingsPanelDraw.Invoke(selection.Mod!.Identifier);
5255
DrawEnabledInput();
5356
tutorial.OpenTutorial(BasicTutorialSteps.EnablingMods);
@@ -56,6 +59,7 @@ public void DrawContent()
5659
tutorial.OpenTutorial(BasicTutorialSteps.Priority);
5760
DrawRemoveSettings();
5861

62+
ImGui.TableNextColumn();
5963
communicator.PostEnabledDraw.Invoke(selection.Mod!.Identifier);
6064

6165
modGroupDrawer.Draw(selection.Mod!, selection.Settings, selection.TemporarySettings);
@@ -71,7 +75,8 @@ private void DrawTemporaryWarning()
7175

7276
using var color = ImRaii.PushColor(ImGuiCol.Button, ImGuiCol.Button.Tinted(ColorId.TemporaryModSettingsTint));
7377
var width = new Vector2(ImGui.GetContentRegionAvail().X, 0);
74-
if (ImUtf8.ButtonEx($"These settings are temporary from {selection.TemporarySettings!.Source}{(_locked ? " and locked." : ".")}", width,
78+
if (ImUtf8.ButtonEx($"These settings are temporarily set by {selection.TemporarySettings!.Source}{(_locked ? " and locked." : ".")}",
79+
width,
7580
_locked))
7681
collectionManager.Editor.SetTemporarySettings(collectionManager.Active.Current, selection.Mod!, null);
7782

@@ -174,23 +179,45 @@ private void DrawPriorityInput()
174179
/// </summary>
175180
private void DrawRemoveSettings()
176181
{
177-
if (_inherited || selection.Settings == ModSettings.Empty)
182+
var drawInherited = !_inherited && selection.Settings != ModSettings.Empty;
183+
if (!drawInherited && _temporary)
178184
return;
179185

180-
var scroll = ImGui.GetScrollMaxY() > 0 ? ImGui.GetStyle().ScrollbarSize : 0;
181-
ImGui.SameLine(ImGui.GetWindowWidth() - ImUtf8.CalcTextSize("Inherit Settings"u8).X - ImGui.GetStyle().FramePadding.X * 2 - scroll);
182-
if (!ImUtf8.ButtonEx("Inherit Settings"u8, "Remove current settings from this collection so that it can inherit them.\n"u8
183-
+ "If no inherited collection has settings for this mod, it will be disabled."u8, default, _locked))
184-
return;
185-
186-
if (_temporary)
186+
var scroll = ImGui.GetScrollMaxY() > 0 ? ImGui.GetStyle().ScrollbarSize + ImGui.GetStyle().ItemInnerSpacing.X: 0;
187+
var offset = (drawInherited, _temporary) switch
187188
{
188-
selection.TemporarySettings!.ForceInherit = true;
189-
collectionManager.Editor.SetTemporarySettings(collectionManager.Active.Current, selection.Mod!, selection.TemporarySettings);
190-
}
191-
else
189+
(true, true) => ImUtf8.CalcTextSize("Inherit Settings"u8).X + ImGui.GetStyle().FramePadding.X * 2,
190+
(false, false) => ImUtf8.CalcTextSize("Turn Temporary"u8).X + ImGui.GetStyle().FramePadding.X * 2,
191+
(true, false) => ImUtf8.CalcTextSize("Inherit Settings"u8).X
192+
+ ImUtf8.CalcTextSize("Turn Temporary"u8).X
193+
+ ImGui.GetStyle().FramePadding.X * 4
194+
+ ImGui.GetStyle().ItemSpacing.X,
195+
(false, true) => 0, // can not happen
196+
};
197+
198+
ImGui.SameLine(ImGui.GetWindowWidth() - offset - scroll);
199+
if (!_temporary
200+
&& ImUtf8.ButtonEx("Turn Temporary"u8, "Copy the current settings over to temporary settings to experiment with them."u8))
201+
collectionManager.Editor.SetTemporarySettings(collectionManager.Active.Current, selection.Mod!,
202+
new TemporaryModSettings(selection.Settings, "yourself"));
203+
if (drawInherited)
192204
{
193-
collectionManager.Editor.SetModInheritance(collectionManager.Active.Current, selection.Mod!, true);
205+
if (!_temporary)
206+
ImGui.SameLine(0, ImGui.GetStyle().ItemSpacing.X);
207+
if (ImUtf8.ButtonEx("Inherit Settings"u8, "Remove current settings from this collection so that it can inherit them.\n"u8
208+
+ "If no inherited collection has settings for this mod, it will be disabled."u8, default, _locked))
209+
{
210+
if (_temporary)
211+
{
212+
selection.TemporarySettings!.ForceInherit = true;
213+
collectionManager.Editor.SetTemporarySettings(collectionManager.Active.Current, selection.Mod!,
214+
selection.TemporarySettings);
215+
}
216+
else
217+
{
218+
collectionManager.Editor.SetModInheritance(collectionManager.Active.Current, selection.Mod!, true);
219+
}
220+
}
194221
}
195222
}
196223
}

0 commit comments

Comments
 (0)