private void AddCastTimeTextNode(AtkUnitBase *unit, AtkTextNode *cloneTextNode, bool visible = false) { var textNode = (AtkTextNode *)GetNodeById(unit, TargetCastNodeId); if (textNode == null) { textNode = UiHelper.CloneNode(cloneTextNode); textNode->AtkResNode.NodeID = TargetCastNodeId; var newStrPtr = Common.Alloc(512); textNode->NodeText.StringPtr = (byte *)newStrPtr; textNode->NodeText.BufSize = 512; textNode->SetText(""); UiHelper.ExpandNodeList(unit, 1); unit->UldManager.NodeList[unit->UldManager.NodeListCount++] = (AtkResNode *)textNode; var nextNode = (AtkResNode *)cloneTextNode; while (nextNode->PrevSiblingNode != null) { nextNode = nextNode->PrevSiblingNode; } textNode->AtkResNode.ParentNode = nextNode->ParentNode; textNode->AtkResNode.ChildNode = null; textNode->AtkResNode.NextSiblingNode = nextNode; textNode->AtkResNode.PrevSiblingNode = null; nextNode->PrevSiblingNode = (AtkResNode *)textNode; nextNode->ParentNode->ChildCount += 1; } if (!visible) { UiHelper.Hide(textNode); } else { textNode->AlignmentFontType = (byte)(0x26 + (byte)LoadedConfig.CastTimeAlignment); textNode->AtkResNode.Height = (ushort)LoadedConfig.TimerOffset; //UiHelper.SetPosition(textNode, PluginConfig.UiAdjustments.ShiftTargetCastBarText.CastTimeOffsetX, // PluginConfig.UiAdjustments.ShiftTargetCastBarText.CastTimeOffsetY); //UiHelper.SetSize(textNode, cloneTextNode->AtkResNode.Width, cloneTextNode->AtkResNode.Height); textNode->FontSize = 15;//(byte) PluginConfig.UiAdjustments.ShiftTargetCastBarText.CastTimeFontSize; textNode->SetText(GetTargetCastTime().ToString("00.00")); UiHelper.Show(textNode); } }
private void FrameworkOnUpdateSetup(Framework framework) { try { var parameterWidget = Common.GetUnitBase("_ParameterWidget"); if (parameterWidget == null) { return; } if (parameterWidget->UldManager.LoadedState != 3) { return; } if (!parameterWidget->IsVisible) { return; } var hpGaugeBar = ((AtkComponentNode *)parameterWidget->UldManager.NodeList[2]); var hpNineGrid = (AtkNineGridNode *)hpGaugeBar->Component->UldManager.NodeList[3]; if (hpGaugeBar->Component->UldManager.NodeListCount == 7) { // Create Nodes UiHelper.ExpandNodeList(hpGaugeBar, 2); shieldGrid = UiHelper.CloneNode(hpNineGrid); //shieldGrid->AtkResNode.NodeID = NodeSlideCastMarker; hpGaugeBar->Component->UldManager.NodeList[6]->PrevSiblingNode = (AtkResNode *)shieldGrid; shieldGrid->AtkResNode.NextSiblingNode = hpGaugeBar->Component->UldManager.NodeList[6]; shieldGrid->AtkResNode.ParentNode = (AtkResNode *)hpGaugeBar; hpGaugeBar->Component->UldManager.NodeList[hpGaugeBar->Component->UldManager.NodeListCount++] = (AtkResNode *)shieldGrid; shieldGrid->AtkResNode.MultiplyRed = 255; shieldGrid->AtkResNode.MultiplyGreen = 255; shieldGrid->AtkResNode.MultiplyBlue = 0; shieldGrid->AtkResNode.AddRed = ushort.MaxValue; shieldGrid->AtkResNode.AddGreen = ushort.MaxValue; shieldGrid->AtkResNode.AddBlue = ushort.MaxValue; shieldGrid->PartID = 5; shieldGrid->AtkResNode.Width = 0; shieldGrid->AtkResNode.Flags_2 |= 1; shieldGridOver = UiHelper.CloneNode(hpNineGrid); shieldGrid->AtkResNode.PrevSiblingNode = (AtkResNode *)shieldGridOver; shieldGridOver->AtkResNode.NextSiblingNode = (AtkResNode *)shieldGrid; shieldGridOver->AtkResNode.ParentNode = (AtkResNode *)hpGaugeBar; hpGaugeBar->Component->UldManager.NodeList[hpGaugeBar->Component->UldManager.NodeListCount++] = (AtkResNode *)shieldGridOver; shieldGridOver->AtkResNode.MultiplyRed = 255; shieldGridOver->AtkResNode.MultiplyGreen = 255; shieldGridOver->AtkResNode.MultiplyBlue = 0; shieldGridOver->AtkResNode.AddRed = ushort.MaxValue; shieldGridOver->AtkResNode.AddGreen = ushort.MaxValue; shieldGridOver->AtkResNode.AddBlue = ushort.MaxValue; shieldGridOver->PartID = 5; shieldGridOver->AtkResNode.Width = 0; shieldGridOver->AtkResNode.Flags_2 |= 1; } shieldGrid = (AtkNineGridNode *)hpGaugeBar->Component->UldManager.NodeList[7]; shieldGridOver = (AtkNineGridNode *)hpGaugeBar->Component->UldManager.NodeList[8]; Service.Framework.Update -= FrameworkOnUpdateSetup; Service.Framework.Update += FrameworkOnUpdate; } catch (Exception ex) { SimpleLog.Error(ex); } }
public void UpdateCastBar(bool reset = false) { var castBar = Common.GetUnitBase <AddonCastBar>(); if (castBar == null) { return; } if (castBar->AtkUnitBase.UldManager.NodeList == null || castBar->AtkUnitBase.UldManager.NodeListCount < 12) { return; } var barNode = castBar->AtkUnitBase.UldManager.NodeList[3]; var icon = (AtkComponentNode *)castBar->AtkUnitBase.UldManager.NodeList[7]; var countdownText = (AtkTextNode *)castBar->AtkUnitBase.UldManager.NodeList[8]; var castingText = (AtkTextNode *)castBar->AtkUnitBase.UldManager.NodeList[9]; var skillNameText = (AtkTextNode *)castBar->AtkUnitBase.UldManager.NodeList[11]; var progressBar = (AtkNineGridNode *)castBar->AtkUnitBase.UldManager.NodeList[5]; var interruptedText = (AtkTextNode *)castBar->AtkUnitBase.UldManager.NodeList[12]; var slideMarker = (AtkNineGridNode *)null; for (var i = 13; i < castBar->AtkUnitBase.UldManager.NodeListCount; i++) { if (castBar->AtkUnitBase.UldManager.NodeList[i]->NodeID == CustomNodes.SlideCastMarker) { slideMarker = (AtkNineGridNode *)castBar->AtkUnitBase.UldManager.NodeList[i]; break; } } if (reset) { UiHelper.Show(icon); UiHelper.Show(countdownText); UiHelper.Show(castingText); UiHelper.Show(skillNameText); UiHelper.SetSize(skillNameText, 170, null); UiHelper.SetPosition(skillNameText, barNode->X + 4, null); UiHelper.SetSize(countdownText, 42, null); UiHelper.SetPosition(countdownText, 170, null); interruptedText->AtkResNode.SetScale(1, 1); if (slideMarker != null) { UiHelper.Hide(slideMarker); } countdownText->AlignmentFontType = 0x25; skillNameText->AlignmentFontType = 0x03; return; } if (Config.RemoveIcon) { UiHelper.Hide(icon); } if (Config.RemoveName) { UiHelper.Hide(skillNameText); } if (Config.RemoveCounter) { UiHelper.Hide(countdownText); } if (Config.RemoveCastingText) { UiHelper.Hide(castingText); } if (Config.RemoveCastingText && !Config.RemoveCounter) { countdownText->AlignmentFontType = (byte)(0x20 | (byte)Config.AlignCounter); UiHelper.SetSize(countdownText, barNode->Width - 8, null); UiHelper.SetPosition(countdownText, (barNode->X + 4) + Config.OffsetCounterPosition, null); } else { countdownText->AlignmentFontType = (byte)(0x20 | (byte)Alignment.Right); UiHelper.SetSize(countdownText, 42, null); UiHelper.SetPosition(countdownText, 170, null); } if (!Config.RemoveName) { skillNameText->AlignmentFontType = (byte)(0x00 | (byte)Config.AlignName); UiHelper.SetPosition(skillNameText, (barNode->X + 4) + Config.OffsetNamePosition, null); UiHelper.SetSize(skillNameText, barNode->Width - 8, null); } if (Config.RemoveInterruptedText) { interruptedText->AtkResNode.SetScale(0, 0); } if (Config.SlideCast) { if (slideMarker == null) { // Create Node UiHelper.ExpandNodeList((AtkUnitBase *)castBar, 1); slideMarker = UiHelper.CloneNode(progressBar); slideMarker->AtkResNode.NodeID = CustomNodes.SlideCastMarker; castBar->AtkUnitBase.UldManager.NodeList[6]->PrevSiblingNode = (AtkResNode *)slideMarker; slideMarker->AtkResNode.NextSiblingNode = castBar->AtkUnitBase.UldManager.NodeList[6]; slideMarker->AtkResNode.ParentNode = castBar->AtkUnitBase.UldManager.NodeList[3]; castBar->AtkUnitBase.UldManager.NodeList[castBar->AtkUnitBase.UldManager.NodeListCount++] = (AtkResNode *)slideMarker; } if (slideMarker != null) { var slidePer = ((float)(castBar->CastTime * 10) - Config.SlideCastAdjust) / (castBar->CastTime * 10); var pos = 160 * slidePer; UiHelper.Show(slideMarker); UiHelper.SetSize(slideMarker, 168 - (int)pos, 20); UiHelper.SetPosition(slideMarker, pos - 8, 0); var c = (slidePer * 100) >= castBar->CastPercent ? Config.SlideCastColor : Config.SlideCastReadyColor; slideMarker->AtkResNode.AddRed = (byte)(255 * c.X); slideMarker->AtkResNode.AddGreen = (byte)(255 * c.Y); slideMarker->AtkResNode.AddBlue = (byte)(255 * c.Z); slideMarker->AtkResNode.MultiplyRed = (byte)(255 * c.X); slideMarker->AtkResNode.MultiplyGreen = (byte)(255 * c.Y); slideMarker->AtkResNode.MultiplyBlue = (byte)(255 * c.Z); slideMarker->AtkResNode.Color.A = (byte)(255 * c.W); slideMarker->PartID = 0; slideMarker->AtkResNode.Flags_2 |= 1; } } }
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], }); } } }
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(""); } }
private void UpdateGaugeBar(AtkComponentNode *gauge, AtkTextNode *cloneTextNode, Actor target, Vector2 positionOffset, bool reset = false) { if (gauge == null || (ushort)gauge->AtkResNode.Type < 1000) { 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 == TargetHPNodeID) { textNode = (AtkTextNode *)node; break; } } if (textNode == null && reset) { return; // Nothing to clean } if (textNode == null) { textNode = UiHelper.CloneNode(cloneTextNode); textNode->AtkResNode.NodeID = TargetHPNodeID; var newStrPtr = Common.Alloc(512); textNode->NodeText.StringPtr = (byte *)newStrPtr; textNode->NodeText.BufSize = 512; UiHelper.SetText(textNode, ""); 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); textNode->TextColor = cloneTextNode->TextColor; textNode->EdgeColor = cloneTextNode->EdgeColor; if (target is Chara chara) { UiHelper.SetText(textNode, $"{FormatNumber(chara.CurrentHp)}/{FormatNumber(chara.MaxHp)}"); } else { UiHelper.SetText(textNode, ""); } }