Example #1
0
        private void Update()
        {
            var atkUnitBase = (AtkUnitBase *)PluginInterface.Framework.Gui.GetUiObjectByName("SalvageItemSelector", 1);

            if (atkUnitBase == null)
            {
                return;
            }
            if ((atkUnitBase->Flags & 0x20) != 0x20)
            {
                return;
            }

            var nodeList   = atkUnitBase->UldManager.NodeList;
            var windowNode = (AtkComponentNode *)atkUnitBase->UldManager.NodeList[1];

            if (windowNode->AtkResNode.Width == 600)
            {
                desynthRows.Clear();
                UiHelper.SetWindowSize(windowNode, NewWidth, null);
                UiHelper.SetSize(nodeList[0], NewWidth, null);
                UiHelper.SetSize(nodeList[3], NewWidth - 32, null);
                UiHelper.SetSize(nodeList[4], NewWidth - 25, null);
                UiHelper.SetSize(nodeList[5], NewWidth - 32, null);
                UiHelper.SetSize(nodeList[2], nodeList[2]->Width + AddedWidth, null);
                var listComponent = (AtkComponentNode *)atkUnitBase->UldManager.NodeList[3];
                var listNodeList  = listComponent->Component->UldManager.NodeList;
                UiHelper.SetSize(listNodeList[0], NewWidth - 32, null);
                UiHelper.SetPosition(listNodeList[1], NewWidth - 40, null);


                UiHelper.ExpandNodeList(atkUnitBase, 2);
                var newHeaderItem = (AtkTextNode *)UiHelper.CloneNode(nodeList[6]);
                newHeaderItem->NodeText.StringPtr = (byte *)UiHelper.Alloc((ulong)newHeaderItem->NodeText.BufSize);
                UiHelper.SetText(newHeaderItem, "Skill");

                newHeaderItem->AtkResNode.X               = NewWidth - (AddedWidth + 60);
                newHeaderItem->AtkResNode.Width           = AddedWidth;
                newHeaderItem->AtkResNode.ParentNode      = nodeList[5];
                newHeaderItem->AtkResNode.NextSiblingNode = nodeList[8];
                nodeList[8]->PrevSiblingNode              = (AtkResNode *)newHeaderItem;
                atkUnitBase->UldManager.NodeList[atkUnitBase->UldManager.NodeListCount++] = (AtkResNode *)newHeaderItem;

                var gsHeaderItem = (AtkTextNode *)UiHelper.CloneNode(nodeList[6]);
                gsHeaderItem->NodeText.StringPtr = (byte *)UiHelper.Alloc((ulong)gsHeaderItem->NodeText.BufSize);
                UiHelper.SetText(gsHeaderItem, "Gear\nSet");
                gsHeaderItem->TextFlags                  |= (byte)TextFlags.MultiLine;
                gsHeaderItem->AtkResNode.X                = NewWidth - 80;
                gsHeaderItem->AlignmentFontType           = (byte)AlignmentType.Bottom;
                gsHeaderItem->AtkResNode.Width            = 30;
                gsHeaderItem->AtkResNode.ParentNode       = nodeList[5];
                gsHeaderItem->AtkResNode.NextSiblingNode  = (AtkResNode *)newHeaderItem;
                newHeaderItem->AtkResNode.PrevSiblingNode = (AtkResNode *)gsHeaderItem;
                atkUnitBase->UldManager.NodeList[atkUnitBase->UldManager.NodeListCount++] = (AtkResNode *)gsHeaderItem;

                for (var i = 2; i < 18; i++)
                {
                    var listItem      = (AtkComponentNode *)listNodeList[i];
                    var listItemNodes = listItem->Component->UldManager.NodeList;
                    UiHelper.SetSize(listItem, NewWidth - 40, null);
                    UiHelper.SetSize(listItemNodes[0], NewWidth - 59, null);
                    UiHelper.SetSize(listItemNodes[1], NewWidth - 59, null);
                    UiHelper.SetSize(listItemNodes[2], NewWidth - 40, null);


                    UiHelper.ExpandNodeList(listItem, 2);

                    var newRowItem = (AtkTextNode *)UiHelper.CloneNode(listItemNodes[3]);
                    newRowItem->NodeText.StringPtr = (byte *)UiHelper.Alloc((ulong)newRowItem->NodeText.BufSize);
                    UiHelper.SetText(newRowItem, "Error");
                    newRowItem->AtkResNode.X               = NewWidth - (AddedWidth + 60);
                    newRowItem->AtkResNode.Width           = AddedWidth;
                    newRowItem->AtkResNode.ParentNode      = (AtkResNode *)listItem;
                    newRowItem->AtkResNode.NextSiblingNode = listItemNodes[7];
                    newRowItem->AlignmentFontType          = (byte)AlignmentType.Center;
                    listItemNodes[7]->PrevSiblingNode      = (AtkResNode *)newRowItem;
                    listItem->Component->UldManager.NodeList[listItem->Component->UldManager.NodeListCount++] = (AtkResNode *)newRowItem;

                    var gearsetWarning = (AtkTextNode *)UiHelper.CloneNode(listItemNodes[3]);
                    gearsetWarning->NodeText.StringPtr = (byte *)UiHelper.Alloc((ulong)gearsetWarning->NodeText.BufSize);
                    UiHelper.SetText(gearsetWarning, "?");
                    gearsetWarning->AtkResNode.X               = NewWidth - 80;
                    gearsetWarning->AtkResNode.Width           = 30;
                    gearsetWarning->AtkResNode.ParentNode      = (AtkResNode *)listItem;
                    gearsetWarning->AtkResNode.NextSiblingNode = (AtkResNode *)newRowItem;
                    gearsetWarning->AlignmentFontType          = (byte)AlignmentType.Center;
                    newRowItem->AtkResNode.PrevSiblingNode     = (AtkResNode *)gearsetWarning;
                    listItem->Component->UldManager.NodeList[listItem->Component->UldManager.NodeListCount++] = (AtkResNode *)gearsetWarning;

                    desynthRows.Add((ulong)listItem->Component, new DesynthRow()
                    {
                        SkillTextNode      = newRowItem,
                        GearsetWarningNode = gearsetWarning,
                        CollisionNode      = (AtkCollisionNode *)listItemNodes[0],
                    });
                }
            }
        }