This commit is contained in:
Ottermandias 2023-06-09 17:57:40 +02:00
parent 7710cfadfa
commit 2d6fd6015d
88 changed files with 2304 additions and 383 deletions

View file

@ -1,57 +0,0 @@
using Glamourer.Designs;
using ImGuiNET;
using OtterGui;
using OtterGui.Raii;
using Penumbra.GameData.Enums;
namespace Glamourer.Gui;
public static class ActorDebug
{
/// <summary> Draw the model data values as straight table data without evaluation. </summary>
public static unsafe void Draw(in ModelData model)
{
using var table = ImRaii.Table("##drawObjectData", 3, ImGuiTableFlags.SizingFixedFit | ImGuiTableFlags.RowBg);
if (!table)
return;
ImGuiUtil.DrawTableColumn("Model ID");
ImGuiUtil.DrawTableColumn(model.ModelId.ToString());
ImGuiUtil.DrawTableColumn(model.ModelId.ToString("X8"));
for (var i = 0; i < Penumbra.GameData.Structs.CustomizeData.Size; ++i)
{
ImGuiUtil.DrawTableColumn($"Customize[{i:D2}]");
ImGuiUtil.DrawTableColumn(model.Customize.Data.Data[i].ToString());
ImGuiUtil.DrawTableColumn(model.Customize.Data.Data[i].ToString("X2"));
}
ImGuiUtil.DrawTableColumn("Race");
ImGuiUtil.DrawTableColumn(model.Customize.Race.ToString());
ImGui.TableNextColumn();
ImGuiUtil.DrawTableColumn("Clan");
ImGuiUtil.DrawTableColumn(model.Customize.Clan.ToString());
ImGui.TableNextColumn();
ImGuiUtil.DrawTableColumn("Gender");
ImGuiUtil.DrawTableColumn(model.Customize.Gender.ToString());
ImGui.TableNextColumn();
for (var i = 0; i < 10; ++i)
{
var slot = EquipSlotExtensions.EqdpSlots[i];
ImGuiUtil.DrawTableColumn($"Equipment[{i}] ({slot})");
var armor = model.Armor(slot);
ImGuiUtil.DrawTableColumn($"{armor.Set.Value}, {armor.Variant}, {armor.Stain.Value}");
ImGuiUtil.DrawTableColumn(armor.Value.ToString("X8"));
}
ImGuiUtil.DrawTableColumn("Mainhand");
ImGuiUtil.DrawTableColumn($"{model.MainHand.Set.Value}, {model.MainHand.Type.Value}, {model.MainHand.Variant}, {model.MainHand.Stain.Value}");
ImGuiUtil.DrawTableColumn(model.MainHand.Value.ToString("X16"));
ImGuiUtil.DrawTableColumn("Offhand");
ImGuiUtil.DrawTableColumn($"{model.OffHand.Set.Value}, {model.OffHand.Type.Value}, {model.OffHand.Variant}, {model.OffHand.Stain.Value}");
ImGuiUtil.DrawTableColumn(model.OffHand.Value.ToString("X16"));
}
}

View file

@ -1,64 +0,0 @@
using System;
using System.Numerics;
using Glamourer.Customization;
using ImGuiNET;
using OtterGui.Raii;
namespace Glamourer.Gui.Customization;
public partial class CustomizationDrawer
{
private const string ColorPickerPopupName = "ColorPicker";
private void DrawColorPicker(CustomizeIndex index)
{
using var _ = SetId(index);
var (current, custom) = GetCurrentCustomization(index);
var color = ImGui.ColorConvertU32ToFloat4(custom.Color);
// Print 1-based index instead of 0.
if (ImGui.ColorButton($"{current + 1}##color", color, ImGuiColorEditFlags.None, _framedIconSize))
ImGui.OpenPopup(ColorPickerPopupName);
ImGui.SameLine();
using (var group = ImRaii.Group())
{
DataInputInt(current);
ImGui.TextUnformatted(_currentOption);
}
DrawColorPickerPopup();
}
private void DrawColorPickerPopup()
{
using var popup = ImRaii.Popup(ColorPickerPopupName, ImGuiWindowFlags.AlwaysAutoResize);
if (!popup)
return;
using var style = ImRaii.PushStyle(ImGuiStyleVar.ItemSpacing, Vector2.Zero)
.Push(ImGuiStyleVar.FrameRounding, 0);
for (var i = 0; i < _currentCount; ++i)
{
var custom = _set.Data(_currentIndex, i, _customize[CustomizeIndex.Face]);
if (ImGui.ColorButton((i + 1).ToString(), ImGui.ColorConvertU32ToFloat4(custom.Color)))
{
UpdateValue(custom.Value);
ImGui.CloseCurrentPopup();
}
if (i % 8 != 7)
ImGui.SameLine();
}
}
// Obtain the current customization and print a warning if it is not known.
private (int, CustomizeData) GetCurrentCustomization(CustomizeIndex index)
{
var current = _set.DataByValue(index, _customize[index], out var custom, _customize.Face);
if (_set.IsAvailable(index) && current < 0)
throw new Exception($"Read invalid customization value {_customize[index]} for {index}.");
return (current, custom!.Value);
}
}

View file

@ -1,58 +0,0 @@
using System;
using System.Linq;
using Dalamud.Interface;
using Glamourer.Customization;
using Glamourer.Util;
using ImGuiNET;
using OtterGui;
using OtterGui.Raii;
using Penumbra.GameData.Enums;
using Penumbra.GameData.Structs;
namespace Glamourer.Gui.Customization;
public partial class CustomizationDrawer
{
private void DrawRaceGenderSelector()
{
DrawGenderSelector();
ImGui.SameLine();
using var group = ImRaii.Group();
DrawRaceCombo();
var gender = _service.AwaitedService.GetName(CustomName.Gender);
var clan = _service.AwaitedService.GetName(CustomName.Clan);
ImGui.TextUnformatted($"{gender} & {clan}");
}
private void DrawGenderSelector()
{
using var font = ImRaii.PushFont(UiBuilder.IconFont);
var icon = _customize.Gender switch
{
Gender.Male when _customize.Race is Race.Hrothgar => FontAwesomeIcon.MarsDouble,
Gender.Male => FontAwesomeIcon.Mars,
Gender.Female => FontAwesomeIcon.Venus,
_ => throw new Exception($"Gender value {_customize.Gender} is not a valid gender for a design."),
};
if (!ImGuiUtil.DrawDisabledButton(icon.ToIconString(), _framedIconSize, string.Empty, icon == FontAwesomeIcon.MarsDouble, true))
return;
Changed |= _customize.ChangeGender(CharacterEquip.Null, _customize.Gender is Gender.Male ? Gender.Female : Gender.Male, _items, _service.AwaitedService);
}
private void DrawRaceCombo()
{
ImGui.SetNextItemWidth(_raceSelectorWidth);
using var combo = ImRaii.Combo("##subRaceCombo", _customize.ClanName(_service.AwaitedService));
if (!combo)
return;
foreach (var subRace in Enum.GetValues<SubRace>().Skip(1)) // Skip Unknown
{
if (ImGui.Selectable(CustomizeExtensions.ClanName(_service.AwaitedService, subRace, _customize.Gender), subRace == _customize.Clan))
Changed |= _customize.ChangeRace(CharacterEquip.Null, subRace, _items, _service.AwaitedService);
}
}
}

View file

@ -1,150 +0,0 @@
using System;
using System.Numerics;
using Glamourer.Customization;
using ImGuiNET;
using OtterGui;
using OtterGui.Raii;
using Penumbra.GameData.Enums;
namespace Glamourer.Gui.Customization;
public partial class CustomizationDrawer
{
private const string IconSelectorPopup = "Style Picker";
private void DrawIconSelector(CustomizeIndex index)
{
using var _ = SetId(index);
using var bigGroup = ImRaii.Group();
var label = _currentOption;
var current = _set.DataByValue(index, _currentByte, out var custom, _customize.Face);
if (current < 0)
{
label = $"{_currentOption} (Custom #{_customize[index]})";
current = 0;
custom = _set.Data(index, 0);
}
var icon = _service.AwaitedService.GetIcon(custom!.Value.IconId);
if (ImGui.ImageButton(icon.ImGuiHandle, _iconSize))
ImGui.OpenPopup(IconSelectorPopup);
ImGuiUtil.HoverIconTooltip(icon, _iconSize);
ImGui.SameLine();
using (var group = ImRaii.Group())
{
if (_currentIndex == CustomizeIndex.Face)
FaceInputInt(current);
else
DataInputInt(current);
ImGui.TextUnformatted($"{label} ({custom.Value.Value})");
}
DrawIconPickerPopup();
}
private bool UpdateFace(CustomizeData data)
{
// Hrothgar Hack
var value = _set.Race == Race.Hrothgar ? data.Value + 4 : data.Value;
if (_customize.Face == value)
return false;
_customize.Face = value;
Changed |= CustomizeFlag.Face;
return true;
}
private void FaceInputInt(int currentIndex)
{
++currentIndex;
ImGui.SetNextItemWidth(_inputIntSize);
if (ImGui.InputInt("##text", ref currentIndex, 1, 1))
{
currentIndex = Math.Clamp(currentIndex - 1, 0, _currentCount - 1);
var data = _set.Data(_currentIndex, currentIndex, _customize.Face);
UpdateFace(data);
}
ImGuiUtil.HoverTooltip($"Input Range: [1, {_currentCount}]");
}
private void DrawIconPickerPopup()
{
using var popup = ImRaii.Popup(IconSelectorPopup, ImGuiWindowFlags.AlwaysAutoResize);
if (!popup)
return;
using var style = ImRaii.PushStyle(ImGuiStyleVar.ItemSpacing, Vector2.Zero)
.Push(ImGuiStyleVar.FrameRounding, 0);
for (var i = 0; i < _currentCount; ++i)
{
var custom = _set.Data(_currentIndex, i, _customize.Face);
var icon = _service.AwaitedService.GetIcon(custom.IconId);
using (var _ = ImRaii.Group())
{
if (ImGui.ImageButton(icon.ImGuiHandle, _iconSize))
{
if (_currentIndex == CustomizeIndex.Face)
UpdateFace(custom);
else
UpdateValue(custom.Value);
ImGui.CloseCurrentPopup();
}
ImGuiUtil.HoverIconTooltip(icon, _iconSize);
var text = custom.Value.ToString();
var textWidth = ImGui.CalcTextSize(text).X;
ImGui.SetCursorPosX(ImGui.GetCursorPosX() + (_iconSize.X - textWidth + 2 * ImGui.GetStyle().FramePadding.X) / 2);
ImGui.TextUnformatted(text);
}
if (i % 8 != 7)
ImGui.SameLine();
}
}
// Only used for facial features, so fixed ID.
private void DrawMultiIconSelector()
{
using var bigGroup = ImRaii.Group();
DrawMultiIcons();
ImGui.SameLine();
using var group = ImRaii.Group();
ImGui.Dummy(new Vector2(0, ImGui.GetTextLineHeightWithSpacing() + ImGui.GetStyle().ItemSpacing.Y / 2));
_currentCount = 256;
PercentageInputInt();
ImGui.TextUnformatted(_set.Option(CustomizeIndex.LegacyTattoo));
}
private void DrawMultiIcons()
{
var options = _set.Order[CharaMakeParams.MenuType.IconCheckmark];
using var _ = ImRaii.Group();
foreach (var (featureIdx, idx) in options.WithIndex())
{
using var id = SetId(featureIdx);
var enabled = _customize.Get(featureIdx) != CustomizeValue.Zero;
var feature = _set.Data(featureIdx, 0, _customize.Face);
var icon = featureIdx == CustomizeIndex.LegacyTattoo
? _legacyTattoo ?? _service.AwaitedService.GetIcon(feature.IconId)
: _service.AwaitedService.GetIcon(feature.IconId);
if (ImGui.ImageButton(icon.ImGuiHandle, _iconSize, Vector2.Zero, Vector2.One, (int)ImGui.GetStyle().FramePadding.X,
Vector4.Zero, enabled ? Vector4.One : _redTint))
{
_customize.Set(featureIdx, enabled ? CustomizeValue.Zero : CustomizeValue.Max);
Changed |= _currentFlag;
}
ImGuiUtil.HoverIconTooltip(icon, _iconSize);
if (idx % 4 != 3)
ImGui.SameLine();
}
}
}

View file

@ -1,102 +0,0 @@
using System;
using Glamourer.Customization;
using ImGuiNET;
using OtterGui;
using OtterGui.Raii;
namespace Glamourer.Gui.Customization;
public partial class CustomizationDrawer
{
private void PercentageSelector(CustomizeIndex index)
{
using var _ = SetId(index);
using var bigGroup = ImRaii.Group();
DrawPercentageSlider();
ImGui.SameLine();
PercentageInputInt();
ImGui.SameLine();
ImGui.TextUnformatted(_currentOption);
}
private void DrawPercentageSlider()
{
var tmp = (int)_currentByte.Value;
ImGui.SetNextItemWidth(_comboSelectorSize);
if (ImGui.SliderInt("##slider", ref tmp, 0, _currentCount - 1, "%i", ImGuiSliderFlags.AlwaysClamp))
UpdateValue((CustomizeValue)tmp);
}
private void PercentageInputInt()
{
var tmp = (int)_currentByte.Value;
ImGui.SetNextItemWidth(_inputIntSize);
if (ImGui.InputInt("##text", ref tmp, 1, 1))
UpdateValue((CustomizeValue)Math.Clamp(tmp, 0, _currentCount - 1));
ImGuiUtil.HoverTooltip($"Input Range: [0, {_currentCount - 1}]");
}
// Integral input for an icon- or color based item.
private void DataInputInt(int currentIndex)
{
++currentIndex;
ImGui.SetNextItemWidth(_inputIntSize);
if (ImGui.InputInt("##text", ref currentIndex, 1, 1))
{
currentIndex = Math.Clamp(currentIndex - 1, 0, _currentCount - 1);
var data = _set.Data(_currentIndex, currentIndex, _customize.Face);
UpdateValue(data.Value);
}
ImGuiUtil.HoverTooltip($"Input Range: [1, {_currentCount}]");
}
private void DrawListSelector(CustomizeIndex index)
{
using var _ = SetId(index);
using var bigGroup = ImRaii.Group();
ListCombo();
ImGui.SameLine();
ListInputInt();
ImGui.SameLine();
ImGui.TextUnformatted(_currentOption);
}
private void ListCombo()
{
ImGui.SetNextItemWidth(_comboSelectorSize * ImGui.GetIO().FontGlobalScale);
using var combo = ImRaii.Combo("##combo", $"{_currentOption} #{_currentByte.Value + 1}");
if (!combo)
return;
for (var i = 0; i < _currentCount; ++i)
{
if (ImGui.Selectable($"{_currentOption} #{i + 1}##combo", i == _currentByte.Value))
UpdateValue((CustomizeValue)i);
}
}
private void ListInputInt()
{
var tmp = _currentByte.Value + 1;
ImGui.SetNextItemWidth(_inputIntSize);
if (ImGui.InputInt("##text", ref tmp, 1, 1) && tmp > 0 && tmp <= _currentCount)
UpdateValue((CustomizeValue)Math.Clamp(tmp - 1, 0, _currentCount - 1));
ImGuiUtil.HoverTooltip($"Input Range: [1, {_currentCount}]");
}
// Draw a customize checkbox.
private void DrawCheckbox(CustomizeIndex idx)
{
using var id = SetId(idx);
var tmp = _currentByte != CustomizeValue.Zero;
if (ImGui.Checkbox(_currentOption, ref tmp))
{
_customize.Set(idx, tmp ? CustomizeValue.Max : CustomizeValue.Zero);
Changed |= _currentFlag;
}
}
}

View file

@ -1,164 +0,0 @@
using System;
using System.Numerics;
using System.Reflection;
using Dalamud.Plugin;
using Glamourer.Customization;
using Glamourer.Services;
using ImGuiNET;
using OtterGui;
using OtterGui.Raii;
namespace Glamourer.Gui.Customization;
public partial class CustomizationDrawer : IDisposable
{
private readonly Vector4 _redTint = new(0.6f, 0.3f, 0.3f, 1f);
private readonly ImGuiScene.TextureWrap? _legacyTattoo;
private bool _withFlags = false;
private Exception? _terminate = null;
private Customize _customize;
private CustomizationSet _set = null!;
public Customize Customize;
public CustomizeFlag CurrentFlag { get; private set; }
public CustomizeFlag Changed { get; private set; }
public bool RequiresRedraw
=> Changed.RequiresRedraw();
private bool _locked = false;
private Vector2 _iconSize;
private Vector2 _framedIconSize;
private float _inputIntSize;
private float _comboSelectorSize;
private float _raceSelectorWidth;
private readonly CustomizationService _service;
private readonly ItemManager _items;
public CustomizationDrawer(DalamudPluginInterface pi, CustomizationService service, ItemManager items)
{
_service = service;
_items = items;
_legacyTattoo = GetLegacyTattooIcon(pi);
Customize = Customize.Default;
}
public void Dispose()
{
_legacyTattoo?.Dispose();
}
public bool Draw(Customize current, bool locked)
{
_withFlags = false;
CurrentFlag = CustomizeFlagExtensions.All;
Init(current, locked);
return DrawInternal();
}
public bool Draw(Customize current, CustomizeFlag currentFlags, bool locked)
{
_withFlags = true;
CurrentFlag = currentFlags;
Init(current, locked);
return DrawInternal();
}
private void Init(Customize current, bool locked)
{
UpdateSizes();
_terminate = null;
Changed = 0;
_customize.Load(current);
_locked = locked;
}
// Set state for drawing of current customization.
private CustomizeIndex _currentIndex;
private CustomizeFlag _currentFlag;
private CustomizeValue _currentByte = CustomizeValue.Zero;
private int _currentCount;
private string _currentOption = string.Empty;
// Prepare a new customization option.
private ImRaii.Id SetId(CustomizeIndex index)
{
_currentIndex = index;
_currentFlag = index.ToFlag();
_currentByte = _customize[index];
_currentCount = _set.Count(index, _customize.Face);
_currentOption = _set.Option(index);
return ImRaii.PushId((int)index);
}
// Update the current id with a new value.
private void UpdateValue(CustomizeValue value)
{
if (_currentByte == value)
return;
_customize[_currentIndex] = value;
Changed |= _currentFlag;
}
private bool DrawInternal()
{
using var disabled = ImRaii.Disabled(_locked);
try
{
DrawRaceGenderSelector();
_set = _service.AwaitedService.GetList(_customize.Clan, _customize.Gender);
foreach (var id in _set.Order[CharaMakeParams.MenuType.Percentage])
PercentageSelector(id);
Functions.IteratePairwise(_set.Order[CharaMakeParams.MenuType.IconSelector], DrawIconSelector, ImGui.SameLine);
DrawMultiIconSelector();
foreach (var id in _set.Order[CharaMakeParams.MenuType.ListSelector])
DrawListSelector(id);
Functions.IteratePairwise(_set.Order[CharaMakeParams.MenuType.ColorPicker], DrawColorPicker, ImGui.SameLine);
Functions.IteratePairwise(_set.Order[CharaMakeParams.MenuType.Checkmark], DrawCheckbox,
() => ImGui.SameLine(_inputIntSize + _framedIconSize.X + 3 * ImGui.GetStyle().ItemSpacing.X));
return Changed != 0;
}
catch (Exception ex)
{
_terminate = ex;
using var color = ImRaii.PushColor(ImGuiCol.Text, 0xFF4040FF);
ImGui.NewLine();
ImGuiUtil.TextWrapped(_terminate.ToString());
return false;
}
}
private void UpdateSizes()
{
_iconSize = new Vector2(ImGui.GetTextLineHeightWithSpacing() * 2);
_framedIconSize = _iconSize + 2 * ImGui.GetStyle().FramePadding;
_inputIntSize = 2 * _framedIconSize.X + ImGui.GetStyle().ItemSpacing.X;
_comboSelectorSize = 4 * _framedIconSize.X + 3 * ImGui.GetStyle().ItemSpacing.X;
_raceSelectorWidth = _inputIntSize + _comboSelectorSize - _framedIconSize.X;
}
private static ImGuiScene.TextureWrap? GetLegacyTattooIcon(DalamudPluginInterface pi)
{
using var resource = Assembly.GetExecutingAssembly().GetManifestResourceStream("Glamourer.LegacyTattoo.raw");
if (resource == null)
return null;
var rawImage = new byte[resource.Length];
var length = resource.Read(rawImage, 0, (int)resource.Length);
return length == resource.Length
? pi.UiBuilder.LoadImageRaw(rawImage, 192, 192, 4)
: null;
}
}

View file

@ -1,59 +0,0 @@
using System.Numerics;
using Dalamud.Game.ClientState.Keys;
using Dalamud.Interface;
using Glamourer.Designs;
using OtterGui;
using OtterGui.FileSystem.Selector;
namespace Glamourer.Gui.Designs;
public sealed class DesignFileSystemSelector : FileSystemSelector<Design, DesignFileSystemSelector.DesignState>
{
private readonly DesignManager _designManager;
public struct DesignState
{ }
public DesignFileSystemSelector(DesignManager designManager, DesignFileSystem fileSystem, KeyState keyState)
: base(fileSystem, keyState)
{
_designManager = designManager;
_designManager.DesignChange += OnDesignChange;
AddButton(DeleteButton, 1000);
}
public override void Dispose()
{
base.Dispose();
_designManager.DesignChange -= OnDesignChange;
}
private void OnDesignChange(DesignManager.DesignChangeType type, Design design, object? oldData)
{
switch (type)
{
case DesignManager.DesignChangeType.ReloadedAll:
case DesignManager.DesignChangeType.Renamed:
case DesignManager.DesignChangeType.AddedTag:
case DesignManager.DesignChangeType.ChangedTag:
case DesignManager.DesignChangeType.RemovedTag:
SetFilterDirty();
break;
}
}
private void DeleteButton(Vector2 size)
{
var keys = true;
var tt = SelectedLeaf == null
? "No design selected."
: "Delete the currently selected design entirely from your drive.\n"
+ "This can not be undone.";
//if (!keys)
// tt += $"\nHold {_config.DeleteModModifier} while clicking to delete the mod.";
if (ImGuiUtil.DrawDisabledButton(FontAwesomeIcon.Trash.ToIconString(), size, tt, SelectedLeaf == null || !keys, true)
&& Selected != null)
_designManager.Delete(Selected);
}
}

View file

@ -1,368 +0,0 @@
using Dalamud.Game.ClientState.Keys;
using Glamourer.Designs;
using OtterGui.Filesystem;
using OtterGui.FileSystem.Selector;
namespace Glamourer.Gui.Designs;
//internal partial class Interface
//{
// private int _totalObject;
//
// private bool _inDesignMode;
// private Design? _selection;
// private string _newChildName = string.Empty;
//
// private void DrawDesignSelector()
// {
// _totalObject = 0;
// ImGui.BeginGroup();
// if (ImGui.BeginChild("##selector", new Vector2(SelectorWidth * ImGui.GetIO().FontGlobalScale, -ImGui.GetFrameHeight() - 1), true))
// {
// DrawFolderContent(_designs.FileSystem.Root, Glamourer.Config.FoldersFirst ? SortMode.FoldersFirst : SortMode.Lexicographical);
// ImGui.PushStyleVar(ImGuiStyleVar.ItemSpacing, Vector2.Zero);
// ImGui.EndChild();
// ImGui.PopStyleVar();
// }
//
// DrawDesignSelectorButtons();
// ImGui.EndGroup();
// }
//
// private void DrawPasteClipboardButton()
// {
// if (_selection!.Data.WriteProtected)
// ImGui.PushStyleVar(ImGuiStyleVar.Alpha, 0.5f);
//
// ImGui.PushFont(UiBuilder.IconFont);
// var applyButton = ImGui.Button(FontAwesomeIcon.Paste.ToIconString());
// ImGui.PopFont();
// if (_selection!.Data.WriteProtected)
// ImGui.PopStyleVar();
//
// ImGuiUtil.HoverTooltip("Overwrite with customization code from clipboard.");
//
// if (_selection!.Data.WriteProtected || !applyButton)
// return;
//
// var text = ImGui.GetClipboardText();
// if (!text.Any())
// return;
//
// try
// {
// _selection!.Data.Load(text, out _);
// _designs.SaveToFile();
// }
// catch (Exception e)
// {
// PluginLog.Information($"{e}");
// }
// }
//
// private void DrawNewFolderButton()
// {
// ImGui.PushFont(UiBuilder.IconFont);
// if (ImGui.Button(FontAwesomeIcon.FolderPlus.ToIconString(), Vector2.UnitX * SelectorWidth / 5))
// OpenDesignNamePopup(DesignNameUse.NewFolder);
// ImGui.PopFont();
// ImGuiUtil.HoverTooltip("Create a new, empty Folder.");
//
// DrawDesignNamePopup(DesignNameUse.NewFolder);
// }
//
// private void DrawNewDesignButton()
// {
// ImGui.PushFont(UiBuilder.IconFont);
// if (ImGui.Button(FontAwesomeIcon.Plus.ToIconString(), Vector2.UnitX * SelectorWidth / 5))
// OpenDesignNamePopup(DesignNameUse.NewDesign);
// ImGui.PopFont();
// ImGuiUtil.HoverTooltip("Create a new, empty Design.");
//
// DrawDesignNamePopup(DesignNameUse.NewDesign);
// }
//
// private void DrawClipboardDesignButton()
// {
// ImGui.PushFont(UiBuilder.IconFont);
// if (ImGui.Button(FontAwesomeIcon.Paste.ToIconString(), Vector2.UnitX * SelectorWidth / 5))
// OpenDesignNamePopup(DesignNameUse.FromClipboard);
// ImGui.PopFont();
// ImGuiUtil.HoverTooltip("Create a new design from the customization string in your clipboard.");
//
// DrawDesignNamePopup(DesignNameUse.FromClipboard);
// }
//
// private void DrawDeleteDesignButton()
// {
// ImGui.PushFont(UiBuilder.IconFont);
// var style = _selection == null;
// if (style)
// ImGui.PushStyleVar(ImGuiStyleVar.Alpha, 0.5f);
// if (ImGui.Button(FontAwesomeIcon.Trash.ToIconString(), Vector2.UnitX * SelectorWidth / 5) && _selection != null)
// {
// _designs.DeleteAllChildren(_selection, false);
// _selection = null;
// }
//
// ImGui.PopFont();
// if (style)
// ImGui.PopStyleVar();
// ImGuiUtil.HoverTooltip("Delete the currently selected Design.");
// }
//
// private void DrawDuplicateDesignButton()
// {
// ImGui.PushFont(UiBuilder.IconFont);
// if (_selection == null)
// ImGui.PushStyleVar(ImGuiStyleVar.Alpha, 0.5f);
// if (ImGui.Button(FontAwesomeIcon.Clone.ToIconString(), Vector2.UnitX * SelectorWidth / 5) && _selection != null)
// OpenDesignNamePopup(DesignNameUse.DuplicateDesign);
// ImGui.PopFont();
// if (_selection == null)
// ImGui.PopStyleVar();
// ImGuiUtil.HoverTooltip(
// "Clone the currently selected Design.\nHold Shift to only clone the customizations.\nHold Control to only clone the equipment.");
//
// DrawDesignNamePopup(DesignNameUse.DuplicateDesign);
// }
//
// private void DrawDesignSelectorButtons()
// {
// using var style = ImRaii.PushStyle(ImGuiStyleVar.ItemSpacing, Vector2.Zero)
// .Push(ImGuiStyleVar.FrameRounding, 0f);
//
// DrawNewFolderButton();
// ImGui.SameLine();
// DrawNewDesignButton();
// ImGui.SameLine();
// DrawClipboardDesignButton();
// ImGui.SameLine();
// DrawDuplicateDesignButton();
// ImGui.SameLine();
// DrawDeleteDesignButton();
// }
//
// private void DrawDesignHeaderButtons()
// {
// DrawCopyClipboardButton(_selection!.Data);
// ImGui.SameLine();
// DrawPasteClipboardButton();
// ImGui.SameLine();
// DrawApplyToPlayerButton(_selection!.Data);
// if (!_inGPose)
// {
// ImGui.SameLine();
// DrawApplyToTargetButton(_selection!.Data);
// }
//
// ImGui.SameLine();
// DrawCheckbox("Write Protected", _selection!.Data.WriteProtected, v => _selection!.Data.WriteProtected = v, false);
// }
//
// private void DrawDesignPanel()
// {
// if (ImGui.BeginChild("##details", -Vector2.One * 0.001f, true))
// {
// DrawDesignHeaderButtons();
// var data = _selection!.Data;
// var prot = _selection!.Data.WriteProtected;
// if (prot)
// {
// ImGui.PushStyleVar(ImGuiStyleVar.Alpha, 0.8f);
// data = data.Copy();
// }
//
// DrawGeneralSettings(data, prot);
// var mask = data.WriteEquipment;
// if (DrawEquip(data.Equipment, ref mask) && !prot)
// {
// data.WriteEquipment = mask;
// _designs.SaveToFile();
// }
//
// if (DrawCustomization(ref data.Customizations) && !prot)
// _designs.SaveToFile();
//
// if (DrawMiscellaneous(data, null) && !prot)
// _designs.SaveToFile();
//
// if (prot)
// ImGui.PopStyleVar();
//
// ImGui.EndChild();
// }
// }
//
// private void DrawSaves()
// {
// using var style = ImRaii.PushStyle(ImGuiStyleVar.IndentSpacing, 12.5f * ImGui.GetIO().FontGlobalScale);
// using var tab = ImRaii.TabItem("Designs");
// _inDesignMode = tab.Success;
// if (!_inDesignMode)
// return;
//
// DrawDesignSelector();
//
// if (_selection != null)
// {
// ImGui.SameLine();
// DrawDesignPanel();
// }
// }
//
// private void DrawCheckbox(string label, bool value, Action<bool> setter, bool prot)
// {
// var tmp = value;
// if (ImGui.Checkbox(label, ref tmp) && tmp != value)
// {
// setter(tmp);
// if (!prot)
// _designs.SaveToFile();
// }
// }
//
// private void DrawGeneralSettings(CharacterSave data, bool prot)
// {
// ImGui.BeginGroup();
// DrawCheckbox("Apply Customizations", data.WriteCustomizations, v => data.WriteCustomizations = v, prot);
// DrawCheckbox("Write Weapon State", data.SetWeaponState, v => data.SetWeaponState = v, prot);
// ImGui.EndGroup();
// ImGui.SameLine();
// ImGui.BeginGroup();
// DrawCheckbox("Write Hat State", data.SetHatState, v => data.SetHatState = v, prot);
// DrawCheckbox("Write Visor State", data.SetVisorState, v => data.SetVisorState = v, prot);
// ImGui.EndGroup();
// }
//
// private void RenameChildInput(IFileSystemBase child)
// {
// ImGui.SetNextItemWidth(150);
// if (!ImGui.InputTextWithHint("##fsNewName", "Rename...", ref _newChildName, 64,
// ImGuiInputTextFlags.EnterReturnsTrue))
// return;
//
// if (_newChildName.Any() && _newChildName != child.Name)
// try
// {
// var oldPath = child.FullName();
// if (_designs.FileSystem.Rename(child, _newChildName))
// _designs.UpdateAllChildren(oldPath, child);
// }
// catch (Exception e)
// {
// PluginLog.Error($"Could not rename {child.Name} to {_newChildName}:\n{e}");
// }
// else if (child is Folder f)
// try
// {
// var oldPath = child.FullName();
// if (_designs.FileSystem.Merge(f, f.Parent, true))
// _designs.UpdateAllChildren(oldPath, f.Parent);
// }
// catch (Exception e)
// {
// PluginLog.Error($"Could not merge folder {child.Name} into parent:\n{e}");
// }
//
// _newChildName = string.Empty;
// }
//
// private void ContextMenu(IFileSystemBase child)
// {
// var label = $"##fsPopup{child.FullName()}";
// if (ImGui.BeginPopup(label))
// {
// if (ImGui.MenuItem("Delete") && ImGui.GetIO().KeyCtrl && ImGui.GetIO().KeyShift)
// _designs.DeleteAllChildren(child, false);
// ImGuiUtil.HoverTooltip("Hold Control and Shift to delete.");
//
// RenameChildInput(child);
//
// if (child is Design d && ImGui.MenuItem("Copy to Clipboard"))
// ImGui.SetClipboardText(d.Data.ToBase64());
//
// ImGui.EndPopup();
// }
//
// if (ImGui.IsItemClicked(ImGuiMouseButton.Right))
// {
// _newChildName = child.Name;
// ImGui.OpenPopup(label);
// }
// }
//
// private static uint GetDesignColor(CharacterSave save)
// {
// const uint white = 0xFFFFFFFF;
// const uint grey = 0xFF808080;
// if (!Glamourer.Config.ColorDesigns)
// return white;
//
// var changesStates = save.SetHatState || save.SetVisorState || save.SetWeaponState || save.IsWet || save.Alpha != 1.0f;
// if (save.WriteCustomizations)
// if (save.WriteEquipment != CharacterEquipMask.None)
// return white;
// else
// return changesStates ? white : Glamourer.Config.CustomizationColor;
//
// if (save.WriteEquipment != CharacterEquipMask.None)
// return changesStates ? white : Glamourer.Config.EquipmentColor;
//
// return changesStates ? Glamourer.Config.StateColor : grey;
// }
//
// private void DrawFolderContent(Folder folder, SortMode mode)
// {
// foreach (var child in folder.AllChildren(mode).ToArray())
// {
// if (child.IsFolder(out var subFolder))
// {
// var treeNode = ImGui.TreeNodeEx($"{subFolder.Name}##{_totalObject}");
// DrawOrnaments(child);
//
// if (treeNode)
// {
// DrawFolderContent(subFolder, mode);
// ImGui.TreePop();
// }
// else
// {
// _totalObject += subFolder.TotalDescendantLeaves();
// }
// }
// else
// {
// if (child is not Design d)
// continue;
//
// ++_totalObject;
// var color = GetDesignColor(d.Data);
// using var c = ImRaii.PushColor(ImGuiCol.Text, color);
//
// var selected = ImGui.Selectable($"{child.Name}##{_totalObject}", ReferenceEquals(child, _selection));
// c.Pop();
// DrawOrnaments(child);
//
// if (Glamourer.Config.ShowLocks && d.Data.WriteProtected)
// {
// ImGui.SameLine();
// using var font = ImRaii.PushFont(UiBuilder.IconFont);
// c.Push(ImGuiCol.Text, color);
// ImGui.TextUnformatted(FontAwesomeIcon.Lock.ToIconString());
// }
//
// if (selected)
// _selection = d;
// }
// }
// }
//
// private void DrawOrnaments(IFileSystemBase child)
// {
// FileSystemImGui.DragDropSource(child);
// if (FileSystemImGui.DragDropTarget(_designs.FileSystem, child, out var oldPath, out var draggedFolder))
// _designs.UpdateAllChildren(oldPath, draggedFolder!);
// ContextMenu(child);
// }
//}

View file

@ -1,187 +0,0 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using Dalamud.Data;
using Dalamud.Interface;
using Glamourer.Designs;
using Glamourer.Services;
using Glamourer.State;
using ImGuiNET;
using OtterGui;
using OtterGui.Widgets;
using Penumbra.GameData.Data;
using Penumbra.GameData.Enums;
using Penumbra.GameData.Structs;
namespace Glamourer.Gui.Equipment;
public class EquipmentDrawer
{
private readonly ItemManager _items;
private readonly FilterComboColors _stainCombo;
private readonly StainData _stainData;
private readonly ItemCombo[] _itemCombo;
private readonly Dictionary<(FullEquipType, EquipSlot), WeaponCombo> _weaponCombo;
public EquipmentDrawer(DataManager gameData, ItemManager items)
{
_items = items;
_stainData = items.Stains;
_stainCombo = new FilterComboColors(140,
_stainData.Data.Prepend(new KeyValuePair<byte, (string Name, uint Dye, bool Gloss)>(0, ("None", 0, false))));
_itemCombo = EquipSlotExtensions.EqdpSlots.Select(e => new ItemCombo(gameData, items, e)).ToArray();
_weaponCombo = new Dictionary<(FullEquipType, EquipSlot), WeaponCombo>(FullEquipTypeExtensions.WeaponTypes.Count * 2);
foreach (var type in Enum.GetValues<FullEquipType>())
{
if (type.ToSlot() is EquipSlot.MainHand)
_weaponCombo.TryAdd((type, EquipSlot.MainHand), new WeaponCombo(gameData, items, type, EquipSlot.MainHand));
else if (type.ToSlot() is EquipSlot.OffHand)
_weaponCombo.TryAdd((type, EquipSlot.OffHand), new WeaponCombo(gameData, items, type, EquipSlot.OffHand));
var offhand = type.Offhand();
if (offhand is not FullEquipType.Unknown && !_weaponCombo.ContainsKey((offhand, EquipSlot.OffHand)))
_weaponCombo.TryAdd((offhand, EquipSlot.OffHand), new WeaponCombo(gameData, items, type, EquipSlot.OffHand));
}
_weaponCombo.Add((FullEquipType.Unknown, EquipSlot.MainHand), new WeaponCombo(gameData, items, FullEquipType.Unknown, EquipSlot.MainHand));
}
private string VerifyRestrictedGear(Item gear, EquipSlot slot, Gender gender, Race race)
{
if (slot.IsAccessory())
return gear.Name;
var (changed, _) = _items.ResolveRestrictedGear(gear.Model, slot, race, gender);
if (changed)
return gear.Name + " (Restricted)";
return gear.Name;
}
public bool DrawArmor(Item current, EquipSlot slot, out Item armor, Gender gender = Gender.Unknown, Race race = Race.Unknown)
{
Debug.Assert(slot.IsEquipment() || slot.IsAccessory(), $"Called {nameof(DrawArmor)} on {slot}.");
var combo = _itemCombo[slot.ToIndex()];
armor = current;
var change = combo.Draw(VerifyRestrictedGear(armor, slot, gender, race), armor.ItemId, 320 * ImGuiHelpers.GlobalScale);
if (armor.ModelBase.Value != 0)
{
ImGuiUtil.HoverTooltip("Right-click to clear.");
if (ImGui.IsItemClicked(ImGuiMouseButton.Right))
{
change = true;
armor = ItemManager.NothingItem(slot);
}
else if (change)
{
armor = combo.CurrentSelection.WithStain(armor.Stain);
}
}
else if (change)
{
armor = combo.CurrentSelection.WithStain(armor.Stain);
}
return change;
}
public bool DrawStain(StainId current, EquipSlot slot, out Stain stain)
{
var found = _stainData.TryGetValue(current, out stain);
if (!_stainCombo.Draw($"##stain{slot}", stain.RgbaColor, stain.Name, found))
return false;
return _stainData.TryGetValue(_stainCombo.CurrentSelection.Key, out stain);
}
public bool DrawMainhand(Weapon current, bool drawAll, out Weapon weapon)
{
weapon = current;
if (!_weaponCombo.TryGetValue((drawAll ? FullEquipType.Unknown : current.Type, EquipSlot.MainHand), out var combo))
return false;
if (!combo.Draw(weapon.Name, weapon.ItemId, 320 * ImGuiHelpers.GlobalScale))
return false;
weapon = combo.CurrentSelection.WithStain(current.Stain);
return true;
}
public bool DrawOffhand(Weapon current, FullEquipType mainType, out Weapon weapon)
{
weapon = current;
var offType = mainType.Offhand();
if (offType == FullEquipType.Unknown)
return false;
if (!_weaponCombo.TryGetValue((offType, EquipSlot.OffHand), out var combo))
return false;
var change = combo.Draw(weapon.Name, weapon.ItemId, 320 * ImGuiHelpers.GlobalScale);
if (offType.ToSlot() is EquipSlot.OffHand && weapon.ModelBase.Value != 0)
{
ImGuiUtil.HoverTooltip("Right-click to clear.");
if (ImGui.IsItemClicked(ImGuiMouseButton.Right))
{
change = true;
weapon = ItemManager.NothingItem(offType);
}
}
else if (change)
{
weapon = combo.CurrentSelection.WithStain(current.Stain);
}
return change;
}
public bool DrawApply(Design design, EquipSlot slot, out bool enabled)
=> DrawCheckbox($"##apply{slot}", design.DoApplyEquip(slot), out enabled);
public bool DrawApplyStain(Design design, EquipSlot slot, out bool enabled)
=> DrawCheckbox($"##applyStain{slot}", design.DoApplyStain(slot), out enabled);
private static bool DrawCheckbox(string label, bool value, out bool on)
{
var ret = ImGuiUtil.Checkbox(label, string.Empty, value, v => value = v);
on = value;
return ret;
}
public bool DrawVisor(Design design, out bool on)
=> DrawCheckbox("##visorToggled", design.Visor.ForcedValue, out on);
public bool DrawVisor(ActiveDesign design, out bool on)
=> DrawCheckbox("##visorToggled", design.IsVisorToggled, out on);
public bool DrawHat(Design design, out bool on)
=> DrawCheckbox("##hatVisible", design.Hat.ForcedValue, out on);
public bool DrawHat(ActiveDesign design, out bool on)
=> DrawCheckbox("##hatVisible", design.IsHatVisible, out on);
public bool DrawWeapon(Design design, out bool on)
=> DrawCheckbox("##weaponVisible", design.Weapon.ForcedValue, out on);
public bool DrawWeapon(ActiveDesign design, out bool on)
=> DrawCheckbox("##weaponVisible", design.IsWeaponVisible, out on);
public bool DrawWetness(Design design, out bool on)
=> DrawCheckbox("##wetness", design.Wetness.ForcedValue, out on);
public bool DrawWetness(ActiveDesign design, out bool on)
=> DrawCheckbox("##wetnessVisible", design.IsWet, out on);
public bool DrawApplyVisor(Design design, out bool on)
=> DrawCheckbox("##applyVisor", design.Visor.Enabled, out on);
public bool DrawApplyWetness(Design design, out bool on)
=> DrawCheckbox("##applyWetness", design.Wetness.Enabled, out on);
public bool DrawApplyHatState(Design design, out bool on)
=> DrawCheckbox("##applyHatState", design.Hat.Enabled, out on);
public bool DrawApplyWeaponState(Design design, out bool on)
=> DrawCheckbox("##applyWeaponState", design.Weapon.Enabled, out on);
}

View file

@ -1,105 +0,0 @@
using System.Collections.Generic;
using System.Linq;
using Dalamud.Data;
using Glamourer.Designs;
using Glamourer.Services;
using ImGuiNET;
using Lumina.Excel.GeneratedSheets;
using OtterGui;
using OtterGui.Classes;
using OtterGui.Raii;
using OtterGui.Widgets;
using Penumbra.GameData.Enums;
using Item = Glamourer.Designs.Item;
namespace Glamourer.Gui.Equipment;
public sealed class ItemCombo : FilterComboCache<Item>
{
public readonly string Label;
private uint _currentItem;
public ItemCombo(DataManager gameData, ItemManager items, EquipSlot slot)
: base(() => GetItems(items, slot))
{
Label = GetLabel(gameData, slot);
_currentItem = ItemManager.NothingId(slot);
}
protected override void DrawList(float width, float itemHeight)
{
base.DrawList(width, itemHeight);
if (NewSelection != null && Items.Count > NewSelection.Value)
CurrentSelection = Items[NewSelection.Value];
}
protected override int UpdateCurrentSelected(int currentSelected)
{
if (CurrentSelection.ItemId != _currentItem)
{
CurrentSelectionIdx = Items.IndexOf(i => i.ItemId == _currentItem);
CurrentSelection = CurrentSelectionIdx >= 0 ? Items[CurrentSelectionIdx] : default;
return base.UpdateCurrentSelected(CurrentSelectionIdx);
}
return currentSelected;
}
public bool Draw(string previewName, uint previewIdx, float width)
{
_currentItem = previewIdx;
return Draw(Label, previewName, string.Empty, width, ImGui.GetTextLineHeightWithSpacing());
}
protected override bool DrawSelectable(int globalIdx, bool selected)
{
var obj = Items[globalIdx];
var name = ToString(obj);
var ret = ImGui.Selectable(name, selected);
ImGui.SameLine();
using var color = ImRaii.PushColor(ImGuiCol.Text, 0xFF808080);
ImGuiUtil.RightAlign($"({obj.ModelBase.Value}-{obj.Variant})");
return ret;
}
protected override bool IsVisible(int globalIndex, LowerString filter)
=> base.IsVisible(globalIndex, filter) || filter.IsContained(Items[globalIndex].ModelBase.ToString());
protected override string ToString(Item obj)
=> obj.Name;
private static string GetLabel(DataManager gameData, EquipSlot slot)
{
var sheet = gameData.GetExcelSheet<Addon>()!;
return slot switch
{
EquipSlot.Head => sheet.GetRow(740)?.Text.ToString() ?? "Head",
EquipSlot.Body => sheet.GetRow(741)?.Text.ToString() ?? "Body",
EquipSlot.Hands => sheet.GetRow(742)?.Text.ToString() ?? "Hands",
EquipSlot.Legs => sheet.GetRow(744)?.Text.ToString() ?? "Legs",
EquipSlot.Feet => sheet.GetRow(745)?.Text.ToString() ?? "Feet",
EquipSlot.Ears => sheet.GetRow(746)?.Text.ToString() ?? "Ears",
EquipSlot.Neck => sheet.GetRow(747)?.Text.ToString() ?? "Neck",
EquipSlot.Wrists => sheet.GetRow(748)?.Text.ToString() ?? "Wrists",
EquipSlot.RFinger => sheet.GetRow(749)?.Text.ToString() ?? "Right Ring",
EquipSlot.LFinger => sheet.GetRow(750)?.Text.ToString() ?? "Left Ring",
_ => string.Empty,
};
}
private static IReadOnlyList<Item> GetItems(ItemManager items, EquipSlot slot)
{
var nothing = ItemManager.NothingItem(slot);
if (!items.ItemService.AwaitedService.TryGetValue(slot.ToEquipType(), out var list))
return new[]
{
nothing,
};
var enumerable = list.Select(i => new Item(i));
if (slot.IsEquipment())
enumerable = enumerable.Append(ItemManager.SmallClothesItem(slot));
return enumerable.OrderBy(i => i.Name).Prepend(nothing).ToList();
}
}

View file

@ -1,108 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Dalamud.Data;
using Glamourer.Designs;
using Glamourer.Services;
using ImGuiNET;
using Lumina.Excel.GeneratedSheets;
using OtterGui;
using OtterGui.Classes;
using OtterGui.Raii;
using OtterGui.Widgets;
using Penumbra.GameData.Enums;
namespace Glamourer.Gui.Equipment;
public sealed class WeaponCombo : FilterComboCache<Weapon>
{
public readonly string Label;
private uint _currentItem;
public WeaponCombo(DataManager gameData, ItemManager items, FullEquipType type, EquipSlot offhand)
: base(offhand is EquipSlot.OffHand ? () => GetOff(items, type) : () => GetMain(items, type))
=> Label = GetLabel(gameData, offhand);
protected override void DrawList(float width, float itemHeight)
{
base.DrawList(width, itemHeight);
if (NewSelection != null && Items.Count > NewSelection.Value)
CurrentSelection = Items[NewSelection.Value];
}
protected override int UpdateCurrentSelected(int currentSelected)
{
if (CurrentSelection.ItemId != _currentItem)
{
CurrentSelectionIdx = Items.IndexOf(i => i.ItemId == _currentItem);
CurrentSelection = CurrentSelectionIdx >= 0 ? Items[CurrentSelectionIdx] : default;
return base.UpdateCurrentSelected(CurrentSelectionIdx);
}
return currentSelected;
}
public bool Draw(string previewName, uint previewIdx, float width)
{
_currentItem = previewIdx;
return Draw(Label, previewName, string.Empty, width, ImGui.GetTextLineHeightWithSpacing());
}
protected override bool DrawSelectable(int globalIdx, bool selected)
{
var obj = Items[globalIdx];
var name = ToString(obj);
var ret = ImGui.Selectable(name, selected);
ImGui.SameLine();
using var color = ImRaii.PushColor(ImGuiCol.Text, 0xFF808080);
ImGuiUtil.RightAlign($"({obj.ModelBase.Value}-{obj.WeaponBase.Value}-{obj.Variant})");
return ret;
}
protected override bool IsVisible(int globalIndex, LowerString filter)
=> base.IsVisible(globalIndex, filter) || filter.IsContained(Items[globalIndex].ModelBase.ToString());
protected override string ToString(Weapon obj)
=> obj.Name;
private static string GetLabel(DataManager gameData, EquipSlot offhand)
{
var sheet = gameData.GetExcelSheet<Addon>()!;
return offhand is EquipSlot.OffHand
? sheet.GetRow(739)?.Text.ToString() ?? "Off Hand"
: sheet.GetRow(738)?.Text.ToString() ?? "Main Hand";
}
private static IReadOnlyList<Weapon> GetMain(ItemManager items, FullEquipType type)
{
var list = new List<Weapon>();
if (type is FullEquipType.Unknown)
foreach (var t in Enum.GetValues<FullEquipType>().Where(t => t.ToSlot() == EquipSlot.MainHand))
list.AddRange(items.ItemService.AwaitedService[t].Select(w => new Weapon(w, false)));
else if (type.ToSlot() is EquipSlot.MainHand)
list.AddRange(items.ItemService.AwaitedService[type].Select(w => new Weapon(w, false)));
list.Sort((w1, w2) => string.CompareOrdinal(w1.Name, w2.Name));
return list;
}
private static IReadOnlyList<Weapon> GetOff(ItemManager items, FullEquipType type)
{
if (type.ToSlot() == EquipSlot.OffHand)
{
var nothing = ItemManager.NothingItem(type);
if (!items.ItemService.AwaitedService.TryGetValue(type, out var list))
return new[]
{
nothing,
};
return list.Select(w => new Weapon(w, true)).OrderBy(w => w.Name).Prepend(nothing).ToList();
}
else if (items.ItemService.AwaitedService.TryGetValue(type, out var list))
{
return list.Select(w => new Weapon(w, true)).OrderBy(w => w.Name).ToList();
}
return Array.Empty<Weapon>();
}
}

View file

@ -8,9 +8,9 @@ public class GlamourerWindowSystem : IDisposable
{
private readonly WindowSystem _windowSystem = new("Glamourer");
private readonly UiBuilder _uiBuilder;
private readonly Interface _ui;
private readonly MainWindow _ui;
public GlamourerWindowSystem(UiBuilder uiBuilder, Interface ui)
public GlamourerWindowSystem(UiBuilder uiBuilder, MainWindow ui)
{
_uiBuilder = uiBuilder;
_ui = ui;
@ -24,7 +24,4 @@ public class GlamourerWindowSystem : IDisposable
_uiBuilder.Draw -= _windowSystem.Draw;
_uiBuilder.OpenConfigUi -= _ui.Toggle;
}
public void Toggle()
=> _ui.Toggle();
}

View file

@ -1,291 +0,0 @@
using System;
using System.Collections.Generic;
using System.Numerics;
using Dalamud.Game.ClientState.Objects;
using Dalamud.Interface;
using Glamourer.Interop;
using Glamourer.Services;
using Glamourer.State;
using ImGuiNET;
using OtterGui;
using OtterGui.Classes;
using OtterGui.Raii;
using Penumbra.GameData.Actors;
using Penumbra.GameData.Enums;
using ImGui = ImGuiNET.ImGui;
namespace Glamourer.Gui;
public partial class Interface
{
private class ActorTab
{
private readonly Interface _main;
private readonly ActiveDesign.Manager _activeDesigns;
private readonly ObjectManager _objects;
private readonly TargetManager _targets;
private readonly ActorService _actors;
private readonly ItemManager _items;
public ActorTab(Interface main, ActiveDesign.Manager activeDesigns, ObjectManager objects, TargetManager targets, ActorService actors,
ItemManager items)
{
_main = main;
_activeDesigns = activeDesigns;
_objects = objects;
_targets = targets;
_actors = actors;
_items = items;
}
private ActorIdentifier _identifier = ActorIdentifier.Invalid;
private ActorData _currentData = ActorData.Invalid;
private ActiveDesign? _currentSave;
public void Draw()
{
using var tab = ImRaii.TabItem("Actors");
if (!tab)
return;
DrawActorSelector();
if (!_objects.TryGetValue(_identifier, out _currentData))
_currentData = ActorData.Invalid;
ImGui.SameLine();
DrawPanel();
}
private unsafe void DrawPanel()
{
if (_identifier == ActorIdentifier.Invalid)
return;
using var group = ImRaii.Group();
DrawPanelHeader();
using var child = ImRaii.Child("##ActorPanel", -Vector2.One, true);
if (!child || _currentSave == null)
return;
if (_currentData.Valid)
_currentSave.Initialize(_items, _currentData.Objects[0]);
RevertButton();
ActorDebug.Draw(_currentSave.ModelData);
return;
if (_main._customizationDrawer.Draw(_currentSave.ModelData.Customize, _identifier.Type == IdentifierType.Special))
_activeDesigns.ChangeCustomize(_currentSave, _main._customizationDrawer.Changed, _main._customizationDrawer.Customize.Data,
false);
foreach (var slot in EquipSlotExtensions.EqdpSlots)
{
var current = _currentSave.Armor(slot);
if (_main._equipmentDrawer.DrawStain(current.Stain, slot, out var stain))
_activeDesigns.ChangeStain(_currentSave, slot, stain.RowIndex, false);
ImGui.SameLine();
if (_main._equipmentDrawer.DrawArmor(current, slot, out var armor, _currentSave.ModelData.Customize.Gender,
_currentSave.ModelData.Customize.Race))
_activeDesigns.ChangeEquipment(_currentSave, slot, armor, false);
}
var currentMain = _currentSave.WeaponMain;
if (_main._equipmentDrawer.DrawStain(currentMain.Stain, EquipSlot.MainHand, out var stainMain))
_activeDesigns.ChangeStain(_currentSave, EquipSlot.MainHand, stainMain.RowIndex, false);
ImGui.SameLine();
_main._equipmentDrawer.DrawMainhand(currentMain, true, out var main);
if (currentMain.Type.Offhand() != FullEquipType.Unknown)
{
var currentOff = _currentSave.WeaponOff;
if (_main._equipmentDrawer.DrawStain(currentOff.Stain, EquipSlot.OffHand, out var stainOff))
_activeDesigns.ChangeStain(_currentSave, EquipSlot.OffHand, stainOff.RowIndex, false);
ImGui.SameLine();
_main._equipmentDrawer.DrawOffhand(currentOff, main.Type, out var off);
}
if (_main._equipmentDrawer.DrawVisor(_currentSave, out var value))
_activeDesigns.ChangeVisor(_currentSave, value, false);
}
private const uint RedHeaderColor = 0xFF1818C0;
private const uint GreenHeaderColor = 0xFF18C018;
private unsafe void RevertButton()
{
if (ImGui.Button("Revert"))
_activeDesigns.RevertDesign(_currentSave!);
//foreach (var actor in _currentData.Objects)
// _currentSave!.ApplyToActor(actor);
//
//if (_currentData.Objects.Count > 0)
// _currentSave = _manipulations.GetOrCreateSave(_currentData.Objects[0]);
//
//_currentSave!.Reset();
if (_currentData.Objects.Count > 0)
ImGui.TextUnformatted(_currentData.Objects[0].Pointer->GameObject.DataID.ToString());
//VisorBox();
}
//private unsafe void VisorBox()
//{
// var (flags, mask) = (_currentSave!.Data.Flags & (ApplicationFlags.SetVisor | ApplicationFlags.Visor)) switch
// {
// ApplicationFlags.SetVisor => (0u, 3u),
// ApplicationFlags.Visor => (1u, 3u),
// ApplicationFlags.SetVisor | ApplicationFlags.Visor => (3u, 3u),
// _ => (2u, 3u),
// };
// var tmp = flags;
// if (ImGui.CheckboxFlags("Visor Toggled", ref tmp, mask))
// {
// _currentSave.Data.Flags = flags switch
// {
// 0 => (_currentSave.Data.Flags | ApplicationFlags.Visor) & ~ApplicationFlags.SetVisor,
// 1 => _currentSave.Data.Flags | ApplicationFlags.SetVisor,
// 2 => _currentSave.Data.Flags | ApplicationFlags.SetVisor,
// _ => _currentSave.Data.Flags & ~(ApplicationFlags.SetVisor | ApplicationFlags.Visor),
// };
// if (_currentSave.Data.Flags.HasFlag(ApplicationFlags.SetVisor))
// {
// var on = _currentSave.Data.Flags.HasFlag(ApplicationFlags.Visor);
// foreach (var actor in _currentData.Objects.Where(a => a.IsHuman && a.DrawObject))
// RedrawManager.SetVisor(actor.DrawObject.Pointer, on);
// }
// }
//}
private void DrawPanelHeader()
{
var color = _currentData.Valid ? GreenHeaderColor : RedHeaderColor;
var buttonColor = ImGui.GetColorU32(ImGuiCol.FrameBg);
using var c = ImRaii.PushColor(ImGuiCol.Text, color)
.Push(ImGuiCol.Button, buttonColor)
.Push(ImGuiCol.ButtonHovered, buttonColor)
.Push(ImGuiCol.ButtonActive, buttonColor);
using var style = ImRaii.PushStyle(ImGuiStyleVar.ItemSpacing, Vector2.Zero)
.Push(ImGuiStyleVar.FrameRounding, 0);
ImGui.Button($"{_currentData.Label}##playerHeader", -Vector2.UnitX);
}
//private void DrawActorPanel()
//{
// using var group = ImRaii.Group();
// if (!_data.Identifier.IsValid)
// return;
//
// if (DrawCustomization(_currentSave.Customize, _currentSave.Equipment, !_data.Modifiable))
// //Glamourer.RedrawManager.Set(_data.Actor.Address, _character);
// Glamourer.Penumbra.RedrawObject(_data.Actor.Character, RedrawType.Redraw, true);
//
// if (ImGui.Button("Set Machinist Goggles"))
// Glamourer.RedrawManager.ChangeEquip(_data.Actor, EquipSlot.Head, new CharacterArmor(265, 1, 0));
//
// if (ImGui.Button("Set Weapon"))
// Glamourer.RedrawManager.LoadWeapon(_data.Actor.Address, new CharacterWeapon(0x00C9, 0x004E, 0x0001, 0x00),
// new CharacterWeapon(0x0065, 0x003D, 0x0001, 0x00));
//
// if (ImGui.Button("Set Customize"))
// {
// unsafe
// {
// var data = _data.Actor.Customize.Data->Clone();
// Glamourer.RedrawManager.UpdateCustomize(_data.Actor.DrawObject, new Customize(&data)
// {
// SkinColor = 154,
// });
// }
// }
//}
//
//private void DrawMonsterPanel()
//{
// using var group = ImRaii.Group();
// var currentModel = (uint)_data.Actor.ModelId;
// var models = GameData.Models(Dalamud.GameData);
// var currentData = models.Models.TryGetValue(currentModel, out var c) ? c.FirstName : $"#{currentModel}";
// using var combo = ImRaii.Combo("Model Id", currentData);
// if (!combo)
// return;
//
// foreach (var (id, data) in models.Models)
// {
// if (ImGui.Selectable(data.FirstName, id == currentModel) && id != currentModel)
// {
// _data.Actor.SetModelId((int)id);
// Glamourer.Penumbra.RedrawObject(_data.Actor.Character, RedrawType.Redraw, true);
// }
//
// ImGuiUtil.HoverTooltip(data.AllNames);
// }
//}
private LowerString _actorFilter = LowerString.Empty;
private void DrawActorSelector()
{
using var group = ImRaii.Group();
var oldSpacing = ImGui.GetStyle().ItemSpacing;
using var style = ImRaii.PushStyle(ImGuiStyleVar.ItemSpacing, Vector2.Zero)
.Push(ImGuiStyleVar.FrameRounding, 0);
ImGui.SetNextItemWidth(_actorSelectorWidth);
LowerString.InputWithHint("##actorFilter", "Filter...", ref _actorFilter, 64);
DrawSelector(oldSpacing);
DrawSelectionButtons();
}
private void DrawSelector(Vector2 oldSpacing)
{
using var child = ImRaii.Child("##actorSelector", new Vector2(_actorSelectorWidth, -ImGui.GetFrameHeight()), true);
if (!child)
return;
_objects.Update();
if (!_activeDesigns.TryGetValue(_identifier, out _currentSave))
_currentSave = null;
using var style = ImRaii.PushStyle(ImGuiStyleVar.ItemSpacing, oldSpacing);
var skips = ImGuiClip.GetNecessarySkips(ImGui.GetTextLineHeight());
var remainder = ImGuiClip.FilteredClippedDraw(_objects, skips, CheckFilter, DrawSelectable);
ImGuiClip.DrawEndDummy(remainder, ImGui.GetTextLineHeight());
if (_currentSave == null)
{
_identifier = ActorIdentifier.Invalid;
_currentData = ActorData.Invalid;
}
}
private bool CheckFilter(KeyValuePair<ActorIdentifier, ActorData> pair)
=> _actorFilter.IsEmpty || pair.Value.Label.Contains(_actorFilter.Lower, StringComparison.OrdinalIgnoreCase);
private void DrawSelectable(KeyValuePair<ActorIdentifier, ActorData> pair)
{
var equal = pair.Key.Equals(_identifier);
if (ImGui.Selectable(pair.Value.Label, equal) || equal)
{
_identifier = pair.Key.CreatePermanent();
_currentData = pair.Value;
if (!_activeDesigns.TryGetValue(_identifier, out _currentSave))
_currentSave = _currentData.Valid ? _activeDesigns.GetOrCreateSave(_currentData.Objects[0]) : null;
}
}
private void DrawSelectionButtons()
{
using var style = ImRaii.PushStyle(ImGuiStyleVar.ItemSpacing, Vector2.Zero)
.Push(ImGuiStyleVar.FrameRounding, 0);
var buttonWidth = new Vector2(_actorSelectorWidth / 2, 0);
if (ImGuiUtil.DrawDisabledButton(FontAwesomeIcon.UserCircle.ToIconString(), buttonWidth
, "Select the local player character.", !_objects.Player, true))
_identifier = _objects.Player.GetIdentifier(_actors.AwaitedService);
ImGui.SameLine();
Actor targetActor = _targets.Target?.Address;
if (ImGuiUtil.DrawDisabledButton(FontAwesomeIcon.HandPointer.ToIconString(), buttonWidth,
"Select the current target, if it is in the list.", _objects.IsInGPose || !targetActor, true))
_identifier = targetActor.GetIdentifier(_actors.AwaitedService);
}
}
}

View file

@ -1,55 +0,0 @@
using System;
using Glamourer.Customization;
using Glamourer.Services;
using Glamourer.Util;
using ImGuiNET;
using OtterGui;
using OtterGui.Raii;
namespace Glamourer.Gui;
public partial class Interface
{
private class DebugDataTab
{
private readonly CustomizationService _service;
public DebugDataTab(CustomizationService service)
=> _service = service;
public void Draw()
{
if (!_service.Valid)
return;
using var tab = ImRaii.TabItem("Debug");
if (!tab)
return;
foreach (var clan in _service.AwaitedService.Clans)
{
foreach (var gender in _service.AwaitedService.Genders)
DrawCustomizationInfo(_service.AwaitedService.GetList(clan, gender));
}
}
public void DrawCustomizationInfo(CustomizationSet set)
{
if (!ImGui.CollapsingHeader($"{CustomizeExtensions.ClanName(_service.AwaitedService, set.Clan, set.Gender)} {set.Gender}"))
return;
using var table = ImRaii.Table("data", 5);
if (!table)
return;
foreach (var index in Enum.GetValues<CustomizeIndex>())
{
ImGuiUtil.DrawTableColumn(index.ToString());
ImGuiUtil.DrawTableColumn(set.Option(index));
ImGuiUtil.DrawTableColumn(set.IsAvailable(index) ? "Available" : "Unavailable");
ImGuiUtil.DrawTableColumn(set.Type(index).ToString());
ImGuiUtil.DrawTableColumn(set.Count(index).ToString());
}
}
}
}

View file

@ -1,98 +0,0 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Numerics;
using Glamourer.State;
using ImGuiNET;
using OtterGui;
using OtterGui.Classes;
using OtterGui.Raii;
using Penumbra.GameData.Actors;
namespace Glamourer.Gui;
public partial class Interface
{
private class DebugStateTab
{
private readonly ActiveDesign.Manager _activeDesigns;
private LowerString _manipulationFilter = LowerString.Empty;
private ActorIdentifier _selection = ActorIdentifier.Invalid;
private ActiveDesign? _save = null;
private bool _delete = false;
public DebugStateTab(ActiveDesign.Manager activeDesigns)
=> _activeDesigns = activeDesigns;
[Conditional("DEBUG")]
public void Draw()
{
using var tab = ImRaii.TabItem("Current Manipulations");
if (!tab)
return;
DrawManipulationSelector();
if (_save == null)
return;
ImGui.SameLine();
DrawActorPanel();
if (_delete)
{
_delete = false;
_activeDesigns.DeleteSave(_selection);
_selection = ActorIdentifier.Invalid;
}
}
private void DrawSelector(Vector2 oldSpacing)
{
using var child = ImRaii.Child("##actorSelector", new Vector2(_actorSelectorWidth, -1), true);
if (!child)
return;
using var style = ImRaii.PushStyle(ImGuiStyleVar.ItemSpacing, oldSpacing);
var skips = ImGuiClip.GetNecessarySkips(ImGui.GetTextLineHeight());
var remainder = ImGuiClip.FilteredClippedDraw(_activeDesigns, skips, CheckFilter, DrawSelectable);
ImGuiClip.DrawEndDummy(remainder, ImGui.GetTextLineHeight());
}
private void DrawManipulationSelector()
{
using var group = ImRaii.Group();
var oldSpacing = ImGui.GetStyle().ItemSpacing;
using var style = ImRaii.PushStyle(ImGuiStyleVar.ItemSpacing, Vector2.Zero)
.Push(ImGuiStyleVar.FrameRounding, 0);
ImGui.SetNextItemWidth(_actorSelectorWidth);
LowerString.InputWithHint("##actorFilter", "Filter...", ref _manipulationFilter, 64);
_save = null;
DrawSelector(oldSpacing);
}
private bool CheckFilter(KeyValuePair<ActorIdentifier, ActiveDesign> data)
{
if (data.Key.Equals(_selection))
_save = data.Value;
return _manipulationFilter.Length == 0 || _manipulationFilter.IsContained(data.Key.ToString()!);
}
private void DrawSelectable(KeyValuePair<ActorIdentifier, ActiveDesign> data)
{
var equal = data.Key.Equals(_selection);
if (ImGui.Selectable(data.Key.ToString(), equal))
{
_selection = data.Key;
_save = data.Value;
}
}
private void DrawActorPanel()
{
using var group = ImRaii.Group();
if (ImGui.Button("Delete"))
_delete = true;
}
}
}

View file

@ -1,101 +0,0 @@
using System;
using System.Numerics;
using Dalamud.Game.ClientState.Keys;
using Dalamud.Interface;
using Glamourer.Customization;
using Glamourer.Designs;
using Glamourer.Gui.Designs;
using Glamourer.Interop;
using Glamourer.State;
using ImGuiNET;
using OtterGui;
using OtterGui.Raii;
using Penumbra.GameData.Enums;
namespace Glamourer.Gui;
public partial class Interface
{
private class DesignTab : IDisposable
{
public readonly DesignFileSystemSelector Selector;
private readonly Interface _main;
private readonly DesignFileSystem _fileSystem;
private readonly DesignManager _designManager;
private readonly ActiveDesign.Manager _activeDesignManager;
private readonly ObjectManager _objects;
public DesignTab(Interface main, DesignManager designManager, DesignFileSystem fileSystem, KeyState keyState,
ActiveDesign.Manager activeDesignManager, ObjectManager objects)
{
_main = main;
_designManager = designManager;
_fileSystem = fileSystem;
_activeDesignManager = activeDesignManager;
_objects = objects;
Selector = new DesignFileSystemSelector(designManager, fileSystem, keyState);
}
public void Dispose()
=> Selector.Dispose();
public void Draw()
{
using var tab = ImRaii.TabItem("Designs");
if (!tab)
return;
Selector.Draw(GetDesignSelectorSize());
ImGui.SameLine();
DrawDesignPanel();
}
public float GetDesignSelectorSize()
=> 200f * ImGuiHelpers.GlobalScale;
private void ApplySelfButton()
{
var self = _objects.Player;
if (!ImGuiUtil.DrawDisabledButton("Apply to Self", Vector2.Zero, string.Empty, !self.Valid))
return;
var design = _activeDesignManager.GetOrCreateSave(self);
_activeDesignManager.ApplyDesign(design, Selector.Selected!, false);
}
public void DrawDesignPanel()
{
if (Selector.Selected == null)
return;
using var group = ImRaii.Group();
ApplySelfButton();
using var child = ImRaii.Child("##DesignPanel", new Vector2(-0.001f), true, ImGuiWindowFlags.HorizontalScrollbar);
if (!child)
return;
ActorDebug.Draw(Selector.Selected.ModelData);
_main._customizationDrawer.Draw(Selector.Selected.ModelData.Customize, CustomizeFlagExtensions.All, true);
foreach (var slot in EquipSlotExtensions.EqdpSlots)
{
var current = Selector.Selected.Armor(slot);
_main._equipmentDrawer.DrawStain(current.Stain, slot, out var stain);
ImGui.SameLine();
_main._equipmentDrawer.DrawArmor(current, slot, out var armor);
}
var currentMain = Selector.Selected.WeaponMain;
_main._equipmentDrawer.DrawStain(currentMain.Stain, EquipSlot.MainHand, out var stainMain);
ImGui.SameLine();
_main._equipmentDrawer.DrawMainhand(currentMain, true, out var main);
if (currentMain.Type.Offhand() != FullEquipType.Unknown)
{
var currentOff = Selector.Selected.WeaponOff;
_main._equipmentDrawer.DrawStain(currentOff.Stain, EquipSlot.OffHand, out var stainOff);
ImGui.SameLine();
_main._equipmentDrawer.DrawOffhand(currentOff, main.Type, out var off);
}
}
}
}

View file

@ -1,84 +0,0 @@
using System;
using ImGuiNET;
using OtterGui;
using OtterGui.Raii;
namespace Glamourer.Gui;
public partial class Interface
{
private void Checkmark(string label, string tooltip, bool value, Action<bool> setter)
{
if (ImGuiUtil.Checkbox(label, tooltip, value, setter))
_config.Save();
}
private void ChangeAndSave<T>(T value, T currentValue, Action<T> setter) where T : IEquatable<T>
{
if (value.Equals(currentValue))
return;
setter(value);
_config.Save();
}
private void DrawColorPicker(string name, string tooltip, uint value, uint defaultValue, Action<uint> setter)
{
const ImGuiColorEditFlags flags = ImGuiColorEditFlags.AlphaPreviewHalf | ImGuiColorEditFlags.NoInputs;
var tmp = ImGui.ColorConvertU32ToFloat4(value);
if (ImGui.ColorEdit4($"##{name}", ref tmp, flags))
ChangeAndSave(ImGui.ColorConvertFloat4ToU32(tmp), value, setter);
ImGui.SameLine();
if (ImGui.Button($"Default##{name}"))
ChangeAndSave(defaultValue, value, setter);
ImGuiUtil.HoverTooltip(
$"Reset to default: #{defaultValue & 0xFF:X2}{(defaultValue >> 8) & 0xFF:X2}{(defaultValue >> 16) & 0xFF:X2}{defaultValue >> 24:X2}");
ImGui.SameLine();
ImGui.Text(name);
ImGuiUtil.HoverTooltip(tooltip);
}
private static void DrawRestorePenumbraButton()
{
//const string buttonLabel = "Re-Register Penumbra";
// TODO
//if (ImGui.Button(buttonLabel))
// Glamourer.Penumbra.Reattach(true);
//ImGuiUtil.HoverTooltip(
// "If Penumbra did not register the functions for some reason, pressing this button might help restore functionality.");
}
private void DrawSettingsTab()
{
using var tab = ImRaii.TabItem("Settings");
if (!tab)
return;
ImGui.Dummy(_spacing);
Checkmark("Folders First", "Sort Folders before all designs instead of lexicographically.", _config.FoldersFirst,
v => _config.FoldersFirst = v);
Checkmark("Color Designs", "Color the names of designs in the selector using the colors from below for the given cases.",
_config.ColorDesigns,
v => _config.ColorDesigns = v);
Checkmark("Show Locks", "Write-protected Designs show a lock besides their name in the selector.", _config.ShowLocks,
v => _config.ShowLocks = v);
DrawRestorePenumbraButton();
Checkmark("Apply Fixed Designs",
"Automatically apply fixed designs to characters and redraw them when anything changes.",
_config.ApplyFixedDesigns,
v => { _config.ApplyFixedDesigns = v; });
ImGui.Dummy(_spacing);
DrawColorPicker("Customization Color", "The color for designs that only apply their character customization.",
_config.CustomizationColor, Configuration.DefaultCustomizationColor, c => _config.CustomizationColor = c);
DrawColorPicker("Equipment Color", "The color for designs that only apply some or all of their equipment slots and stains.",
_config.EquipmentColor, Configuration.DefaultEquipmentColor, c => _config.EquipmentColor = c);
DrawColorPicker("State Color", "The color for designs that only apply some state modification.",
_config.StateColor, Configuration.DefaultStateColor, c => _config.StateColor = c);
}
}

View file

@ -1,17 +0,0 @@
using System.Numerics;
using Dalamud.Interface;
using ImGuiNET;
namespace Glamourer.Gui;
public partial class Interface
{
private static Vector2 _spacing = Vector2.Zero;
private static float _actorSelectorWidth;
private static void UpdateState()
{
_spacing = _spacing with { Y = ImGui.GetTextLineHeightWithSpacing() / 2 };
_actorSelectorWidth = 200 * ImGuiHelpers.GlobalScale;
}
}

View file

@ -1,88 +0,0 @@
using System;
using System.Numerics;
using Dalamud.Data;
using Dalamud.Game.ClientState.Keys;
using Dalamud.Game.ClientState.Objects;
using Dalamud.Interface.Windowing;
using Dalamud.Logging;
using Dalamud.Plugin;
using Glamourer.Designs;
using Glamourer.Gui.Customization;
using Glamourer.Gui.Equipment;
using Glamourer.Interop;
using Glamourer.Services;
using Glamourer.State;
using ImGuiNET;
using OtterGui.Raii;
namespace Glamourer.Gui;
public partial class Interface : Window, IDisposable
{
private readonly DalamudPluginInterface _pi;
private readonly EquipmentDrawer _equipmentDrawer;
private readonly CustomizationDrawer _customizationDrawer;
private readonly Configuration _config;
private readonly ActorTab _actorTab;
private readonly DesignTab _designTab;
private readonly DebugStateTab _debugStateTab;
private readonly DebugDataTab _debugDataTab;
public Interface(DalamudPluginInterface pi, ItemManager items, ActiveDesign.Manager activeDesigns, DesignManager designManager,
DesignFileSystem fileSystem, ObjectManager objects, CustomizationService customization, Configuration config, DataManager gameData, TargetManager targets, ActorService actors, KeyState keyState)
: base(GetLabel())
{
_pi = pi;
_config = config;
_equipmentDrawer = new EquipmentDrawer(gameData, items);
_customizationDrawer = new CustomizationDrawer(pi, customization, items);
pi.UiBuilder.DisableGposeUiHide = true;
SizeConstraints = new WindowSizeConstraints()
{
MinimumSize = new Vector2(675, 675),
MaximumSize = ImGui.GetIO().DisplaySize,
};
_actorTab = new ActorTab(this, activeDesigns, objects, targets, actors, items);
_debugStateTab = new DebugStateTab(activeDesigns);
_debugDataTab = new DebugDataTab(customization);
_designTab = new DesignTab(this, designManager, fileSystem, keyState, activeDesigns, objects);
}
public override void Draw()
{
using var tabBar = ImRaii.TabBar("##Tabs");
if (!tabBar)
return;
try
{
UpdateState();
_actorTab.Draw();
_designTab.Draw();
DrawSettingsTab();
_debugStateTab.Draw();
_debugDataTab.Draw();
// DrawSaves();
// DrawFixedDesignsTab();
// DrawRevertablesTab();
}
catch (Exception e)
{
PluginLog.Error($"Unexpected Error during Draw:\n{e}");
}
}
public void Dispose()
{
_pi.UiBuilder.OpenConfigUi -= Toggle;
_customizationDrawer.Dispose();
_designTab.Dispose();
}
private static string GetLabel()
=> Glamourer.Version.Length == 0
? "Glamourer###GlamourerConfigWindow"
: $"Glamourer v{Glamourer.Version}###GlamourerConfigWindow";
}

View file

@ -1,290 +0,0 @@

namespace Glamourer.Gui;
public partial class Interface
{
//private readonly CharacterSave _currentSave = new();
//private string _newDesignName = string.Empty;
//private bool _keyboardFocus;
//private bool _holdShift;
//private bool _holdCtrl;
//private const string DesignNamePopupLabel = "Save Design As...";
//
//private void DrawPlayerHeader()
//{
// var color = _player == null ? RedHeaderColor : GreenHeaderColor;
// var buttonColor = ImGui.GetColorU32(ImGuiCol.FrameBg);
// using var c = ImRaii.PushColor(ImGuiCol.Text, color)
// .Push(ImGuiCol.Button, buttonColor)
// .Push(ImGuiCol.ButtonHovered, buttonColor)
// .Push(ImGuiCol.ButtonActive, buttonColor);
// using var style = ImRaii.PushStyle(ImGuiStyleVar.ItemSpacing, Vector2.Zero)
// .Push(ImGuiStyleVar.FrameRounding, 0);
// ImGui.Button($"{_currentLabel}##playerHeader", -Vector2.UnitX * 0.0001f);
//}
//
//private static void DrawCopyClipboardButton(CharacterSave save)
//{
// ImGui.PushFont(UiBuilder.IconFont);
// if (ImGui.Button(FontAwesomeIcon.Clipboard.ToIconString()))
// ImGui.SetClipboardText(save.ToBase64());
// ImGui.PopFont();
// ImGuiUtil.HoverTooltip("Copy customization code to clipboard.");
//}
//
//private static void ConditionalApply(CharacterSave save, Character player)
//{
// if (ImGui.GetIO().KeyShift)
// save.ApplyOnlyCustomizations(player);
// else if (ImGui.GetIO().KeyCtrl)
// save.ApplyOnlyEquipment(player);
// else
// save.Apply(player);
//}
//
//private static CharacterSave ConditionalCopy(CharacterSave save, bool shift, bool ctrl)
//{
// var copy = save.Copy();
// if (shift)
// {
// copy.Load(new CharacterEquipment());
// copy.SetHatState = false;
// copy.SetVisorState = false;
// copy.SetWeaponState = false;
// copy.WriteEquipment = CharacterEquipMask.None;
// }
// else if (ctrl)
// {
// copy.Load(CharacterCustomization.Default);
// copy.SetHatState = false;
// copy.SetVisorState = false;
// copy.SetWeaponState = false;
// copy.WriteCustomizations = false;
// }
//
// return copy;
//}
//
//private bool DrawApplyClipboardButton()
//{
// ImGui.PushFont(UiBuilder.IconFont);
// var applyButton = ImGui.Button(FontAwesomeIcon.Paste.ToIconString()) && _player != null;
// ImGui.PopFont();
// ImGuiUtil.HoverTooltip(
// "Apply customization code from clipboard.\nHold Shift to apply only customizations.\nHold Control to apply only equipment.");
//
// if (!applyButton)
// return false;
//
// try
// {
// var text = ImGui.GetClipboardText();
// if (!text.Any())
// return false;
//
// var save = CharacterSave.FromString(text);
// ConditionalApply(save, _player!);
// }
// catch (Exception e)
// {
// PluginLog.Information($"{e}");
// return false;
// }
//
// return true;
//}
//
//private void DrawSaveDesignButton()
//{
// ImGui.PushFont(UiBuilder.IconFont);
// if (ImGui.Button(FontAwesomeIcon.Save.ToIconString()))
// OpenDesignNamePopup(DesignNameUse.SaveCurrent);
//
// ImGui.PopFont();
// ImGuiUtil.HoverTooltip("Save the current design.\nHold Shift to save only customizations.\nHold Control to save only equipment.");
//
// DrawDesignNamePopup(DesignNameUse.SaveCurrent);
//}
//
//private void DrawTargetPlayerButton()
//{
// if (ImGui.Button("Target Player"))
// Dalamud.Targets.SetTarget(_player);
//}
//
//private void DrawApplyToPlayerButton(CharacterSave save)
//{
// if (!ImGui.Button("Apply to Self"))
// return;
//
// var player = _inGPose
// ? (Character?)Dalamud.Objects[GPoseObjectId]
// : Dalamud.ClientState.LocalPlayer;
// var fallback = _inGPose ? Dalamud.ClientState.LocalPlayer : null;
// if (player == null)
// return;
//
// ConditionalApply(save, player);
// if (_inGPose)
// ConditionalApply(save, fallback!);
// Glamourer.Penumbra.UpdateCharacters(player, fallback);
//}
//
//
//private static Character? TransformToCustomizable(Character? actor)
//{
// if (actor == null)
// return null;
//
// if (actor.ModelType() == 0)
// return actor;
//
// actor.SetModelType(0);
// CharacterCustomization.Default.Write(actor.Address);
// return actor;
//}
//
//private void DrawApplyToTargetButton(CharacterSave save)
//{
// if (!ImGui.Button("Apply to Target"))
// return;
//
// var player = TransformToCustomizable(CharacterFactory.Convert(Dalamud.Targets.Target));
// if (player == null)
// return;
//
// var fallBackCharacter = _gPoseActors.TryGetValue(player.Name.ToString(), out var f) ? f : null;
// ConditionalApply(save, player);
// if (fallBackCharacter != null)
// ConditionalApply(save, fallBackCharacter!);
// Glamourer.Penumbra.UpdateCharacters(player, fallBackCharacter);
//}
//
//private void DrawRevertButton()
//{
// if (!ImGuiUtil.DrawDisabledButton("Revert", Vector2.Zero, string.Empty, _player == null))
// return;
//
// Glamourer.RevertableDesigns.Revert(_player!);
// var fallBackCharacter = _gPoseActors.TryGetValue(_player!.Name.ToString(), out var f) ? f : null;
// if (fallBackCharacter != null)
// Glamourer.RevertableDesigns.Revert(fallBackCharacter);
// Glamourer.Penumbra.UpdateCharacters(_player, fallBackCharacter);
//}
//
//private void SaveNewDesign(CharacterSave save)
//{
// try
// {
// var (folder, name) = _designs.FileSystem.CreateAllFolders(_newDesignName);
// if (!name.Any())
// return;
//
// var newDesign = new Design(folder, name) { Data = save };
// folder.AddChild(newDesign);
// _designs.Designs[newDesign.FullName()] = save;
// _designs.SaveToFile();
// }
// catch (Exception e)
// {
// PluginLog.Error($"Could not save new design {_newDesignName}:\n{e}");
// }
//}
//
//private void DrawMonsterPanel()
//{
// if (DrawApplyClipboardButton())
// Glamourer.Penumbra.UpdateCharacters(_player!);
//
// ImGui.SameLine();
// if (ImGui.Button("Convert to Character"))
// {
// TransformToCustomizable(_player);
// _currentLabel = _currentLabel.Replace("(Monster)", "(NPC)");
// Glamourer.Penumbra.UpdateCharacters(_player!);
// }
//
// if (!_inGPose)
// {
// ImGui.SameLine();
// DrawTargetPlayerButton();
// }
//
// var currentModel = _player!.ModelType();
// using var combo = ImRaii.Combo("Model Id", currentModel.ToString());
// if (!combo)
// return;
//
// foreach (var (id, _) in _models.Skip(1))
// {
// if (!ImGui.Selectable($"{id:D6}##models", id == currentModel) || id == currentModel)
// continue;
//
// _player!.SetModelType((int)id);
// Glamourer.Penumbra.UpdateCharacters(_player!);
// }
//}
//
//private void DrawPlayerPanel()
//{
// DrawCopyClipboardButton(_currentSave);
// ImGui.SameLine();
// var changes = !_currentSave.WriteProtected && DrawApplyClipboardButton();
// ImGui.SameLine();
// DrawSaveDesignButton();
// ImGui.SameLine();
// DrawApplyToPlayerButton(_currentSave);
// if (!_inGPose)
// {
// ImGui.SameLine();
// DrawApplyToTargetButton(_currentSave);
// if (_player != null && !_currentSave.WriteProtected)
// {
// ImGui.SameLine();
// DrawTargetPlayerButton();
// }
// }
//
// var data = _currentSave;
// if (!_currentSave.WriteProtected)
// {
// ImGui.SameLine();
// DrawRevertButton();
// }
// else
// {
// ImGui.PushStyleVar(ImGuiStyleVar.Alpha, 0.8f);
// data = data.Copy();
// }
//
// if (DrawCustomization(ref data.Customizations) && _player != null)
// {
// Glamourer.RevertableDesigns.Add(_player);
// _currentSave.Customizations.Write(_player.Address);
// changes = true;
// }
//
// changes |= DrawEquip(data.Equipment);
// changes |= DrawMiscellaneous(data, _player);
//
// if (_player != null && changes)
// Glamourer.Penumbra.UpdateCharacters(_player);
// if (_currentSave.WriteProtected)
// ImGui.PopStyleVar();
//}
//
//private void DrawActorPanel()
//{
// using var group = ImRaii.Group();
// DrawPlayerHeader();
// using var child = ImRaii.Child("##playerData", -Vector2.One, true);
// if (!child)
// return;
//
// if (_player == null || _player.ModelType() == 0)
// DrawPlayerPanel();
// else
// DrawMonsterPanel();
//}
}

View file

@ -1,196 +0,0 @@
using Dalamud.Interface;
using Glamourer.Structs;
using ImGuiNET;
using Lumina.Text;
using OtterGui;
using Penumbra.GameData.Enums;
using Penumbra.GameData.Structs;
namespace Glamourer.Gui;
//internal partial class Interface
//{
// private bool DrawStainSelector(ComboWithFilter<Stain> stainCombo, EquipSlot slot, StainId stainIdx)
// {
// stainCombo.PostPreview = null;
// if (_stains.TryGetValue((byte)stainIdx, out var stain))
// {
// var previewPush = PushColor(stain, ImGuiCol.FrameBg);
// stainCombo.PostPreview = () => ImGui.PopStyleColor(previewPush);
// }
//
// var change = stainCombo.Draw(string.Empty, out var newStain) && !newStain.RowIndex.Equals(stainIdx);
// if (!change && (byte)stainIdx != 0)
// {
// ImGuiUtil.HoverTooltip("Right-click to clear.");
// if (ImGui.IsItemClicked(ImGuiMouseButton.Right))
// {
// change = true;
// newStain = Stain.None;
// }
// }
//
// if (!change)
// return false;
//
// if (_player == null)
// return _inDesignMode && (_selection?.Data.WriteStain(slot, newStain.RowIndex) ?? false);
//
// Glamourer.RevertableDesigns.Add(_player);
// newStain.Write(_player.Address, slot);
// return true;
// }
//
// private bool DrawItemSelector(ComboWithFilter<Item> equipCombo, Lumina.Excel.GeneratedSheets.Item item, EquipSlot slot = EquipSlot.Unknown)
// {
// var currentName = item.Name.ToString();
// var change = equipCombo.Draw(currentName, out var newItem, _itemComboWidth) && newItem.Base.RowId != item.RowId;
// if (!change && !ReferenceEquals(item, SmallClothes))
// {
// ImGuiUtil.HoverTooltip("Right-click to clear.");
// if (ImGui.IsItemClicked(ImGuiMouseButton.Right))
// {
// change = true;
// newItem = Item.Nothing(slot);
// }
// }
//
// if (!change)
// return false;
//
// newItem = new Item(newItem.Base, newItem.Name, slot);
// if (_player == null)
// return _inDesignMode && (_selection?.Data.WriteItem(newItem) ?? false);
//
// Glamourer.RevertableDesigns.Add(_player);
// newItem.Write(_player.Address);
// return true;
// }
//
// private static bool DrawCheckbox(CharacterEquipMask flag, ref CharacterEquipMask mask)
// {
// var tmp = (uint)mask;
// var ret = false;
// if (ImGui.CheckboxFlags($"##flag_{(uint)flag}", ref tmp, (uint)flag) && tmp != (uint)mask)
// {
// mask = (CharacterEquipMask)tmp;
// ret = true;
// }
//
// if (ImGui.IsItemHovered())
// ImGui.SetTooltip("Enable writing this slot in this save.");
// return ret;
// }
//
// private static readonly Lumina.Excel.GeneratedSheets.Item SmallClothes = new()
// {
// Name = new SeString("Nothing"),
// RowId = 0,
// };
//
// private static readonly Lumina.Excel.GeneratedSheets.Item SmallClothesNpc = new()
// {
// Name = new SeString("Smallclothes (NPC)"),
// RowId = 1,
// };
//
// private static readonly Lumina.Excel.GeneratedSheets.Item Unknown = new()
// {
// Name = new SeString("Unknown"),
// RowId = 2,
// };
//
// private Lumina.Excel.GeneratedSheets.Item Identify(SetId set, WeaponType weapon, ushort variant, EquipSlot slot)
// {
// return (uint)set switch
// {
// 0 => SmallClothes,
// 9903 => SmallClothesNpc,
// _ => _identifier.Identify(set, weapon, variant, slot.ToSlot()).FirstOrDefault() ?? Unknown,
// };
// }
//
// private bool DrawEquipSlot(EquipSlot slot, CharacterArmor equip)
// {
// var (equipCombo, stainCombo) = _combos[slot];
//
// var ret = DrawStainSelector(stainCombo, slot, equip.Stain);
// ImGui.SameLine();
// var item = Identify(equip.Set, new WeaponType(), equip.Variant, slot);
// ret |= DrawItemSelector(equipCombo, item, slot);
//
// return ret;
// }
//
// private bool DrawEquipSlotWithCheck(EquipSlot slot, CharacterArmor equip, CharacterEquipMask flag, ref CharacterEquipMask mask)
// {
// var ret = DrawCheckbox(flag, ref mask);
// ImGui.SameLine();
// ret |= DrawEquipSlot(slot, equip);
// return ret;
// }
//
// private bool DrawWeapon(EquipSlot slot, CharacterWeapon weapon)
// {
// var (equipCombo, stainCombo) = _combos[slot];
//
// var ret = DrawStainSelector(stainCombo, slot, weapon.Stain);
// ImGui.SameLine();
// var item = Identify(weapon.Set, weapon.Type, weapon.Variant, slot);
// ret |= DrawItemSelector(equipCombo, item, slot);
//
// return ret;
// }
//
// private bool DrawWeaponWithCheck(EquipSlot slot, CharacterWeapon weapon, CharacterEquipMask flag, ref CharacterEquipMask mask)
// {
// var ret = DrawCheckbox(flag, ref mask);
// ImGui.SameLine();
// ret |= DrawWeapon(slot, weapon);
// return ret;
// }
//
// private bool DrawEquip(CharacterEquipment equip)
// {
// var ret = false;
// if (ImGui.CollapsingHeader("Character Equipment"))
// {
// ret |= DrawWeapon(EquipSlot.MainHand, equip.MainHand);
// ret |= DrawWeapon(EquipSlot.OffHand, equip.OffHand);
// ret |= DrawEquipSlot(EquipSlot.Head, equip.Head);
// ret |= DrawEquipSlot(EquipSlot.Body, equip.Body);
// ret |= DrawEquipSlot(EquipSlot.Hands, equip.Hands);
// ret |= DrawEquipSlot(EquipSlot.Legs, equip.Legs);
// ret |= DrawEquipSlot(EquipSlot.Feet, equip.Feet);
// ret |= DrawEquipSlot(EquipSlot.Ears, equip.Ears);
// ret |= DrawEquipSlot(EquipSlot.Neck, equip.Neck);
// ret |= DrawEquipSlot(EquipSlot.Wrists, equip.Wrists);
// ret |= DrawEquipSlot(EquipSlot.RFinger, equip.RFinger);
// ret |= DrawEquipSlot(EquipSlot.LFinger, equip.LFinger);
// }
//
// return ret;
// }
//
// private bool DrawEquip(CharacterEquipment equip, ref CharacterEquipMask mask)
// {
// var ret = false;
// if (ImGui.CollapsingHeader("Character Equipment"))
// {
// ret |= DrawWeaponWithCheck(EquipSlot.MainHand, equip.MainHand, CharacterEquipMask.MainHand, ref mask);
// ret |= DrawWeaponWithCheck(EquipSlot.OffHand, equip.OffHand, CharacterEquipMask.OffHand, ref mask);
// ret |= DrawEquipSlotWithCheck(EquipSlot.Head, equip.Head, CharacterEquipMask.Head, ref mask);
// ret |= DrawEquipSlotWithCheck(EquipSlot.Body, equip.Body, CharacterEquipMask.Body, ref mask);
// ret |= DrawEquipSlotWithCheck(EquipSlot.Hands, equip.Hands, CharacterEquipMask.Hands, ref mask);
// ret |= DrawEquipSlotWithCheck(EquipSlot.Legs, equip.Legs, CharacterEquipMask.Legs, ref mask);
// ret |= DrawEquipSlotWithCheck(EquipSlot.Feet, equip.Feet, CharacterEquipMask.Feet, ref mask);
// ret |= DrawEquipSlotWithCheck(EquipSlot.Ears, equip.Ears, CharacterEquipMask.Ears, ref mask);
// ret |= DrawEquipSlotWithCheck(EquipSlot.Neck, equip.Neck, CharacterEquipMask.Neck, ref mask);
// ret |= DrawEquipSlotWithCheck(EquipSlot.Wrists, equip.Wrists, CharacterEquipMask.Wrists, ref mask);
// ret |= DrawEquipSlotWithCheck(EquipSlot.RFinger, equip.RFinger, CharacterEquipMask.RFinger, ref mask);
// ret |= DrawEquipSlotWithCheck(EquipSlot.LFinger, equip.LFinger, CharacterEquipMask.LFinger, ref mask);
// }
//
// return ret;
// }
//}

View file

@ -1,168 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using Dalamud.Interface;
using Glamourer.Designs;
using Glamourer.Structs;
using ImGuiNET;
using OtterGui.Raii;
namespace Glamourer.Gui;
//internal partial class Interface
//{
// private const string FixDragDropLabel = "##FixDragDrop";
//
// private List<string>? _fullPathCache;
// private string _newFixCharacterName = string.Empty;
// private string _newFixDesignPath = string.Empty;
// private JobGroup? _newFixDesignGroup;
// private Design? _newFixDesign;
// private int _fixDragDropIdx = -1;
//
// private static unsafe bool IsDropping()
// => ImGui.AcceptDragDropPayload(FixDragDropLabel).NativePtr != null;
//
// private void DrawFixedDesignsTab()
// {
// _newFixDesignGroup ??= Glamourer.FixedDesignManager.FixedDesigns.JobGroups[1];
//
// using var tabItem = ImRaii.TabItem("Fixed Designs");
// if (!tabItem)
// {
// _fullPathCache = null;
// _newFixDesign = null;
// _newFixDesignPath = string.Empty;
// _newFixDesignGroup = Glamourer.FixedDesignManager.FixedDesigns.JobGroups[1];
// return;
// }
//
// _fullPathCache ??= Glamourer.FixedDesignManager.FixedDesigns.Data.Select(d => d.Design.FullName()).ToList();
//
// using var table = ImRaii.Table("##FixedTable", 4);
// var buttonWidth = 23.5f * ImGuiHelpers.GlobalScale;
//
// ImGui.TableSetupColumn("##DeleteColumn", ImGuiTableColumnFlags.WidthFixed, 2 * buttonWidth);
// ImGui.TableSetupColumn("Character", ImGuiTableColumnFlags.WidthFixed, 200 * ImGuiHelpers.GlobalScale);
// ImGui.TableSetupColumn("Jobs", ImGuiTableColumnFlags.WidthFixed, 175 * ImGuiHelpers.GlobalScale);
// ImGui.TableSetupColumn("Design", ImGuiTableColumnFlags.WidthStretch);
// ImGui.TableHeadersRow();
// var xPos = 0f;
//
// using var style = new ImRaii.Style();
// using var font = new ImRaii.Font();
// for (var i = 0; i < _fullPathCache.Count; ++i)
// {
// var path = _fullPathCache[i];
// var name = Glamourer.FixedDesignManager.FixedDesigns.Data[i];
//
// ImGui.TableNextRow();
// ImGui.TableNextColumn();
// style.Push(ImGuiStyleVar.ItemSpacing, ImGui.GetStyle().ItemSpacing / 2);
// font.Push(UiBuilder.IconFont);
// if (ImGui.Button($"{FontAwesomeIcon.Trash.ToIconChar()}##{i}"))
// {
// _fullPathCache.RemoveAt(i--);
// Glamourer.FixedDesignManager.FixedDesigns.Remove(name);
// continue;
// }
//
// var tmp = name.Enabled;
// ImGui.SameLine();
// xPos = ImGui.GetCursorPosX();
// if (ImGui.Checkbox($"##Enabled{i}", ref tmp))
// if (tmp && Glamourer.FixedDesignManager.FixedDesigns.EnableDesign(name)
// || !tmp && Glamourer.FixedDesignManager.FixedDesigns.DisableDesign(name))
// {
// Glamourer.Config.FixedDesigns[i].Enabled = tmp;
// Glamourer.Config.Save();
// }
//
// style.Pop();
// font.Pop();
// ImGui.TableNextColumn();
// ImGui.Selectable($"{name.Name}##Fix{i}");
// if (ImGui.BeginDragDropSource())
// {
// _fixDragDropIdx = i;
// ImGui.SetDragDropPayload("##FixDragDrop", IntPtr.Zero, 0);
// ImGui.Text($"Dragging {name.Name} ({path})...");
// ImGui.EndDragDropSource();
// }
//
// if (ImGui.BeginDragDropTarget())
// {
// if (IsDropping() && _fixDragDropIdx >= 0)
// {
// var d = Glamourer.FixedDesignManager.FixedDesigns.Data[_fixDragDropIdx];
// Glamourer.FixedDesignManager.FixedDesigns.Move(d, i);
// var p = _fullPathCache[_fixDragDropIdx];
// _fullPathCache.RemoveAt(_fixDragDropIdx);
// _fullPathCache.Insert(i, p);
// _fixDragDropIdx = -1;
// }
//
// ImGui.EndDragDropTarget();
// }
//
// ImGui.TableNextColumn();
// ImGui.Text(Glamourer.FixedDesignManager.FixedDesigns.Data[i].Jobs.Name);
// ImGui.TableNextColumn();
// ImGui.Text(path);
// }
//
// ImGui.TableNextRow();
// ImGui.TableNextColumn();
// font.Push(UiBuilder.IconFont);
//
// ImGui.SetCursorPosX(xPos);
// if (_newFixDesign == null || _newFixCharacterName == string.Empty)
// {
// style.Push(ImGuiStyleVar.Alpha, 0.5f);
// ImGui.Button($"{FontAwesomeIcon.Plus.ToIconChar()}##NewFix");
// style.Pop();
// }
// else if (ImGui.Button($"{FontAwesomeIcon.Plus.ToIconChar()}##NewFix"))
// {
// _fullPathCache.Add(_newFixDesignPath);
// Glamourer.FixedDesignManager.FixedDesigns.Add(_newFixCharacterName, _newFixDesign, _newFixDesignGroup.Value, false);
// _newFixCharacterName = string.Empty;
// _newFixDesignPath = string.Empty;
// _newFixDesign = null;
// _newFixDesignGroup = Glamourer.FixedDesignManager.FixedDesigns.JobGroups[1];
// }
//
// font.Pop();
// ImGui.TableNextColumn();
// ImGui.SetNextItemWidth(200 * ImGuiHelpers.GlobalScale);
// ImGui.InputTextWithHint("##NewFix", "Enter new Character", ref _newFixCharacterName, 32);
// ImGui.TableNextColumn();
// ImGui.SetNextItemWidth(-1);
// using var combo = ImRaii.Combo("##NewFixDesignGroup", _newFixDesignGroup.Value.Name);
// if (combo)
// foreach (var (id, group) in Glamourer.FixedDesignManager.FixedDesigns.JobGroups)
// {
// ImGui.SetNextItemWidth(-1);
// if (ImGui.Selectable($"{group.Name}##NewFixDesignGroup", group.Name == _newFixDesignGroup.Value.Name))
// _newFixDesignGroup = group;
// }
//
// ImGui.TableNextColumn();
// ImGui.SetNextItemWidth(-1);
// using var combo2 = ImRaii.Combo("##NewFixPath", _newFixDesignPath);
// if (!combo2)
// return;
//
// foreach (var design in _plugin.Designs.FileSystem.Root.AllLeaves(SortMode.Lexicographical).Cast<Design>())
// {
// var fullName = design.FullName();
// ImGui.SetNextItemWidth(-1);
// if (!ImGui.Selectable($"{fullName}##NewFixDesign", fullName == _newFixDesignPath))
// continue;
//
// _newFixDesignPath = fullName;
// _newFixDesign = design;
// }
// }
//}

View file

@ -1,90 +0,0 @@
using System;
using System.Linq;
using Dalamud.Logging;
using Glamourer.Customization;
using Glamourer.Structs;
using ImGuiNET;
using Penumbra.GameData.Enums;
namespace Glamourer.Gui;
//internal partial class Interface
//{
//
//
//
//
// private enum DesignNameUse
// {
// SaveCurrent,
// NewDesign,
// DuplicateDesign,
// NewFolder,
// FromClipboard,
// }
//
// private void DrawDesignNamePopup(DesignNameUse use)
// {
// if (ImGui.BeginPopup($"{DesignNamePopupLabel}{use}"))
// {
// if (ImGui.InputText("##designName", ref _newDesignName, 64, ImGuiInputTextFlags.EnterReturnsTrue)
// && _newDesignName.Any())
// {
// switch (use)
// {
// case DesignNameUse.SaveCurrent:
// SaveNewDesign(ConditionalCopy(_currentSave, _holdShift, _holdCtrl));
// break;
// case DesignNameUse.NewDesign:
// var empty = new CharacterSave();
// empty.Load(CharacterCustomization.Default);
// empty.WriteCustomizations = false;
// SaveNewDesign(empty);
// break;
// case DesignNameUse.DuplicateDesign:
// SaveNewDesign(ConditionalCopy(_selection!.Data, _holdShift, _holdCtrl));
// break;
// case DesignNameUse.NewFolder:
// _designs.FileSystem
// .CreateAllFolders($"{_newDesignName}/a"); // Filename is just ignored, but all folders are created.
// break;
// case DesignNameUse.FromClipboard:
// try
// {
// var text = ImGui.GetClipboardText();
// var save = CharacterSave.FromString(text);
// SaveNewDesign(save);
// }
// catch (Exception e)
// {
// PluginLog.Information($"Could not save new Design from Clipboard:\n{e}");
// }
//
// break;
// }
//
// _newDesignName = string.Empty;
// ImGui.CloseCurrentPopup();
// }
//
// if (_keyboardFocus)
// {
// ImGui.SetKeyboardFocusHere();
// _keyboardFocus = false;
// }
//
// ImGui.EndPopup();
// }
// }
//
// private void OpenDesignNamePopup(DesignNameUse use)
// {
// _newDesignName = string.Empty;
// _keyboardFocus = true;
// _holdCtrl = ImGui.GetIO().KeyCtrl;
// _holdShift = ImGui.GetIO().KeyShift;
// ImGui.OpenPopup($"{DesignNamePopupLabel}{use}");
// }
//}

View file

@ -1,82 +0,0 @@
using System.Collections.Generic;
using System.Numerics;
using System.Reflection;
using ImGuiNET;
using Penumbra.GameData.Enums;
using Lumina.Excel.GeneratedSheets;
namespace Glamourer.Gui;
//internal partial class Interface
//{
// private const float ColorButtonWidth = 22.5f;
// private const float ColorComboWidth = 140f;
// private const float ItemComboWidth = 350f;
//
// private static readonly Vector4 GreyVector = new(0.5f, 0.5f, 0.5f, 1);
//
// private static ComboWithFilter<Stain> CreateDefaultStainCombo(IReadOnlyList<Stain> stains)
// => new("##StainCombo", ColorComboWidth, ColorButtonWidth, stains,
// s => s.Name.ToString())
// {
// Flags = ImGuiComboFlags.NoArrowButton | ImGuiComboFlags.HeightLarge,
// PreList = () =>
// {
// ImGui.PushStyleVar(ImGuiStyleVar.ItemSpacing, Vector2.Zero);
// ImGui.PushStyleVar(ImGuiStyleVar.WindowPadding, Vector2.Zero);
// ImGui.PushStyleVar(ImGuiStyleVar.FrameRounding, 0);
// },
// PostList = () => { ImGui.PopStyleVar(3); },
// CreateSelectable = s =>
// {
// var push = PushColor(s);
// var ret = ImGui.Button($"{s.Name}##Stain{(byte)s.RowIndex}",
// Vector2.UnitX * (ColorComboWidth - ImGui.GetStyle().ScrollbarSize));
// ImGui.PopStyleColor(push);
// return ret;
// },
// ItemsAtOnce = 12,
// };
//
// private ComboWithFilter<Item> CreateItemCombo(EquipSlot slot, IReadOnlyList<Item> items)
// => new($"{_equipSlotNames[slot]}##Equip", ItemComboWidth, ItemComboWidth, items, i => i.Name)
// {
// Flags = ImGuiComboFlags.HeightLarge,
// CreateSelectable = i =>
// {
// var ret = ImGui.Selectable(i.Name);
// var setId = $"({(int)i.MainModel.id})";
// var size = ImGui.CalcTextSize(setId).X;
// ImGui.SameLine(ImGui.GetWindowContentRegionWidth() - size - ImGui.GetStyle().ItemInnerSpacing.X);
// ImGui.TextColored(GreyVector, setId);
// return ret;
// },
// };
//
// private (ComboWithFilter<Item>, ComboWithFilter<Stain>) CreateCombos(EquipSlot slot, IReadOnlyList<Item> items,
// ComboWithFilter<Stain> defaultStain)
// => (CreateItemCombo(slot, items), new ComboWithFilter<Stain>($"##{slot}Stain", defaultStain));
//
//
// private static Dictionary<EquipSlot, string> GetEquipSlotNames()
// {
// var sheet = Dalamud.GameData.GetExcelSheet<Addon>()!;
// var ret = new Dictionary<EquipSlot, string>(12)
// {
// [EquipSlot.MainHand] = sheet.GetRow(738)?.Text.ToString() ?? "Main Hand",
// [EquipSlot.OffHand] = sheet.GetRow(739)?.Text.ToString() ?? "Off Hand",
// [EquipSlot.Head] = sheet.GetRow(740)?.Text.ToString() ?? "Head",
// [EquipSlot.Body] = sheet.GetRow(741)?.Text.ToString() ?? "Body",
// [EquipSlot.Hands] = sheet.GetRow(742)?.Text.ToString() ?? "Hands",
// [EquipSlot.Legs] = sheet.GetRow(744)?.Text.ToString() ?? "Legs",
// [EquipSlot.Feet] = sheet.GetRow(745)?.Text.ToString() ?? "Feet",
// [EquipSlot.Ears] = sheet.GetRow(746)?.Text.ToString() ?? "Ears",
// [EquipSlot.Neck] = sheet.GetRow(747)?.Text.ToString() ?? "Neck",
// [EquipSlot.Wrists] = sheet.GetRow(748)?.Text.ToString() ?? "Wrists",
// [EquipSlot.RFinger] = sheet.GetRow(749)?.Text.ToString() ?? "Right Ring",
// [EquipSlot.LFinger] = sheet.GetRow(750)?.Text.ToString() ?? "Left Ring",
// };
// return ret;
// }
//}

View file

@ -1,52 +0,0 @@
using System;
using Dalamud.Game.ClientState.Objects.Types;
using ImGuiNET;
namespace Glamourer.Gui;
//internal partial class Interface
//{
//
// private static bool DrawMiscellaneous(CharacterSave save, Character? player)
// {
// var ret = false;
// if (!ImGui.CollapsingHeader("Miscellaneous"))
// return ret;
//
// ret |= DrawCheckMark("Hat Visible", save.HatState, v =>
// {
// save.HatState = v;
// player?.SetHatVisible(v);
// });
//
// ret |= DrawCheckMark("Weapon Visible", save.WeaponState, v =>
// {
// save.WeaponState = v;
// player?.SetWeaponHidden(!v);
// });
//
// ret |= DrawCheckMark("Visor Toggled", save.VisorState, v =>
// {
// save.VisorState = v;
// player?.SetVisorToggled(v);
// });
//
// ret |= DrawCheckMark("Is Wet", save.IsWet, v =>
// {
// save.IsWet = v;
// player?.SetWetness(v);
// });
//
// var alpha = save.Alpha;
// if (ImGui.DragFloat("Alpha", ref alpha, 0.01f, 0f, 1f, "%.2f") && alpha != save.Alpha)
// {
// alpha = (float)Math.Round(alpha > 1 ? 1 : alpha < 0 ? 0 : alpha, 2);
// save.Alpha = alpha;
// ret = true;
// if (player != null)
// player.Alpha() = alpha;
// }
//
// return ret;
// }
//}

View file

@ -1,87 +0,0 @@
using System.Diagnostics;
using System.Linq;
using System.Numerics;
using ImGuiNET;
using OtterGui.Raii;
namespace Glamourer.Gui;
//internal partial class Interface
//{
// private string? _currentRevertableName;
// private CharacterSave? _currentRevertable;
//
// private void DrawRevertablesSelector()
// {
// ImGui.BeginGroup();
// DrawPlayerFilter();
// if (!ImGui.BeginChild("##playerSelector",
// new Vector2(SelectorWidth * ImGui.GetIO().FontGlobalScale, -ImGui.GetFrameHeight() - 1), true))
// {
// ImGui.EndChild();
// ImGui.EndGroup();
// return;
// }
//
// foreach (var (name, save) in Glamourer.RevertableDesigns.Saves)
// {
// if (name.ToLowerInvariant().Contains(_playerFilterLower) && ImGui.Selectable(name, name == _currentRevertableName))
// {
// _currentRevertableName = name;
// _currentRevertable = save;
// }
// }
//
// using (var _ = ImRaii.PushStyle(ImGuiStyleVar.ItemSpacing, Vector2.Zero))
// {
// ImGui.EndChild();
// }
//
// DrawSelectionButtons();
// ImGui.EndGroup();
// }
//
// private void DrawRevertablePanel()
// {
// using var group = ImRaii.Group();
// {
// var buttonColor = ImGui.GetColorU32(ImGuiCol.FrameBg);
// using var color = ImRaii.PushColor(ImGuiCol.Text, GreenHeaderColor)
// .Push(ImGuiCol.Button, buttonColor)
// .Push(ImGuiCol.ButtonHovered, buttonColor)
// .Push(ImGuiCol.ButtonActive, buttonColor);
// using var style = ImRaii.PushStyle(ImGuiStyleVar.ItemSpacing, Vector2.Zero)
// .Push(ImGuiStyleVar.FrameRounding, 0);
// ImGui.Button($"{_currentRevertableName}##playerHeader", -Vector2.UnitX * 0.0001f);
// }
//
// if (!ImGui.BeginChild("##revertableData", -Vector2.One, true))
// {
// ImGui.EndChild();
// return;
// }
//
// var save = _currentRevertable!.Copy();
// DrawCustomization(ref save.Customizations);
// DrawEquip(save.Equipment);
// DrawMiscellaneous(save, null);
//
// ImGui.EndChild();
// }
//
// [Conditional("DEBUG")]
// private void DrawRevertablesTab()
// {
// using var tabItem = ImRaii.TabItem("Revertables");
// if (!tabItem)
// return;
//
// DrawRevertablesSelector();
//
// if (_currentRevertableName == null)
// return;
//
// ImGui.SameLine();
// DrawRevertablePanel();
// }
//}

View file

@ -0,0 +1,39 @@
using System;
using System.Numerics;
using Dalamud.Interface.Windowing;
using Dalamud.Plugin;
using Glamourer.Gui.Tabs;
using ImGuiNET;
using OtterGui.Widgets;
namespace Glamourer.Gui;
public class MainWindow : Window
{
private readonly ITab[] _tabs;
public MainWindow(DalamudPluginInterface pi, DebugTab debugTab)
: base(GetLabel())
{
pi.UiBuilder.DisableGposeUiHide = true;
SizeConstraints = new WindowSizeConstraints()
{
MinimumSize = new Vector2(675, 675),
MaximumSize = ImGui.GetIO().DisplaySize,
};
_tabs = new ITab[]
{
debugTab,
};
}
public override void Draw()
{
TabBar.Draw("##tabs", ImGuiTabBarFlags.None, ReadOnlySpan<byte>.Empty, out var currentTab, () => { }, _tabs);
}
private static string GetLabel()
=> Item.Version.Length == 0
? "Glamourer###GlamourerMainWindow"
: $"Glamourer v{Item.Version}###GlamourerMainWindow";
}

View file

@ -0,0 +1,491 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Runtime.CompilerServices;
using Dalamud.Game.ClientState.Objects;
using Dalamud.Interface;
using Dalamud.Utility;
using FFXIVClientStructs.FFXIV.Client.Graphics.Scene;
using Glamourer.Customization;
using Glamourer.Interop;
using Glamourer.Interop.Penumbra;
using Glamourer.Interop.Structs;
using Glamourer.Services;
using ImGuiNET;
using OtterGui;
using OtterGui.Raii;
using OtterGui.Widgets;
using Penumbra.Api.Enums;
using Penumbra.GameData.Enums;
using Penumbra.GameData.Structs;
namespace Glamourer.Gui.Tabs;
public unsafe class DebugTab : ITab
{
private readonly VisorService _visorService;
private readonly ChangeCustomizeService _changeCustomizeService;
private readonly UpdateSlotService _updateSlotService;
private readonly WeaponService _weaponService;
private readonly PenumbraService _penumbra;
private readonly ObjectTable _objects;
private readonly IdentifierService _identifier;
private readonly ActorService _actors;
private readonly ItemService _items;
private readonly CustomizationService _customization;
private int _gameObjectIndex;
public DebugTab(ChangeCustomizeService changeCustomizeService, VisorService visorService, ObjectTable objects,
UpdateSlotService updateSlotService, WeaponService weaponService, PenumbraService penumbra, IdentifierService identifier,
ActorService actors, ItemService items, CustomizationService customization)
{
_changeCustomizeService = changeCustomizeService;
_visorService = visorService;
_objects = objects;
_updateSlotService = updateSlotService;
_weaponService = weaponService;
_penumbra = penumbra;
_identifier = identifier;
_actors = actors;
_items = items;
_customization = customization;
}
public ReadOnlySpan<byte> Label
=> "Debug"u8;
public void DrawContent()
{
DrawInteropHeader();
DrawGameDataHeader();
DrawPenumbraHeader();
}
#region Interop
private void DrawInteropHeader()
{
if (!ImGui.CollapsingHeader("Interop"))
return;
ImGui.InputInt("Game Object Index", ref _gameObjectIndex, 0, 0);
var actor = (Actor)_objects.GetObjectAddress(_gameObjectIndex);
var model = actor.Model;
using var table = ImRaii.Table("##interopTable", 4, ImGuiTableFlags.SizingFixedFit | ImGuiTableFlags.RowBg);
ImGui.TableNextColumn();
ImGui.TableNextColumn();
ImGui.TableHeader("Actor");
ImGui.TableNextColumn();
ImGui.TableHeader("Model");
ImGui.TableNextColumn();
ImGuiUtil.DrawTableColumn("Address");
ImGui.TableNextColumn();
if (ImGui.Selectable($"0x{model.Address:X}"))
ImGui.SetClipboardText($"0x{model.Address:X}");
ImGui.TableNextColumn();
if (ImGui.Selectable($"0x{model.Address:X}"))
ImGui.SetClipboardText($"0x{model.Address:X}");
ImGui.TableNextColumn();
ImGuiUtil.DrawTableColumn("Mainhand");
ImGuiUtil.DrawTableColumn(actor.IsCharacter ? actor.GetMainhand().ToString() : "No Character");
ImGui.TableNextColumn();
var weapon = model.AsDrawObject->Object.ChildObject;
if (ImGui.Selectable($"0x{(ulong)weapon:X}"))
ImGui.SetClipboardText($"0x{(ulong)weapon:X}");
ImGuiUtil.DrawTableColumn("Offhand");
ImGuiUtil.DrawTableColumn(actor.IsCharacter ? actor.GetOffhand().ToString() : "No Character");
if (weapon != null && ImGui.Selectable($"0x{(ulong)weapon->NextSiblingObject:X}"))
ImGui.SetClipboardText($"0x{(ulong)weapon->NextSiblingObject:X}");
DrawVisor(actor, model);
DrawHatState(actor, model);
DrawWeaponState(actor, model);
DrawWetness(actor, model);
DrawEquip(actor, model);
DrawCustomize(actor, model);
}
private void DrawVisor(Actor actor, Model model)
{
using var id = ImRaii.PushId("Visor");
ImGuiUtil.DrawTableColumn("Visor State");
ImGuiUtil.DrawTableColumn(actor.IsCharacter ? actor.AsCharacter->DrawData.IsVisorToggled.ToString() : "No Character");
ImGuiUtil.DrawTableColumn(model.IsHuman ? _visorService.GetVisorState(model).ToString() : "No Human");
ImGui.TableNextColumn();
if (!model.IsHuman)
return;
if (ImGui.SmallButton("Set True"))
_visorService.SetVisorState(model, true);
ImGui.SameLine();
if (ImGui.SmallButton("Set False"))
_visorService.SetVisorState(model, false);
ImGui.SameLine();
if (ImGui.SmallButton("Toggle"))
_visorService.SetVisorState(model, !_visorService.GetVisorState(model));
}
private void DrawHatState(Actor actor, Model model)
{
using var id = ImRaii.PushId("HatState");
ImGuiUtil.DrawTableColumn("Hat State");
ImGuiUtil.DrawTableColumn(actor.IsCharacter
? actor.AsCharacter->DrawData.IsHatHidden ? "Hidden" : actor.GetArmor(EquipSlot.Head).ToString()
: "No Character");
ImGuiUtil.DrawTableColumn(model.IsHuman
? model.AsHuman->Head.Value == 0 ? "No Hat" : model.GetArmor(EquipSlot.Head).ToString()
: "No Human");
ImGui.TableNextColumn();
if (!model.IsHuman)
return;
if (ImGui.SmallButton("Hide"))
_updateSlotService.UpdateSlot(model, EquipSlot.Head, CharacterArmor.Empty);
ImGui.SameLine();
if (ImGui.SmallButton("Show"))
_updateSlotService.UpdateSlot(model, EquipSlot.Head, actor.GetArmor(EquipSlot.Head));
ImGui.SameLine();
if (ImGui.SmallButton("Toggle"))
_updateSlotService.UpdateSlot(model, EquipSlot.Head,
model.AsHuman->Head.Value == 0 ? actor.GetArmor(EquipSlot.Head) : CharacterArmor.Empty);
}
private void DrawWeaponState(Actor actor, Model model)
{
using var id = ImRaii.PushId("WeaponState");
ImGuiUtil.DrawTableColumn("Weapon State");
ImGuiUtil.DrawTableColumn(actor.IsCharacter
? actor.AsCharacter->DrawData.IsWeaponHidden ? "Hidden" : "Visible"
: "No Character");
var text = string.Empty;
// TODO
if (!model.IsHuman)
{
text = "No Model";
}
else if (model.AsDrawObject->Object.ChildObject == null)
{
text = "No Weapon";
}
else
{
var weapon = (DrawObject*)model.AsDrawObject->Object.ChildObject;
if ((weapon->Flags & 0x09) == 0x09)
text = "Visible";
else
text = "Hidden";
}
ImGuiUtil.DrawTableColumn(text);
ImGui.TableNextColumn();
if (!model.IsHuman)
return;
}
private void DrawWetness(Actor actor, Model model)
{
using var id = ImRaii.PushId("Wetness");
ImGuiUtil.DrawTableColumn("Wetness");
ImGuiUtil.DrawTableColumn(actor.IsCharacter ? actor.AsCharacter->IsGPoseWet ? "GPose" : "None" : "No Character");
var modelString = model.IsCharacterBase
? $"{model.AsCharacterBase->SwimmingWetness:F4} Swimming\n"
+ $"{model.AsCharacterBase->WeatherWetness:F4} Weather\n"
+ $"{model.AsCharacterBase->ForcedWetness:F4} Forced\n"
+ $"{model.AsCharacterBase->WetnessDepth:F4} Depth\n"
: "No CharacterBase";
ImGuiUtil.DrawTableColumn(modelString);
ImGui.TableNextColumn();
if (!actor.IsCharacter)
return;
if (ImGui.SmallButton("GPose On"))
actor.AsCharacter->IsGPoseWet = true;
ImGui.SameLine();
if (ImGui.SmallButton("GPose Off"))
actor.AsCharacter->IsGPoseWet = false;
ImGui.SameLine();
if (ImGui.SmallButton("GPose Toggle"))
actor.AsCharacter->IsGPoseWet = !actor.AsCharacter->IsGPoseWet;
}
private void DrawEquip(Actor actor, Model model)
{
using var id = ImRaii.PushId("Equipment");
foreach (var slot in EquipSlotExtensions.EqdpSlots)
{
using var id2 = ImRaii.PushId((int)slot);
ImGuiUtil.DrawTableColumn(slot.ToName());
ImGuiUtil.DrawTableColumn(actor.IsCharacter ? actor.GetArmor(slot).ToString() : "No Character");
ImGuiUtil.DrawTableColumn(model.IsHuman ? model.GetArmor(slot).ToString() : "No Human");
ImGui.TableNextColumn();
if (!model.IsHuman)
continue;
if (ImGui.SmallButton("Change Piece"))
_updateSlotService.UpdateArmor(model, slot,
new CharacterArmor((SetId)(slot == EquipSlot.Hands ? 6064 : slot == EquipSlot.Head ? 6072 : 1), 1, 0));
ImGui.SameLine();
if (ImGui.SmallButton("Change Stain"))
_updateSlotService.UpdateStain(model, slot, 5);
ImGui.SameLine();
if (ImGui.SmallButton("Reset"))
_updateSlotService.UpdateSlot(model, slot, actor.GetArmor(slot));
}
}
private void DrawCustomize(Actor actor, Model model)
{
using var id = ImRaii.PushId("Customize");
var actorCustomize = new Customize(actor.IsCharacter
? *(Penumbra.GameData.Structs.CustomizeData*)&actor.AsCharacter->DrawData.CustomizeData
: new Penumbra.GameData.Structs.CustomizeData());
var modelCustomize = new Customize(model.IsHuman
? *(Penumbra.GameData.Structs.CustomizeData*)model.AsHuman->CustomizeData
: new Penumbra.GameData.Structs.CustomizeData());
foreach (var type in Enum.GetValues<CustomizeIndex>())
{
using var id2 = ImRaii.PushId((int)type);
ImGuiUtil.DrawTableColumn(type.ToDefaultName());
ImGuiUtil.DrawTableColumn(actor.IsCharacter ? actorCustomize[type].Value.ToString("X2") : "No Character");
ImGuiUtil.DrawTableColumn(model.IsHuman ? modelCustomize[type].Value.ToString("X2") : "No Human");
ImGui.TableNextColumn();
if (!model.IsHuman || type.ToFlag().RequiresRedraw())
continue;
if (ImGui.SmallButton("++"))
{
modelCustomize.Set(type, (CustomizeValue)(modelCustomize[type].Value + 1));
_changeCustomizeService.UpdateCustomize(model, modelCustomize.Data);
}
ImGui.SameLine();
if (ImGui.SmallButton("--"))
{
modelCustomize.Set(type, (CustomizeValue)(modelCustomize[type].Value - 1));
_changeCustomizeService.UpdateCustomize(model, modelCustomize.Data);
}
ImGui.SameLine();
if (ImGui.SmallButton("Reset"))
{
modelCustomize.Set(type, actorCustomize[type]);
_changeCustomizeService.UpdateCustomize(model, modelCustomize.Data);
}
}
}
#endregion
#region Penumbra
private Model _drawObject = Model.Null;
private void DrawPenumbraHeader()
{
if (!ImGui.CollapsingHeader("Penumbra"))
return;
using var table = ImRaii.Table("##PenumbraTable", 3, ImGuiTableFlags.SizingFixedFit | ImGuiTableFlags.RowBg);
if (!table)
return;
ImGuiUtil.DrawTableColumn("Available");
ImGuiUtil.DrawTableColumn(_penumbra.Available.ToString());
ImGui.TableNextColumn();
if (ImGui.SmallButton("Unattach"))
_penumbra.Unattach();
ImGui.SameLine();
if (ImGui.SmallButton("Reattach"))
_penumbra.Reattach();
ImGuiUtil.DrawTableColumn("Draw Object");
ImGui.TableNextColumn();
var address = _drawObject.Address;
ImGui.SetNextItemWidth(200 * ImGuiHelpers.GlobalScale);
if (ImGui.InputScalar("##drawObjectPtr", ImGuiDataType.U64, (nint)(&address), IntPtr.Zero, IntPtr.Zero, "%llx",
ImGuiInputTextFlags.CharsHexadecimal))
_drawObject = address;
ImGuiUtil.DrawTableColumn(_penumbra.Available
? $"0x{_penumbra.GameObjectFromDrawObject(_drawObject).Address:X}"
: "Penumbra Unavailable");
ImGuiUtil.DrawTableColumn("Cutscene Object");
ImGui.TableNextColumn();
ImGui.SetNextItemWidth(200 * ImGuiHelpers.GlobalScale);
ImGui.InputInt("##CutsceneIndex", ref _gameObjectIndex, 0, 0);
ImGuiUtil.DrawTableColumn(_penumbra.Available
? _penumbra.CutsceneParent(_gameObjectIndex).ToString()
: "Penumbra Unavailable");
ImGuiUtil.DrawTableColumn("Redraw Object");
ImGui.TableNextColumn();
ImGui.SetNextItemWidth(200 * ImGuiHelpers.GlobalScale);
ImGui.InputInt("##redrawObject", ref _gameObjectIndex, 0, 0);
ImGui.TableNextColumn();
using (var disabled = ImRaii.Disabled(!_penumbra.Available))
{
if (ImGui.SmallButton("Redraw"))
_penumbra.RedrawObject(_objects.GetObjectAddress(_gameObjectIndex), RedrawType.Redraw);
}
}
#endregion
#region GameData
private void DrawGameDataHeader()
{
if (!ImGui.CollapsingHeader("Game Data"))
return;
DrawIdentifierService();
DrawActorService();
DrawItemService();
DrawCustomizationService();
}
private string _gamePath = string.Empty;
private int _setId;
private int _secondaryId;
private int _variant;
private void DrawIdentifierService()
{
using var disabled = ImRaii.Disabled(!_identifier.Valid);
using var tree = ImRaii.TreeNode("Identifier Service");
if (!tree || !_identifier.Valid)
return;
disabled.Dispose();
static void Text(string text)
{
if (text.Length > 0)
ImGui.TextUnformatted(text);
}
ImGui.TextUnformatted("Parse Game Path");
ImGui.SameLine();
ImGui.SetNextItemWidth(300 * ImGuiHelpers.GlobalScale);
ImGui.InputTextWithHint("##gamePath", "Enter game path...", ref _gamePath, 256);
var fileInfo = _identifier.AwaitedService.GamePathParser.GetFileInfo(_gamePath);
ImGui.TextUnformatted(
$"{fileInfo.ObjectType} {fileInfo.EquipSlot} {fileInfo.PrimaryId} {fileInfo.SecondaryId} {fileInfo.Variant} {fileInfo.BodySlot} {fileInfo.CustomizationType}");
Text(string.Join("\n", _identifier.AwaitedService.Identify(_gamePath).Keys));
ImGui.Separator();
ImGui.TextUnformatted("Identify Model");
ImGui.SameLine();
ImGui.SetNextItemWidth(100 * ImGuiHelpers.GlobalScale);
ImGui.InputInt("##SetId", ref _setId, 0, 0);
ImGui.SameLine();
ImGui.SetNextItemWidth(100 * ImGuiHelpers.GlobalScale);
ImGui.InputInt("##TypeId", ref _secondaryId, 0, 0);
ImGui.SameLine();
ImGui.SetNextItemWidth(100 * ImGuiHelpers.GlobalScale);
ImGui.InputInt("##Variant", ref _variant, 0, 0);
foreach (var slot in EquipSlotExtensions.EqdpSlots)
{
var identified = _identifier.AwaitedService.Identify((SetId)_setId, (ushort)_variant, slot);
Text(string.Join("\n", identified.Select(i => i.Name.ToDalamudString().TextValue)));
}
var main = _identifier.AwaitedService.Identify((SetId)_setId, (WeaponType)_secondaryId, (ushort)_variant, EquipSlot.MainHand);
Text(string.Join("\n", main.Select(i => i.Name.ToDalamudString().TextValue)));
var off = _identifier.AwaitedService.Identify((SetId)_setId, (WeaponType)_secondaryId, (ushort)_variant, EquipSlot.OffHand);
Text(string.Join("\n", off.Select(i => i.Name.ToDalamudString().TextValue)));
}
private string _bnpcFilter = string.Empty;
private string _enpcFilter = string.Empty;
private string _companionFilter = string.Empty;
private string _mountFilter = string.Empty;
private string _ornamentFilter = string.Empty;
private string _worldFilter = string.Empty;
private void DrawActorService()
{
using var disabled = ImRaii.Disabled(!_actors.Valid);
using var tree = ImRaii.TreeNode("Actor Service");
if (!tree || !_actors.Valid)
return;
disabled.Dispose();
DrawNameTable("BNPCs", ref _bnpcFilter, _actors.AwaitedService.Data.BNpcs.Select(kvp => (kvp.Key, kvp.Value)));
DrawNameTable("ENPCs", ref _enpcFilter, _actors.AwaitedService.Data.ENpcs.Select(kvp => (kvp.Key, kvp.Value)));
DrawNameTable("Companions", ref _companionFilter, _actors.AwaitedService.Data.Companions.Select(kvp => (kvp.Key, kvp.Value)));
DrawNameTable("Mounts", ref _mountFilter, _actors.AwaitedService.Data.Mounts.Select(kvp => (kvp.Key, kvp.Value)));
DrawNameTable("Ornaments", ref _ornamentFilter, _actors.AwaitedService.Data.Ornaments.Select(kvp => (kvp.Key, kvp.Value)));
DrawNameTable("Worlds", ref _worldFilter, _actors.AwaitedService.Data.Worlds.Select(kvp => ((uint)kvp.Key, kvp.Value)));
}
private static void DrawNameTable(string label, ref string filter, IEnumerable<(uint, string)> names)
{
using var _ = ImRaii.PushId(label);
using var tree = ImRaii.TreeNode(label);
if (!tree)
return;
var resetScroll = ImGui.InputTextWithHint("##filter", "Filter...", ref filter, 256);
var height = ImGui.GetTextLineHeightWithSpacing() + 2 * ImGui.GetStyle().CellPadding.Y;
using var table = ImRaii.Table("##table", 2, ImGuiTableFlags.RowBg | ImGuiTableFlags.ScrollY | ImGuiTableFlags.BordersOuter,
new Vector2(-1, 10 * height));
if (!table)
return;
if (resetScroll)
ImGui.SetScrollY(0);
ImGui.TableSetupColumn("1", ImGuiTableColumnFlags.WidthFixed, 50 * ImGuiHelpers.GlobalScale);
ImGui.TableSetupColumn("2", ImGuiTableColumnFlags.WidthStretch);
ImGui.TableNextColumn();
var skips = ImGuiClip.GetNecessarySkips(height);
ImGui.TableNextColumn();
var f = filter;
var remainder = ImGuiClip.FilteredClippedDraw(names.Select(p => (p.Item1.ToString("D5"), p.Item2)), skips,
p => p.Item1.Contains(f) || p.Item2.Contains(f, StringComparison.OrdinalIgnoreCase),
p =>
{
ImGuiUtil.DrawTableColumn(p.Item1);
ImGuiUtil.DrawTableColumn(p.Item2);
});
ImGuiClip.DrawEndDummy(remainder, height);
}
private void DrawItemService()
{
using var disabled = ImRaii.Disabled(!_items.Valid);
using var tree = ImRaii.TreeNode("Item Manager");
if (!tree || !_items.Valid)
return;
disabled.Dispose();
}
private void DrawCustomizationService()
{
using var id = ImRaii.PushId("Customization");
ImGuiUtil.DrawTableColumn("Customization Service");
ImGui.TableNextColumn();
if (!_customization.Valid)
{
ImGui.TextUnformatted("Unavailable");
ImGui.TableNextColumn();
return;
}
using var tree = ImRaii.TreeNode("Available###Customization", ImGuiTreeNodeFlags.NoTreePushOnOpen);
ImGui.TableNextColumn();
if (!tree)
return;
}
#endregion
}