This commit is contained in:
Ottermandias 2023-06-29 16:09:43 +02:00
parent c505286220
commit 5e410d8786
9 changed files with 148 additions and 54 deletions

View file

@ -3,8 +3,6 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17 # Visual Studio Version 17
VisualStudioVersion = 17.2.32210.308 VisualStudioVersion = 17.2.32210.308
MinimumVisualStudioVersion = 10.0.40219.1 MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GlamourerOld", "GlamourerOld\GlamourerOld.csproj", "{A5439F6B-83C1-4078-9371-354A147FF554}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{383AEE76-D423-431C-893A-7AB3DEA13630}" Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{383AEE76-D423-431C-893A-7AB3DEA13630}"
ProjectSection(SolutionItems) = preProject ProjectSection(SolutionItems) = preProject
.editorconfig = .editorconfig .editorconfig = .editorconfig
@ -25,10 +23,6 @@ Global
Release|Any CPU = Release|Any CPU Release|Any CPU = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution GlobalSection(ProjectConfigurationPlatforms) = postSolution
{A5439F6B-83C1-4078-9371-354A147FF554}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A5439F6B-83C1-4078-9371-354A147FF554}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A5439F6B-83C1-4078-9371-354A147FF554}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A5439F6B-83C1-4078-9371-354A147FF554}.Release|Any CPU.Build.0 = Release|Any CPU
{51F4DDB0-1FA0-4629-9CFE-C55B6062907B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {51F4DDB0-1FA0-4629-9CFE-C55B6062907B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{51F4DDB0-1FA0-4629-9CFE-C55B6062907B}.Debug|Any CPU.Build.0 = Debug|Any CPU {51F4DDB0-1FA0-4629-9CFE-C55B6062907B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{51F4DDB0-1FA0-4629-9CFE-C55B6062907B}.Release|Any CPU.ActiveCfg = Release|Any CPU {51F4DDB0-1FA0-4629-9CFE-C55B6062907B}.Release|Any CPU.ActiveCfg = Release|Any CPU

View file

@ -22,6 +22,7 @@ public class Configuration : IPluginConfiguration, ISavable
public bool OpenFoldersByDefault { get; set; } = false; public bool OpenFoldersByDefault { get; set; } = false;
public bool AutoRedrawEquipOnChanges { get; set; } = false; public bool AutoRedrawEquipOnChanges { get; set; } = false;
public bool EnableAutoDesigns { get; set; } = true; public bool EnableAutoDesigns { get; set; } = true;
public bool IncognitoMode { get; set; } = false;
public MainWindow.TabType SelectedTab { get; set; } = MainWindow.TabType.Settings; public MainWindow.TabType SelectedTab { get; set; } = MainWindow.TabType.Settings;
public DoubleModifier DeleteDesignModifier { get; set; } = new(ModifierHotkey.Control, ModifierHotkey.Shift); public DoubleModifier DeleteDesignModifier { get; set; } = new(ModifierHotkey.Control, ModifierHotkey.Shift);

View file

@ -35,6 +35,9 @@ public class Design : ISavable
internal DesignData DesignData; internal DesignData DesignData;
public string Incognito
=> Identifier.ToString()[..8];
/// <summary> Unconditionally apply a design to a designdata. </summary> /// <summary> Unconditionally apply a design to a designdata. </summary>
/// <returns>Whether a redraw is required for the changes to take effect.</returns> /// <returns>Whether a redraw is required for the changes to take effect.</returns>
public (bool, CustomizeFlag, EquipFlag) ApplyDesign(ref DesignData data) public (bool, CustomizeFlag, EquipFlag) ApplyDesign(ref DesignData data)

View file

@ -1,4 +1,5 @@
using System.Numerics; using System.Numerics;
using Dalamud.Interface;
using Glamourer.Events; using Glamourer.Events;
using Glamourer.Gui.Customization; using Glamourer.Gui.Customization;
using Glamourer.Gui.Equipment; using Glamourer.Gui.Equipment;
@ -36,42 +37,52 @@ public class ActorPanel
public void Draw() public void Draw()
{ {
if (!_selector.HasSelection)
return;
(_identifier, _data) = _selector.Selection;
if (_data.Valid)
{
_actorName = _data.Label;
_actor = _data.Objects[0];
}
else
{
_actorName = _identifier.ToString();
_actor = Actor.Null;
}
if (!_stateManager.GetOrCreate(_identifier, _actor, out _state))
return;
using var group = ImRaii.Group(); using var group = ImRaii.Group();
(_identifier, _data) = _selector.Selection;
(_actorName, _actor) = GetHeaderName();
DrawHeader(); DrawHeader();
DrawPanel(); DrawPanel();
} }
private void DrawHeader() private void DrawHeader()
{ {
var color = _data.Valid ? ColorId.ActorAvailable.Value() : ColorId.ActorUnavailable.Value(); var frameHeight = ImGui.GetFrameHeightWithSpacing();
var color = !_identifier.IsValid ? ImGui.GetColorU32(ImGuiCol.Text) : _data.Valid ? ColorId.ActorAvailable.Value() : ColorId.ActorUnavailable.Value();
var buttonColor = ImGui.GetColorU32(ImGuiCol.FrameBg); var buttonColor = ImGui.GetColorU32(ImGuiCol.FrameBg);
using var style = ImRaii.PushStyle(ImGuiStyleVar.ItemSpacing, Vector2.Zero) using var style = ImRaii.PushStyle(ImGuiStyleVar.ItemSpacing, Vector2.Zero)
.Push(ImGuiStyleVar.FrameRounding, 0); .Push(ImGuiStyleVar.FrameRounding, 0);
ImGuiUtil.DrawTextButton($"{(_data.Valid ? _data.Label : _identifier.ToString())}##playerHeader", -Vector2.UnitX, buttonColor, color); ImGuiUtil.DrawTextButton($"{_actorName}##playerHeader", new Vector2(-frameHeight, ImGui.GetFrameHeight()), buttonColor, color);
ImGui.SameLine();
style.Push(ImGuiStyleVar.FrameBorderSize, ImGuiHelpers.GlobalScale);
using (var c = ImRaii.PushColor(ImGuiCol.Text, ColorId.FolderExpanded.Value())
.Push(ImGuiCol.Border, ColorId.FolderExpanded.Value()))
{
if (ImGuiUtil.DrawDisabledButton(
$"{(_selector.IncognitoMode ? FontAwesomeIcon.Eye : FontAwesomeIcon.EyeSlash).ToIconString()}###IncognitoMode",
new Vector2(frameHeight, ImGui.GetFrameHeight()), string.Empty, false, true))
_selector.IncognitoMode = !_selector.IncognitoMode;
}
var hovered = ImGui.IsItemHovered();
if (hovered)
ImGui.SetTooltip(_selector.IncognitoMode ? "Toggle incognito mode off." : "Toggle incognito mode on.");
}
private (string, Actor) GetHeaderName()
{
if (!_identifier.IsValid)
return ("No Selection", Actor.Null);
if (_data.Valid)
return (_selector.IncognitoMode ? _identifier.Incognito(_data.Label) : _data.Label, _data.Objects[0]);
return (_selector.IncognitoMode ? _identifier.Incognito(null) : _identifier.ToString(), Actor.Null);
} }
private unsafe void DrawPanel() private unsafe void DrawPanel()
{ {
using var child = ImRaii.Child("##ActorPanel", -Vector2.One, true); using var child = ImRaii.Child("##Panel", -Vector2.One, true);
if (!child || _state == null) if (!child || !_selector.HasSelection || !_stateManager.GetOrCreate(_identifier, _actor, out _state))
return; return;
if (_customizationDrawer.Draw(_state.ModelData.Customize, false)) if (_customizationDrawer.Draw(_state.ModelData.Customize, false))

View file

@ -16,17 +16,29 @@ namespace Glamourer.Gui.Tabs.ActorTab;
public class ActorSelector public class ActorSelector
{ {
private readonly Configuration _config;
private readonly ObjectManager _objects; private readonly ObjectManager _objects;
private readonly ActorService _actors; private readonly ActorService _actors;
private readonly TargetManager _targets; private readonly TargetManager _targets;
private ActorIdentifier _identifier = ActorIdentifier.Invalid; private ActorIdentifier _identifier = ActorIdentifier.Invalid;
public ActorSelector(ObjectManager objects, TargetManager targets, ActorService actors) public ActorSelector(ObjectManager objects, TargetManager targets, ActorService actors, Configuration config)
{ {
_objects = objects; _objects = objects;
_targets = targets; _targets = targets;
_actors = actors; _actors = actors;
_config = config;
}
public bool IncognitoMode
{
get => _config.IncognitoMode;
set
{
_config.IncognitoMode = value;
_config.Save();
}
} }
private LowerString _actorFilter = LowerString.Empty; private LowerString _actorFilter = LowerString.Empty;
@ -55,7 +67,7 @@ public class ActorSelector
private void DrawSelector() private void DrawSelector()
{ {
using var child = ImRaii.Child("##actorSelector", new Vector2(_width, -ImGui.GetFrameHeight()), true); using var child = ImRaii.Child("##Selector", new Vector2(_width, -ImGui.GetFrameHeight()), true);
if (!child) if (!child)
return; return;
@ -72,7 +84,7 @@ public class ActorSelector
private void DrawSelectable(KeyValuePair<ActorIdentifier, ActorData> pair) private void DrawSelectable(KeyValuePair<ActorIdentifier, ActorData> pair)
{ {
var equals = pair.Key.Equals(_identifier); var equals = pair.Key.Equals(_identifier);
if (ImGui.Selectable(pair.Value.Label, equals) && !equals) if (ImGui.Selectable(IncognitoMode ? pair.Key.Incognito(pair.Value.Label) : pair.Value.Label, equals) && !equals)
_identifier = pair.Key.CreatePermanent(); _identifier = pair.Key.CreatePermanent();
} }

View file

@ -40,9 +40,6 @@ public class SetPanel
public void Draw() public void Draw()
{ {
if (!_selector.HasSelection)
return;
using var group = ImRaii.Group(); using var group = ImRaii.Group();
DrawHeader(); DrawHeader();
DrawPanel(); DrawPanel();
@ -51,15 +48,28 @@ public class SetPanel
private void DrawHeader() private void DrawHeader()
{ {
var buttonColor = ImGui.GetColorU32(ImGuiCol.FrameBg); var buttonColor = ImGui.GetColorU32(ImGuiCol.FrameBg);
var frameHeight = ImGui.GetFrameHeightWithSpacing();
using var style = ImRaii.PushStyle(ImGuiStyleVar.ItemSpacing, Vector2.Zero) using var style = ImRaii.PushStyle(ImGuiStyleVar.ItemSpacing, Vector2.Zero)
.Push(ImGuiStyleVar.FrameRounding, 0); .Push(ImGuiStyleVar.FrameRounding, 0);
ImGuiUtil.DrawTextButton(Selection.Name, -Vector2.UnitX, buttonColor); ImGuiUtil.DrawTextButton(_selector.SelectionName, new Vector2(-frameHeight, ImGui.GetFrameHeight()), buttonColor);
ImGui.SameLine();
style.Push(ImGuiStyleVar.FrameBorderSize, ImGuiHelpers.GlobalScale);
using var color = ImRaii.PushColor(ImGuiCol.Text, ColorId.FolderExpanded.Value())
.Push(ImGuiCol.Border, ColorId.FolderExpanded.Value());
if (ImGuiUtil.DrawDisabledButton(
$"{(_selector.IncognitoMode ? FontAwesomeIcon.Eye : FontAwesomeIcon.EyeSlash).ToIconString()}###IncognitoMode",
new Vector2(frameHeight, ImGui.GetFrameHeight()), string.Empty, false, true))
_selector.IncognitoMode = !_selector.IncognitoMode;
var hovered = ImGui.IsItemHovered();
color.Pop(2);
if (hovered)
ImGui.SetTooltip(_selector.IncognitoMode ? "Toggle incognito mode off." : "Toggle incognito mode on.");
} }
private void DrawPanel() private void DrawPanel()
{ {
using var child = ImRaii.Child("##SetPanel", -Vector2.One, true); using var child = ImRaii.Child("##Panel", -Vector2.One, true);
if (!child) if (!child || !_selector.HasSelection)
return; return;
var name = _tempName ?? Selection.Name; var name = _tempName ?? Selection.Name;
@ -104,7 +114,7 @@ public class SetPanel
ImGui.Selectable($"#{idx + 1:D2}"); ImGui.Selectable($"#{idx + 1:D2}");
DrawDragDrop(Selection, idx); DrawDragDrop(Selection, idx);
ImGui.TableNextColumn(); ImGui.TableNextColumn();
_designCombo.Draw(Selection, design, idx); _designCombo.Draw(Selection, design, idx, _selector.IncognitoMode);
DrawDragDrop(Selection, idx); DrawDragDrop(Selection, idx);
ImGui.TableNextColumn(); ImGui.TableNextColumn();
DrawApplicationTypeBoxes(Selection, design, idx); DrawApplicationTypeBoxes(Selection, design, idx);
@ -117,7 +127,7 @@ public class SetPanel
ImGui.AlignTextToFramePadding(); ImGui.AlignTextToFramePadding();
ImGui.TextUnformatted("New"); ImGui.TextUnformatted("New");
ImGui.TableNextColumn(); ImGui.TableNextColumn();
_designCombo.Draw(Selection, null, -1); _designCombo.Draw(Selection, null, -1, _selector.IncognitoMode);
ImGui.TableNextColumn(); ImGui.TableNextColumn();
ImGui.TableNextColumn(); ImGui.TableNextColumn();
@ -219,11 +229,12 @@ public class SetPanel
_manager = manager; _manager = manager;
} }
public void Draw(AutoDesignSet set, AutoDesign? design, int autoDesignIndex) public void Draw(AutoDesignSet set, AutoDesign? design, int autoDesignIndex, bool incognito)
{ {
CurrentSelection = design?.Design ?? (Items.Count > 0 ? Items[0] : null); CurrentSelection = design?.Design ?? (Items.Count > 0 ? Items[0] : null);
CurrentSelectionIdx = design?.Design.Index ?? (Items.Count > 0 ? 0 : -1); CurrentSelectionIdx = design?.Design.Index ?? (Items.Count > 0 ? 0 : -1);
if (Draw("##design", CurrentSelection?.Name.Text ?? string.Empty, string.Empty, 220 * ImGuiHelpers.GlobalScale, var name = (incognito ? CurrentSelection?.Incognito : CurrentSelection?.Name.Text) ?? string.Empty;
if (Draw("##design", name, string.Empty, 220 * ImGuiHelpers.GlobalScale,
ImGui.GetTextLineHeight()) ImGui.GetTextLineHeight())
&& CurrentSelection != null) && CurrentSelection != null)
{ {

View file

@ -1,7 +1,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Numerics;
using System.Text.RegularExpressions;
using Dalamud.Interface; using Dalamud.Interface;
using Glamourer.Automation; using Glamourer.Automation;
using Glamourer.Events; using Glamourer.Events;
@ -12,7 +11,6 @@ using OtterGui;
using OtterGui.Classes; using OtterGui.Classes;
using OtterGui.Raii; using OtterGui.Raii;
using Penumbra.String; using Penumbra.String;
using Vector2 = FFXIVClientStructs.FFXIV.Common.Math.Vector2;
namespace Glamourer.Gui.Tabs.AutomationTab; namespace Glamourer.Gui.Tabs.AutomationTab;
@ -28,7 +26,16 @@ public class SetSelector : IDisposable
public AutoDesignSet? Selection { get; private set; } public AutoDesignSet? Selection { get; private set; }
public int SelectionIndex { get; private set; } = -1; public int SelectionIndex { get; private set; } = -1;
private bool IncognitoMode; public bool IncognitoMode
{
get => _config.IncognitoMode;
set
{
_config.IncognitoMode = value;
_config.Save();
}
}
private int _dragIndex = -1; private int _dragIndex = -1;
private Action? _endAction; private Action? _endAction;
@ -47,6 +54,12 @@ public class SetSelector : IDisposable
_event.Unsubscribe(OnAutomationChanged); _event.Unsubscribe(OnAutomationChanged);
} }
public string SelectionName
=> GetSetName(Selection, SelectionIndex);
public string GetSetName(AutoDesignSet? set, int index)
=> set == null ? "No Selection" : IncognitoMode ? $"Auto Design Set #{index + 1}" : set.Name;
private void OnAutomationChanged(AutomationChanged.Type type, AutoDesignSet? set, object? data) private void OnAutomationChanged(AutomationChanged.Type type, AutoDesignSet? set, object? data)
{ {
switch (type) switch (type)
@ -151,7 +164,7 @@ public class SetSelector : IDisposable
private void DrawSelector() private void DrawSelector()
{ {
using var child = ImRaii.Child("##actorSelector", new Vector2(_width, -ImGui.GetFrameHeight()), true); using var child = ImRaii.Child("##Selector", new Vector2(_width, -ImGui.GetFrameHeight()), true);
if (!child) if (!child)
return; return;
@ -169,13 +182,17 @@ public class SetSelector : IDisposable
using var id = ImRaii.PushId(index); using var id = ImRaii.PushId(index);
using (var color = ImRaii.PushColor(ImGuiCol.Text, set.Enabled ? ColorId.EnabledAutoSet.Value() : ColorId.DisabledAutoSet.Value())) using (var color = ImRaii.PushColor(ImGuiCol.Text, set.Enabled ? ColorId.EnabledAutoSet.Value() : ColorId.DisabledAutoSet.Value()))
{ {
if (ImGui.Selectable(set.Name, set == Selection, ImGuiSelectableFlags.None, _selectableSize)) if (ImGui.Selectable(GetSetName(set, index), set == Selection, ImGuiSelectableFlags.None, _selectableSize))
{ {
Selection = set; Selection = set;
SelectionIndex = index; SelectionIndex = index;
} }
} }
var lineEnd = ImGui.GetItemRectMax();
var lineStart = new Vector2(ImGui.GetItemRectMin().X, lineEnd.Y);
ImGui.GetWindowDrawList().AddLine(lineStart, lineEnd, ImGui.GetColorU32(ImGuiCol.Border), ImGuiHelpers.GlobalScale);
DrawDragDrop(set, index); DrawDragDrop(set, index);
var text = set.Identifier.ToString(); var text = set.Identifier.ToString();
@ -252,7 +269,7 @@ public class SetSelector : IDisposable
if (source.Success && ImGui.SetDragDropPayload(dragDropLabel, nint.Zero, 0)) if (source.Success && ImGui.SetDragDropPayload(dragDropLabel, nint.Zero, 0))
{ {
_dragIndex = index; _dragIndex = index;
ImGui.TextUnformatted($"Moving design set {set.Name} from position {index + 1}..."); ImGui.TextUnformatted($"Moving design set {GetSetName(set, index)} from position {index + 1}...");
} }
} }
} }

View file

@ -3,9 +3,11 @@ using Dalamud.Game.ClientState.Keys;
using Dalamud.Interface; using Dalamud.Interface;
using Glamourer.Designs; using Glamourer.Designs;
using Glamourer.Events; using Glamourer.Events;
using ImGuiNET;
using OtterGui; using OtterGui;
using OtterGui.Filesystem; using OtterGui.Filesystem;
using OtterGui.FileSystem.Selector; using OtterGui.FileSystem.Selector;
using OtterGui.Raii;
namespace Glamourer.Gui.Tabs.DesignTab; namespace Glamourer.Gui.Tabs.DesignTab;
@ -15,6 +17,16 @@ public sealed class DesignFileSystemSelector : FileSystemSelector<Design, Design
private readonly DesignChanged _event; private readonly DesignChanged _event;
private readonly Configuration _config; private readonly Configuration _config;
public bool IncognitoMode
{
get => _config.IncognitoMode;
set
{
_config.IncognitoMode = value;
_config.Save();
}
}
public struct DesignState public struct DesignState
{ } { }
@ -29,6 +41,13 @@ public sealed class DesignFileSystemSelector : FileSystemSelector<Design, Design
AddButton(DeleteButton, 1000); AddButton(DeleteButton, 1000);
} }
protected override void DrawLeafName(FileSystem<Design>.Leaf leaf, in DesignState state, bool selected)
{
var flag = selected ? ImGuiTreeNodeFlags.Selected | LeafFlags : LeafFlags;
var name = IncognitoMode ? leaf.Value.Incognito : leaf.Name;
using var _ = ImRaii.TreeNode(name, flag);
}
public override void Dispose() public override void Dispose()
{ {
base.Dispose(); base.Dispose();

View file

@ -1,10 +1,12 @@
using System.Numerics; using System.Numerics;
using Dalamud.Interface;
using Glamourer.Designs; using Glamourer.Designs;
using Glamourer.Gui.Customization; using Glamourer.Gui.Customization;
using Glamourer.Gui.Equipment; using Glamourer.Gui.Equipment;
using Glamourer.Interop; using Glamourer.Interop;
using Glamourer.State; using Glamourer.State;
using ImGuiNET; using ImGuiNET;
using OtterGui;
using OtterGui.Raii; using OtterGui.Raii;
using Penumbra.GameData.Enums; using Penumbra.GameData.Enums;
@ -30,14 +32,38 @@ public class DesignPanel
_equipmentDrawer = equipmentDrawer; _equipmentDrawer = equipmentDrawer;
} }
private void DrawHeader()
{
var buttonColor = ImGui.GetColorU32(ImGuiCol.FrameBg);
var frameHeight = ImGui.GetFrameHeightWithSpacing();
using var style = ImRaii.PushStyle(ImGuiStyleVar.ItemSpacing, Vector2.Zero)
.Push(ImGuiStyleVar.FrameRounding, 0);
ImGuiUtil.DrawTextButton(SelectionName, new Vector2(-frameHeight, ImGui.GetFrameHeight()), buttonColor);
ImGui.SameLine();
style.Push(ImGuiStyleVar.FrameBorderSize, ImGuiHelpers.GlobalScale);
using var color = ImRaii.PushColor(ImGuiCol.Text, ColorId.FolderExpanded.Value())
.Push(ImGuiCol.Border, ColorId.FolderExpanded.Value());
if (ImGuiUtil.DrawDisabledButton(
$"{(_selector.IncognitoMode ? FontAwesomeIcon.Eye : FontAwesomeIcon.EyeSlash).ToIconString()}###IncognitoMode",
new Vector2(frameHeight, ImGui.GetFrameHeight()), string.Empty, false, true))
_selector.IncognitoMode = !_selector.IncognitoMode;
var hovered = ImGui.IsItemHovered();
color.Pop(2);
if (hovered)
ImGui.SetTooltip(_selector.IncognitoMode ? "Toggle incognito mode off." : "Toggle incognito mode on.");
}
private string SelectionName
=> _selector.Selected == null ? "No Selection" : _selector.IncognitoMode ? _selector.Selected.Incognito : _selector.Selected.Name.Text;
public void Draw() public void Draw()
{ {
var design = _selector.Selected; using var group = ImRaii.Group();
if (design == null) DrawHeader();
return;
var design = _selector.Selected;
using var child = ImRaii.Child("##panel", -Vector2.One, true); using var child = ImRaii.Child("##Panel", -Vector2.One, true);
if (!child) if (!child || design == null)
return; return;
if (ImGui.Button("TEST")) if (ImGui.Button("TEST"))