private void Update(AtkUnitBase *atkUnitBase) { var textNode = atkUnitBase->GetTextNodeById(CustomNodes.InventoryGil); if (textNode == null) { // Because GetTextNodeById is stupid and doesn't work for added nodes for (var n = 0; n < atkUnitBase->UldManager.NodeListCount; n++) { var node = atkUnitBase->UldManager.NodeList[n]; if (node == null) { continue; } if (node->NodeID == CustomNodes.InventoryGil && node->Type == NodeType.Text) { textNode = node->GetAsAtkTextNode(); break; } } } if (textNode == null) { textNode = IMemorySpace.GetUISpace()->Create <AtkTextNode>(); textNode->AtkResNode.NodeID = CustomNodes.InventoryGil; textNode->AtkResNode.Type = NodeType.Text; textNode->AtkResNode.SetWidth(200); textNode->AtkResNode.SetHeight(21); textNode->AtkResNode.SetScale(1, 1); textNode->AtkResNode.SetPositionFloat(atkUnitBase->RootNode->Width - 218, atkUnitBase->RootNode->Height - 40); textNode->FontSize = 12; textNode->AlignmentFontType = 0x05; textNode->TextColor.A = 0xFF; textNode->TextColor.R = 0xEE; textNode->TextColor.G = 0xE1; textNode->TextColor.B = 0xC5; textNode->EdgeColor.A = 0xFF; textNode->EdgeColor.R = 0x00; textNode->EdgeColor.G = 0x00; textNode->EdgeColor.B = 0x00; var lastNode = atkUnitBase->RootNode->ChildNode; if (lastNode == null) { return; } while (true) { if (lastNode->PrevSiblingNode == null) { break; } lastNode = lastNode->PrevSiblingNode; } lastNode->PrevSiblingNode = (AtkResNode *)textNode; textNode->AtkResNode.NextSiblingNode = lastNode; textNode->AtkResNode.ParentNode = lastNode->ParentNode; atkUnitBase->UldManager.UpdateDrawNodeList(); } var gil = InventoryManager.Instance()->GetItemCountInContainer(1, InventoryType.Currency); textNode->SetText(gil.ToString("N0", Culture) + $"{(char) SeIconChar.Gil}"); }
private void BagWidgetUpdate(AtkUnitBase *atkUnitBase, NumberArrayData **numberArrayData, StringArrayData **stringArrayData) { var equipmentComponentNode = atkUnitBase->GetNodeById(6); if (equipmentComponentNode == null) { return; } if ((ushort)equipmentComponentNode->Type < 1000) { return; } var equipmentComponent = ((AtkComponentNode *)equipmentComponentNode)->Component; if (equipmentComponent == null) { return; } MoveNode(equipmentComponent, 3, 5, 10); MoveNode(equipmentComponent, 4, 23, 10); for (var i = 5U; i < 10; i++) { MoveNode(equipmentComponent, i, 5, 10 + (i - 4) * 6); } for (var i = 10U; i < 15; i++) { MoveNode(equipmentComponent, i, 23, 10 + (i - 9) * 6); } var backgroundImage = (AtkImageNode *)equipmentComponent->UldManager.SearchNodeById(15); if (backgroundImage != null) { backgroundImage->AtkResNode.ToggleVisibility(false); for (var i = 0U; i < 2; i++) { // Create var bgImageNode = Common.GetNodeByID <AtkImageNode>(equipmentComponent->UldManager, CustomNodes.GearPositionsBg + i, NodeType.Image); if (bgImageNode == null) { SimpleLog.Log($"Create Custom BG Image Node#{i}"); bgImageNode = IMemorySpace.GetUISpace()->Create <AtkImageNode>(); bgImageNode->AtkResNode.Type = NodeType.Image; bgImageNode->AtkResNode.NodeID = CustomNodes.GearPositionsBg + i; bgImageNode->AtkResNode.Flags = (short)(NodeFlags.AnchorTop | NodeFlags.AnchorLeft); bgImageNode->AtkResNode.DrawFlags = 0; bgImageNode->WrapMode = 1; bgImageNode->Flags = 0; var partsList = (AtkUldPartsList *)IMemorySpace.GetUISpace()->Malloc((ulong)sizeof(AtkUldPartsList), 8); if (partsList == null) { SimpleLog.Error("Failed to alloc memory for parts list."); bgImageNode->AtkResNode.Destroy(true); break; } partsList->Id = 0; partsList->PartCount = 1; var part = (AtkUldPart *)IMemorySpace.GetUISpace()->Malloc((ulong)sizeof(AtkUldPart), 8); if (part == null) { SimpleLog.Error("Failed to alloc memory for part."); IMemorySpace.Free(partsList, (ulong)sizeof(AtkUldPartsList)); bgImageNode->AtkResNode.Destroy(true); break; } part->U = 21; part->V = 13; part->Width = 11; part->Height = 41; partsList->Parts = part; var asset = (AtkUldAsset *)IMemorySpace.GetUISpace()->Malloc((ulong)sizeof(AtkUldAsset), 8); if (asset == null) { SimpleLog.Error("Failed to alloc memory for asset."); IMemorySpace.Free(part, (ulong)sizeof(AtkUldPart)); IMemorySpace.Free(partsList, (ulong)sizeof(AtkUldPartsList)); bgImageNode->AtkResNode.Destroy(true); break; } asset->Id = 0; asset->AtkTexture.Ctor(); part->UldAsset = asset; bgImageNode->PartsList = partsList; bgImageNode->LoadTexture("ui/uld/BagStatus.tex"); bgImageNode->AtkResNode.ToggleVisibility(true); bgImageNode->AtkResNode.SetWidth(11); bgImageNode->AtkResNode.SetHeight(41); bgImageNode->AtkResNode.SetPositionShort((short)(i == 0 ? 3 : 21), 10); var prev = backgroundImage->AtkResNode.PrevSiblingNode; bgImageNode->AtkResNode.ParentNode = backgroundImage->AtkResNode.ParentNode; backgroundImage->AtkResNode.PrevSiblingNode = (AtkResNode *)bgImageNode; prev->NextSiblingNode = (AtkResNode *)bgImageNode; bgImageNode->AtkResNode.PrevSiblingNode = prev; bgImageNode->AtkResNode.NextSiblingNode = (AtkResNode *)backgroundImage; equipmentComponent->UldManager.UpdateDrawNodeList(); } } } }
/// <summary> /// Allocate memory in the game's UI memory space. /// </summary> /// <param name="size">Amount of bytes to allocate.</param> /// <param name="alignment">The alignment of the allocation.</param> /// <returns>Pointer to the allocated region.</returns> public static IntPtr GameAllocateUi(ulong size, ulong alignment = 0) { return(new IntPtr(IMemorySpace.GetUISpace()->Malloc(size, alignment))); }