chore: some imraii conversion

This commit is contained in:
goat 2023-03-26 00:38:34 +01:00
parent 14ce85627d
commit 1ce98a2350
No known key found for this signature in database
GPG key ID: 49E2AA8C6A76498B
8 changed files with 115 additions and 109 deletions

View file

@ -9,6 +9,7 @@ using Dalamud.Game;
using Dalamud.Game.ClientState;
using Dalamud.Game.Gui;
using Dalamud.Interface.Animation.EasingFunctions;
using Dalamud.Interface.Raii;
using Dalamud.Interface.Windowing;
using ImGuiNET;
using ImGuiScene;
@ -169,23 +170,22 @@ internal class TitleScreenMenuWindow : Window, IDisposable
this.fadeOutEasing.Update();
ImGui.PushStyleVar(ImGuiStyleVar.Alpha, (float)this.fadeOutEasing.Value);
for (var i = 0; i < tsm.Entries.Count; i++)
using (ImRaii.PushStyle(ImGuiStyleVar.Alpha, (float)this.fadeOutEasing.Value))
{
var entry = tsm.Entries[i];
for (var i = 0; i < tsm.Entries.Count; i++)
{
var entry = tsm.Entries[i];
var finalPos = (i + 1) * this.shadeTexture.Height * scale;
var finalPos = (i + 1) * this.shadeTexture.Height * scale;
this.DrawEntry(entry, i != 0, true, i == 0, false, false);
this.DrawEntry(entry, i != 0, true, i == 0, false, false);
var cursor = ImGui.GetCursorPos();
cursor.Y = finalPos;
ImGui.SetCursorPos(cursor);
var cursor = ImGui.GetCursorPos();
cursor.Y = finalPos;
ImGui.SetCursorPos(cursor);
}
}
ImGui.PopStyleVar();
var isHover = ImGui.IsWindowHovered(ImGuiHoveredFlags.RootAndChildWindows |
ImGuiHoveredFlags.AllowWhenBlockedByActiveItem);
@ -254,9 +254,11 @@ internal class TitleScreenMenuWindow : Window, IDisposable
var initialCursor = ImGui.GetCursorPos();
ImGui.PushStyleVar(ImGuiStyleVar.Alpha, (float)shadeEasing.Value);
ImGui.Image(this.shadeTexture.ImGuiHandle, new Vector2(this.shadeTexture.Width * scale, this.shadeTexture.Height * scale));
ImGui.PopStyleVar();
using (ImRaii.PushStyle(ImGuiStyleVar.Alpha, (float)shadeEasing.Value))
{
ImGui.Image(this.shadeTexture.ImGuiHandle, new Vector2(this.shadeTexture.Width * scale, this.shadeTexture.Height * scale));
}
var isHover = ImGui.IsItemHovered();
if (isHover && (!shadeEasing.IsRunning || (shadeEasing.IsDone && shadeEasing.IsInverse)) && !inhibitFadeout)
@ -331,15 +333,15 @@ internal class TitleScreenMenuWindow : Window, IDisposable
}
// Drop shadow
ImGui.PushStyleColor(ImGuiCol.Text, 0xFF000000);
for (int i = 0, i_ = (int)Math.Ceiling(1 * scale); i < i_; i++)
using (ImRaii.PushColor(ImGuiCol.Text, 0xFF000000))
{
ImGui.SetCursorPos(new Vector2(cursor.X, cursor.Y + i));
ImGui.Text(entry.Name);
for (int i = 0, i_ = (int)Math.Ceiling(1 * scale); i < i_; i++)
{
ImGui.SetCursorPos(new Vector2(cursor.X, cursor.Y + i));
ImGui.Text(entry.Name);
}
}
ImGui.PopStyleColor();
ImGui.SetCursorPos(cursor);
ImGui.Text(entry.Name);