Skip to content

Commit a561e70

Browse files
committed
Add option to always work in temporary settings.
1 parent b7b9def commit a561e70

7 files changed

+72
-32
lines changed

Penumbra/Configuration.cs

+1
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ public bool EnableMods
7070
public bool HidePrioritiesInSelector { get; set; } = false;
7171
public bool HideRedrawBar { get; set; } = false;
7272
public bool HideMachinistOffhandFromChangedItems { get; set; } = true;
73+
public bool DefaultTemporaryMode { get; set; } = false;
7374
public RenameField ShowRename { get; set; } = RenameField.BothDataPrio;
7475
public int OptionGroupCollapsibleMin { get; set; } = 5;
7576

Penumbra/Mods/Settings/TemporaryModSettings.cs

+5-4
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@ namespace Penumbra.Mods.Settings;
22

33
public sealed class TemporaryModSettings : ModSettings
44
{
5-
public string Source = string.Empty;
6-
public int Lock = 0;
7-
public bool ForceInherit;
5+
public const string OwnSource = "yourself";
6+
public string Source = string.Empty;
7+
public int Lock = 0;
8+
public bool ForceInherit;
89

910
// Create default settings for a given mod.
1011
public static TemporaryModSettings DefaultSettings(Mod mod, string source, bool enabled = false, int key = 0)
@@ -20,7 +21,7 @@ public static TemporaryModSettings DefaultSettings(Mod mod, string source, bool
2021
public TemporaryModSettings()
2122
{ }
2223

23-
public TemporaryModSettings(Mod mod, ModSettings? clone, string source, int key = 0)
24+
public TemporaryModSettings(Mod mod, ModSettings? clone, string source = OwnSource, int key = 0)
2425
{
2526
Source = source;
2627
Lock = key;

Penumbra/UI/Classes/CollectionSelectHeader.cs

+37-6
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1+
using Dalamud.Interface;
12
using ImGuiNET;
23
using OtterGui.Raii;
34
using OtterGui;
45
using OtterGui.Services;
6+
using OtterGui.Text;
7+
using OtterGui.Text.Widget;
58
using Penumbra.Collections;
69
using Penumbra.Collections.Manager;
710
using Penumbra.Interop.PathResolving;
@@ -12,18 +15,21 @@ namespace Penumbra.UI.Classes;
1215

1316
public class CollectionSelectHeader : IUiService
1417
{
15-
private readonly CollectionCombo _collectionCombo;
16-
private readonly ActiveCollections _activeCollections;
17-
private readonly TutorialService _tutorial;
18-
private readonly ModSelection _selection;
19-
private readonly CollectionResolver _resolver;
18+
private readonly CollectionCombo _collectionCombo;
19+
private readonly ActiveCollections _activeCollections;
20+
private readonly TutorialService _tutorial;
21+
private readonly ModSelection _selection;
22+
private readonly CollectionResolver _resolver;
23+
private readonly FontAwesomeCheckbox _temporaryCheckbox = new(FontAwesomeIcon.Stopwatch);
24+
private readonly Configuration _config;
2025

2126
public CollectionSelectHeader(CollectionManager collectionManager, TutorialService tutorial, ModSelection selection,
22-
CollectionResolver resolver)
27+
CollectionResolver resolver, Configuration config)
2328
{
2429
_tutorial = tutorial;
2530
_selection = selection;
2631
_resolver = resolver;
32+
_config = config;
2733
_activeCollections = collectionManager.Active;
2834
_collectionCombo = new CollectionCombo(collectionManager, () => collectionManager.Storage.OrderBy(c => c.Identity.Name).ToList());
2935
}
@@ -33,6 +39,8 @@ public void Draw(bool spacing)
3339
{
3440
using var style = ImRaii.PushStyle(ImGuiStyleVar.FrameRounding, 0)
3541
.Push(ImGuiStyleVar.ItemSpacing, new Vector2(0, spacing ? ImGui.GetStyle().ItemSpacing.Y : 0));
42+
DrawTemporaryCheckbox();
43+
ImGui.SameLine();
3644
var comboWidth = ImGui.GetContentRegionAvail().X / 4f;
3745
var buttonSize = new Vector2(comboWidth * 3f / 4f, 0f);
3846
using (var _ = ImRaii.Group())
@@ -51,6 +59,29 @@ public void Draw(bool spacing)
5159
ImGuiUtil.DrawTextButton("The currently selected collection is not used in any way.", -Vector2.UnitX, Colors.PressEnterWarningBg);
5260
}
5361

62+
private void DrawTemporaryCheckbox()
63+
{
64+
var hold = _config.DeleteModModifier.IsActive();
65+
using (ImRaii.PushStyle(ImGuiStyleVar.FrameBorderSize, ImUtf8.GlobalScale))
66+
{
67+
var tint = ImGuiCol.Text.Tinted(ColorId.TemporaryModSettingsTint);
68+
using var color = ImRaii.PushColor(ImGuiCol.FrameBgHovered, ImGui.GetColorU32(ImGuiCol.FrameBg), !hold)
69+
.Push(ImGuiCol.FrameBgActive, ImGui.GetColorU32(ImGuiCol.FrameBg), !hold)
70+
.Push(ImGuiCol.CheckMark, tint)
71+
.Push(ImGuiCol.Border, tint, _config.DefaultTemporaryMode);
72+
if (_temporaryCheckbox.Draw("##tempCheck"u8, _config.DefaultTemporaryMode, out var newValue) && hold)
73+
{
74+
_config.DefaultTemporaryMode = newValue;
75+
_config.Save();
76+
}
77+
}
78+
79+
ImUtf8.HoverTooltip(ImGuiHoveredFlags.AllowWhenDisabled,
80+
"Toggle the temporary settings mode, where all changes you do create temporary settings first and need to be made permanent if desired.\n"u8);
81+
if (!hold)
82+
ImUtf8.HoverTooltip(ImGuiHoveredFlags.AllowWhenDisabled, $"Hold {_config.DeleteModModifier} while clicking to toggle.");
83+
}
84+
5485
private enum CollectionState
5586
{
5687
Empty,

Penumbra/UI/ModsTab/Groups/ModGroupDrawer.cs

+6-3
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,15 @@ public sealed class ModGroupDrawer(Configuration config, CollectionManager colle
2020
private bool _temporary;
2121
private bool _locked;
2222
private TemporaryModSettings? _tempSettings;
23+
private ModSettings? _settings;
2324

2425
public void Draw(Mod mod, ModSettings settings, TemporaryModSettings? tempSettings)
2526
{
2627
if (mod.Groups.Count <= 0)
2728
return;
2829

2930
_blockGroupCache.Clear();
31+
_settings = settings;
3032
_tempSettings = tempSettings;
3133
_temporary = tempSettings != null;
3234
_locked = (tempSettings?.Lock ?? 0) > 0;
@@ -242,10 +244,11 @@ private ModCollection Current
242244
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
243245
private void SetModSetting(IModGroup group, int groupIdx, Setting setting)
244246
{
245-
if (_temporary)
247+
if (_temporary || config.DefaultTemporaryMode)
246248
{
247-
_tempSettings!.ForceInherit = false;
248-
_tempSettings!.Settings[groupIdx] = setting;
249+
_tempSettings ??= new TemporaryModSettings(group.Mod, _settings);
250+
_tempSettings!.ForceInherit = false;
251+
_tempSettings!.Settings[groupIdx] = setting;
249252
collectionManager.Editor.SetTemporarySettings(Current, group.Mod, _tempSettings);
250253
}
251254
else

Penumbra/UI/ModsTab/ModFileSystemSelector.cs

+5-6
Original file line numberDiff line numberDiff line change
@@ -274,8 +274,7 @@ private void ToggleLeafFavorite(FileSystem<Mod>.Leaf mod)
274274

275275
private void DrawTemporaryOptions(FileSystem<Mod>.Leaf mod)
276276
{
277-
const string source = "yourself";
278-
var tempSettings = _collectionManager.Active.Current.GetTempSettings(mod.Value.Index);
277+
var tempSettings = _collectionManager.Active.Current.GetTempSettings(mod.Value.Index);
279278
if (tempSettings is { Lock: > 0 })
280279
return;
281280

@@ -284,19 +283,19 @@ private void DrawTemporaryOptions(FileSystem<Mod>.Leaf mod)
284283
var actual = _collectionManager.Active.Current.GetActualSettings(mod.Value.Index).Settings;
285284
if (actual?.Enabled is true && ImUtf8.MenuItem("Disable Temporarily"u8))
286285
_collectionManager.Editor.SetTemporarySettings(_collectionManager.Active.Current, mod.Value,
287-
new TemporaryModSettings(mod.Value, actual, source) { Enabled = false });
286+
new TemporaryModSettings(mod.Value, actual) { Enabled = false });
288287

289288
if (actual is not { Enabled: true } && ImUtf8.MenuItem("Enable Temporarily"u8))
290289
{
291290
var newSettings = actual is null
292-
? TemporaryModSettings.DefaultSettings(mod.Value, source, true)
293-
: new TemporaryModSettings(mod.Value, actual, source) { Enabled = true };
291+
? TemporaryModSettings.DefaultSettings(mod.Value, TemporaryModSettings.OwnSource, true)
292+
: new TemporaryModSettings(mod.Value, actual) { Enabled = true };
294293
_collectionManager.Editor.SetTemporarySettings(_collectionManager.Active.Current, mod.Value, newSettings);
295294
}
296295

297296
if (tempSettings is null && ImUtf8.MenuItem("Turn Temporary"u8))
298297
_collectionManager.Editor.SetTemporarySettings(_collectionManager.Active.Current, mod.Value,
299-
new TemporaryModSettings(mod.Value, actual, source));
298+
new TemporaryModSettings(mod.Value, actual));
300299
}
301300

302301
private void SetDefaultImportFolder(ModFileSystem.Folder folder)

Penumbra/UI/ModsTab/ModPanelSettingsTab.cs

+15-12
Original file line numberDiff line numberDiff line change
@@ -120,11 +120,12 @@ private void DrawEnabledInput()
120120
return;
121121

122122
modManager.SetKnown(selection.Mod!);
123-
if (_temporary)
123+
if (_temporary || config.DefaultTemporaryMode)
124124
{
125-
selection.TemporarySettings!.ForceInherit = false;
126-
selection.TemporarySettings!.Enabled = enabled;
127-
collectionManager.Editor.SetTemporarySettings(collectionManager.Active.Current, selection.Mod!, selection.TemporarySettings);
125+
var temporarySettings = selection.TemporarySettings ?? new TemporaryModSettings(selection.Mod!, selection.Settings);
126+
temporarySettings.ForceInherit = false;
127+
temporarySettings.Enabled = enabled;
128+
collectionManager.Editor.SetTemporarySettings(collectionManager.Active.Current, selection.Mod!, temporarySettings);
128129
}
129130
else
130131
{
@@ -154,12 +155,13 @@ private void DrawPriorityInput()
154155
{
155156
if (_currentPriority != settings.Priority.Value)
156157
{
157-
if (_temporary)
158+
if (_temporary || config.DefaultTemporaryMode)
158159
{
159-
selection.TemporarySettings!.ForceInherit = false;
160-
selection.TemporarySettings!.Priority = new ModPriority(_currentPriority.Value);
160+
var temporarySettings = selection.TemporarySettings ?? new TemporaryModSettings(selection.Mod!, selection.Settings);
161+
temporarySettings.ForceInherit = false;
162+
temporarySettings.Priority = new ModPriority(_currentPriority.Value);
161163
collectionManager.Editor.SetTemporarySettings(collectionManager.Active.Current, selection.Mod!,
162-
selection.TemporarySettings);
164+
temporarySettings);
163165
}
164166
else
165167
{
@@ -205,11 +207,12 @@ private void DrawRemoveSettings()
205207
};
206208
if (inherit)
207209
{
208-
if (_temporary)
210+
if (_temporary || config.DefaultTemporaryMode)
209211
{
210-
selection.TemporarySettings!.ForceInherit = true;
212+
var temporarySettings = selection.TemporarySettings ?? new TemporaryModSettings(selection.Mod!, selection.Settings);
213+
temporarySettings.ForceInherit = true;
211214
collectionManager.Editor.SetTemporarySettings(collectionManager.Active.Current, selection.Mod!,
212-
selection.TemporarySettings);
215+
temporarySettings);
213216
}
214217
else
215218
{
@@ -252,7 +255,7 @@ private void DrawRemoveSettings()
252255
var actual = collectionManager.Active.Current.GetActualSettings(selection.Mod!.Index).Settings;
253256
if (ImUtf8.ButtonEx("Turn Temporary"u8, "Copy the current settings over to temporary settings to experiment with them."u8))
254257
collectionManager.Editor.SetTemporarySettings(collectionManager.Active.Current, selection.Mod!,
255-
new TemporaryModSettings(selection.Mod!, actual, "yourself"));
258+
new TemporaryModSettings(selection.Mod!, actual));
256259
}
257260
}
258261
}

Penumbra/UI/Tabs/SettingsTab.cs

+3-1
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,6 @@ private void DrawMiscSettings()
430430
Checkbox("Automatically Select Character-Associated Collection",
431431
"On every login, automatically select the collection associated with the current character as the current collection for editing.",
432432
_config.AutoSelectCollection, _autoSelector.SetAutomaticSelection);
433-
434433
Checkbox("Print Chat Command Success Messages to Chat",
435434
"Chat Commands usually print messages on failure but also on success to confirm your action. You can disable this here.",
436435
_config.PrintSuccessfulCommandsToChat, v => _config.PrintSuccessfulCommandsToChat = v);
@@ -618,6 +617,9 @@ private void DrawModSelectorSettings()
618617
/// <summary> Draw all settings pertaining to import and export of mods. </summary>
619618
private void DrawModHandlingSettings()
620619
{
620+
Checkbox("Use Temporary Settings Per Default",
621+
"When you make any changes to your collection, apply them as temporary changes first and require a click to 'turn permanent' if you want to keep them.",
622+
_config.DefaultTemporaryMode, v => _config.DefaultTemporaryMode = v);
621623
Checkbox("Replace Non-Standard Symbols On Import",
622624
"Replace all non-ASCII symbols in mod and option names with underscores when importing mods.", _config.ReplaceNonAsciiOnImport,
623625
v => _config.ReplaceNonAsciiOnImport = v);

0 commit comments

Comments
 (0)