コード例 #1
0
        private void ResetBagWidget(AtkUnitBase *atkUnitBase)
        {
            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, 5);
            MoveNode(equipmentComponent, 4, 23, 13);
            for (var i = 5U; i < 10; i++)
            {
                MoveNode(equipmentComponent, i, 5, 13 + (i - 5) * 6);
            }
            for (var i = 10U; i < 15; i++)
            {
                MoveNode(equipmentComponent, i, 23, 19 + (i - 10) * 6);
            }

            var backgroundImage = (AtkImageNode *)equipmentComponent->UldManager.SearchNodeById(15);

            if (backgroundImage != null)
            {
                backgroundImage->AtkResNode.ToggleVisibility(true);

                for (var i = 0U; i < 2; i++)
                {
                    var bgImageNode = Common.GetNodeByID <AtkImageNode>(equipmentComponent->UldManager, CustomNodes.GearPositionsBg + i, NodeType.Image);
                    if (bgImageNode != null)
                    {
                        if (bgImageNode->AtkResNode.PrevSiblingNode != null)
                        {
                            bgImageNode->AtkResNode.PrevSiblingNode->NextSiblingNode = bgImageNode->AtkResNode.NextSiblingNode;
                        }
                        if (bgImageNode->AtkResNode.NextSiblingNode != null)
                        {
                            bgImageNode->AtkResNode.NextSiblingNode->PrevSiblingNode = bgImageNode->AtkResNode.PrevSiblingNode;
                        }
                        equipmentComponent->UldManager.UpdateDrawNodeList();

                        IMemorySpace.Free(bgImageNode->PartsList->Parts->UldAsset, (ulong)sizeof(AtkUldPart));
                        IMemorySpace.Free(bgImageNode->PartsList->Parts, (ulong)sizeof(AtkUldPart));
                        IMemorySpace.Free(bgImageNode->PartsList, (ulong)sizeof(AtkUldPartsList));
                        bgImageNode->AtkResNode.Destroy(true);
                    }
                }
            }
        }
コード例 #2
0
        /// <summary>
        /// Free memory in the game's memory space.
        /// </summary>
        /// <remarks>The memory you are freeing must be allocated with game allocators.</remarks>
        /// <param name="ptr">Position at which the memory to be freed is located.</param>
        /// <param name="size">Amount of bytes to free.</param>
        public static void GameFree(ref IntPtr ptr, ulong size)
        {
            if (ptr == IntPtr.Zero)
            {
                return;
            }

            IMemorySpace.Free((void *)ptr, size);
            ptr = IntPtr.Zero;
        }
コード例 #3
0
    [FieldOffset(0x22)] public fixed byte InlineBuffer[0x40]; // inline buffer used until strlen > 0x40

    public static Utf8String *FromString(string str)
    {
        return(FromString(str, IMemorySpace.GetDefaultSpace()));
    }
コード例 #4
0
        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();
                    }
                }
            }
        }
コード例 #5
0
        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}");
        }
コード例 #6
0
 /// <summary>
 /// Allocate memory in the game's sound 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 GameAllocateSound(ulong size, ulong alignment = 0)
 {
     return(new IntPtr(IMemorySpace.GetSoundSpace()->Malloc(size, alignment)));
 }
コード例 #7
0
 /// <summary>
 /// Allocate memory in the game's animation 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 GameAllocateAnimation(ulong size, ulong alignment = 0)
 {
     return(new IntPtr(IMemorySpace.GetAnimationSpace()->Malloc(size, alignment)));
 }