private void PrintComponentNode(AtkResNode *node, string treePrefix) { var compNode = (AtkComponentNode *)node; var popped = false; var isVisible = (node->Flags & 0x10) == 0x10; if (isVisible) { ImGui.PushStyleColor(ImGuiCol.Text, new Vector4(0, 255, 0, 255)); } var componentInfo = compNode->Component->UldManager; var childCount = componentInfo.NodeListCount; var objectInfo = (AtkUldComponentInfo *)componentInfo.Objects; if (ImGui.TreeNode($"{treePrefix}{objectInfo->ComponentType} Component Node (ptr = {(long)node:X}, component ptr = {(long)compNode->Component:X}) child count = {childCount} ###{(long)node}")) { if (ImGui.IsItemHovered()) { this.DrawOutline(node); } if (isVisible) { ImGui.PopStyleColor(); popped = true; } ImGui.Text("Node: "); ImGui.SameLine(); ImGuiHelpers.ClickToCopyText($"{(ulong)node:X}"); ImGui.SameLine(); Util.ShowStruct(*compNode, (ulong)compNode); ImGui.Text("Component: "); ImGui.SameLine(); ImGuiHelpers.ClickToCopyText($"{(ulong)compNode->Component:X}"); ImGui.SameLine(); switch (objectInfo->ComponentType) { case ComponentType.Button: Util.ShowStruct(*(AtkComponentButton *)compNode->Component, (ulong)compNode->Component); break; case ComponentType.Slider: Util.ShowStruct(*(AtkComponentSlider *)compNode->Component, (ulong)compNode->Component); break; case ComponentType.Window: Util.ShowStruct(*(AtkComponentWindow *)compNode->Component, (ulong)compNode->Component); break; case ComponentType.CheckBox: Util.ShowStruct(*(AtkComponentCheckBox *)compNode->Component, (ulong)compNode->Component); break; case ComponentType.GaugeBar: Util.ShowStruct(*(AtkComponentGaugeBar *)compNode->Component, (ulong)compNode->Component); break; case ComponentType.RadioButton: Util.ShowStruct(*(AtkComponentRadioButton *)compNode->Component, (ulong)compNode->Component); break; case ComponentType.TextInput: Util.ShowStruct(*(AtkComponentTextInput *)compNode->Component, (ulong)compNode->Component); break; case ComponentType.Icon: Util.ShowStruct(*(AtkComponentIcon *)compNode->Component, (ulong)compNode->Component); break; default: Util.ShowStruct(*compNode->Component, (ulong)compNode->Component); break; } this.PrintResNode(node); this.PrintNode(componentInfo.RootNode); switch (objectInfo->ComponentType) { case ComponentType.TextInput: var textInputComponent = (AtkComponentTextInput *)compNode->Component; ImGui.Text($"InputBase Text1: {Marshal.PtrToStringAnsi(new IntPtr(textInputComponent->AtkComponentInputBase.UnkText1.StringPtr))}"); ImGui.Text($"InputBase Text2: {Marshal.PtrToStringAnsi(new IntPtr(textInputComponent->AtkComponentInputBase.UnkText2.StringPtr))}"); ImGui.Text($"Text1: {Marshal.PtrToStringAnsi(new IntPtr(textInputComponent->UnkText1.StringPtr))}"); ImGui.Text($"Text2: {Marshal.PtrToStringAnsi(new IntPtr(textInputComponent->UnkText2.StringPtr))}"); ImGui.Text($"Text3: {Marshal.PtrToStringAnsi(new IntPtr(textInputComponent->UnkText3.StringPtr))}"); ImGui.Text($"Text4: {Marshal.PtrToStringAnsi(new IntPtr(textInputComponent->UnkText4.StringPtr))}"); ImGui.Text($"Text5: {Marshal.PtrToStringAnsi(new IntPtr(textInputComponent->UnkText5.StringPtr))}"); break; } ImGui.PushStyleColor(ImGuiCol.Text, 0xFFFFAAAA); if (ImGui.TreeNode($"Node List##{(ulong)node:X}")) { ImGui.PopStyleColor(); for (var i = 0; i < compNode->Component->UldManager.NodeListCount; i++) { this.PrintNode(compNode->Component->UldManager.NodeList[i], false, $"[{i}] "); } ImGui.TreePop(); } else { ImGui.PopStyleColor(); } ImGui.TreePop(); } else if (ImGui.IsItemHovered()) { this.DrawOutline(node); } if (isVisible && !popped) { ImGui.PopStyleColor(); } }
private void DrawUnitBase(AtkUnitBase *atkUnitBase) { var isVisible = (atkUnitBase->Flags & 0x20) == 0x20; var addonName = Marshal.PtrToStringAnsi(new IntPtr(atkUnitBase->Name)); var agent = Service <GameGui> .Get().FindAgentInterface(atkUnitBase); ImGui.Text($"{addonName}"); ImGui.SameLine(); ImGui.PushStyleColor(ImGuiCol.Text, isVisible ? 0xFF00FF00 : 0xFF0000FF); ImGui.Text(isVisible ? "Visible" : "Not Visible"); ImGui.PopStyleColor(); ImGui.SameLine(ImGui.GetWindowContentRegionWidth() - 25); if (ImGui.SmallButton("V")) { atkUnitBase->Flags ^= 0x20; } ImGui.Separator(); ImGuiHelpers.ClickToCopyText($"Address: {(ulong)atkUnitBase:X}", $"{(ulong)atkUnitBase:X}"); ImGuiHelpers.ClickToCopyText($"Agent: {(ulong)agent:X}", $"{(ulong)agent:X}"); ImGui.Separator(); ImGui.Text($"Position: [ {atkUnitBase->X} , {atkUnitBase->Y} ]"); ImGui.Text($"Scale: {atkUnitBase->Scale * 100}%%"); ImGui.Text($"Widget Count {atkUnitBase->UldManager.ObjectCount}"); ImGui.Separator(); object addonObj = *atkUnitBase; Util.ShowStruct(addonObj, (ulong)atkUnitBase); ImGui.Dummy(new Vector2(25 * ImGui.GetIO().FontGlobalScale)); ImGui.Separator(); if (atkUnitBase->RootNode != null) { this.PrintNode(atkUnitBase->RootNode); } if (atkUnitBase->UldManager.NodeListCount > 0) { ImGui.Dummy(new Vector2(25 * ImGui.GetIO().FontGlobalScale)); ImGui.Separator(); ImGui.PushStyleColor(ImGuiCol.Text, 0xFFFFAAAA); if (ImGui.TreeNode($"Node List##{(ulong)atkUnitBase:X}")) { ImGui.PopStyleColor(); for (var j = 0; j < atkUnitBase->UldManager.NodeListCount; j++) { this.PrintNode(atkUnitBase->UldManager.NodeList[j], false, $"[{j}] "); } ImGui.TreePop(); } else { ImGui.PopStyleColor(); } } }
private void PrintSimpleNode(AtkResNode *node, string treePrefix) { var popped = false; var isVisible = (node->Flags & 0x10) == 0x10; if (isVisible) { ImGui.PushStyleColor(ImGuiCol.Text, new Vector4(0, 255, 0, 255)); } if (ImGui.TreeNode($"{treePrefix}{node->Type} Node (ptr = {(long)node:X})###{(long)node}")) { if (ImGui.IsItemHovered()) { this.DrawOutline(node); } if (isVisible) { ImGui.PopStyleColor(); popped = true; } ImGui.Text("Node: "); ImGui.SameLine(); ImGuiHelpers.ClickToCopyText($"{(ulong)node:X}"); ImGui.SameLine(); switch (node->Type) { case NodeType.Text: Util.ShowStruct(*(AtkTextNode *)node, (ulong)node); break; case NodeType.Image: Util.ShowStruct(*(AtkImageNode *)node, (ulong)node); break; case NodeType.Collision: Util.ShowStruct(*(AtkCollisionNode *)node, (ulong)node); break; case NodeType.NineGrid: Util.ShowStruct(*(AtkNineGridNode *)node, (ulong)node); break; case NodeType.Counter: Util.ShowStruct(*(AtkCounterNode *)node, (ulong)node); break; default: Util.ShowStruct(*node, (ulong)node); break; } this.PrintResNode(node); if (node->ChildNode != null) { this.PrintNode(node->ChildNode); } switch (node->Type) { case NodeType.Text: var textNode = (AtkTextNode *)node; ImGui.Text($"text: {Marshal.PtrToStringAnsi(new IntPtr(textNode->NodeText.StringPtr))}"); ImGui.InputText($"Replace Text##{(ulong)textNode:X}", new IntPtr(textNode->NodeText.StringPtr), (uint)textNode->NodeText.BufSize); ImGui.Text($"AlignmentType: {(AlignmentType)textNode->AlignmentFontType} FontSize: {textNode->FontSize}"); int b = textNode->AlignmentFontType; if (ImGui.InputInt($"###setAlignment{(ulong)textNode:X}", ref b, 1)) { while (b > byte.MaxValue) { b -= byte.MaxValue; } while (b < byte.MinValue) { b += byte.MaxValue; } textNode->AlignmentFontType = (byte)b; textNode->AtkResNode.Flags_2 |= 0x1; } ImGui.Text($"Color: #{textNode->TextColor.R:X2}{textNode->TextColor.G:X2}{textNode->TextColor.B:X2}{textNode->TextColor.A:X2}"); ImGui.SameLine(); ImGui.Text($"EdgeColor: #{textNode->EdgeColor.R:X2}{textNode->EdgeColor.G:X2}{textNode->EdgeColor.B:X2}{textNode->EdgeColor.A:X2}"); ImGui.SameLine(); ImGui.Text($"BGColor: #{textNode->BackgroundColor.R:X2}{textNode->BackgroundColor.G:X2}{textNode->BackgroundColor.B:X2}{textNode->BackgroundColor.A:X2}"); ImGui.Text($"TextFlags: {textNode->TextFlags}"); ImGui.SameLine(); ImGui.Text($"TextFlags2: {textNode->TextFlags2}"); break; case NodeType.Counter: var counterNode = (AtkCounterNode *)node; ImGui.Text($"text: {Marshal.PtrToStringAnsi(new IntPtr(counterNode->NodeText.StringPtr))}"); break; case NodeType.Image: var imageNode = (AtkImageNode *)node; if (imageNode->PartsList != null) { if (imageNode->PartId > imageNode->PartsList->PartCount) { ImGui.Text("part id > part count?"); } else { var textureInfo = imageNode->PartsList->Parts[imageNode->PartId].UldAsset; var texType = textureInfo->AtkTexture.TextureType; ImGui.Text($"texture type: {texType} part_id={imageNode->PartId} part_id_count={imageNode->PartsList->PartCount}"); if (texType == TextureType.Resource) { var texFileNameStdString = &textureInfo->AtkTexture.Resource->TexFileResourceHandle->ResourceHandle.FileName; var texString = texFileNameStdString->Length < 16 ? Marshal.PtrToStringAnsi((IntPtr)texFileNameStdString->Buffer) : Marshal.PtrToStringAnsi((IntPtr)texFileNameStdString->BufferPtr); ImGui.Text($"texture path: {texString}"); var kernelTexture = textureInfo->AtkTexture.Resource->KernelTextureObject; if (ImGui.TreeNode($"Texture##{(ulong)kernelTexture->D3D11ShaderResourceView:X}")) { ImGui.Image(new IntPtr(kernelTexture->D3D11ShaderResourceView), new Vector2(kernelTexture->Width, kernelTexture->Height)); ImGui.TreePop(); } } else if (texType == TextureType.KernelTexture) { if (ImGui.TreeNode($"Texture##{(ulong)textureInfo->AtkTexture.KernelTexture->D3D11ShaderResourceView:X}")) { ImGui.Image(new IntPtr(textureInfo->AtkTexture.KernelTexture->D3D11ShaderResourceView), new Vector2(textureInfo->AtkTexture.KernelTexture->Width, textureInfo->AtkTexture.KernelTexture->Height)); ImGui.TreePop(); } } } } else { ImGui.Text("no texture loaded"); } break; } ImGui.TreePop(); } else if (ImGui.IsItemHovered()) { this.DrawOutline(node); } if (isVisible && !popped) { ImGui.PopStyleColor(); } }