diff --git a/Craftimizer/Craftimizer.csproj b/Craftimizer/Craftimizer.csproj index 393c9aa..89a86bd 100644 --- a/Craftimizer/Craftimizer.csproj +++ b/Craftimizer/Craftimizer.csproj @@ -1,8 +1,8 @@ - + Asriel Camora - 2.7.2.1 + 2.7.2.2 https://github.com/WorkingRobot/Craftimizer.git Debug;Release diff --git a/Craftimizer/ImGuiExtras.cs b/Craftimizer/ImGuiExtras.cs index 6583adc..146e6fc 100644 --- a/Craftimizer/ImGuiExtras.cs +++ b/Craftimizer/ImGuiExtras.cs @@ -1,4 +1,4 @@ -using ImGuiNET; +using Dalamud.Bindings.ImGui; using System; using System.Numerics; using System.Runtime.CompilerServices; @@ -101,7 +101,7 @@ internal static unsafe class ImGuiExtras utf8HintBytes = stackPtr; } GetUtf8(hint, utf8HintBytes, utf8HintByteCount); - + var utf8InputByteCount = Encoding.UTF8.GetByteCount(input); var inputBufSize = Math.Max(maxLength + 1, utf8InputByteCount + 1); @@ -179,7 +179,7 @@ internal static unsafe class ImGuiExtras igRenderFrame(p_min, p_max, fill_col, border, rounding); public static unsafe void RenderRectFilledRangeH(ImDrawListPtr draw_list, Vector4 rect, uint col, float x_start_norm, float x_end_norm, float rounding) => - igRenderRectFilledRangeH(draw_list.NativePtr, &rect, col, x_start_norm, x_end_norm, rounding); + igRenderRectFilledRangeH(draw_list, &rect, col, x_start_norm, x_end_norm, rounding); public static unsafe bool ItemSize(Vector2 size, float text_baseline_y = -1.0f) => igItemSize_Vec2(size, text_baseline_y); @@ -202,7 +202,7 @@ internal static unsafe class ImGuiExtras } GetUtf8(text, utf8TextBytes, utf8TextByteCount); - var ret = ImGuiNative.ImFont_CalcWordWrapPositionA(font.NativePtr, scale, utf8TextBytes, utf8TextBytes + utf8TextByteCount, wrap_width); + var ret = ImGuiNative.CalcWordWrapPositionA(font, scale, utf8TextBytes, utf8TextBytes + utf8TextByteCount, wrap_width); int? retVal = null; if (utf8TextBytes <= ret && ret <= utf8TextBytes + utf8TextByteCount) @@ -218,12 +218,12 @@ internal static unsafe class ImGuiExtras } public static unsafe bool SetDragDropPayload(string type, T data) where T : unmanaged => - ImGui.SetDragDropPayload(type, (nint)(&data), (uint)sizeof(T)); + ImGui.SetDragDropPayload(type, MemoryMarshal.AsBytes(new ReadOnlySpan(&data, 1))); public static unsafe bool AcceptDragDropPayload(string type, out T data) where T : unmanaged { var payload = ImGui.AcceptDragDropPayload(type); - if (payload.NativePtr == null || payload.DataSize != sizeof(T)) + if (payload.IsNull || payload.DataSize != sizeof(T)) { data = default; return false; diff --git a/Craftimizer/ImGuiUtils.cs b/Craftimizer/ImGuiUtils.cs index 60d7ffa..849147d 100644 --- a/Craftimizer/ImGuiUtils.cs +++ b/Craftimizer/ImGuiUtils.cs @@ -3,8 +3,8 @@ using Dalamud.Interface; using Dalamud.Interface.ManagedFontAtlas; using Dalamud.Interface.Utility; using Dalamud.Interface.Utility.Raii; -using ImGuiNET; -using ImPlotNET; +using Dalamud.Bindings.ImGui; +using Dalamud.Bindings.ImPlot; using MathNet.Numerics.Statistics; using System; using System.Collections.Generic; @@ -251,7 +251,7 @@ internal static class ImGuiUtils { var style = ImGui.GetStyle(); var pos = ImGui.GetCursorScreenPos(); - + //size = ImGuiExtras.CalcItemSize(size, ImGui.CalcItemWidth(), ImGui.GetFontSize() + style.FramePadding.Y * 2.0f); var bbMin = pos; @@ -259,12 +259,12 @@ internal static class ImGuiUtils ImGuiExtras.ItemSize(size, style.FramePadding.Y); if (!ImGuiExtras.ItemAdd(new(bbMin.X, bbMin.Y, bbMax.X, bbMax.Y), 0)) return; - + var bar_begin = 0.0f; var bar_end = Math.Clamp(value, 0, 1); - + var indeterminate = value < 0.0f; - if (indeterminate) + if (indeterminate) { const float bar_fraction = 0.2f; bar_begin = (-value % 1.0f * (1.0f + bar_fraction)) - bar_fraction; @@ -297,7 +297,8 @@ internal static class ImGuiUtils Max = max; bandwidth *= Max - Min; var samplesList = samples.AsParallel().Select(s => (double)s).ToArray(); - _ = Task.Run(() => { + _ = Task.Run(() => + { var s = Stopwatch.StartNew(); var data = ParallelEnumerable.Range(0, resolution + 1) .Select(n => Lerp(min, max, n / (float)resolution)) @@ -315,14 +316,14 @@ internal static class ImGuiUtils public static void ViolinPlot(in ViolinData data, Vector2 size) { - using var padding = ImRaii2.PushStyle(ImPlotStyleVar.PlotPadding, Vector2.Zero); - using var plotBg = ImRaii2.PushColor(ImPlotCol.PlotBg, Vector4.Zero); + using var padding = ImRaii2.PushStyle(ImPlotStyleVar.Padding, Vector2.Zero); + using var plotBg = ImRaii2.PushColor(ImPlotCol.Bg, Vector4.Zero); using var fill = ImRaii2.PushColor(ImPlotCol.Fill, Vector4.One.WithAlpha(.5f)); using var plot = ImRaii2.Plot("##violin", size, ImPlotFlags.CanvasOnly | ImPlotFlags.NoInputs | ImPlotFlags.NoChild | ImPlotFlags.NoFrame); if (plot) { - ImPlot.SetupAxes(null, null, ImPlotAxisFlags.NoDecorations, ImPlotAxisFlags.NoDecorations | ImPlotAxisFlags.AutoFit); + ImPlot.SetupAxes([], [], ImPlotAxisFlags.NoDecorations, ImPlotAxisFlags.NoDecorations | ImPlotAxisFlags.AutoFit); ImPlot.SetupAxisLimits(ImAxis.X1, data.Min, data.Max, ImPlotCond.Always); ImPlot.SetupFinish(); @@ -333,7 +334,7 @@ internal static class ImGuiUtils var label_id = stackalloc byte[] { (byte)'\0' }; fixed (ViolinData.Point* p = points) { - ImPlotNative.ImPlot_PlotShaded_FloatPtrFloatPtrFloatPtr(label_id, &p->X, &p->Y, &p->Y2, points.Length, ImPlotShadedFlags.None, 0, sizeof(ViolinData.Point)); + ImPlot.PlotShaded(label_id, &p->X, &p->Y, &p->Y2, points.Length, ImPlotShadedFlags.None, 0, sizeof(ViolinData.Point)); } } } @@ -522,7 +523,7 @@ internal static class ImGuiUtils ImGuiListClipperPtr imGuiListClipperPtr; unsafe { - imGuiListClipperPtr = new ImGuiListClipperPtr(ImGuiNative.ImGuiListClipper_ImGuiListClipper()); + imGuiListClipperPtr = new ImGuiListClipperPtr(ImGuiNative.ImGuiListClipper()); } try { @@ -662,7 +663,9 @@ internal static class ImGuiUtils currentWrapWidth = wrapPosX - currentPos; var textBuf = text.AsSpan(); - var lineSize = font.CalcWordWrapPositionA(ImGuiHelpers.GlobalScale, textBuf, currentWrapWidth) ?? textBuf.Length; + var lineSize = font.CalcWordWrapPositionA(ImGuiHelpers.GlobalScale, textBuf, currentWrapWidth); + if (lineSize == 0) + lineSize = textBuf.Length; var lineBuf = textBuf[..lineSize]; ImGui.TextUnformatted(lineBuf.ToString()); var remainingBuf = textBuf[lineSize..].TrimStart(); diff --git a/Craftimizer/ImRaii2.cs b/Craftimizer/ImRaii2.cs index 4f2afbf..83d253e 100644 --- a/Craftimizer/ImRaii2.cs +++ b/Craftimizer/ImRaii2.cs @@ -1,6 +1,6 @@ using Dalamud.Interface.Utility.Raii; -using ImGuiNET; -using ImPlotNET; +using Dalamud.Bindings.ImGui; +using Dalamud.Bindings.ImPlot; using System; using System.Numerics; diff --git a/Craftimizer/Utils/Colors.cs b/Craftimizer/Utils/Colors.cs index cb8d98d..a64c088 100644 --- a/Craftimizer/Utils/Colors.cs +++ b/Craftimizer/Utils/Colors.cs @@ -1,6 +1,6 @@ using Craftimizer.Plugin; using Dalamud.Interface.Colors; -using ImGuiNET; +using Dalamud.Bindings.ImGui; using System; using System.Numerics; diff --git a/Craftimizer/Utils/DynamicBars.cs b/Craftimizer/Utils/DynamicBars.cs index bacb877..08e1c62 100644 --- a/Craftimizer/Utils/DynamicBars.cs +++ b/Craftimizer/Utils/DynamicBars.cs @@ -1,6 +1,6 @@ using Craftimizer.Plugin; using Dalamud.Interface.Utility.Raii; -using ImGuiNET; +using Dalamud.Bindings.ImGui; using System.Collections.Generic; using System; using System.Numerics; diff --git a/Craftimizer/Utils/IconManager.cs b/Craftimizer/Utils/IconManager.cs index 9903084..e613e34 100644 --- a/Craftimizer/Utils/IconManager.cs +++ b/Craftimizer/Utils/IconManager.cs @@ -1,4 +1,5 @@ using Craftimizer.Plugin; +using Dalamud.Bindings.ImGui; using Dalamud.Interface.Textures; using Dalamud.Interface.Textures.TextureWraps; using Dalamud.Utility; @@ -19,7 +20,7 @@ public interface ITextureIcon float? AspectRatio => Dimensions is { } d ? d.X / d.Y : null; - nint ImGuiHandle { get; } + ImTextureID Handle { get; } } public interface ILoadedTextureIcon : ITextureIcon, IDisposable { } @@ -32,7 +33,7 @@ public sealed class IconManager : IDisposable public Vector2? Dimensions => GetWrap()?.Size; - public nint ImGuiHandle => GetWrapOrEmpty().ImGuiHandle; + public ImTextureID Handle => GetWrapOrEmpty().Handle; private Task TextureWrapTask { get; } private CancellationTokenSource DisposeToken { get; } @@ -69,7 +70,7 @@ public sealed class IconManager : IDisposable public Vector2? Dimensions => Base.Dimensions; - public nint ImGuiHandle => Base.ImGuiHandle; + public ImTextureID Handle => Base.Handle; public void Release() { diff --git a/Craftimizer/Utils/MacroCopy.cs b/Craftimizer/Utils/MacroCopy.cs index d078583..eb48cb3 100644 --- a/Craftimizer/Utils/MacroCopy.cs +++ b/Craftimizer/Utils/MacroCopy.cs @@ -5,7 +5,7 @@ using Dalamud.Interface.ImGuiNotification; using FFXIVClientStructs.FFXIV.Client.System.Memory; using FFXIVClientStructs.FFXIV.Client.System.String; using FFXIVClientStructs.FFXIV.Client.UI.Misc; -using ImGuiNET; +using Dalamud.Bindings.ImGui; using System; using System.Collections.Generic; @@ -54,7 +54,7 @@ public static class MacroCopy var mustSplit = (config.Type == MacroCopyConfiguration.CopyType.CopyToMacro || !config.CombineMacro) && config.Type != MacroCopyConfiguration.CopyType.CopyToMacroMate; var macros = new List(); - + var m = new List(); for (var i = 0; i < actions.Count; ++i) diff --git a/Craftimizer/Utils/RecipeData.cs b/Craftimizer/Utils/RecipeData.cs index 58691bf..c430744 100644 --- a/Craftimizer/Utils/RecipeData.cs +++ b/Craftimizer/Utils/RecipeData.cs @@ -34,10 +34,10 @@ public sealed record RecipeData ClassJob = (ClassJob)Recipe.CraftType.RowId; var resolvedLevelTableRow = Recipe.RecipeLevelTable.RowId; - if (Recipe.Unknown0 != 0) + if (Recipe.MaxAdjustableJobLevel.RowId != 0) { - AdjustedJobLevel = Math.Min(explicitlyAdjustedJobLevel ?? ClassJob.GetWKSSyncedLevel(), Recipe.Unknown0); - resolvedLevelTableRow = LuminaSheets.GathererCrafterLvAdjustTableSheet.GetRow(AdjustedJobLevel.Value).Unknown0; + AdjustedJobLevel = Math.Min(explicitlyAdjustedJobLevel ?? ClassJob.GetWKSSyncedLevel(), (ushort)Recipe.MaxAdjustableJobLevel.RowId); + resolvedLevelTableRow = LuminaSheets.GathererCrafterLvAdjustTableSheet.GetRow(AdjustedJobLevel.Value).RecipeLevel.RowId; } Table = LuminaSheets.RecipeLevelTableSheet.GetRow(resolvedLevelTableRow); @@ -46,7 +46,7 @@ public sealed record RecipeData IsExpert = Recipe.IsExpert, ClassJobLevel = Table.ClassJobLevel, ConditionsFlag = Table.ConditionsFlag, - MaxDurability = (Recipe.Unknown0 != 0 ? 80 : Table.Durability) * Recipe.DurabilityFactor / 100, + MaxDurability = (Recipe.MaxAdjustableJobLevel.RowId != 0 ? 80 : Table.Durability) * Recipe.DurabilityFactor / 100, MaxQuality = (Recipe.CanHq || Recipe.IsExpert) ? (int)Table.Quality * Recipe.QualityFactor / 100 : 0, MaxProgress = Table.Difficulty * Recipe.DifficultyFactor / 100, QualityModifier = Table.QualityModifier, diff --git a/Craftimizer/Windows/MacroClipboard.cs b/Craftimizer/Windows/MacroClipboard.cs index 0714e6e..1177e7b 100644 --- a/Craftimizer/Windows/MacroClipboard.cs +++ b/Craftimizer/Windows/MacroClipboard.cs @@ -2,7 +2,7 @@ using Craftimizer.Plugin; using Dalamud.Interface; using Dalamud.Interface.Utility.Raii; using Dalamud.Interface.Windowing; -using ImGuiNET; +using Dalamud.Bindings.ImGui; using System; using System.Collections.Generic; using System.Numerics; @@ -32,7 +32,7 @@ public sealed class MacroClipboard : Window, IDisposable public override void Draw() { var idx = 0; - foreach(var macro in Macros) + foreach (var macro in Macros) DrawMacro(idx++, macro); } @@ -77,7 +77,7 @@ public sealed class MacroClipboard : Window, IDisposable using var padding = ImRaii.PushStyle(ImGuiStyleVar.FramePadding, Vector2.Zero); using var bg = ImRaii.PushColor(ImGuiCol.FrameBg, Vector4.Zero); var lineCount = macro.Count(c => c == '\n') + 1; - ImGui.InputTextMultiline("", ref macro, (uint)macro.Length + 1, new(availWidth, ImGui.GetTextLineHeight() * Math.Max(15, lineCount) + ImGui.GetStyle().FramePadding.Y), ImGuiInputTextFlags.ReadOnly | ImGuiInputTextFlags.AutoSelectAll); + ImGui.InputTextMultiline("", ref macro, macro.Length + 1, new(availWidth, ImGui.GetTextLineHeight() * Math.Max(15, lineCount) + ImGui.GetStyle().FramePadding.Y), ImGuiInputTextFlags.ReadOnly | ImGuiInputTextFlags.AutoSelectAll); } if (buttonHovered) diff --git a/Craftimizer/Windows/MacroEditor.cs b/Craftimizer/Windows/MacroEditor.cs index 85fbc5d..5e7a181 100644 --- a/Craftimizer/Windows/MacroEditor.cs +++ b/Craftimizer/Windows/MacroEditor.cs @@ -12,7 +12,7 @@ using Dalamud.Interface.ManagedFontAtlas; using Dalamud.Interface.Utility; using Dalamud.Interface.Utility.Raii; using Dalamud.Interface.Windowing; -using ImGuiNET; +using Dalamud.Bindings.ImGui; using System; using System.Collections.Generic; using System.Linq; @@ -270,7 +270,7 @@ public sealed class MacroEditor : Window, IDisposable uv0 /= new Vector2(56); uv1 /= new Vector2(56); - ImGui.Image(Service.IconManager.GetIconCached(RecipeData.ClassJob.GetIconId()).ImGuiHandle, new Vector2(imageSize), uv0, uv1); + ImGui.Image(Service.IconManager.GetIconCached(RecipeData.ClassJob.GetIconId()).Handle, new Vector2(imageSize), uv0, uv1); ImGui.SameLine(0, 5); AxisFont.Text(textClassName); @@ -346,7 +346,7 @@ public sealed class MacroEditor : Window, IDisposable { var v = CharacterStats.HasSplendorousBuff; var tint = v ? Vector4.One : disabledTint; - if (ImGui.ImageButton(SplendorousBadge.ImGuiHandle, new Vector2(imageButtonSize), default, Vector2.One, imageButtonPadding, default, tint)) + if (ImGui.ImageButton(SplendorousBadge.Handle, new Vector2(imageButtonSize), default, Vector2.One, imageButtonPadding, default, tint)) CharacterStats = CharacterStats with { HasSplendorousBuff = !v }; } if (ImGui.IsItemHovered(ImGuiHoveredFlags.AllowWhenDisabled)) @@ -364,7 +364,7 @@ public sealed class MacroEditor : Window, IDisposable using (var d = ImRaii.Disabled(specialistLevel > CharacterStats.Level)) { var tint = new Vector4(0.99f, 0.97f, 0.62f, 1f) * (v ? Vector4.One : disabledTint); - if (ImGui.ImageButton(SpecialistBadge.ImGuiHandle, new Vector2(imageButtonSize), default, Vector2.One, imageButtonPadding, default, tint)) + if (ImGui.ImageButton(SpecialistBadge.Handle, new Vector2(imageButtonSize), default, Vector2.One, imageButtonPadding, default, tint)) { v = !v; newIsSpecialist = v; @@ -380,7 +380,7 @@ public sealed class MacroEditor : Window, IDisposable { var v = CharacterStats.CanUseManipulation && manipLevel <= CharacterStats.Level; var tint = (v || manipLevel > CharacterStats.Level) ? disabledTint : Vector4.One; - if (ImGui.ImageButton((v ? ManipulationBadge : NoManipulationBadge).ImGuiHandle, new Vector2(imageButtonSize), default, Vector2.One, imageButtonPadding, default, tint)) + if (ImGui.ImageButton((v ? ManipulationBadge : NoManipulationBadge).Handle, new Vector2(imageButtonSize), default, Vector2.One, imageButtonPadding, default, tint)) CharacterStats = CharacterStats with { CanUseManipulation = !v }; } if (ImGui.IsItemHovered(ImGuiHoveredFlags.AllowWhenDisabled)) @@ -392,7 +392,7 @@ public sealed class MacroEditor : Window, IDisposable var buffBadgeSize = new Vector2(imageSize * (WellFedBadge.AspectRatio ?? 1), imageSize); (uint ItemId, bool HQ)? newFoodBuff = null; - ImGui.Image(WellFedBadge.ImGuiHandle, buffBadgeSize); + ImGui.Image(WellFedBadge.Handle, buffBadgeSize); if (ImGui.IsItemHovered()) ImGuiUtils.Tooltip("Food"); ImGui.SameLine(0, 5); @@ -427,7 +427,7 @@ public sealed class MacroEditor : Window, IDisposable } (uint ItemId, bool HQ)? newMedicineBuff = null; - ImGui.Image(MedicatedBadge.ImGuiHandle, buffBadgeSize); + ImGui.Image(MedicatedBadge.Handle, buffBadgeSize); if (ImGui.IsItemHovered()) ImGuiUtils.Tooltip("Medicine"); ImGui.SameLine(0, 5); @@ -464,7 +464,7 @@ public sealed class MacroEditor : Window, IDisposable ImGui.TableNextColumn(); int? newFCCraftsmanshipBuff = null; - ImGui.Image(EatFromTheHandBadge.ImGuiHandle, buffBadgeSize); + ImGui.Image(EatFromTheHandBadge.Handle, buffBadgeSize); var fcBuffName = "Eat from the Hand"; var fcStatName = "Craftsmanship"; if (ImGui.IsItemHovered()) @@ -491,7 +491,7 @@ public sealed class MacroEditor : Window, IDisposable } int? newFCControlBuff = null; - ImGui.Image(InControlBadge.ImGuiHandle, buffBadgeSize); + ImGui.Image(InControlBadge.Handle, buffBadgeSize); fcBuffName = "In Control"; fcStatName = "Control"; if (ImGui.IsItemHovered()) @@ -763,7 +763,7 @@ public sealed class MacroEditor : Window, IDisposable (isExpert ? badgeSize.X + 3 : 0); ImGui.AlignTextToFramePadding(); - ImGui.Image(Service.IconManager.GetIconCached(RecipeData.Recipe.ItemResult.Value.Icon).ImGuiHandle, new Vector2(imageSize)); + ImGui.Image(Service.IconManager.GetIconCached(RecipeData.Recipe.ItemResult.Value.Icon).Handle, new Vector2(imageSize)); ImGui.SameLine(0, 5); @@ -801,7 +801,7 @@ public sealed class MacroEditor : Window, IDisposable uv1 /= new Vector2(56); ImGui.SetCursorPosY(ImGui.GetCursorPosY() + ImGui.GetStyle().FramePadding.Y / 2); - ImGui.Image(Service.IconManager.GetIconCached(classJob.GetIconId()).ImGuiHandle, new Vector2(imageSize), uv0, uv1); + ImGui.Image(Service.IconManager.GetIconCached(classJob.GetIconId()).Handle, new Vector2(imageSize), uv0, uv1); ImGui.SameLine(0, 5); ImGui.SetCursorPosY(ImGui.GetCursorPosY() + (fontHandle.FontSize - textLevelSize.Y) / 2); ImGui.TextUnformatted(textLevel); @@ -821,7 +821,8 @@ public sealed class MacroEditor : Window, IDisposable newAdjustedJobLevel = (ushort)level; } } - else { + else + { ImGui.TextUnformatted(textLevel); } @@ -837,7 +838,7 @@ public sealed class MacroEditor : Window, IDisposable if (isAdjustable) { ImGui.SameLine(0, 3); - ImGui.Image(CosmicExplorationBadge.ImGuiHandle, new(imageSize)); + ImGui.Image(CosmicExplorationBadge.Handle, new(imageSize)); if (ImGui.IsItemHovered()) ImGuiUtils.Tooltip($"Cosmic Exploration"); } @@ -846,7 +847,7 @@ public sealed class MacroEditor : Window, IDisposable { ImGui.SameLine(0, 3); ImGui.SetCursorPosY(ImGui.GetCursorPosY() + badgeOffset); - ImGui.Image(CollectibleBadge.ImGuiHandle, badgeSize); + ImGui.Image(CollectibleBadge.Handle, badgeSize); if (ImGui.IsItemHovered()) ImGuiUtils.Tooltip($"Collectible"); } @@ -855,7 +856,7 @@ public sealed class MacroEditor : Window, IDisposable { ImGui.SameLine(0, 3); ImGui.SetCursorPosY(ImGui.GetCursorPosY() + badgeOffset); - ImGui.Image(ExpertBadge.ImGuiHandle, badgeSize); + ImGui.Image(ExpertBadge.Handle, badgeSize); if (ImGui.IsItemHovered()) ImGuiUtils.Tooltip($"Expert Recipe"); } @@ -957,7 +958,7 @@ public sealed class MacroEditor : Window, IDisposable var imageSize = ImGui.GetFrameHeight(); using (var d = ImRaii.Disabled(!canHq)) - ImGui.Image(icon.ImGuiHandle, new Vector2(imageSize)); + ImGui.Image(icon.Handle, new Vector2(imageSize)); if (ImGui.IsItemHovered(ImGuiHoveredFlags.AllowWhenDisabled)) { if (canHq) @@ -1002,15 +1003,15 @@ public sealed class MacroEditor : Window, IDisposable var levelTextWidth = ImGui.CalcTextSize(SqText.ToLevelString(MAX_LEVEL)).X + ImGui.GetStyle().FramePadding.X * 2 + 5; return ImGui.CalcTextSize(SqText.LevelPrefix.ToIconString()).X + 5 + levelTextWidth; } - + private bool DrawLevelEntry(ref int level) { - static unsafe int LevelInputCallback(ImGuiInputTextCallbackData* data) + static int LevelInputCallback(ImGuiInputTextCallbackDataPtr data) { - if (data->EventFlag == ImGuiInputTextFlags.CallbackCharFilter) + if (data.EventFlag == ImGuiInputTextFlags.CallbackCharFilter) { - if (SqText.LevelNumReplacements.TryGetValue((char)data->EventChar, out var seChar)) - data->EventChar = seChar.ToIconChar(); + if (SqText.LevelNumReplacements.TryGetValue((char)data.EventChar, out var seChar)) + data.EventChar = seChar.ToIconChar(); else return 1; } @@ -1025,11 +1026,7 @@ public sealed class MacroEditor : Window, IDisposable ImGui.SameLine(0, 3); ImGui.SetNextItemWidth(levelTextWidth); var levelText = SqText.ToLevelString(level); - bool textChanged; - unsafe - { - textChanged = ImGui.InputText("##levelText", ref levelText, 12, ImGuiInputTextFlags.CallbackCharFilter | ImGuiInputTextFlags.AutoSelectAll, LevelInputCallback); - } + var textChanged = ImGui.InputText("##levelText", ref levelText, 12, ImGuiInputTextFlags.CallbackCharFilter | ImGuiInputTextFlags.AutoSelectAll, LevelInputCallback); if (textChanged) { var newLevel = SqText.TryParseLevelString(levelText, out var lv) @@ -1073,7 +1070,7 @@ public sealed class MacroEditor : Window, IDisposable { var actionBase = actions[i].Base(); var canUse = actionBase.CanUse(sim); - if (ImGui.ImageButton(actions[i].GetIcon(RecipeData!.ClassJob).ImGuiHandle, new(imageSize), default, Vector2.One, 0, default, !canUse ? new(1, 1, 1, ImGui.GetStyle().DisabledAlpha) : Vector4.One) && !SolverRunning) + if (ImGui.ImageButton(actions[i].GetIcon(RecipeData!.ClassJob).Handle, new(imageSize), default, Vector2.One, 0, default, !canUse ? new(1, 1, 1, ImGui.GetStyle().DisabledAlpha) : Vector4.One) && !SolverRunning) AddStep(actions[i]); if (!canUse && (CharacterStats.Level < actionBase.Level || @@ -1097,7 +1094,7 @@ public sealed class MacroEditor : Window, IDisposable if (_source) { ImGuiExtras.SetDragDropPayload("macroActionInsert", actions[i]); - ImGui.ImageButton(actions[i].GetIcon(RecipeData!.ClassJob).ImGuiHandle, new(imageSize)); + ImGui.ImageButton(actions[i].GetIcon(RecipeData!.ClassJob).Handle, new(imageSize)); } } } @@ -1228,7 +1225,7 @@ public sealed class MacroEditor : Window, IDisposable var icon = effect.GetIcon(effects.GetStrength(effect)); var size = new Vector2(buffIconHeight * (icon.AspectRatio ?? 1), buffIconHeight); - ImGui.Image(icon.ImGuiHandle, size); + ImGui.Image(icon.Handle, size); if (!effect.IsIndefinite()) { ImGui.SetCursorPosY(ImGui.GetCursorPosY() - buffDurationShift); @@ -1302,7 +1299,7 @@ public sealed class MacroEditor : Window, IDisposable var actionBase = action.Base(); var failedAction = response != ActionResponse.UsedAction; using var id = ImRaii.PushId(i); - if (ImGui.ImageButton(action.GetIcon(RecipeData!.ClassJob).ImGuiHandle, new(imageSize), default, Vector2.One, 0, default, failedAction ? new(1, 1, 1, ImGui.GetStyle().DisabledAlpha) : Vector4.One) && !SolverRunning) + if (ImGui.ImageButton(action.GetIcon(RecipeData!.ClassJob).Handle, new(imageSize), default, Vector2.One, 0, default, failedAction ? new(1, 1, 1, ImGui.GetStyle().DisabledAlpha) : Vector4.One) && !SolverRunning) RemoveStep(i); if (response is ActionResponse.ActionNotUnlocked || ( @@ -1331,7 +1328,7 @@ public sealed class MacroEditor : Window, IDisposable if (_source) { ImGuiExtras.SetDragDropPayload("macroAction", i); - ImGui.ImageButton(action.GetIcon(RecipeData!.ClassJob).ImGuiHandle, new(imageSize)); + ImGui.ImageButton(action.GetIcon(RecipeData!.ClassJob).Handle, new(imageSize)); } } using (var _target = ImRaii.DragDropTarget()) diff --git a/Craftimizer/Windows/MacroList.cs b/Craftimizer/Windows/MacroList.cs index f7fbfcc..969fbbf 100644 --- a/Craftimizer/Windows/MacroList.cs +++ b/Craftimizer/Windows/MacroList.cs @@ -3,7 +3,7 @@ using Craftimizer.Utils; using Dalamud.Interface.Utility.Raii; using Dalamud.Interface; using Dalamud.Interface.Windowing; -using ImGuiNET; +using Dalamud.Bindings.ImGui; using System; using Craftimizer.Simulator; using Craftimizer.Simulator.Actions; @@ -82,7 +82,7 @@ public sealed class MacroList : Window, IDisposable { var width = ImGui.GetContentRegionAvail().X; var macros = new List(sortedMacros); - for(var i = 0; i < macros.Count; ++i) + for (var i = 0; i < macros.Count; ++i) { var pos = ImGui.GetCursorPos(); DrawMacro(macros[i]); @@ -281,7 +281,7 @@ public sealed class MacroList : Window, IDisposable var shouldShowMore = i + 1 == itemsPerRow * 2 && i + 1 < itemCount; if (!shouldShowMore) { - ImGui.Image(macro.Actions[i].GetIcon(RecipeData!.ClassJob).ImGuiHandle, new(miniRowHeight)); + ImGui.Image(macro.Actions[i].GetIcon(RecipeData!.ClassJob).Handle, new(miniRowHeight)); if (ImGui.IsItemHovered()) ImGuiUtils.Tooltip(macro.Actions[i].GetName(RecipeData!.ClassJob)); } @@ -289,7 +289,7 @@ public sealed class MacroList : Window, IDisposable { var amtMore = itemCount - itemsPerRow * 2; var pos = ImGui.GetCursorPos(); - ImGui.Image(macro.Actions[i].GetIcon(RecipeData!.ClassJob).ImGuiHandle, new(miniRowHeight), default, Vector2.One, new(1, 1, 1, .5f)); + ImGui.Image(macro.Actions[i].GetIcon(RecipeData!.ClassJob).Handle, new(miniRowHeight), default, Vector2.One, new(1, 1, 1, .5f)); if (ImGui.IsItemHovered()) ImGuiUtils.Tooltip($"{macro.Actions[i].GetName(RecipeData!.ClassJob)}\nand {amtMore} more"); ImGui.SetCursorPos(pos); diff --git a/Craftimizer/Windows/RecipeNote.cs b/Craftimizer/Windows/RecipeNote.cs index c7e9209..9fa1b4a 100644 --- a/Craftimizer/Windows/RecipeNote.cs +++ b/Craftimizer/Windows/RecipeNote.cs @@ -20,7 +20,7 @@ using FFXIVClientStructs.FFXIV.Client.Game.UI; using FFXIVClientStructs.FFXIV.Client.System.String; using FFXIVClientStructs.FFXIV.Client.UI.Misc; using FFXIVClientStructs.FFXIV.Component.GUI; -using ImGuiNET; +using Dalamud.Bindings.ImGui; using System; using System.Collections.Generic; using System.Globalization; @@ -45,7 +45,7 @@ public sealed unsafe class RecipeNote : Window, IDisposable private const string WindowNamePinned = "Craftimizer Crafting Log Helper###CraftimizerRecipeNote"; private const string WindowNameFloating = $"{WindowNamePinned}Floating"; - public enum CraftableStatus + public enum CraftableStatus { OK, LockedClassJob, @@ -194,7 +194,7 @@ public sealed unsafe class RecipeNote : Window, IDisposable bool ShouldUseRecipeNote() { - Addon = (AtkUnitBase*)Service.GameGui.GetAddonByName("RecipeNote"); + Addon = (AtkUnitBase*)Service.GameGui.GetAddonByName("RecipeNote").Address; if (Addon == null) return false; @@ -211,7 +211,7 @@ public sealed unsafe class RecipeNote : Window, IDisposable bool ShouldUseWKSRecipeNote() { - Addon = (AtkUnitBase*)Service.GameGui.GetAddonByName("WKSRecipeNotebook"); + Addon = (AtkUnitBase*)Service.GameGui.GetAddonByName("WKSRecipeNotebook").Address; if (Addon == null) return false; @@ -297,7 +297,7 @@ public sealed unsafe class RecipeNote : Window, IDisposable SuggestedMacroTask?.Cancel(); SuggestedMacroTask = null; } - + // If we want to search automatically, we should recalculate if (Service.Configuration.ShowCommunityMacros && Service.Configuration.SearchCommunityMacroAutomatically) CalculateCommunityMacro(); @@ -533,7 +533,7 @@ public sealed unsafe class RecipeNote : Window, IDisposable uv0 /= new Vector2(56); uv1 /= new Vector2(56); - ImGui.Image(Service.IconManager.GetIconCached(RecipeData.ClassJob.GetIconId()).ImGuiHandle, new Vector2(imageSize), uv0, uv1); + ImGui.Image(Service.IconManager.GetIconCached(RecipeData.ClassJob.GetIconId()).Handle, new Vector2(imageSize), uv0, uv1); ImGui.SameLine(0, 5); if (level != 0) @@ -547,7 +547,7 @@ public sealed unsafe class RecipeNote : Window, IDisposable if (hasSplendorous) { ImGui.SameLine(0, 3); - ImGui.Image(SplendorousBadge.ImGuiHandle, new Vector2(imageSize)); + ImGui.Image(SplendorousBadge.Handle, new Vector2(imageSize)); if (ImGui.IsItemHovered()) ImGuiUtils.Tooltip($"Splendorous Tool"); } @@ -555,7 +555,7 @@ public sealed unsafe class RecipeNote : Window, IDisposable if (hasSpecialist) { ImGui.SameLine(0, 3); - ImGui.Image(SpecialistBadge.ImGuiHandle, new Vector2(imageSize), Vector2.Zero, Vector2.One, new(0.99f, 0.97f, 0.62f, 1f)); + ImGui.Image(SpecialistBadge.Handle, new Vector2(imageSize), Vector2.Zero, Vector2.One, new(0.99f, 0.97f, 0.62f, 1f)); if (ImGui.IsItemHovered()) ImGuiUtils.Tooltip($"Specialist"); } @@ -563,7 +563,7 @@ public sealed unsafe class RecipeNote : Window, IDisposable if (shouldHaveManip) { ImGui.SameLine(0, 3); - ImGui.Image(NoManipulationBadge.ImGuiHandle, new Vector2(imageSize)); + ImGui.Image(NoManipulationBadge.Handle, new Vector2(imageSize)); if (ImGui.IsItemHovered()) ImGuiUtils.Tooltip($"No Manipulation (Missing Job Quest)"); } @@ -637,7 +637,7 @@ public sealed unsafe class RecipeNote : Window, IDisposable ImGuiUtils.TextCentered($"You are missing the required equipment."); ImGuiUtils.AlignCentered(imageSize + 5 + ImGui.CalcTextSize(itemName).X); ImGui.AlignTextToFramePadding(); - ImGui.Image(Service.IconManager.GetIconCached(item.Icon).ImGuiHandle, new(imageSize)); + ImGui.Image(Service.IconManager.GetIconCached(item.Icon).Handle, new(imageSize)); ImGui.SameLine(0, 5); ImGui.TextUnformatted(itemName); } @@ -652,7 +652,7 @@ public sealed unsafe class RecipeNote : Window, IDisposable ImGuiUtils.TextCentered($"You are missing the required status effect."); ImGuiUtils.AlignCentered(imageSize.X + 5 + ImGui.CalcTextSize(statusName).X); ImGui.AlignTextToFramePadding(); - ImGui.Image(statusIcon.ImGuiHandle, imageSize); + ImGui.Image(statusIcon.Handle, imageSize); ImGui.SameLine(0, 5); ImGui.TextUnformatted(statusName); } @@ -709,7 +709,8 @@ public sealed unsafe class RecipeNote : Window, IDisposable { var textStars = new string('★', RecipeData!.Table.Stars); var textStarsSize = Vector2.Zero; - if (!string.IsNullOrEmpty(textStars)) { + if (!string.IsNullOrEmpty(textStars)) + { textStarsSize = AxisFont.CalcTextSize(textStars); } var textLevel = SqText.LevelPrefix.ToIconChar() + SqText.ToLevelString(RecipeData.AdjustedJobLevel ?? RecipeData.RecipeInfo.ClassJobLevel); @@ -731,7 +732,7 @@ public sealed unsafe class RecipeNote : Window, IDisposable ); ImGui.AlignTextToFramePadding(); - ImGui.Image(Service.IconManager.GetIconCached(RecipeData.Recipe.ItemResult.Value!.Icon).ImGuiHandle, new Vector2(imageSize)); + ImGui.Image(Service.IconManager.GetIconCached(RecipeData.Recipe.ItemResult.Value!.Icon).Handle, new Vector2(imageSize)); ImGui.SameLine(0, 5); ImGui.TextUnformatted(textLevel); @@ -748,7 +749,7 @@ public sealed unsafe class RecipeNote : Window, IDisposable if (isAdjustable) { ImGui.SameLine(0, 3); - ImGui.Image(CosmicExplorationBadge.ImGuiHandle, new(imageSize)); + ImGui.Image(CosmicExplorationBadge.Handle, new(imageSize)); if (ImGui.IsItemHovered()) ImGuiUtils.Tooltip($"Cosmic Exploration"); } @@ -757,7 +758,7 @@ public sealed unsafe class RecipeNote : Window, IDisposable { ImGui.SameLine(0, 3); ImGui.SetCursorPosY(ImGui.GetCursorPosY() + badgeOffset); - ImGui.Image(CollectibleBadge.ImGuiHandle, badgeSize); + ImGui.Image(CollectibleBadge.Handle, badgeSize); if (ImGui.IsItemHovered()) ImGuiUtils.Tooltip($"Collectible"); } @@ -766,7 +767,7 @@ public sealed unsafe class RecipeNote : Window, IDisposable { ImGui.SameLine(0, 3); ImGui.SetCursorPosY(ImGui.GetCursorPosY() + badgeOffset); - ImGui.Image(ExpertBadge.ImGuiHandle, badgeSize); + ImGui.Image(ExpertBadge.Handle, badgeSize); if (ImGui.IsItemHovered()) ImGuiUtils.Tooltip($"Expert Recipe"); } @@ -1071,7 +1072,7 @@ public sealed unsafe class RecipeNote : Window, IDisposable var shouldShowMore = i + 1 == itemsPerRow * 2 && i + 1 < itemCount; if (!shouldShowMore) { - ImGui.Image(actions[i].GetIcon(RecipeData!.ClassJob).ImGuiHandle, new(miniRowHeight)); + ImGui.Image(actions[i].GetIcon(RecipeData!.ClassJob).Handle, new(miniRowHeight)); if (ImGui.IsItemHovered()) ImGuiUtils.Tooltip(actions[i].GetName(RecipeData!.ClassJob)); } @@ -1079,7 +1080,7 @@ public sealed unsafe class RecipeNote : Window, IDisposable { var amtMore = itemCount - itemsPerRow * 2; var pos = ImGui.GetCursorPos(); - ImGui.Image(actions[i].GetIcon(RecipeData!.ClassJob).ImGuiHandle, new(miniRowHeight), default, Vector2.One, new(1, 1, 1, .5f)); + ImGui.Image(actions[i].GetIcon(RecipeData!.ClassJob).Handle, new(miniRowHeight), default, Vector2.One, new(1, 1, 1, .5f)); if (ImGui.IsItemHovered()) ImGuiUtils.Tooltip($"{actions[i].GetName(RecipeData!.ClassJob)}\nand {amtMore} more"); ImGui.SetCursorPos(pos); @@ -1108,12 +1109,12 @@ public sealed unsafe class RecipeNote : Window, IDisposable ImGui.TableNextColumn(); ImGui.TextUnformatted("Current"); ImGui.TableNextColumn(); - ImGui.TextColored(new(0, 1, 0, 1), $"{current}"); + ImGui.TextColored(new Vector4(0, 1, 0, 1), $"{current}"); ImGui.TableNextColumn(); ImGui.TextUnformatted("Required"); ImGui.TableNextColumn(); - ImGui.TextColored(new(1, 0, 0, 1), $"{required}"); + ImGui.TextColored(new Vector4(1, 0, 0, 1), $"{required}"); ImGui.TableNextColumn(); ImGui.TextUnformatted("You need"); diff --git a/Craftimizer/Windows/Settings.cs b/Craftimizer/Windows/Settings.cs index 54b62d7..cff9945 100644 --- a/Craftimizer/Windows/Settings.cs +++ b/Craftimizer/Windows/Settings.cs @@ -8,7 +8,7 @@ using Dalamud.Interface.Utility; using Dalamud.Interface.Utility.Raii; using Dalamud.Interface.Windowing; using FFXIVClientStructs.FFXIV.Client.UI; -using ImGuiNET; +using Dalamud.Bindings.ImGui; using System; using System.Collections.Generic; using System.Linq; @@ -834,7 +834,7 @@ public sealed class Settings : Window, IDisposable iconTint = new(1, 1f, .5f, 1); else if (isRisky) iconTint = new(1, .5f, .5f, 1); - if (ImGui.ImageButton(actions[i].GetIcon(recipeData.ClassJob).ImGuiHandle, new(imageSize), default, Vector2.One, 0, default, iconTint)) + if (ImGui.ImageButton(actions[i].GetIcon(recipeData.ClassJob).Handle, new(imageSize), default, Vector2.One, 0, default, iconTint)) { isDirty = true; if (isEnabled) @@ -893,7 +893,7 @@ public sealed class Settings : Window, IDisposable return true; } - foreach(var combo in ActionCategory.Combo.GetActions()) + foreach (var combo in ActionCategory.Combo.GetActions()) { if (combo.Base() is BaseComboAction { } comboAction) { @@ -1104,7 +1104,7 @@ public sealed class Settings : Window, IDisposable ImGui.TableSetupColumn("", ImGuiTableColumnFlags.WidthFixed, iconDim.X); ImGui.TableNextColumn(); - ImGui.Image(icon.ImGuiHandle, iconDim); + ImGui.Image(icon.Handle, iconDim); ImGui.TableNextColumn(); ImGuiUtils.AlignMiddle(new(float.PositiveInfinity, HeaderFont.GetFontSize() + SubheaderFont.GetFontSize() + ImGui.GetFontSize() * 3 + ImGui.GetStyle().ItemSpacing.Y * 4), new(0, iconDim.Y)); diff --git a/Craftimizer/Windows/SynthHelper.cs b/Craftimizer/Windows/SynthHelper.cs index ea4e2fd..120a119 100644 --- a/Craftimizer/Windows/SynthHelper.cs +++ b/Craftimizer/Windows/SynthHelper.cs @@ -15,7 +15,7 @@ using FFXIVClientStructs.FFXIV.Client.Game; using FFXIVClientStructs.FFXIV.Client.Game.Character; using FFXIVClientStructs.FFXIV.Client.UI; using FFXIVClientStructs.FFXIV.Client.UI.Shell; -using ImGuiNET; +using Dalamud.Bindings.ImGui; using System; using System.Collections.Generic; using System.Linq; @@ -32,7 +32,7 @@ public sealed unsafe class SynthHelper : Window, IDisposable private const ImGuiWindowFlags WindowFlagsPinned = WindowFlagsFloating | ImGuiWindowFlags.NoSavedSettings; - private const ImGuiWindowFlags WindowFlagsFloating = + private const ImGuiWindowFlags WindowFlagsFloating = ImGuiWindowFlags.AlwaysAutoResize | ImGuiWindowFlags.NoFocusOnAppearing; @@ -168,7 +168,7 @@ public sealed unsafe class SynthHelper : Window, IDisposable return false; } - Addon = (AddonSynthesis*)Service.GameGui.GetAddonByName("Synthesis"); + Addon = (AddonSynthesis*)Service.GameGui.GetAddonByName("Synthesis").Address; if (Addon == null) { @@ -210,7 +210,7 @@ public sealed unsafe class SynthHelper : Window, IDisposable Macro.FlushQueue(); - var isInCraftAction = Service.Condition[ConditionFlag.Crafting40]; + var isInCraftAction = Service.Condition[ConditionFlag.ExecutingCraftingAction]; if (!isInCraftAction && wasInCraftAction) RefreshCurrentState(); wasInCraftAction = isInCraftAction; @@ -289,7 +289,7 @@ public sealed unsafe class SynthHelper : Window, IDisposable { var spacing = ImGui.GetStyle().ItemSpacing.X; var imageSize = ImGui.GetFrameHeight() * 2; - var canExecute = !Service.Condition[ConditionFlag.Crafting40]; + var canExecute = !Service.Condition[ConditionFlag.ExecutingCraftingAction]; var lastState = Macro.InitialState; hoveredState = null; @@ -328,10 +328,10 @@ public sealed unsafe class SynthHelper : Window, IDisposable var id = ImGui.GetID($"###ButtonContainer"); var isClipped = !ImGuiExtras.ItemAdd(bb, id, out _, 0); - + isPressed = ImGuiExtras.ButtonBehavior(bb, id, out isHovered, out isHeld, ImGuiButtonFlags.None); } - ImGui.ImageButton(action.GetIcon(RecipeData!.ClassJob).ImGuiHandle, new(imageSize), default, Vector2.One, 0, default, failedAction ? new(1, 1, 1, ImGui.GetStyle().DisabledAlpha) : Vector4.One); + ImGui.ImageButton(action.GetIcon(RecipeData!.ClassJob).Handle, new(imageSize), default, Vector2.One, 0, default, failedAction ? new(1, 1, 1, ImGui.GetStyle().DisabledAlpha) : Vector4.One); if (isPressed && i == 0) { if (ExecuteNextAction()) @@ -380,7 +380,7 @@ public sealed unsafe class SynthHelper : Window, IDisposable var icon = effect.GetIcon(effects.GetStrength(effect)); var size = new Vector2(iconHeight * (icon.AspectRatio ?? 1), iconHeight); - ImGui.Image(icon.ImGuiHandle, size); + ImGui.Image(icon.Handle, size); if (!effect.IsIndefinite()) { ImGui.SetCursorPosY(ImGui.GetCursorPosY() - durationShift); @@ -476,7 +476,7 @@ public sealed unsafe class SynthHelper : Window, IDisposable public bool ExecuteNextAction() { - var canExecute = !Service.Condition[ConditionFlag.Crafting40]; + var canExecute = !Service.Condition[ConditionFlag.ExecutingCraftingAction]; var action = NextAction; if (canExecute && action != null) { @@ -528,7 +528,7 @@ public sealed unsafe class SynthHelper : Window, IDisposable private void OnUseAction(ActionType action) { - Addon = (AddonSynthesis*)Service.GameGui.GetAddonByName("Synthesis"); + Addon = (AddonSynthesis*)Service.GameGui.GetAddonByName("Synthesis").Address; if (Addon == null) return; if (Addon->AtkUnitBase.WindowNode == null) diff --git a/Craftimizer/packages.lock.json b/Craftimizer/packages.lock.json index 6b54cdd..40dbcf8 100644 --- a/Craftimizer/packages.lock.json +++ b/Craftimizer/packages.lock.json @@ -4,9 +4,9 @@ "net9.0-windows7.0": { "DalamudPackager": { "type": "Direct", - "requested": "[12.0.0, )", - "resolved": "12.0.0", - "contentHash": "J5TJLV3f16T/E2H2P17ClWjtfEBPpq3yxvqW46eN36JCm6wR+EaoaYkqG9Rm5sHqs3/nK/vKjWWyvEs/jhKoXw==" + "requested": "[13.0.0, )", + "resolved": "13.0.0", + "contentHash": "Mb3cUDSK/vDPQ8gQIeuCw03EMYrej1B4J44a1AvIJ9C759p9XeqdU9Hg4WgOmlnlPe0G7ILTD32PKSUpkQNa8w==" }, "DotNet.ReproducibleBuilds": { "type": "Direct",