public WorldTravelSelect(AtkUnitBase *address) { UnitBase = address; try { RootNode = UnitBase->RootNode; if (RootNode == null) { return; } WindowComponent = (AtkComponentNode *)RootNode->ChildNode; InformationBox = (AtkComponentNode *)WindowComponent->AtkResNode.PrevSiblingNode; InformationBoxBorder = (AtkNineGridNode *)InformationBox->AtkResNode.PrevSiblingNode; WorldListComponent = (AtkComponentNode *)InformationBoxBorder->AtkResNode.PrevSiblingNode; WorldListHeader = (AtkTextNode *)WorldListComponent->AtkResNode.PrevSiblingNode; CurrentWorldContainer = WorldListHeader->AtkResNode.PrevSiblingNode; HomeWorldContainer = CurrentWorldContainer->PrevSiblingNode; WorldInfoHeader = (AtkTextNode *)HomeWorldContainer->PrevSiblingNode; CurrentWorldName = (AtkTextNode *)CurrentWorldContainer->ChildNode; CurrentWorldHeaderUnderline = (AtkNineGridNode *)CurrentWorldName->AtkResNode.PrevSiblingNode; CurrentWorldHeader = (AtkTextNode *)CurrentWorldHeaderUnderline->AtkResNode.PrevSiblingNode; CurrentWorldIcon = (AtkImageNode *)CurrentWorldHeader->AtkResNode.PrevSiblingNode; IsValid = true; } catch (Exception ex) { SimpleLog.Error(ex); IsValid = false; } }
private void SetHp(AtkTextNode *node, MemberData member) { var se = new SeString(new List <Payload>()); if (member.CurrentHP == 1) { se.Payloads.Add(new TextPayload("1")); } else if (member.MaxHp == 1) { se.Payloads.Add(new TextPayload("???")); } else { se.Payloads.Add(new TextPayload((member.CurrentHP * 100 / member.MaxHp).ToString())); if (member.ShieldPercent != 0) { UIForegroundPayload uiYellow = new(559); UIForegroundPayload uiNoColor = new(0); se.Payloads.Add(new TextPayload("+")); se.Payloads.Add(uiYellow); se.Payloads.Add(new TextPayload(member.ShieldPercent.ToString())); se.Payloads.Add(uiNoColor); } se.Payloads.Add(new TextPayload("%")); } Plugin.Common.WriteSeString(node->NodeText, se); }
private long FocusUpdateDelegate(long a1, long a2, long a3) { var ret = focusUpdateHook.Original(a1, a2, a3); focusTextNode = (AtkTextNode *)((AtkUnitBase *)a1)->UldManager.NodeList[10]; UpdateFocus(); return(ret); }
private void SetName(AtkTextNode *node, string payload) { if (node == null || payload == string.Empty) { return; } Plugin.Common.WriteSeString(node->NodeText, payload); }
private unsafe void SetTextDetour(AtkTextNode *self, byte *strPtr) { if (self == textNodePtr) { return; // Block update of Time String } setTextHook.Original(self, strPtr); }
public static void SetText(AtkTextNode *textNode, string str) { if (!Ready) { return; } var seStr = new SeString(new Payload[] { new TextPayload(str) }); SetText(textNode, seStr); }
private void TargetUpdateDelegate(long a1, long a2, long a3) { targetUpdateHook.Original(a1, a2, a3); var targetUi = (AtkUnitBase *)a1; if (!targetUi->IsVisible) { return; } tTextNode = (AtkTextNode *)targetUi->UldManager.NodeList[39]; ttTextNode = (AtkTextNode *)targetUi->UldManager.NodeList[49]; UpdateTarget(); }
private void MainTargetUpdateDelegate(long a1, long a2, long a3) { mainTargetUpdateHook.Original(a1, a2, a3); var mainTargetUi = (AtkUnitBase *)a1; if (!mainTargetUi->IsVisible) { return; } tTextNode = (AtkTextNode *)mainTargetUi->UldManager.NodeList[8]; ttTextNode = (AtkTextNode *)mainTargetUi->UldManager.NodeList[12]; UpdateTarget(); }
public static void SetText(AtkTextNode *textNode, SeString str) { if (!Ready) { return; } var bytes = str.Encode(); var ptr = Marshal.AllocHGlobal(bytes.Length + 1); Marshal.Copy(bytes, 0, ptr, bytes.Length); Marshal.WriteByte(ptr, bytes.Length, 0); _atkTextNodeSetText(textNode, (byte *)ptr); Marshal.FreeHGlobal(ptr); }
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); } }
public static unsafe AtkTextNode *CloneNode(AtkTextNode *original, bool autoInsert = true) { var newAllocation = Common.Alloc((ulong)sizeof(AtkTextNode)); var bytes = new byte[sizeof(AtkTextNode)]; Marshal.Copy(new IntPtr(original), bytes, 0, bytes.Length); Marshal.Copy(bytes, 0, newAllocation, bytes.Length); var newNode = (AtkTextNode *)newAllocation; newNode->AtkResNode.NextSiblingNode = (AtkResNode *)original; original->AtkResNode.PrevSiblingNode = (AtkResNode *)newNode; if (newNode->AtkResNode.PrevSiblingNode != null) { newNode->AtkResNode.NextSiblingNode = (AtkResNode *)newNode; } newNode->AtkResNode.ParentNode->ChildCount += 1; return(newNode); }
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(""); } }
/// <summary> /// Initializes a new instance of the <see cref="DtrBarEntry"/> class. /// </summary> /// <param name="title">The title of the bar entry.</param> /// <param name="textNode">The corresponding text node.</param> internal DtrBarEntry(string title, AtkTextNode *textNode) { this.Title = title; this.TextNode = textNode; }
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, ""); } }
public static void Show(AtkTextNode *node) => Show((AtkResNode *)node);
public static void SetSize(AtkTextNode *node, int?w, int?h) => SetSize((AtkResNode *)node, w, h);
public static void SetPosition(AtkTextNode *node, float?x, float?y) => SetPosition((AtkResNode *)node, x, y);
public static AtkTextNode *CloneNode(AtkTextNode *node) => (AtkTextNode *)CloneNode((AtkResNode *)node);
public static void Hide(AtkTextNode *node) => Hide((AtkResNode *)node);
public void Draw() { if (!IsVisible) { return; } var mobData = DataHandler.Mobs(TargetData.NameID); if (mobData == null) { return; } // Get Floor number so that the MobData tips can be tailored down the line for more dangerous floors int? floorLowerBound = null; int? floorUpperBound = null; bool InDeepDungeon = this.pluginInterface.ClientState.Condition[Dalamud.Game.ClientState.ConditionFlag.InDeepDungeon]; var windowTitle = "cool strati window"; if (InDeepDungeon) { unsafe { AtkUnitBase * _ToDoListBasePtr = (AtkUnitBase *)pluginInterface.Framework.Gui.GetUiObjectByName("_ToDoList", 1); AtkComponentNode *_ToDoListComponentPtr = (AtkComponentNode *)_ToDoListBasePtr->RootNode->ChildNode->PrevSiblingNode->PrevSiblingNode->PrevSiblingNode->PrevSiblingNode->PrevSiblingNode->PrevSiblingNode->PrevSiblingNode->PrevSiblingNode; AtkTextNode * dutyNamePtr = (AtkTextNode *)((_ToDoListComponentPtr->Component)->ULDData.RootNode->PrevSiblingNode->PrevSiblingNode->PrevSiblingNode->PrevSiblingNode->PrevSiblingNode->PrevSiblingNode->PrevSiblingNode->PrevSiblingNode->PrevSiblingNode->PrevSiblingNode); string dutyNameStr = Marshal.PtrToStringAnsi(new IntPtr(dutyNamePtr->NodeText.StringPtr)); string[] aDutyName = String.Join("", String.Join("", dutyNameStr.Split(')')).Split('(')).Split(' '); aDutyName = aDutyName[aDutyName.Length - 1].Split('-'); floorLowerBound = int.Parse(aDutyName[0]); floorUpperBound = int.Parse(aDutyName[1]); } } var flags = ImGuiWindowFlags.NoResize | ImGuiWindowFlags.AlwaysAutoResize | ImGuiWindowFlags.NoTitleBar; //var flags = ImGuiWindowFlags.NoScrollbar; if (config.IsClickthrough) { flags |= ImGuiWindowFlags.NoInputs; } ImGui.SetNextWindowSizeConstraints(new Vector2(250, 0), new Vector2(9001, 9001)); ImGui.SetNextWindowBgAlpha(config.Opacity); if (InDeepDungeon) { windowTitle += " (Floors " + floorLowerBound + "-" + floorUpperBound + ")"; } ImGui.Begin(windowTitle, flags); ImGui.Text(TargetData.Name); ImGui.PopTextWrapPos(); ImGui.SameLine(); ImGui.Text("( "); ImGui.SameLine(); // Special details column: Undead, Patrol, Blood Aggro, etc ImGui.PushFont(UiBuilder.IconFont); ImGui.Text(DataHandler.MobData.AggroTypeExtra[mobData.Aggro][0]); ImGui.PopFont(); if (ImGui.IsItemHovered()) { ImGui.BeginTooltip(); ImGui.PushTextWrapPos(400f); ImGui.TextWrapped(DataHandler.MobData.AggroTypeExtra[mobData.Aggro][1]); ImGui.PopTextWrapPos(); ImGui.EndTooltip(); } ImGui.SameLine(); if (mobData.IsPatrol) { ImGui.PushFont(UiBuilder.IconFont); ImGui.PushStyleColor(ImGuiCol.Text, 0xFF1249FF); ImGui.Text(FontAwesomeIcon.Walking.ToIconString()); ImGui.PopStyleColor(); ImGui.PopFont(); if (ImGui.IsItemHovered()) { ImGui.BeginTooltip(); ImGui.PushTextWrapPos(400f); ImGui.TextWrapped("Enemy is a patrol unit.\nDon't let it creep up on you!"); ImGui.PopTextWrapPos(); ImGui.EndTooltip(); } ImGui.SameLine(); } if (mobData.IsUndead) { ImGui.PushFont(UiBuilder.IconFont); ImGui.PushStyleColor(ImGuiCol.Text, 0xFFFF00FF); ImGui.Text(FontAwesomeIcon.Ghost.ToIconString()); ImGui.PopStyleColor(); ImGui.PopFont(); if (ImGui.IsItemHovered()) { ImGui.BeginTooltip(); ImGui.PushTextWrapPos(400f); ImGui.TextWrapped("Enemy type is Undead.\nWeak to Pomander of Resolution."); ImGui.PopTextWrapPos(); ImGui.EndTooltip(); } ImGui.SameLine(); } if (mobData.IsBloodAggro) { ImGui.PushFont(UiBuilder.IconFont); ImGui.PushStyleColor(ImGuiCol.Text, 0xFF2300AF); ImGui.Text(FontAwesomeIcon.Tint.ToIconString()); ImGui.PopStyleColor(); ImGui.PopFont(); if (ImGui.IsItemHovered()) { ImGui.BeginTooltip(); ImGui.PushTextWrapPos(400f); ImGui.TextWrapped("Enemy will aggro if your HP isn't topped up."); ImGui.PopTextWrapPos(); ImGui.EndTooltip(); } ImGui.SameLine(); } ImGui.Text(" )"); ImGui.NewLine(); ImGui.NewLine(); ImGui.Columns(3, null, false); ImGui.Text("Aggro Type:\n"); ImGui.PushStyleColor(ImGuiCol.Text, 0xFFB0B0B0); ImGui.Text(mobData.Aggro.ToString()); ImGui.PopStyleColor(); ImGui.NextColumn(); ImGui.Text("Threat:\n"); switch (mobData.Threat) { case DataHandler.MobData.ThreatLevel.Easy: ImGui.PushStyleColor(ImGuiCol.Text, 0xFF00FF00); ImGui.Text("Easy"); ImGui.PopStyleColor(); break; case DataHandler.MobData.ThreatLevel.Caution: ImGui.PushStyleColor(ImGuiCol.Text, 0xFFFF003C); ImGui.Text("Caution"); ImGui.PopStyleColor(); break; case DataHandler.MobData.ThreatLevel.Dangerous: ImGui.PushStyleColor(ImGuiCol.Text, 0xFF0000FF); ImGui.Text("Dangerous"); ImGui.PopStyleColor(); break; case DataHandler.MobData.ThreatLevel.Vicious: ImGui.PushStyleColor(ImGuiCol.Text, 0xFFFF00FF); ImGui.Text("Vicious"); ImGui.PopStyleColor(); break; default: ImGui.Text("Undefined"); break; } ImGui.NextColumn(); ImGui.Text("Can stun:\n"); switch (mobData.IsStunnable) { case true: ImGui.PushStyleColor(ImGuiCol.Text, 0xFF00FF00); ImGui.Text("Yes"); ImGui.PopStyleColor(); break; case false: ImGui.PushStyleColor(ImGuiCol.Text, 0xFF0000FF); ImGui.Text("No"); ImGui.PopStyleColor(); break; default: ImGui.PushStyleColor(ImGuiCol.Text, 0xFF919191); ImGui.Text("Untested"); ImGui.PopStyleColor(); break; } ImGui.NextColumn(); ImGui.Columns(1); ImGui.NewLine(); ImGui.TextWrapped(mobData.MobNotes); ImGui.End(); }
public static void SetScale(AtkTextNode *node, float?scaleX, float?scaleY) => SetScale((AtkResNode *)node, scaleX, scaleY);