mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-12 18:27:23 +01:00
don't implicitly depend on DataManager in data widget load functions
This commit is contained in:
parent
f3d7c6f2ea
commit
10f4009a0c
3 changed files with 35 additions and 16 deletions
23
Dalamud/Interface/Internal/Asserts/RenderScopes.cs
Normal file
23
Dalamud/Interface/Internal/Asserts/RenderScopes.cs
Normal file
|
|
@ -0,0 +1,23 @@
|
||||||
|
using System.Diagnostics;
|
||||||
|
|
||||||
|
namespace Dalamud.Interface.Internal.Asserts;
|
||||||
|
|
||||||
|
public static class RenderScopes
|
||||||
|
{
|
||||||
|
private static RenderScopeFrame currentFrame = new();
|
||||||
|
private static RenderScopeFrame lastFrame = new();
|
||||||
|
|
||||||
|
public static RenderScopeFrame GetLastFrame() => lastFrame;
|
||||||
|
|
||||||
|
public static RenderScopeFrame GetCurrentFrame() => currentFrame;
|
||||||
|
|
||||||
|
public static void NewFrame()
|
||||||
|
{
|
||||||
|
//Debug.Assert(currentFrame.IsRoot, "NewFrame() but we didn't pop all the way to .");
|
||||||
|
}
|
||||||
|
|
||||||
|
public class RenderScopeFrame
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -15,7 +15,6 @@ using FFXIVClientStructs.FFXIV.Component.GUI;
|
||||||
|
|
||||||
using ImGuiNET;
|
using ImGuiNET;
|
||||||
|
|
||||||
using Lumina.Excel;
|
|
||||||
using Lumina.Excel.Sheets;
|
using Lumina.Excel.Sheets;
|
||||||
using Lumina.Text;
|
using Lumina.Text;
|
||||||
using Lumina.Text.Payloads;
|
using Lumina.Text.Payloads;
|
||||||
|
|
@ -31,7 +30,6 @@ internal unsafe class SeStringRendererTestWidget : IDataWindowWidget
|
||||||
private static readonly string[] ThemeNames = ["Dark", "Light", "Classic FF", "Clear Blue"];
|
private static readonly string[] ThemeNames = ["Dark", "Light", "Classic FF", "Clear Blue"];
|
||||||
private ImVectorWrapper<byte> testStringBuffer;
|
private ImVectorWrapper<byte> testStringBuffer;
|
||||||
private string testString = string.Empty;
|
private string testString = string.Empty;
|
||||||
private ExcelSheet<Addon> addons = null!;
|
|
||||||
private ReadOnlySeString? logkind;
|
private ReadOnlySeString? logkind;
|
||||||
private SeStringDrawParams style;
|
private SeStringDrawParams style;
|
||||||
private bool interactable;
|
private bool interactable;
|
||||||
|
|
@ -51,7 +49,6 @@ internal unsafe class SeStringRendererTestWidget : IDataWindowWidget
|
||||||
public void Load()
|
public void Load()
|
||||||
{
|
{
|
||||||
this.style = new() { GetEntity = this.GetEntity };
|
this.style = new() { GetEntity = this.GetEntity };
|
||||||
this.addons = Service<DataManager>.Get().GetExcelSheet<Addon>();
|
|
||||||
this.logkind = null;
|
this.logkind = null;
|
||||||
this.testString = string.Empty;
|
this.testString = string.Empty;
|
||||||
this.interactable = this.useEntity = true;
|
this.interactable = this.useEntity = true;
|
||||||
|
|
@ -193,13 +190,16 @@ internal unsafe class SeStringRendererTestWidget : IDataWindowWidget
|
||||||
ImGui.CalcTextSize("AAAAAAAAAAAAAAAAA").X);
|
ImGui.CalcTextSize("AAAAAAAAAAAAAAAAA").X);
|
||||||
ImGui.TableHeadersRow();
|
ImGui.TableHeadersRow();
|
||||||
|
|
||||||
|
var addon = Service<DataManager>.GetNullable()?.GetExcelSheet<Addon>() ??
|
||||||
|
throw new InvalidOperationException("Addon sheet not loaded.");
|
||||||
|
|
||||||
var clipper = new ImGuiListClipperPtr(ImGuiNative.ImGuiListClipper_ImGuiListClipper());
|
var clipper = new ImGuiListClipperPtr(ImGuiNative.ImGuiListClipper_ImGuiListClipper());
|
||||||
clipper.Begin(this.addons.Count);
|
clipper.Begin(addon.Count);
|
||||||
while (clipper.Step())
|
while (clipper.Step())
|
||||||
{
|
{
|
||||||
for (var i = clipper.DisplayStart; i < clipper.DisplayEnd; i++)
|
for (var i = clipper.DisplayStart; i < clipper.DisplayEnd; i++)
|
||||||
{
|
{
|
||||||
var row = this.addons.GetRowAt(i);
|
var row = addon.GetRowAt(i);
|
||||||
|
|
||||||
ImGui.TableNextRow();
|
ImGui.TableNextRow();
|
||||||
ImGui.PushID(i);
|
ImGui.PushID(i);
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
using System.Buffers.Binary;
|
using System.Buffers.Binary;
|
||||||
using System.Linq;
|
|
||||||
using System.Numerics;
|
using System.Numerics;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
|
|
@ -7,12 +6,9 @@ using Dalamud.Data;
|
||||||
using Dalamud.Interface.ImGuiNotification;
|
using Dalamud.Interface.ImGuiNotification;
|
||||||
using Dalamud.Interface.ImGuiNotification.Internal;
|
using Dalamud.Interface.ImGuiNotification.Internal;
|
||||||
using Dalamud.Interface.ImGuiSeStringRenderer.Internal;
|
using Dalamud.Interface.ImGuiSeStringRenderer.Internal;
|
||||||
using Dalamud.Interface.Utility;
|
|
||||||
using Dalamud.Storage.Assets;
|
|
||||||
|
|
||||||
using ImGuiNET;
|
using ImGuiNET;
|
||||||
|
|
||||||
using Lumina.Excel;
|
|
||||||
using Lumina.Excel.Sheets;
|
using Lumina.Excel.Sheets;
|
||||||
|
|
||||||
namespace Dalamud.Interface.Internal.Windows.Data.Widgets;
|
namespace Dalamud.Interface.Internal.Windows.Data.Widgets;
|
||||||
|
|
@ -22,8 +18,6 @@ namespace Dalamud.Interface.Internal.Windows.Data.Widgets;
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal class UiColorWidget : IDataWindowWidget
|
internal class UiColorWidget : IDataWindowWidget
|
||||||
{
|
{
|
||||||
private ExcelSheet<UIColor> colors;
|
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public string[]? CommandShortcuts { get; init; } = ["uicolor"];
|
public string[]? CommandShortcuts { get; init; } = ["uicolor"];
|
||||||
|
|
||||||
|
|
@ -37,12 +31,14 @@ internal class UiColorWidget : IDataWindowWidget
|
||||||
public void Load()
|
public void Load()
|
||||||
{
|
{
|
||||||
this.Ready = true;
|
this.Ready = true;
|
||||||
this.colors = Service<DataManager>.Get().GetExcelSheet<UIColor>();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public unsafe void Draw()
|
public unsafe void Draw()
|
||||||
{
|
{
|
||||||
|
var colors = Service<DataManager>.GetNullable()?.GetExcelSheet<UIColor>()
|
||||||
|
?? throw new InvalidOperationException("UIColor sheet not loaded.");
|
||||||
|
|
||||||
Service<SeStringRenderer>.Get().CompileAndDrawWrapped(
|
Service<SeStringRenderer>.Get().CompileAndDrawWrapped(
|
||||||
"· Color notation is #" +
|
"· Color notation is #" +
|
||||||
"<edgecolor(0xFFEEEE)><color(0xFF0000)>RR<color(stackcolor)><edgecolor(stackcolor)>" +
|
"<edgecolor(0xFFEEEE)><color(0xFF0000)>RR<color(stackcolor)><edgecolor(stackcolor)>" +
|
||||||
|
|
@ -71,16 +67,16 @@ internal class UiColorWidget : IDataWindowWidget
|
||||||
ImGui.TableHeadersRow();
|
ImGui.TableHeadersRow();
|
||||||
|
|
||||||
var clipper = new ImGuiListClipperPtr(ImGuiNative.ImGuiListClipper_ImGuiListClipper());
|
var clipper = new ImGuiListClipperPtr(ImGuiNative.ImGuiListClipper_ImGuiListClipper());
|
||||||
clipper.Begin(this.colors.Count, ImGui.GetFrameHeightWithSpacing());
|
clipper.Begin(colors.Count, ImGui.GetFrameHeightWithSpacing());
|
||||||
while (clipper.Step())
|
while (clipper.Step())
|
||||||
{
|
{
|
||||||
for (var i = clipper.DisplayStart; i < clipper.DisplayEnd; i++)
|
for (var i = clipper.DisplayStart; i < clipper.DisplayEnd; i++)
|
||||||
{
|
{
|
||||||
var row = this.colors.GetRowAt(i);
|
var row = colors.GetRowAt(i);
|
||||||
UIColor? adjacentRow = null;
|
UIColor? adjacentRow = null;
|
||||||
if (i + 1 < this.colors.Count)
|
if (i + 1 < colors.Count)
|
||||||
{
|
{
|
||||||
var adjRow = this.colors.GetRowAt(i + 1);
|
var adjRow = colors.GetRowAt(i + 1);
|
||||||
if (adjRow.RowId == row.RowId + 1)
|
if (adjRow.RowId == row.RowId + 1)
|
||||||
{
|
{
|
||||||
adjacentRow = adjRow;
|
adjacentRow = adjRow;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue