Minor cleanup v0.6
authorLiza Carvelli <liza@carvel.li>
Sun, 9 Jun 2024 14:37:26 +0000 (16:37 +0200)
committerLiza Carvelli <liza@carvel.li>
Sun, 9 Jun 2024 14:37:26 +0000 (16:37 +0200)
Questionable/Controller/GameUiController.cs
Questionable/Windows/DebugWindow.cs

index 3e8293341d5a98e5bf87b0bf788f9e431f2a5a21..964235862b50a32ab4f63e4878a12a5256921e2a 100644 (file)
@@ -12,6 +12,7 @@ using Lumina.Excel.GeneratedSheets;
 using Microsoft.Extensions.Logging;
 using Questionable.Model.V1;
 using Quest = Questionable.Model.Quest;
+using ValueType = FFXIVClientStructs.FFXIV.Component.GUI.ValueType;
 
 namespace Questionable.Controller;
 
@@ -84,7 +85,10 @@ internal sealed class GameUiController : IDisposable
 
         List<string?> answers = new();
         for (ushort i = 7; i < addonSelectString->AtkUnitBase.AtkValuesCount; ++i)
-            answers.Add(addonSelectString->AtkUnitBase.AtkValues[i].ReadAtkString());
+        {
+            if (addonSelectString->AtkUnitBase.AtkValues[i].Type == ValueType.String)
+                answers.Add(addonSelectString->AtkUnitBase.AtkValues[i].ReadAtkString());
+        }
 
         int? answer = HandleListChoice(actualPrompt, answers, checkAllSteps);
         if (answer != null)
index 99ef7e82c16c485f14fcbb33c673a467cd2a956c..2d9b7837f6c74a0becde89265c0b4791b950d77b 100644 (file)
@@ -1,4 +1,5 @@
 using System;
+using System.Diagnostics;
 using System.Globalization;
 using System.Numerics;
 using Dalamud.Game.ClientState.Objects;
@@ -75,14 +76,19 @@ internal sealed class DebugWindow : LWindow, IPersistableWindowConfig, IDisposab
         return currentQuest == null || !currentQuest.Quest.Data.TerritoryBlacklist.Contains(_clientState.TerritoryType);
     }
 
-    public override unsafe void Draw()
+    public override void Draw()
     {
-        if (!_clientState.IsLoggedIn || _clientState.LocalPlayer == null)
-        {
-            ImGui.Text("Not logged in.");
-            return;
-        }
+        DrawQuest();
+        ImGui.Separator();
+
+        DrawCreationUtils();
+        ImGui.Separator();
+
+        DrawQuickAccessButtons();
+    }
 
+    private unsafe void DrawQuest()
+    {
         var currentQuest = _questController.CurrentQuest;
         if (currentQuest != null)
         {
@@ -146,8 +152,11 @@ internal sealed class DebugWindow : LWindow, IPersistableWindowConfig, IDisposab
         }
         else
             ImGui.Text("No active quest");
+    }
 
-        ImGui.Separator();
+    private unsafe void DrawCreationUtils()
+    {
+        Debug.Assert(_clientState.LocalPlayer != null, "_clientState.LocalPlayer != null");
 
         ImGui.Text(
             $"Current TerritoryId: {_clientState.TerritoryType}, Flying: {(_gameFunctions.IsFlyingUnlockedInCurrentZone() ? "Yes" : "No")}");
@@ -209,7 +218,7 @@ internal sealed class DebugWindow : LWindow, IPersistableWindowConfig, IDisposab
             if (ImGui.Button("Interact"))
             {
                 ulong result = TargetSystem.Instance()->InteractWithObject(
-                    (FFXIVClientStructs.FFXIV.Client.Game.Object.GameObject*)_targetManager.Target.Address, false);
+                    (GameObject*)_targetManager.Target.Address, false);
                 _logger.LogInformation("XXXXX Interaction Result: {Result}", result);
             }
 
@@ -251,9 +260,10 @@ internal sealed class DebugWindow : LWindow, IPersistableWindowConfig, IDisposab
                                          """);
             }
         }
+    }
 
-        ImGui.Separator();
-
+    private unsafe void DrawQuickAccessButtons()
+    {
         var map = AgentMap.Instance();
         ImGui.BeginDisabled(map == null || map->IsFlagMarkerSet == 0 ||
                             map->FlagMapMarker.TerritoryId != _clientState.TerritoryType);