Exemple #1
0
        private void OnBuildUi_Debug()
        {
            if (isImguiDebugOpen)
            {
                ImGui.SetNextWindowSize(new Vector2(500, 500), ImGuiCond.FirstUseEver);
                if (ImGui.Begin("JobIcons Debug", ref isImguiDebugOpen))
                {
                    ImGui.PushItemWidth(-1);

                    if (ImGui.CollapsingHeader("PartyMembers"))
                    {
                        var headers = new string[] { "Address", "ActorID", "Name", "IsLocalPlayer", "IsParty", "isPC" };
                        var sizes   = new float[headers.Length];

                        ImGui.Columns(headers.Length);
                        for (int i = 0; i < headers.Length; i++)
                        {
                            DebugTableCell(headers[i], sizes);
                        }

                        ImGui.Separator();

                        foreach (var actor in plugin.Interface.ClientState.Actors)
                        {
                            var isLocalPlayer = XivApi.IsLocalPlayer(actor.ActorId);
                            var isParty       = XivApi.IsPartyMember(actor.ActorId);
                            var isPC          = actor is Dalamud.Game.ClientState.Actors.Types.PlayerCharacter;
                            if (isLocalPlayer || isParty)
                            {
                                DebugTableCell($"0x{actor.Address.ToInt64():X}", sizes);
                                DebugTableCell(actor.ActorId.ToString(), sizes);
                                DebugTableCell(actor.Name, sizes);
                                DebugTableCell(isLocalPlayer.ToString(), sizes);
                                DebugTableCell(isParty.ToString(), sizes);
                                DebugTableCell(isPC.ToString(), sizes);
                            }
                        }

                        for (int i = 0; i < sizes.Length; i++)
                        {
                            ImGui.SetColumnWidth(i, sizes[i] + 20);
                        }

                        ImGui.Columns(1);
                        ImGui.NewLine();
                    }

                    if (ImGui.CollapsingHeader("NamePlateObjects"))
                    {
                        var addon = XivApi.GetSafeAddonNamePlate();
                        if (addon.Pointer == IntPtr.Zero)
                        {
                            ImGui.Text("Addon not available");
                            ImGui.NewLine();
                        }
                        else
                        {
                            var headers = new string[] {
                                "Index",
                                "npObj", "Visible", "isLocalPlayer", "Layer", "XAdjust", "YAdjust", "XPos", "YPos", "XScale", "YScale", "Type",
                                "npInfo", "ActorID", "Name", "isPC", "isParty", "isAlliance", "JobID", "PrefixTitle", "Title", "FcName", "LevelText"
                            };
                            var sizes = new float[headers.Length];

                            ImGui.Columns(headers.Length);

                            for (int i = 0; i < headers.Length; i++)
                            {
                                DebugTableCell(headers[i], sizes);
                            }

                            ImGui.Separator();

                            for (int i = 0; i < 50; i++)
                            {
                                var npObject = addon.GetNamePlateObject(i);
                                if (npObject == null)
                                {
                                    for (int c = 0; c < headers.Length; c++)
                                    {
                                        DebugTableCell("npObj=null", sizes);
                                    }
                                    continue;
                                }

                                var npInfo = npObject.NamePlateInfo;
                                if (npInfo == null)
                                {
                                    for (int c = 0; c < headers.Length; c++)
                                    {
                                        DebugTableCell("npInfo=null", sizes);
                                    }
                                    continue;
                                }

                                var    imageNode = npObject.IconImageNode;
                                string imageX, imageY, scaleX, scaleY;

                                imageX = imageNode.AtkResNode.X.ToString();
                                imageY = imageNode.AtkResNode.Y.ToString();
                                scaleX = imageNode.AtkResNode.ScaleX.ToString();
                                scaleY = imageNode.AtkResNode.ScaleY.ToString();

                                DebugTableCell(i.ToString(), sizes);
                                DebugTableCell($"0x{npObject.Pointer.ToInt64():X}", sizes);
                                DebugTableCell(npObject.IsVisible.ToString(), sizes);
                                DebugTableCell(npObject.IsLocalPlayer.ToString(), sizes);
                                DebugTableCell(npObject.Data.Layer.ToString(), sizes);
                                DebugTableCell(npObject.Data.IconXAdjust.ToString(), sizes);
                                DebugTableCell(npObject.Data.IconYAdjust.ToString(), sizes);
                                DebugTableCell(imageX, sizes);
                                DebugTableCell(imageY, sizes);
                                DebugTableCell(scaleX, sizes);
                                DebugTableCell(scaleY, sizes);
                                DebugTableCell(npObject.Data.NameplateKind.ToString(), sizes);

                                DebugTableCell($"0x{npInfo.Pointer.ToInt64():X}", sizes);
                                DebugTableCell(npInfo.Data.ActorID.ToString(), sizes);
                                DebugTableCell(npInfo.Name, sizes);
                                DebugTableCell(XivApi.IsPlayerCharacter(npInfo.Data.ActorID).ToString(), sizes);
                                DebugTableCell(XivApi.IsPartyMember(npInfo.Data.ActorID).ToString(), sizes);
                                DebugTableCell(XivApi.IsAllianceMember(npInfo.Data.ActorID).ToString(), sizes);
                                DebugTableCell(XivApi.GetJobId(npInfo.Data.ActorID).ToString(), sizes);
                                DebugTableCell(npInfo.Data.IsPrefixTitle.ToString(), sizes);
                                DebugTableCell(npInfo.Title, sizes);
                                DebugTableCell(npInfo.FcName, sizes);
                                DebugTableCell(npInfo.LevelText, sizes);
                            }

                            for (int i = 0; i < sizes.Length; i++)
                            {
                                ImGui.SetColumnWidth(i, sizes[i] + 20);
                            }

                            ImGui.Columns(1);
                            ImGui.NewLine();
                        }
                    }

                    ImGui.PopItemWidth();
                }
                ImGui.End();
            }
        }
Exemple #2
0
        private void UpdateNamePlates()
        {
            // So this doesn't work quite... exactly. Something else updates the NamePlate
            // and resizes things which makes this cause objects to jump around.

            if (Configuration.Enabled)
            {
                var addon = XivApi.GetSafeAddonNamePlate();
                for (int i = 0; i < 50; i++)
                {
                    var npObject = addon.GetNamePlateObject(i);
                    if (npObject == null || !npObject.IsVisible)
                    {
                        continue;
                    }

                    var npInfo = npObject.NamePlateInfo;
                    if (npInfo == null)
                    {
                        continue;
                    }

                    var actorID = npInfo.Data.ActorID;
                    if (actorID == -1)
                    {
                        continue;
                    }

                    if (!npInfo.IsPlayerCharacter())  // Only PlayerCharacters can have icons
                    {
                        continue;
                    }

                    var jobID = npInfo.GetJobID();
                    if (jobID < 1 || jobID >= Enum.GetValues(typeof(Job)).Length)
                    {
                        continue;
                    }

                    var isLocalPlayer    = XivApi.IsLocalPlayer(actorID);
                    var isPartyMember    = XivApi.IsLocalPlayer(actorID);
                    var isAllianceMember = XivApi.IsAllianceMember(actorID);

                    var updateLocalPlayer    = Configuration.SelfIcon && isLocalPlayer;
                    var updatePartyMember    = Configuration.PartyIcons && isPartyMember;
                    var updateAllianceMember = Configuration.AllianceIcons && isAllianceMember;
                    var updateEveryoneElse   = Configuration.EveryoneElseIcons && !isLocalPlayer && !isPartyMember && !isAllianceMember;

                    if (updateLocalPlayer || updatePartyMember || updateAllianceMember || updateEveryoneElse)
                    {
                        var iconSet = Configuration.GetIconSet(jobID);
                        // var iconID = iconSet.GetIconID(jobID);
                        var scaleMult = iconSet.ScaleMultiplier;

                        npObject.SetIconScale(Configuration.Scale * scaleMult);
                        npObject.SetIconPosition(Configuration.XAdjust, Configuration.YAdjust);

                        //var isPrefixTitle = npInfo.Data.IsPrefixTitle;

                        // I couldn't find this in the NamePlateInfo, it'll fix itself the next time SetNamePlate is called by the game.
                        //var displayTitle = true;


                        // plugin.SetNamePlateDetour(npObject.Pointer, isPrefixTitle, displayTitle, npInfo.TitleAddress, npInfo.NameAddress, npInfo.FcNameAddress, iconID);

                        //var title = Encoding.UTF8.GetBytes(Marshal.PtrToStringAnsi(new IntPtr(npi->DisplayTitle.StringPtr)));
                        //var name = Encoding.UTF8.GetBytes(Marshal.PtrToStringAnsi(new IntPtr(npi->Name.StringPtr)));
                        //var fcName = Encoding.UTF8.GetBytes(Marshal.PtrToStringAnsi(new IntPtr(npi->FcName.StringPtr)));

                        //var titlePtr = Marshal.AllocHGlobal(title.Length + 1);
                        //var namePtr = Marshal.AllocHGlobal(name.Length + 1);
                        //var fcNamePtr = Marshal.AllocHGlobal(fcName.Length + 1);

                        //Marshal.Copy(title, 0, titlePtr, title.Length);
                        //Marshal.Copy(name, 0, namePtr, name.Length);
                        //Marshal.Copy(fcName, 0, fcNamePtr, fcName.Length);

                        //Marshal.WriteByte(titlePtr + title.Length, 0);
                        //Marshal.WriteByte(namePtr + name.Length, 0);
                        //Marshal.WriteByte(fcNamePtr + fcName.Length, 0);

                        //plugin.SetNamePlateDetour(npObject.Pointer, isPrefixTitle, displayTitle, titlePtr, namePtr, fcNamePtr, iconID);

                        //Marshal.FreeHGlobal(titlePtr);
                        //Marshal.FreeHGlobal(namePtr);
                        //Marshal.FreeHGlobal(fcNamePtr);
                    }
                }
            }
        }
Exemple #3
0
 public bool IsAllianceMember() => XivApi.IsAllianceMember(Data.ActorID);