mirror of
https://github.com/Ottermandias/Glamourer.git
synced 2025-12-12 18:27:24 +01:00
Merge pull request #95 from Caraxi/update-associated-design
Add ability to update configuration of associated mod
This commit is contained in:
commit
a2843c1298
2 changed files with 57 additions and 3 deletions
|
|
@ -273,6 +273,16 @@ public sealed class DesignManager : DesignEditor
|
||||||
DesignChanged.Invoke(DesignChanged.Type.RemovedMod, design, (mod, settings));
|
DesignChanged.Invoke(DesignChanged.Type.RemovedMod, design, (mod, settings));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void UpdateMod(Design design, Mod mod, ModSettings settings) {
|
||||||
|
if (!design.AssociatedMods.ContainsKey(mod))
|
||||||
|
return;
|
||||||
|
design.AssociatedMods[mod] = settings;
|
||||||
|
design.LastEdit = DateTimeOffset.UtcNow;
|
||||||
|
SaveService.QueueSave(design);
|
||||||
|
Glamourer.Log.Debug($"Updated associated mod {mod.DirectoryName} from design {design.Identifier}.");
|
||||||
|
DesignChanged.Invoke(DesignChanged.Type.AddedMod, design, (mod, settings));
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary> Set the write protection status of a design. </summary>
|
/// <summary> Set the write protection status of a design. </summary>
|
||||||
public void SetWriteProtection(Design design, bool value)
|
public void SetWriteProtection(Design design, bool value)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -66,11 +66,12 @@ public class ModAssociationsTab
|
||||||
|
|
||||||
private void DrawTable()
|
private void DrawTable()
|
||||||
{
|
{
|
||||||
using var table = ImRaii.Table("Mods", 6, ImGuiTableFlags.RowBg);
|
using var table = ImRaii.Table("Mods", 7, ImGuiTableFlags.RowBg);
|
||||||
if (!table)
|
if (!table)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ImGui.TableSetupColumn("##Delete", ImGuiTableColumnFlags.WidthFixed, ImGui.GetFrameHeight());
|
ImGui.TableSetupColumn("##Delete", ImGuiTableColumnFlags.WidthFixed, ImGui.GetFrameHeight());
|
||||||
|
ImGui.TableSetupColumn("##Update", ImGuiTableColumnFlags.WidthFixed, ImGui.GetFrameHeight());
|
||||||
ImGui.TableSetupColumn("Mod Name", ImGuiTableColumnFlags.WidthStretch);
|
ImGui.TableSetupColumn("Mod Name", ImGuiTableColumnFlags.WidthStretch);
|
||||||
ImGui.TableSetupColumn("Directory Name", ImGuiTableColumnFlags.WidthStretch);
|
ImGui.TableSetupColumn("Directory Name", ImGuiTableColumnFlags.WidthStretch);
|
||||||
ImGui.TableSetupColumn("State", ImGuiTableColumnFlags.WidthFixed, ImGui.CalcTextSize("State").X);
|
ImGui.TableSetupColumn("State", ImGuiTableColumnFlags.WidthFixed, ImGui.CalcTextSize("State").X);
|
||||||
|
|
@ -79,28 +80,70 @@ public class ModAssociationsTab
|
||||||
ImGui.TableHeadersRow();
|
ImGui.TableHeadersRow();
|
||||||
|
|
||||||
Mod? removedMod = null;
|
Mod? removedMod = null;
|
||||||
|
(Mod mod, ModSettings settings)? updatedMod = null;
|
||||||
foreach (var ((mod, settings), idx) in _selector.Selected!.AssociatedMods.WithIndex())
|
foreach (var ((mod, settings), idx) in _selector.Selected!.AssociatedMods.WithIndex())
|
||||||
{
|
{
|
||||||
using var id = ImRaii.PushId(idx);
|
using var id = ImRaii.PushId(idx);
|
||||||
DrawAssociatedModRow(mod, settings, out var removedModTmp);
|
DrawAssociatedModRow(mod, settings, out var removedModTmp, out var updatedModTmp);
|
||||||
if (removedModTmp.HasValue)
|
if (removedModTmp.HasValue)
|
||||||
removedMod = removedModTmp;
|
removedMod = removedModTmp;
|
||||||
|
if (updatedModTmp.HasValue)
|
||||||
|
updatedMod = updatedModTmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
DrawNewModRow();
|
DrawNewModRow();
|
||||||
|
|
||||||
if (removedMod.HasValue)
|
if (removedMod.HasValue)
|
||||||
_manager.RemoveMod(_selector.Selected!, removedMod.Value);
|
_manager.RemoveMod(_selector.Selected!, removedMod.Value);
|
||||||
|
|
||||||
|
if (updatedMod.HasValue)
|
||||||
|
_manager.UpdateMod(_selector.Selected!, updatedMod.Value.mod, updatedMod.Value.settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DrawAssociatedModRow(Mod mod, ModSettings settings, out Mod? removedMod)
|
private void DrawAssociatedModRow(Mod mod, ModSettings settings, out Mod? removedMod, out (Mod, ModSettings)? updatedMod)
|
||||||
{
|
{
|
||||||
removedMod = null;
|
removedMod = null;
|
||||||
|
updatedMod = null;
|
||||||
ImGui.TableNextColumn();
|
ImGui.TableNextColumn();
|
||||||
if (ImGuiUtil.DrawDisabledButton(FontAwesomeIcon.Trash.ToIconString(), new Vector2(ImGui.GetFrameHeight()),
|
if (ImGuiUtil.DrawDisabledButton(FontAwesomeIcon.Trash.ToIconString(), new Vector2(ImGui.GetFrameHeight()),
|
||||||
"Delete this mod from associations", false, true))
|
"Delete this mod from associations", false, true))
|
||||||
removedMod = mod;
|
removedMod = mod;
|
||||||
|
|
||||||
|
ImGui.TableNextColumn();
|
||||||
|
ImGuiUtil.DrawDisabledButton(FontAwesomeIcon.RedoAlt.ToIconString(), new Vector2(ImGui.GetFrameHeight()),
|
||||||
|
"Update the settings of this mod association", false, true);
|
||||||
|
|
||||||
|
if (ImGui.IsItemHovered())
|
||||||
|
{
|
||||||
|
var (_, newSettings) = _penumbra.GetMods().FirstOrDefault(m => m.Mod == mod);
|
||||||
|
if (ImGui.IsItemClicked())
|
||||||
|
updatedMod = (mod, newSettings);
|
||||||
|
|
||||||
|
using var style = ImRaii.PushStyle(ImGuiStyleVar.PopupBorderSize, 2 * ImGuiHelpers.GlobalScale);
|
||||||
|
using var tt = ImRaii.Tooltip();
|
||||||
|
ImGui.Separator();
|
||||||
|
var namesDifferent = mod.Name != mod.DirectoryName;
|
||||||
|
ImGui.Dummy(new Vector2(300 * ImGuiHelpers.GlobalScale, 0));
|
||||||
|
using (var group = ImRaii.Group())
|
||||||
|
{
|
||||||
|
if (namesDifferent)
|
||||||
|
ImGui.TextUnformatted("Directory Name");
|
||||||
|
ImGui.TextUnformatted("Enabled");
|
||||||
|
ImGui.TextUnformatted("Priority");
|
||||||
|
ModCombo.DrawSettingsLeft(newSettings);
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGui.SameLine(Math.Max(ImGui.GetItemRectSize().X + 3 * ImGui.GetStyle().ItemSpacing.X, 150 * ImGuiHelpers.GlobalScale));
|
||||||
|
using (var group = ImRaii.Group())
|
||||||
|
{
|
||||||
|
if (namesDifferent)
|
||||||
|
ImGui.TextUnformatted(mod.DirectoryName);
|
||||||
|
ImGui.TextUnformatted(newSettings.Enabled.ToString());
|
||||||
|
ImGui.TextUnformatted(newSettings.Priority.ToString());
|
||||||
|
ModCombo.DrawSettingsRight(newSettings);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ImGui.TableNextColumn();
|
ImGui.TableNextColumn();
|
||||||
var selected = ImGui.Selectable($"{mod.Name}##name");
|
var selected = ImGui.Selectable($"{mod.Name}##name");
|
||||||
var hovered = ImGui.IsItemHovered();
|
var hovered = ImGui.IsItemHovered();
|
||||||
|
|
@ -156,6 +199,7 @@ public class ModAssociationsTab
|
||||||
{
|
{
|
||||||
var currentName = _modCombo.CurrentSelection.Mod.Name;
|
var currentName = _modCombo.CurrentSelection.Mod.Name;
|
||||||
ImGui.TableNextColumn();
|
ImGui.TableNextColumn();
|
||||||
|
ImGui.TableNextColumn();
|
||||||
var tt = currentName.IsNullOrEmpty()
|
var tt = currentName.IsNullOrEmpty()
|
||||||
? "Please select a mod first."
|
? "Please select a mod first."
|
||||||
: _selector.Selected!.AssociatedMods.ContainsKey(_modCombo.CurrentSelection.Mod)
|
: _selector.Selected!.AssociatedMods.ContainsKey(_modCombo.CurrentSelection.Mod)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue