Sync up imgui windows to atk windows

This commit is contained in:
Asriel Camora
2024-06-19 19:41:08 -07:00
parent 747874634c
commit 34b84ec669
2 changed files with 49 additions and 4 deletions
+27 -2
View File
@@ -200,6 +200,12 @@ public sealed unsafe class RecipeNote : Window, IDisposable
} }
} }
if (!ShouldOpen)
{
StyleAlpha = LastAlpha = null;
LastPosition = null;
}
WasOpen = ShouldOpen; WasOpen = ShouldOpen;
WasCollapsed = IsCollapsed; WasCollapsed = IsCollapsed;
WasCalculatable = ShouldCalculate; WasCalculatable = ShouldCalculate;
@@ -302,6 +308,9 @@ public sealed unsafe class RecipeNote : Window, IDisposable
return true; return true;
} }
private Vector2? LastPosition { get; set; }
private byte? StyleAlpha { get; set; }
private byte? LastAlpha { get; set; }
public override void PreDraw() public override void PreDraw()
{ {
base.PreDraw(); base.PreDraw();
@@ -318,16 +327,32 @@ public sealed unsafe class RecipeNote : Window, IDisposable
var node = (AtkResNode*)Addon->Unk458; // unit.GetNodeById(59); var node = (AtkResNode*)Addon->Unk458; // unit.GetNodeById(59);
var nodeParent = Addon->Unk258; // unit.GetNodeById(57); var nodeParent = Addon->Unk258; // unit.GetNodeById(57);
Position = ImGuiHelpers.MainViewport.Pos + pos + new Vector2(size.X, (nodeParent->Y + node->Y) * scale); var newAlpha = unit.WindowNode->AtkResNode.Alpha_2;
StyleAlpha = LastAlpha ?? newAlpha;
LastAlpha = newAlpha;
var newPosition = pos + new Vector2(size.X, (nodeParent->Y + node->Y) * scale);
Position = ImGuiHelpers.MainViewport.Pos + (LastPosition ?? newPosition);
LastPosition = newPosition;
Flags = WindowFlagsPinned; Flags = WindowFlagsPinned;
WindowName = WindowNamePinned; WindowName = WindowNamePinned;
} }
else else
{ {
Position = null; StyleAlpha = LastAlpha = null;
Position = LastPosition = null;
Flags = WindowFlagsFloating; Flags = WindowFlagsFloating;
WindowName = WindowNameFloating; WindowName = WindowNameFloating;
} }
ImGui.PushStyleVar(ImGuiStyleVar.Alpha, StyleAlpha.HasValue ? (StyleAlpha.Value / 255f) : 1);
}
public override void PostDraw()
{
ImGui.PopStyleVar();
base.PostDraw();
} }
public override void Draw() public override void Draw()
+22 -2
View File
@@ -136,6 +136,12 @@ public sealed unsafe class SynthHelper : Window, IDisposable
if (!ShouldCalculate) if (!ShouldCalculate)
IsSuggestedActionExecutionQueued = false; IsSuggestedActionExecutionQueued = false;
if (!ShouldOpen)
{
StyleAlpha = LastAlpha = null;
LastPosition = null;
}
WasOpen = ShouldOpen; WasOpen = ShouldOpen;
WasCollapsed = IsCollapsed; WasCollapsed = IsCollapsed;
WasCalculatable = ShouldCalculate; WasCalculatable = ShouldCalculate;
@@ -189,6 +195,9 @@ public sealed unsafe class SynthHelper : Window, IDisposable
return true; return true;
} }
private Vector2? LastPosition { get; set; }
private byte? StyleAlpha { get; set; }
private byte? LastAlpha { get; set; }
public override void PreDraw() public override void PreDraw()
{ {
base.PreDraw(); base.PreDraw();
@@ -204,20 +213,31 @@ public sealed unsafe class SynthHelper : Window, IDisposable
var offset = 5; var offset = 5;
Position = ImGuiHelpers.MainViewport.Pos + pos + new Vector2(size.X, offset * scale); var newAlpha = unit.WindowNode->AtkResNode.Alpha_2;
StyleAlpha = LastAlpha ?? newAlpha;
LastAlpha = newAlpha;
var newPosition = pos + new Vector2(size.X, offset * scale);
Position = ImGuiHelpers.MainViewport.Pos + (LastPosition ?? newPosition);
LastPosition = newPosition;
Flags = WindowFlagsPinned; Flags = WindowFlagsPinned;
WindowName = WindowNamePinned; WindowName = WindowNamePinned;
} }
else else
{ {
Position = null; StyleAlpha = LastAlpha = null;
Position = LastPosition = null;
Flags = WindowFlagsFloating; Flags = WindowFlagsFloating;
WindowName = WindowNameFloating; WindowName = WindowNameFloating;
} }
ImGui.PushStyleVar(ImGuiStyleVar.Alpha, StyleAlpha.HasValue ? (StyleAlpha.Value / 255f) : 1);
} }
public override void PostDraw() public override void PostDraw()
{ {
ImGui.PopStyleVar();
base.PostDraw(); base.PostDraw();
IsSuggestedActionExecutionQueued = false; IsSuggestedActionExecutionQueued = false;