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;
                }
            }
            public void TrySort()
            {
                var nodeList = (AtkComponentNode **)WorldListComponent->Component->UldManager.NodeList;

                var c     = 0;
                var nodes = new AtkComponentNode *[18];
                var names = new string[nodes.Length];

                for (var i = 0; i < nodes.Length; i++)
                {
                    var n = nodeList[i + 3];
                    if (n->AtkResNode.Y == 0)
                    {
                        continue;
                    }
                    var nameNode = (AtkTextNode *)n->Component->UldManager.NodeList[4];
                    var name     = Helper.Common.PtrToUTF8(new IntPtr(nameNode->NodeText.StringPtr));
                    names[c]   = name;
                    nodes[c++] = n;
                }

                if (c == 0)
                {
                    return;
                }


                var inserted          = false;
                var currentServerName = Helper.Common.PtrToUTF8(new IntPtr(CurrentWorldName->NodeText.StringPtr));

                for (var i = 0; i < c; i++)
                {
                    if (!inserted)
                    {
                        var s = string.Compare(names[i], currentServerName, StringComparison.InvariantCultureIgnoreCase);
                        if (s > 0)
                        {
                            UiHelper.SetPosition(CurrentWorldContainer, 20, 44 + (i + 1) * 24);
                            inserted = true;
                        }
                    }

                    if (!inserted)
                    {
                        continue;
                    }
                    nodes[i]->AtkResNode.Y       += 24;
                    nodes[i]->AtkResNode.Flags_2 |= 0x1;
                }

                if (!inserted)
                {
                    UiHelper.SetPosition(CurrentWorldContainer, 20, 44 + (c + 1) * 24);
                }

                UiHelper.SetWindowSize(WindowComponent, null, (ushort)(44 + (c + 3) * 24));
                UiHelper.SetSize(RootNode, null, (ushort)(44 + (c + 3) * 24));
                UiHelper.Show(CurrentWorldContainer);
            }
 private unsafe void ToggleNode(AtkComponentNode *node, bool enable)
 {
     if (enable)
     {
         node->AtkResNode.MultiplyRed   = 0;
         node->AtkResNode.MultiplyGreen = 100;
         node->AtkResNode.MultiplyBlue  = 0;
     }
     else
     {
         node->AtkResNode.MultiplyRed   = 100;
         node->AtkResNode.MultiplyGreen = 100;
         node->AtkResNode.MultiplyBlue  = 100;
     }
 }
Exemplo n.º 4
0
 public Pointers(
     TargetSystem *targetSystem,
     float *playerViewTriangleRotation,
     AtkUnitBase *currentSourceBase,
     AtkComponentNode *currentMapIconsRootComponentNode,
     AtkImageNode *weatherIconNode,
     nint naviMapTextureD3D11ShaderResourceView
     )
 {
     TargetSystem    = targetSystem;
     WeatherIconNode = weatherIconNode;
     NaviMapTextureD3D11ShaderResourceView = naviMapTextureD3D11ShaderResourceView;
     CurrentMapIconsRootComponentNode      = currentMapIconsRootComponentNode;
     CurrentSourceBase          = currentSourceBase;
     PlayerViewTriangleRotation = playerViewTriangleRotation;
 }
Exemplo n.º 5
0
        private static void SetDeepdungeonWindow(AtkComponentNode *windowNode, ushort?width, ushort?height)
        {
            width ??= windowNode->AtkResNode.Width;
            height ??= windowNode->AtkResNode.Height;

            var n = windowNode->Component->UldManager.RootNode;

            UiHelper.SetSize(windowNode, width, height); // Window
            UiHelper.SetSize(n, width, height);          // Collision
            n = n->PrevSiblingNode->PrevSiblingNode;
            UiHelper.SetSize(n, width - 2, height - 2);  // Background
            n = n->PrevSiblingNode;
            UiHelper.SetSize(n, width - 2, height - 2);  // Focused Border

            windowNode->AtkResNode.Flags_2 |= 0x1;
        }
Exemplo n.º 6
0
        public static void SetWindowSize(AtkComponentNode *windowNode, ushort?width, ushort?height)
        {
            if (((ULDComponentInfo *)windowNode->Component->UldManager.Objects)->ComponentType != ComponentType.Window)
            {
                return;
            }

            width ??= windowNode->AtkResNode.Width;
            height ??= windowNode->AtkResNode.Height;

            if (width < 64)
            {
                width = 64;
            }

            SetSize(windowNode, width, height);  // Window
            var n = windowNode->Component->UldManager.RootNode;

            SetSize(n, width, height);              // Collision
            n = n->PrevSiblingNode;
            SetSize(n, (ushort)(width - 14), null); // Header Collision
            n = n->PrevSiblingNode;
            SetSize(n, width, height);              // Background
            n = n->PrevSiblingNode;
            SetSize(n, width, height);              // Focused Border
            n = n->PrevSiblingNode;
            SetSize(n, (ushort)(width - 5), null);  // Header Node
            n = n->ChildNode;
            SetSize(n, (ushort)(width - 20), null); // Header Seperator
            n = n->PrevSiblingNode;
            SetPosition(n, width - 33, 6);          // Close Button
            n = n->PrevSiblingNode;
            SetPosition(n, width - 47, 8);          // Gear Button
            n = n->PrevSiblingNode;
            SetPosition(n, width - 61, 8);          // Help Button

            windowNode->AtkResNode.Flags_2 |= 0x1;
        }
Exemplo n.º 7
0
        public static void ExpandNodeList(AtkComponentNode *componentNode, ushort addSize)
        {
            var newNodeList = ExpandNodeList(componentNode->Component->UldManager.NodeList, componentNode->Component->UldManager.NodeListCount, (ushort)(componentNode->Component->UldManager.NodeListCount + addSize));

            componentNode->Component->UldManager.NodeList = newNodeList;
        }
Exemplo n.º 8
0
        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();
        }
Exemplo n.º 9
0
    // TODO: Reduce parameter counts by splitting DrawVariables in smaller structs
    private static unsafe Vector2 DrawIcons(
        int currentScaleOffset,
        int componentIconLoopStart,
        int componentIconLoopEnd,
        int centreMarkerOffset,
        float maxDistance,
        float compassUnit,
        float scale,
        float rotationIconHalfWidth,
        float halfWidth40,
        float minScaleFactor,
        float backgroundRounding,
        Vector2 playerForward,
        Vector2 playerPosition,
        Vector2 centre,
        Vector2 backgroundPMin,
        Vector2 backgroundPMax,
        bool useAreaMapAsSource,
        bool enableCentreMarker,
        bool flipCentreMarker,
        AtkUnitBase *unitBase,
        AtkComponentNode *rootComponentNode,
        IReadOnlySet <uint> filteredIconIds
        )
    {
        try {
            var drawList = ImGui.GetWindowDrawList();
            // We loop through all relevant nodes on _NaviMap or AreaMap, depending on the configuration
            // This throws sometimes, but we just ignore those small exceptions, it works a few frames later anyways
            var mapScale       = *(float *)((nint)unitBase + currentScaleOffset);
            var distanceOffset = 20f * mapScale;
            maxDistance *= mapScale;
            for (var i = componentIconLoopStart; i < rootComponentNode->Component->UldManager.NodeListCount; i++)
            {
                var mapIconComponentNode =
                    (AtkComponentNode *)rootComponentNode->Component->UldManager.NodeList[i];
                if (!mapIconComponentNode->AtkResNode.IsVisible)
                {
                    continue;
                }
                for (var j = 2; j < componentIconLoopEnd; j++)
                {
                    var imgNode = (AtkImageNode *)mapIconComponentNode->Component->UldManager.NodeList[j];
                    if (imgNode->AtkResNode.Type != NodeType.Image)
                    {
                        continue;
                    }
                    if (!imgNode->AtkResNode.IsVisible || !imgNode->AtkResNode.ParentNode->IsVisible)
                    {
                        continue;
                    }
                    var part = imgNode->PartsList->Parts[imgNode->PartId];
                    //NOTE Invariant: It should always be a resource
#if DEBUG
                    var type = part.UldAsset->AtkTexture.TextureType;
                    if (type != TextureType.Resource)
                    {
                        SimpleLog.Error($"{i} {j} was not a Resource texture");
                        continue;
                    }
                    ;
#endif
                    var tex = part.UldAsset->AtkTexture.Resource->KernelTextureObject;
                    var texFileNameStdString =
                        part.UldAsset->AtkTexture.Resource->TexFileResourceHandle->ResourceHandle
                        .FileName;
                    // NOTE (Chiv) We are in a try-catch, so we just throw if the read failed.
                    // Cannot act anyways if the texture path is butchered
                    var textureFileName = texFileNameStdString.ToString();
                    var _ = uint.TryParse(
                        textureFileName.Substring(textureFileName.LastIndexOfAny(new[] { '/', '\\' }) + 1, 6),
                        out var iconId);
                    //iconId = 0 (=> success == false as IconID will never be 0) Must have been 'NaviMap(_hr1)?\.tex' (and only that hopefully)
                    if (filteredIconIds.Contains(iconId))
                    {
                        continue;
                    }

                    var textureIdPtr = new IntPtr(tex->D3D11ShaderResourceView);
                    //TODO DEBUG
//                        PluginLog.Debug($"TextureIdPtr is null? {textureIdPtr == IntPtr.Zero}");
                    Vector2 pMin;
                    Vector2 pMax;
                    var     uv         = Vector2.Zero;
                    var     uv1        = Vector2.One;
                    var     tintColour = Constant.WhiteColour;
                    var     rotate     = false;
                    switch (iconId)
                    {
                    case 0 when useAreaMapAsSource:     //0 interpreted as NaviMap texture atlas
                        continue;

                    case 0 when imgNode->PartId == 21:     //Glowy thingy
                        rotate = true;                     // TODO Duplicate code instead of branching?
                        uv     = new Vector2((float)part.U / 448, (float)part.V / 212);
                        uv1    = new Vector2((float)(part.U + 40) / 448, (float)(part.V + 40) / 212);
                        // NOTE (Chiv) Glowy thingy always rotates, but whether its in or outside the mask
                        // determines how to calculate its position on the compass
                        if (mapIconComponentNode->AtkResNode.Rotation == 0)
                        {
                            goto default;
                        }
                        goto case 1;

                    case 0:     //Arrows to quests and fates, part of the Navimap texture atlas
                        // NOTE: We assume part.Width == part.Height == 24
                        // NOTE: We assume tex.Width == 448 && tex.Height == 212
                        var u  = (float)part.U / 448;            // = (float) part.U / tex->Width;
                        var v  = (float)part.V / 212;            // = (float) part.V / tex->Height;
                        var u1 = (float)(part.U + 24) / 448;     // = (float) (part.U + part.Width) / tex->Width;
                        var v1 = (float)(part.V + 24) / 212;     // = (float) (part.V + part.Height) / tex->Height;

                        uv  = new Vector2(u, v);
                        uv1 = new Vector2(u1, v1);
                        // Arrows and such are always rotation based, we draw them slightly on top
                        var naviMapCutIconOffset = compassUnit *
                                                   Util.SignedAngle(mapIconComponentNode->AtkResNode.Rotation,
                                                                    playerForward);
                        // We declare width == height
                        const int naviMapIconHalfWidth = 12;
                        var       naviMapYOffset       = 14 * scale;
                        pMin = new Vector2(centre.X - naviMapIconHalfWidth + naviMapCutIconOffset,
                                           centre.Y - naviMapYOffset - naviMapIconHalfWidth);
                        pMax = new Vector2(centre.X + naviMapCutIconOffset + naviMapIconHalfWidth,
                                           centre.Y - naviMapYOffset + naviMapIconHalfWidth);
                        break;

                    case 1:     // Rotation icons (except naviMap arrows) go here after setting up their UVs
                        // NOTE (Chiv) Rotations for icons on the map are mirrored from the
                        var rotationIconOffset = compassUnit *
                                                 Util.SignedAngle(mapIconComponentNode->AtkResNode.Rotation,
                                                                  playerForward);
                        pMin = new Vector2(centre.X - rotationIconHalfWidth + rotationIconOffset,
                                           centre.Y - rotationIconHalfWidth);
                        pMax = new Vector2(centre.X + rotationIconOffset + rotationIconHalfWidth,
                                           centre.Y + rotationIconHalfWidth);
                        break;

                    case 060443:     //Player Marker
                        if (!enableCentreMarker)
                        {
                            continue;
                        }
                        drawList = ImGui.GetBackgroundDrawList();
                        pMin     = new Vector2(centre.X - halfWidth40,
                                               centre.Y + centreMarkerOffset * scale - halfWidth40);
                        pMax = new Vector2(centre.X + halfWidth40,
                                           centre.Y + centreMarkerOffset * scale + halfWidth40);
                        uv1            = flipCentreMarker ? new Vector2(1, -1) : Vector2.One;
                        playerPosition = new Vector2(mapIconComponentNode->AtkResNode.X, -mapIconComponentNode->AtkResNode.Y);
                        break;

                    //case  >5 and <9 :
                    //    break;
                    case 060495:     // Small Area Circle
                    case 060496:     // Big Area Circle
                    case 060497:     // Another Circle
                    case 060498:     // One More Circle
                        bool inArea;
                        (pMin, pMax, tintColour, inArea)
                            = Util.CalculateAreaCircleVariables(playerPosition, playerForward, mapIconComponentNode,
                                                                imgNode, distanceOffset, compassUnit, halfWidth40, centre,
                                                                maxDistance, minScaleFactor);
                        if (inArea)
                        {
                            //*((byte*) &tintColour + 3) = 0x33  == (0x33FFFFFF) & (tintColour)
                            ImGui.GetBackgroundDrawList().AddRectFilled(backgroundPMin
                                                                        , backgroundPMax
                                                                        , 0x33FFFFFF & tintColour //Set A to 0.2
                                                                        , backgroundRounding
                                                                        );
                        }
                        break;

                    case 060541:     // Arrow UP on Circle
                    case 060542:     // Arrow UP on Circle
                    case 060543:     // Another Arrow UP
                    case 060545:     // Another Arrow DOWN
                    case 060546:     // Arrow DOWN on Circle
                    case 060547:     // Arrow DOWN on Circle
                        (pMin, pMax, tintColour, _)
                            = Util.CalculateAreaCircleVariables(playerPosition, playerForward, mapIconComponentNode,
                                                                imgNode, distanceOffset, compassUnit, halfWidth40, centre,
                                                                maxDistance, minScaleFactor);
                        break;

                    case 071003:     // MSQ Ongoing Marker
                    case 071005:     // MSQ Complete Marker
                    case 071013:     // MSQ Ongoing Red Marker
                    case 071015:     // MSQ Complete Red Marker
                    case 071023:     // Quest Ongoing Marker
                    case 071033:     // Quest Ongoing Red Marker
                    case 071153:     // Quest Ongoing Red Marker 2
                    case 071025:     // Quest Complete Marker
                    case 071035:     // Quest Complete Red Marker
                    case 071155:     // Quest Complete Red Marker
                    case 071063:     // BookQuest Ongoing Marker
                    case 071065:     // BookQuest Complete Marker
                    case 071083:     // LeveQuest Ongoing Marker
                    case 071085:     // LeveQuest Complete Marker
                    case 071143:     // BlueQuest Ongoing Marker
                    case 071145:     // BlueQuest Complete Marker
                    case 071146:     // Weird Blueish Round Exclamation Mark //TODO More of those?
                    case 071026:     // Weird Blueish Round Exclamation Mark 2
                    case 071111:     // Weird Round Quest Mark
                    case 071112:     // Weird Round Quest Complete Mark
                    case 060954:     // Arrow up for quests
                    case 060955:     // Arrow down for quests
                    case 060561:     // Red Flag (Custom marker)
                    case 060437:     // Mining Crop Icon
                    case 060438:     // Mining Crop Icon 2
                    case 060463:     // Mining Crop Icon 3
                    case 060464:     // Mining Crop Icon 4
                    case 060432:     // Botanic Crop Icon
                    case 060433:     // Botanic Crop Icon 2
                    case 060461:     // Botanic Crop Icon 3
                    case 060462:     // Botanic Crop Icon 4
                    case 060455:     // Fishing Icon
                    case 060465:     // Fishing Icon 2
                    case 060466:     // Fishing Icon 3
                    case 060474:     // Waymark A
                    case 060475:     // Waymark B
                    case 060476:     // Waymark C
                    case 060936:     // Waymark D
                    case 060931:     // Waymark 1
                    case 060932:     // Waymark 2
                    case 060933:     // Waymark 3
                    case 063904:     // Waymark 4
                    case 060934:     // FATE EXP Bonus Icon
                        if (mapIconComponentNode->AtkResNode.Rotation == 0)
                        {
                            // => The current quest marker is inside the mask and should be
                            // treated as a map point
                            goto default;
                        }
                        // => The current quest marker is outside the mask and should be
                        // treated as a rotation
                        goto case 1;     //No UV setup needed for quest markers

                    default:
                        // NOTE (Chiv) Remember, Y needs to be flipped to transform to default coordinate system
                        var(distanceScaleFactor, iconAngle, _) = Util.CalculateDrawVariables(playerPosition,
                                                                                             new Vector2(
                                                                                                 mapIconComponentNode->AtkResNode.X,
                                                                                                 -mapIconComponentNode->AtkResNode.Y
                                                                                                 ),
                                                                                             playerForward,
                                                                                             distanceOffset,
                                                                                             maxDistance,
                                                                                             minScaleFactor
                                                                                             );
                        var iconOffset    = compassUnit * iconAngle;
                        var iconHalfWidth = halfWidth40 * distanceScaleFactor;
                        pMin = new Vector2(centre.X - iconHalfWidth + iconOffset, centre.Y - iconHalfWidth);
                        pMax = new Vector2(centre.X + iconOffset + iconHalfWidth, centre.Y + iconHalfWidth);
                        break;
                    }

                    //PluginLog.Debug($"ID: {iconId}; Tintcolor: {tintColour:x8}");
                    if (rotate)
                    {
                        ImGuiHelper.ImageRotated(
                            textureIdPtr,
                            new Vector2(pMin.X + (pMax.X - pMin.X) * 0.5f, pMin.Y + (pMax.Y - pMin.Y) * 0.5f),
                            pMax - pMin,
                            imgNode->AtkResNode.Rotation,
                            uv,
                            uv1,
                            drawList
                            );
                    }
                    else
                    {
                        drawList.AddImage(textureIdPtr, pMin, pMax, uv, uv1, tintColour);
                    }
                }
            }
        }
#if DEBUG
        catch (Exception e) {
            SimpleLog.Error(e);
        }
#else
        catch {
            // ignored
        }
#endif
        return(playerPosition);
    }
Exemplo n.º 10
0
 public static void Hide(AtkComponentNode *node) => Hide((AtkResNode *)node);
Exemplo n.º 11
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("");
            }
        }
Exemplo n.º 12
0
 public static void SetPosition(AtkComponentNode *node, float?x, float?y) => SetPosition((AtkResNode *)node, x, y);
Exemplo n.º 13
0
 public static void SetSize(AtkComponentNode *node, int?w, int?h) => SetSize((AtkResNode *)node, w, h);
Exemplo n.º 14
0
 public static void Show(AtkComponentNode *node) => Show((AtkResNode *)node);
Exemplo n.º 15
0
        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, "");
            }
        }
Exemplo n.º 16
0
 public static void SetScale(AtkComponentNode *node, float?scaleX, float?scaleY) => SetScale((AtkResNode *)node, scaleX, scaleY);