private bool UpdateHotbarRecordedControlHints(AddonActionBarBase *ab, StringArrayData *strArrayData = null)
    {
        if (ab == null || ab->ActionBarSlotsAction == null)
        {
            return(false);
        }

        if (strArrayData == null)
        {
            strArrayData = Framework.Instance()->GetUiModule()->GetRaptureAtkModule()->AtkModule.AtkArrayDataHolder.StringArrays[StrDataIndex];
        }

        var numSlots = ab->HotbarSlotCount;

        var changeFound = false;

        if (recordedControlHints[ab->HotbarID] == null || recordedControlHints[ab->HotbarID].Length != numSlots || recordedControlHints[ab->HotbarID].Length != numSlots)
        {
            recordedControlHints[ab->HotbarID] = new string[numSlots];
            changeFound = true;
        }

        for (int i = 0; i < numSlots; i++)
        {
            var currentControlHint = Marshal.PtrToStringUTF8(new IntPtr(strArrayData->StringArray[(ab->HotbarID * StrDataHotbarLength + i) * StrDataSlotLength + StrDataHintIndex]));
            if (recordedControlHints?[ab->HotbarID]?[i] != currentControlHint)
            {
                recordedControlHints[ab->HotbarID][i] = currentControlHint;
                changeFound = true;
            }
        }

        return(changeFound);
    }
Ejemplo n.º 2
0
 protected static unsafe SeString GetTooltipString(StringArrayData *stringArrayData, TooltipTweaks.ItemTooltipField field)
 {
     try {
         var stringAddress = new IntPtr(stringArrayData->StringArray[(int)field]);
         return(stringAddress == IntPtr.Zero ? null : MemoryHelper.ReadSeStringNullTerminated(stringAddress));
     } catch {
         return(null);
     }
 }
Ejemplo n.º 3
0
 protected static unsafe void SetTooltipString(StringArrayData *stringArrayData, TooltipTweaks.ItemTooltipField field, SeString seString)
 {
     try {
         if (!ItemStringPointers.ContainsKey(field))
         {
             ItemStringPointers.Add(field, Marshal.AllocHGlobal(4096));
         }
         var bytes = seString.Encode();
         Marshal.Copy(bytes, 0, ItemStringPointers[field], bytes.Length);
         Marshal.WriteByte(ItemStringPointers[field], bytes.Length, 0);
         stringArrayData->StringArray[(int)field] = (byte *)ItemStringPointers[field];
     } catch {
         //
     }
 }
    public override void OnGenerateItemTooltip(NumberArrayData *numberArrayData, StringArrayData *stringArrayData)
    {
        if (Config.HideHotkeysOnTooltip)
        {
            return;
        }
        var seStr = GetTooltipString(stringArrayData, ControlsDisplay);

        if (seStr == null)
        {
            return;
        }
        if (seStr.TextValue.Contains('\n'))
        {
            return;
        }
        var split = seStr.TextValue.Split(new[] { weirdTabChar }, StringSplitOptions.None);

        if (split.Length > 0)
        {
            seStr.Payloads.Clear();
            seStr.Payloads.Add(new TextPayload(string.Join("\n", split)));
        }

        if (Config.CopyHotkeyEnabled)
        {
            seStr.Payloads.Add(new TextPayload($"\n{string.Join("+", Config.CopyHotkey.Select(k => k.GetKeyName()))}  Copy item name"));
        }
        if (Config.TeamcraftLinkHotkeyEnabled)
        {
            seStr.Payloads.Add(new TextPayload($"\n{string.Join("+", Config.TeamcraftLinkHotkey.Select(k => k.GetKeyName()))}  View on Teamcraft"));
        }
        if (Config.GardlandToolsLinkHotkeyEnabled)
        {
            seStr.Payloads.Add(new TextPayload($"\n{string.Join("+", Config.GardlandToolsLinkHotkey.Select(k => k.GetKeyName()))}  View on Garland Tools"));
        }
        if (Config.GamerEscapeLinkHotkeyEnabled)
        {
            seStr.Payloads.Add(new TextPayload($"\n{string.Join("+", Config.GamerEscapeLinkHotkey.Select(k => k.GetKeyName()))}  View on Gamer Escape"));
        }
        if (Config.ErionesLinkHotkeyEnabled)
        {
            seStr.Payloads.Add(new TextPayload($"\n{string.Join("+", Config.ErionesLinkHotkey.Select(k => k.GetKeyName()))}  View on Eriones (JP)"));
        }


        SetTooltipString(stringArrayData, ControlsDisplay, seStr);
    }
Ejemplo n.º 5
0
        public override unsafe void OnGenerateItemTooltip(NumberArrayData *numberArrayData, StringArrayData *stringArrayData)
        {
            var id = Service.GameGui.HoveredItem;

            if (id < 2000000)
            {
                id %= 500000;

                var item = itemSheet.GetRow((uint)id);
                if (item != null && item.Desynth > 0)
                {
                    var desynthLevel   = UIState.Instance()->PlayerState.GetDesynthesisLevel(item.ClassJobRepair.Row);
                    var desynthDelta   = item.LevelItem.Row - desynthLevel;
                    var useDescription = desynthesisInDescription.Contains(item.ItemSearchCategory.Row);

                    var seStr = GetTooltipString(stringArrayData, useDescription ? ItemDescription : ExtractableProjectableDesynthesizable);

                    if (seStr != null && seStr.Payloads.Count > 0)
                    {
                        if (seStr.Payloads.Last() is TextPayload textPayload)
                        {
                            if (Config.Delta)
                            {
                                textPayload.Text = textPayload.Text.Replace($"{item.LevelItem.Row},00", $"{item.LevelItem.Row} ({desynthDelta:+#;-#}");
                                textPayload.Text = textPayload.Text.Replace($"{item.LevelItem.Row}.00", $"{item.LevelItem.Row} ({desynthDelta:+#;-#})");
                            }
                            else
                            {
                                textPayload.Text = textPayload.Text.Replace($"{item.LevelItem.Row},00", $"{item.LevelItem.Row} ({desynthLevel:F0})");
                                textPayload.Text = textPayload.Text.Replace($"{item.LevelItem.Row}.00", $"{item.LevelItem.Row} ({desynthLevel:F0})");
                            }
                            SetTooltipString(stringArrayData, useDescription ? ItemDescription : ExtractableProjectableDesynthesizable, seStr);
                        }
                    }
                }
            }
        }
    public override unsafe void OnGenerateItemTooltip(NumberArrayData *numberArrayData, StringArrayData *stringArrayData)
    {
        var c = GetTooltipString(stringArrayData, DurabilityPercent);

        if (c == null || c.TextValue.StartsWith("?"))
        {
            return;
        }
        SetTooltipString(stringArrayData, DurabilityPercent, (Item.Condition / 300f).ToString(Config.TrailingZero ? "F2" : "0.##") + "%");
    }
Ejemplo n.º 7
0
    public override unsafe void OnGenerateItemTooltip(NumberArrayData *numberArrayData, StringArrayData *stringArrayData)
    {
        if (!(Config.Delta || Config.Total == false))
        {
            Config.Total = true;                                           // Config invalid check
        }
        try {
            var item = itemSheet.GetRow(Item.ItemId);
            if (item == null)
            {
                return;
            }
            if (item.MateriaSlotCount == 0)
            {
                return;
            }
            var itemLevel = itemLevelSheet.GetRow(item.LevelItem.Row);
            if (itemLevel == null)
            {
                return;
            }
            var baseParams        = new Dictionary <uint, ExtendedBaseParam>();
            var baseParamDeltas   = new Dictionary <uint, int>();
            var baseParamOriginal = new Dictionary <uint, int>();
            var baseParamLimits   = new Dictionary <uint, int>();
            foreach (var bp in item.BaseParam)
            {
                if (bp.Value == 0 || bp.BaseParam.Row == 0)
                {
                    continue;
                }
                baseParamDeltas.Add(bp.BaseParam.Row, 0);
                baseParamOriginal.Add(bp.BaseParam.Row, bp.Value);
                if (bp.BaseParam.Value != null)
                {
                    baseParamLimits.Add(bp.BaseParam.Row, (int)Math.Ceiling(itemLevel.BaseParam[bp.BaseParam.Row] * (bp.BaseParam.Value.EquipSlotCategoryPct[item.EquipSlotCategory.Row] / 100f)));
                    baseParams.Add(bp.BaseParam.Row, bp.BaseParam.Value);
                }
            }

            if (Item.IsHQ)
            {
                foreach (var bp in item.BaseParamSpecial)
                {
                    if (bp.Value == 0 || bp.BaseParam.Row == 0)
                    {
                        continue;
                    }
                    if (baseParamOriginal.ContainsKey(bp.BaseParam.Row))
                    {
                        baseParamOriginal[bp.BaseParam.Row] += bp.Value;
                    }
                }
            }

            if (baseParamDeltas.Count == 0)
            {
                return;
            }

            foreach (var(materiaId, level) in Item.Materia())
            {
                if (level >= 10)
                {
                    continue;
                }
                var materia = materiaSheet.GetRow(materiaId);
                if (materia == null)
                {
                    continue;
                }
                if (materia.BaseParam.Row == 0)
                {
                    continue;
                }
                if (materia.BaseParam.Value == null)
                {
                    continue;
                }
                if (!baseParamDeltas.ContainsKey(materia.BaseParam.Row))
                {
                    var bp = Service.Data.Excel.GetSheet <ExtendedBaseParam>()?.GetRow(materia.BaseParam.Row);
                    if (bp == null)
                    {
                        continue;
                    }
                    baseParams.Add(materia.BaseParam.Row, bp);
                    baseParamDeltas.Add(materia.BaseParam.Row, materia.Value[level]);
                    baseParamOriginal.Add(materia.BaseParam.Row, 0);
                    baseParamLimits.Add(materia.BaseParam.Row, (int)Math.Ceiling(itemLevel.BaseParam[materia.BaseParam.Row] * (bp.EquipSlotCategoryPct[item.EquipSlotCategory.Row] / 100f)));
                    continue;
                }
                baseParamDeltas[materia.BaseParam.Row] += materia.Value[level];
            }
            foreach (var bp in baseParamDeltas)
            {
                var param = baseParams[bp.Key];
                if (bp.Value == 0)
                {
                    continue;
                }
                var hasApplied = false;
                foreach (var field in Fields().Take(numberArrayData->IntArray[21]))
                {
                    var data = GetTooltipString(stringArrayData, field);
                    if (data == null)
                    {
                        continue;
                    }
                    if (data.TextValue.Contains(param.Name))
                    {
                        hasApplied = true;
                        if (data.TextValue.EndsWith("]"))
                        {
                            continue;
                        }
                        ApplyMateriaDifference(data, baseParamDeltas[param.RowId], baseParamOriginal[param.RowId], baseParamLimits[param.RowId]);
                        SetTooltipString(stringArrayData, field, data);
                    }
                }

                if (!hasApplied)
                {
                    var baseParamLines = numberArrayData->IntArray[21];
                    if (baseParamLines < 8)
                    {
                        var seString = new SeString();
                        seString.Payloads.Add(new TextPayload(param.Name));
                        seString.Payloads.Add(new TextPayload($" +{baseParamOriginal[param.RowId]}"));
                        ApplyMateriaDifference(seString, baseParamDeltas[param.RowId], baseParamOriginal[param.RowId], baseParamLimits[param.RowId]);

                        SetTooltipString(stringArrayData, (TooltipTweaks.ItemTooltipField)(37 + baseParamLines), seString);
                        numberArrayData->IntArray[21] += 1;
                    }
                }
            }
        } catch (Exception ex) {
            SimpleLog.Error(ex);
        }
    }
Ejemplo n.º 8
0
 public virtual unsafe void OnGenerateItemTooltip(NumberArrayData *numberArrayData, StringArrayData *stringArrayData)
 {
 }
    public override unsafe void OnGenerateItemTooltip(NumberArrayData *numberArrayData, StringArrayData *stringArrayData)
    {
        var seStr = GetTooltipString(stringArrayData, ItemUiCategory);

        if (seStr == null)
        {
            return;
        }
        if (seStr.TextValue.EndsWith("]"))
        {
            return;
        }
        var id = Service.GameGui.HoveredItem;

        if (id < 2000000)
        {
            id %= 500000;
        }
        seStr.Payloads.Add(new UIForegroundPayload(3));
        seStr.Payloads.Add(new TextPayload($"   ["));
        if (Config.Hex == false || Config.Both)
        {
            seStr.Payloads.Add(new TextPayload($"{id}"));
        }
        if (Config.Hex)
        {
            if (Config.Both)
            {
                seStr.Payloads.Add(new TextPayload(" - "));
            }
            seStr.Payloads.Add(new TextPayload($"0x{id:X}"));
        }
        seStr.Payloads.Add(new TextPayload($"]"));
        seStr.Payloads.Add(new UIForegroundPayload(0));
        SetTooltipString(stringArrayData, ItemUiCategory, seStr);
    }