mirror of
https://github.com/xivdev/Penumbra.git
synced 2026-01-03 06:13:45 +01:00
Update with workable prototype.
This commit is contained in:
parent
e77fa18c61
commit
795fa7336e
9 changed files with 168 additions and 116 deletions
|
|
@ -1,4 +1,10 @@
|
|||
using Dalamud.Interface;
|
||||
using ImGuiNET;
|
||||
using OtterGui;
|
||||
using OtterGui.Raii;
|
||||
using OtterGui.Text;
|
||||
using Penumbra.Mods.Groups;
|
||||
using Penumbra.Mods.SubMods;
|
||||
|
||||
namespace Penumbra.UI.ModsTab.Groups;
|
||||
|
||||
|
|
@ -6,6 +12,100 @@ public readonly struct CombiningModGroupEditDrawer(ModGroupEditDrawer editor, Co
|
|||
{
|
||||
public void Draw()
|
||||
{
|
||||
|
||||
foreach (var (option, optionIdx) in group.OptionData.WithIndex())
|
||||
{
|
||||
using var id = ImUtf8.PushId(optionIdx);
|
||||
editor.DrawOptionPosition(group, option, optionIdx);
|
||||
|
||||
ImUtf8.SameLineInner();
|
||||
editor.DrawOptionDefaultMultiBehaviour(group, option, optionIdx);
|
||||
|
||||
ImUtf8.SameLineInner();
|
||||
editor.DrawOptionName(option);
|
||||
|
||||
ImUtf8.SameLineInner();
|
||||
editor.DrawOptionDescription(option);
|
||||
|
||||
ImUtf8.SameLineInner();
|
||||
editor.DrawOptionDelete(option);
|
||||
}
|
||||
|
||||
DrawNewOption();
|
||||
DrawContainerNames();
|
||||
}
|
||||
|
||||
private void DrawNewOption()
|
||||
{
|
||||
var count = group.OptionData.Count;
|
||||
if (count >= IModGroup.MaxCombiningOptions)
|
||||
return;
|
||||
|
||||
var name = editor.DrawNewOptionBase(group, count);
|
||||
|
||||
var validName = name.Length > 0;
|
||||
if (ImUtf8.IconButton(FontAwesomeIcon.Plus, validName
|
||||
? "Add a new option to this group."u8
|
||||
: "Please enter a name for the new option."u8, default, !validName))
|
||||
{
|
||||
editor.ModManager.OptionEditor.CombiningEditor.AddOption(group, name);
|
||||
editor.NewOptionName = null;
|
||||
}
|
||||
}
|
||||
|
||||
private unsafe void DrawContainerNames()
|
||||
{
|
||||
if (ImUtf8.ButtonEx("Edit Container Names"u8,
|
||||
"Add optional names to separate data containers of the combining group.\nThose are just for easier identification while editing the mod, and are not generally displayed to the user."u8,
|
||||
new Vector2(400 * ImUtf8.GlobalScale, 0)))
|
||||
ImUtf8.OpenPopup("DataContainerNames"u8);
|
||||
|
||||
var sizeX = group.OptionData.Count * (ImGui.GetStyle().ItemInnerSpacing.X + ImGui.GetFrameHeight()) + 300 * ImUtf8.GlobalScale;
|
||||
ImGui.SetNextWindowSize(new Vector2(sizeX, ImGui.GetFrameHeightWithSpacing() * Math.Min(16, group.Data.Count) + 200 * ImUtf8.GlobalScale));
|
||||
using var popup = ImUtf8.Popup("DataContainerNames"u8);
|
||||
if (!popup)
|
||||
return;
|
||||
|
||||
foreach (var option in group.OptionData)
|
||||
{
|
||||
ImUtf8.RotatedText(option.Name, true);
|
||||
ImUtf8.SameLineInner();
|
||||
}
|
||||
|
||||
ImGui.NewLine();
|
||||
ImGui.Separator();
|
||||
using var child = ImUtf8.Child("##Child"u8, ImGui.GetContentRegionAvail());
|
||||
ImGuiClip.ClippedDraw(group.Data, DrawRow, ImGui.GetFrameHeightWithSpacing());
|
||||
}
|
||||
|
||||
private void DrawRow(CombinedDataContainer container, int index)
|
||||
{
|
||||
using var id = ImUtf8.PushId(index);
|
||||
using (ImRaii.Disabled())
|
||||
{
|
||||
for (var i = 0; i < group.OptionData.Count; ++i)
|
||||
{
|
||||
id.Push(i);
|
||||
var check = (index & (1 << i)) != 0;
|
||||
ImUtf8.Checkbox(""u8, ref check);
|
||||
ImUtf8.SameLineInner();
|
||||
id.Pop();
|
||||
}
|
||||
}
|
||||
|
||||
var name = editor.CombiningDisplayIndex == index ? editor.CombiningDisplayName ?? container.Name : container.Name;
|
||||
if (ImUtf8.InputText("##Nothing"u8, ref name, "Optional Display Name..."u8))
|
||||
{
|
||||
editor.CombiningDisplayIndex = index;
|
||||
editor.CombiningDisplayName = name;
|
||||
}
|
||||
|
||||
if (ImGui.IsItemDeactivatedAfterEdit())
|
||||
editor.ModManager.OptionEditor.CombiningEditor.SetDisplayName(container, name);
|
||||
|
||||
if (ImGui.IsItemDeactivated())
|
||||
{
|
||||
editor.CombiningDisplayIndex = -1;
|
||||
editor.CombiningDisplayName = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -58,6 +58,9 @@ public sealed class ModGroupEditDrawer(
|
|||
private IModOption? _dragDropOption;
|
||||
private bool _draggingAcross;
|
||||
|
||||
internal string? CombiningDisplayName;
|
||||
internal int CombiningDisplayIndex;
|
||||
|
||||
public void Draw(Mod mod)
|
||||
{
|
||||
PrepareStyle();
|
||||
|
|
@ -275,6 +278,7 @@ public sealed class ModGroupEditDrawer(
|
|||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
internal string DrawNewOptionBase(IModGroup group, int count)
|
||||
{
|
||||
ImGui.AlignTextToFramePadding();
|
||||
ImUtf8.Selectable($"Option #{count + 1}", false, size: OptionIdxSelectable);
|
||||
Target(group, count);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue