Skip to content
This repository has been archived by the owner on Jul 1, 2023. It is now read-only.

Commit

Permalink
UI changes and some QoL improvements
Browse files Browse the repository at this point in the history
* Some UI tweaks to use a table and allow for a more responsive UI.
* Adds QoL features for seeing live previews of changes without needing to move.
* Adds a dropper button which will set the current entry line to your current shoe model.
  • Loading branch information
LeonBlade committed Mar 30, 2022
1 parent d31d674 commit 543e29b
Show file tree
Hide file tree
Showing 8 changed files with 419 additions and 287 deletions.
23 changes: 13 additions & 10 deletions HeelsPlugin/Gui/ComboWithFilter.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
using ImGuiNET;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;

namespace HeelsPlugin
{
//
// Source: https://github.com/Ottermandias/Glamourer/blob/main/Glamourer/Gui/ComboWithFilter.cs
//
using ImGuiNET;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;

namespace HeelsPlugin
{
public class ComboWithFilter<T>
{
private readonly string _label;
Expand Down Expand Up @@ -205,5 +208,5 @@ public bool Draw(string currentName, out T? value, float? size = null)

return ret;
}
}
}
}
}
206 changes: 121 additions & 85 deletions HeelsPlugin/Gui/ConfigLine.cs
Original file line number Diff line number Diff line change
@@ -1,97 +1,133 @@
using Dalamud.Interface;
using Dalamud.Interface;
using Dalamud.Interface.Components;
using ImGuiNET;
using Lumina.Excel.GeneratedSheets;

namespace HeelsPlugin.Gui
{
public class ConfigLine
{
private readonly int key = 0;
private readonly ComboWithFilter<Item> combo;
private readonly ConfigModel model;
using ImGuiNET;
using Lumina.Excel.GeneratedSheets;

namespace HeelsPlugin.Gui
{
public class ConfigLine
{
private readonly int key = 0;
private readonly ComboWithFilter<Item> combo;
private readonly ConfigModel model;
private string itemName
{
get {
if (model == null || (model.ModelMain <=0 && model.Model <= 0)) return "";
get
{
if (model == null || (model.ModelMain <= 0 && model.Model <= 0)) return "";
return combo.Items.Find(c =>
{
if (model.ModelMain > 0) return c.ModelMain == model.ModelMain;
return (short)c.ModelMain == model.Model;
}).Name.ToString();
}
}

public int Key { get => key; }
public ConfigModel Model { get => model; }

public System.Action<int>? OnDelete;
public System.Action? OnChange;

public ConfigLine(int key, ComboWithFilter<Item> combo)
{
this.key = key;
this.combo = combo;

model = new()
{
Name = string.Empty,
Model = 0,
Offset = 0f
};
}

public ConfigLine(int key, ComboWithFilter<Item> combo, ConfigModel model)
{
this.key = key;
this.combo = combo;
this.model = model;
}

public void Draw()
{
try
{
ImGui.BeginGroup();

}

public int Key { get => key; }
public ConfigModel Model { get => model; }

public System.Action<int>? OnDelete;
public System.Action? OnChange;

public ConfigLine(int key, ComboWithFilter<Item> combo)
{
this.key = key;
this.combo = combo;

model = new()
{
Name = string.Empty,
Model = 0,
Offset = 0f
};
}

public ConfigLine(int key, ComboWithFilter<Item> combo, ConfigModel model)
{
this.key = key;
this.combo = combo;
this.model = model;
}

private void UpdatePlayerY()
{
if (model.Enabled && Plugin.Memory.GetPlayerFeet().ToUlong() == model.ModelMain)
Plugin.Memory.SetPosition(Plugin.Memory.PlayerY + model.Offset, 0, true);
else if (!model.Enabled && Plugin.Memory.GetPlayerFeet().ToUlong() == model.ModelMain)
RestorePlayerY();
}

private void RestorePlayerY()
{
Plugin.Memory.SetPosition(Plugin.Memory.PlayerY, 0, true);
}

public void Draw()
{
try
{
var fontScale = ImGui.GetIO().FontGlobalScale;

ImGui.TableNextRow();
ImGui.TableNextColumn();

ImGui.SetCursorPosX(ImGui.GetCursorPosX() + (12 * fontScale));
if (ImGui.Checkbox($"##Enabled{key}", ref model.Enabled))
{
OnChange?.Invoke();
}

ImGui.SameLine();
ImGui.PushItemWidth(200f);
if (ImGui.InputText($"##Name{key}", ref model.Name, 64))
{
OnChange?.Invoke();
}
ImGui.PopItemWidth();

ImGui.SameLine();
if (combo.Draw($"{itemName}##{key}", out var item))
{
model.ModelMain = item.ModelMain;
OnChange?.Invoke();
}

ImGui.SameLine();
ImGui.PushItemWidth(100);
if (ImGui.InputFloat($"##Height{key}", ref model.Offset, 0.01f, 0.01f, "%.2f"))
{
OnChange?.Invoke();
}
ImGui.PopItemWidth();

ImGui.SameLine();
if (ImGuiComponents.IconButton(Key, FontAwesomeIcon.Trash))
{
OnDelete?.Invoke(key);
}
}
finally
{
ImGui.EndGroup();
}
}
}
}
UpdatePlayerY();
}
if (ImGui.IsItemHovered()) ImGui.SetTooltip("Enable or disable this entry from being used");

ImGui.TableNextColumn();
ImGui.PushItemWidth(-1);
if (ImGui.InputText($"##Name{key}", ref model.Name, 64))
OnChange?.Invoke();
if (ImGui.IsItemHovered()) ImGui.SetTooltip("Set a name to remember what this entry is used for");

ImGui.TableNextColumn();

ImGui.BeginGroup();
if (ImGuiComponents.IconButton(Key, FontAwesomeIcon.EyeDropper))
{
var feetPics = Plugin.Memory.GetPlayerFeet();
model.ModelMain = feetPics.ToUlong();
OnChange?.Invoke();
}
if (ImGui.IsItemHovered()) ImGui.SetTooltip("Set as your active footwear");

ImGui.SameLine();
if (combo.Draw($"{itemName}##{key}", out var item, -1))
{
model.ModelMain = item.ModelMain;
OnChange?.Invoke();
}
if (ImGui.IsItemHovered()) ImGui.SetTooltip("Select an item for this entry");
ImGui.EndGroup();
ImGui.PopItemWidth();

ImGui.TableNextColumn();
ImGui.SetNextItemWidth(110 * fontScale);
if (ImGui.InputFloat($"##Height{key}", ref model.Offset, 0.01f, 0.01f, "%.2f"))
{
OnChange?.Invoke();
UpdatePlayerY();
}
if (ImGui.IsItemHovered()) ImGui.SetTooltip("Set how much the heels add to your height");

ImGui.TableNextColumn();
ImGui.SetCursorPosX(ImGui.GetCursorPosX() + (11 * fontScale));
if (ImGuiComponents.IconButton(Key, FontAwesomeIcon.TrashAlt))
{
model.Enabled = false;
OnDelete?.Invoke(key);
RestorePlayerY();
}
if (ImGui.IsItemHovered()) ImGui.SetTooltip("Deletes an entry from your config");
}
finally
{
}
}
}
}
2 changes: 1 addition & 1 deletion HeelsPlugin/HeelsPlugin.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<Version>1.1.3</Version>
<Version>1.1.4</Version>
<TargetFramework>net5.0-windows</TargetFramework>
<LangVersion>latest</LangVersion>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
Expand Down
4 changes: 2 additions & 2 deletions HeelsPlugin/HeelsPlugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
"Name": "Heels Plugin",
"Description": "Offsets your character off the ground for when wearing heels.",
"InternalName": "HeelsPlugin",
"AssemblyVersion": "1.1.3",
"AssemblyVersion": "1.1.4",
"RepoUrl": "https://github.com/LeonBlade/HeelsPlugin",
"ApplicableVersion": "any",
"Tags": ["heels", "high heels", "height", "offset", "leonblade"],
"Tags": [ "heels", "high heels", "height", "offset", "leonblade" ],
"DalamudApiLevel": 5,
"IconUrl": "https://github.com/LeonBlade/HeelsPlugin/raw/main/icon.png"
}
6 changes: 3 additions & 3 deletions HeelsPlugin/Plugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ public class Plugin : IDalamudPlugin
private const string commandName = "/xlheels";

public static Configuration Configuration;
private readonly PluginMemory memory;
public static PluginMemory Memory;
private readonly PluginUI ui;

public Plugin()
{
Configuration = PluginInterface.GetPluginConfig() as Configuration ?? new Configuration();

memory = new();
Memory = new();
ui = new();

CommandManager.AddHandler(commandName, new CommandInfo(OnCommand)
Expand All @@ -45,7 +45,7 @@ public Plugin()
public void Dispose()
{
// Dispose for stuff in Plugin Memory class.
memory.Dispose();
Memory.Dispose();

CommandManager.RemoveHandler(commandName);

Expand Down
Loading

0 comments on commit 543e29b

Please sign in to comment.