示例#1
0
        private void UpdateMainTargetSplit(AtkUnitBase *unitBase, GameObject target, bool reset = false)
        {
            if (unitBase == null || unitBase->UldManager.NodeList == null || unitBase->UldManager.NodeListCount < 9)
            {
                return;
            }
            var gauge    = (AtkComponentNode *)unitBase->UldManager.NodeList[5];
            var textNode = (AtkTextNode *)unitBase->UldManager.NodeList[8];

            UiHelper.SetSize(unitBase->UldManager.NodeList[6], reset ? 44 : 0, reset ? 20 : 0);
            UpdateGaugeBar(gauge, textNode, target, Config.Position, Config.UseCustomColor ? Config.CustomColor : null, Config.FontSize, reset);
        }
示例#2
0
        private void UpdateFocusTarget(AtkUnitBase *unitBase, GameObject target, bool reset = false)
        {
            if (Config.NoFocus)
            {
                reset = true;
            }
            if (unitBase == null || unitBase->UldManager.NodeList == null || unitBase->UldManager.NodeListCount < 11)
            {
                return;
            }
            var gauge    = (AtkComponentNode *)unitBase->UldManager.NodeList[2];
            var textNode = (AtkTextNode *)unitBase->UldManager.NodeList[10];

            UpdateGaugeBar(gauge, textNode, target, Config.FocusPosition, Config.FocusUseCustomColor ? Config.FocusCustomColor : null, Config.FocusFontSize, reset);
        }
示例#3
0
        private void UpdateGaugeBar(AtkComponentNode *gauge, AtkTextNode *cloneTextNode, GameObject target, Vector2 positionOffset, Vector4?customColor, byte fontSize, bool reset = false)
        {
            if (gauge == null || (ushort)gauge->AtkResNode.Type < 1000 || Service.ClientState.LocalPlayer == null)
            {
                return;
            }

            AtkTextNode *textNode = null;

            for (var i = 5; i < gauge->Component->UldManager.NodeListCount; i++)
            {
                var node = gauge->Component->UldManager.NodeList[i];
                if (node->Type == NodeType.Text && node->NodeID == CustomNodes.TargetHP)
                {
                    textNode = (AtkTextNode *)node;
                    break;
                }
            }

            if (textNode == null && reset)
            {
                return;                            // Nothing to clean
            }
            if (textNode == null)
            {
                textNode = UiHelper.CloneNode(cloneTextNode);
                textNode->AtkResNode.NodeID = CustomNodes.TargetHP;
                var newStrPtr = Common.Alloc(512);
                textNode->NodeText.StringPtr = (byte *)newStrPtr;
                textNode->NodeText.BufSize   = 512;
                textNode->SetText("");
                UiHelper.ExpandNodeList(gauge, 1);
                gauge->Component->UldManager.NodeList[gauge->Component->UldManager.NodeListCount++] = (AtkResNode *)textNode;

                var nextNode = gauge->Component->UldManager.RootNode;
                while (nextNode->PrevSiblingNode != null)
                {
                    nextNode = nextNode->PrevSiblingNode;
                }

                textNode->AtkResNode.ParentNode      = (AtkResNode *)gauge;
                textNode->AtkResNode.ChildNode       = null;
                textNode->AtkResNode.PrevSiblingNode = null;
                textNode->AtkResNode.NextSiblingNode = nextNode;
                nextNode->PrevSiblingNode            = (AtkResNode *)textNode;
            }

            if (reset)
            {
                UiHelper.Hide(textNode);
                return;
            }

            textNode->AlignmentFontType = (byte)AlignmentType.BottomRight;

            UiHelper.SetPosition(textNode, positionOffset.X, positionOffset.Y);
            UiHelper.SetSize(textNode, gauge->AtkResNode.Width - 5, gauge->AtkResNode.Height);
            UiHelper.Show(textNode);
            if (!customColor.HasValue)
            {
                textNode->TextColor = cloneTextNode->TextColor;
            }
            else
            {
                textNode->TextColor.A = (byte)(customColor.Value.W * 255);
                textNode->TextColor.R = (byte)(customColor.Value.X * 255);
                textNode->TextColor.G = (byte)(customColor.Value.Y * 255);
                textNode->TextColor.B = (byte)(customColor.Value.Z * 255);
            }
            textNode->EdgeColor = cloneTextNode->EdgeColor;
            textNode->FontSize  = fontSize;


            if (target is Character chara)
            {
                var y = "";
                if (Config.EnableDistance)
                {
                    Vector3 me  = Service.ClientState.LocalPlayer.Position;
                    Vector3 tar = chara.Position;
                    y += "  " + Vector3.Distance(me, tar).ToString("00.0");
                }
                if (Config.EnableEffectiveDistance)
                {
                    y += "  " + target.YalmDistanceX.ToString();
                }
                textNode->SetText($"{FormatNumber(chara.CurrentHp)}/{FormatNumber(chara.MaxHp)}" + y);
            }
            else
            {
                textNode->SetText("");
            }
        }