Switch to dalamud window system

This commit is contained in:
Infi
2024-04-06 23:09:20 +02:00
parent 882099affe
commit 20edc10961
10 changed files with 539 additions and 610 deletions
+57
View File
@@ -0,0 +1,57 @@
using System.Numerics;
using ChatTwo.Util;
using Dalamud.Interface.Utility;
using Dalamud.Interface.Windowing;
using Dalamud.Utility;
using ImGuiNET;
using Lumina.Excel.GeneratedSheets;
namespace ChatTwo.Ui;
public class CommandHelpWindow : Window {
private ChatLogWindow LogWindow { get; }
private TextCommand? Command { get; set; }
internal CommandHelpWindow(ChatLogWindow logWindow) : base($"command help##chat2-commandhelp")
{
LogWindow = logWindow;
Flags = ImGuiWindowFlags.NoSavedSettings | ImGuiWindowFlags.NoTitleBar | ImGuiWindowFlags.NoMove |
ImGuiWindowFlags.NoResize | ImGuiWindowFlags.NoFocusOnAppearing | ImGuiWindowFlags.AlwaysAutoResize;
}
public void UpdateContent(TextCommand command)
{
Command = command;
var width = 350;
var scaledWidth = width * ImGuiHelpers.GlobalScale;
var pos = LogWindow.LastWindowPos;
switch (LogWindow.Plugin.Config.CommandHelpSide) {
case CommandHelpSide.Right:
pos.X += LogWindow.LastWindowSize.X;
break;
case CommandHelpSide.Left:
pos.X -= scaledWidth;
break;
case CommandHelpSide.None:
default:
return;
}
Position = pos;
SizeConstraints = new WindowSizeConstraints
{
MinimumSize = new Vector2(width, 0),
MaximumSize = LogWindow.LastWindowSize with { X = width }
};
}
public override void Draw()
{
if (Command == null)
return;
LogWindow.DrawChunks(ChunkUtil.ToChunks(Command.Description.ToDalamudString(), ChunkSource.None, null).ToList());
}
}