starting new crafting log ui
This commit is contained in:
@@ -11,6 +11,7 @@ using Condition = Craftimizer.Simulator.Condition;
|
|||||||
using Craftimizer.Simulator;
|
using Craftimizer.Simulator;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Numerics;
|
using System.Numerics;
|
||||||
|
using System.Globalization;
|
||||||
|
|
||||||
namespace Craftimizer.Plugin;
|
namespace Craftimizer.Plugin;
|
||||||
|
|
||||||
@@ -95,6 +96,12 @@ internal static class ClassJobUtils
|
|||||||
_ => 0
|
_ => 0
|
||||||
};
|
};
|
||||||
|
|
||||||
|
public static string GetName(this ClassJob classJob)
|
||||||
|
{
|
||||||
|
var job = LuminaSheets.ClassJobSheet.GetRow(classJob.GetClassJobIndex())!;
|
||||||
|
return CultureInfo.InvariantCulture.TextInfo.ToTitleCase(job.Name.ToDalamudString().TextValue);
|
||||||
|
}
|
||||||
|
|
||||||
// Index in the actual ClassJob sheet
|
// Index in the actual ClassJob sheet
|
||||||
public static bool IsClassJob(byte classJobIdx, ClassJob classJob)
|
public static bool IsClassJob(byte classJobIdx, ClassJob classJob)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
using Craftimizer.Plugin.Utils;
|
using Craftimizer.Plugin.Utils;
|
||||||
using Craftimizer.Simulator;
|
using Craftimizer.Simulator;
|
||||||
using Craftimizer.Simulator.Actions;
|
using Craftimizer.Simulator.Actions;
|
||||||
|
using Dalamud;
|
||||||
using Dalamud.Interface;
|
using Dalamud.Interface;
|
||||||
using Dalamud.Interface.Components;
|
using Dalamud.Interface.Components;
|
||||||
using Dalamud.Interface.Windowing;
|
using Dalamud.Interface.Windowing;
|
||||||
@@ -30,9 +31,16 @@ public unsafe class CraftingLog : Window
|
|||||||
|
|
||||||
private AddonRecipeNote* Addon { get; set; }
|
private AddonRecipeNote* Addon { get; set; }
|
||||||
private RecipeNote* State { get; set; }
|
private RecipeNote* State { get; set; }
|
||||||
private ushort SelectedRecipeId { get; set; }
|
private ushort RecipeId { get; set; }
|
||||||
private Recipe SelectedRecipe { get; set; } = null!;
|
private Recipe Recipe { get; set; } = null!;
|
||||||
private RecipeInfo SelectedRecipeInfo { get; set; } = null!;
|
private RecipeInfo RecipeInfo { get; set; } = null!;
|
||||||
|
|
||||||
|
private ClassJob RecipeClassJob => (ClassJob)Recipe.CraftType.Row;
|
||||||
|
private short RecipeCharacterLevel => PlayerState.Instance()->ClassJobLevelArray[RecipeClassJob.GetClassJobIndex()];
|
||||||
|
private bool RecipeCanUseManipulation => ActionManager.CanUseActionOnTarget(ActionType.Manipulation.GetId(RecipeClassJob), (GameObject*)Service.ClientState.LocalPlayer!.Address);
|
||||||
|
private RecipeLevelTable RecipeTable => Recipe.RecipeLevelTable.Value!;
|
||||||
|
|
||||||
|
private int startingQuality;
|
||||||
|
|
||||||
public CraftingLog() : base("RecipeNoteHelper", WindowFlags, true)
|
public CraftingLog() : base("RecipeNoteHelper", WindowFlags, true)
|
||||||
{
|
{
|
||||||
@@ -41,15 +49,74 @@ public unsafe class CraftingLog : Window
|
|||||||
|
|
||||||
public override void Draw()
|
public override void Draw()
|
||||||
{
|
{
|
||||||
var inst = RaptureGearsetModule.Instance();
|
|
||||||
|
|
||||||
if (Service.ClientState.LocalPlayer == null)
|
if (Service.ClientState.LocalPlayer == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var recipeClassJob = (ClassJob)SelectedRecipe.CraftType.Row;
|
DrawCraftInfo();
|
||||||
|
|
||||||
var characterLevel = PlayerState.Instance()->ClassJobLevelArray[recipeClassJob.GetClassJobIndex()];
|
DrawGearsets();
|
||||||
var canUseManipulation = ActionManager.CanUseActionOnTarget(ActionType.Manipulation.GetId(recipeClassJob), (GameObject*)Service.ClientState.LocalPlayer.Address);
|
}
|
||||||
|
|
||||||
|
void DrawCraftInfo()
|
||||||
|
{
|
||||||
|
DrawRecipeInfo();
|
||||||
|
DrawCharacterInfo();
|
||||||
|
|
||||||
|
DrawCraftActions();
|
||||||
|
}
|
||||||
|
|
||||||
|
void DrawRecipeInfo()
|
||||||
|
{
|
||||||
|
var s = new StringBuilder();
|
||||||
|
s.AppendLine($"{RecipeClassJob.GetName()} {new string('★', RecipeTable.Stars)}");
|
||||||
|
s.AppendLine($"Level {RecipeTable.ClassJobLevel} (RLvl {RecipeInfo.RLvl})");
|
||||||
|
s.AppendLine($"Durability: {RecipeInfo.MaxDurability}");
|
||||||
|
s.AppendLine($"Progress: {RecipeInfo.MaxProgress}");
|
||||||
|
s.AppendLine($"Quality: {RecipeInfo.MaxQuality}");
|
||||||
|
s.AppendLine($"Starting Quality: {startingQuality}");
|
||||||
|
ImGui.Text(s.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
|
void DrawCharacterInfo()
|
||||||
|
{
|
||||||
|
var classJob = (byte)Service.ClientState.LocalPlayer!.ClassJob.Id;
|
||||||
|
|
||||||
|
if (!ClassJobUtils.IsClassJob(classJob, RecipeClassJob))
|
||||||
|
{
|
||||||
|
ImGui.Text("Your current class cannot craft this recipe.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var container = InventoryManager.Instance()->GetInventoryContainer(InventoryType.EquippedItems);
|
||||||
|
if (container == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var stats = Gearsets.CalculateCharacterStats(container, RecipeCharacterLevel, RecipeCanUseManipulation);
|
||||||
|
|
||||||
|
var s = new StringBuilder();
|
||||||
|
s.AppendLine($"{RecipeClassJob.GetName()}");
|
||||||
|
s.AppendLine($"Level {stats.Level} (CLvl {stats.CLvl})");
|
||||||
|
s.AppendLine($"Craftsmanship {stats.Craftsmanship}");
|
||||||
|
s.AppendLine($"Control {stats.Control}");
|
||||||
|
s.AppendLine($"CP {stats.CP}");
|
||||||
|
if (stats.IsSpecialist)
|
||||||
|
s.AppendLine($" + Specialist");
|
||||||
|
if (stats.HasSplendorousBuff)
|
||||||
|
s.AppendLine($" + Splendorous");
|
||||||
|
ImGui.Text(s.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
|
void DrawCraftActions()
|
||||||
|
{
|
||||||
|
ImGui.Button("Open Simulator");
|
||||||
|
ImGui.Button("Generate a new macro");
|
||||||
|
}
|
||||||
|
|
||||||
|
void DrawGearsets()
|
||||||
|
{
|
||||||
|
ImGui.Text("Available Gearsets");
|
||||||
|
|
||||||
|
var inst = RaptureGearsetModule.Instance();
|
||||||
|
|
||||||
for (var i = 0; i < 100; i++)
|
for (var i = 0; i < 100; i++)
|
||||||
{
|
{
|
||||||
@@ -61,33 +128,34 @@ public unsafe class CraftingLog : Window
|
|||||||
if (!gearset->Flags.HasFlag(RaptureGearsetModule.GearsetFlag.Exists))
|
if (!gearset->Flags.HasFlag(RaptureGearsetModule.GearsetFlag.Exists))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (!ClassJobUtils.IsClassJob(gearset->ClassJob, recipeClassJob))
|
if (!ClassJobUtils.IsClassJob(gearset->ClassJob, RecipeClassJob))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
var stats = Gearsets.CalculateCharacterStats(gearset, characterLevel, canUseManipulation);
|
var stats = Gearsets.CalculateCharacterStats(gearset, RecipeCharacterLevel, RecipeCanUseManipulation);
|
||||||
ImGui.Text($"Gearset: {gearset->ID + 1} {Marshal.PtrToStringUTF8((nint)gearset->Name)}");
|
var gearsetId = gearset->ID + 1;
|
||||||
|
|
||||||
|
var s = new StringBuilder();
|
||||||
|
s.AppendLine($"{SafeMemory.ReadString((nint)gearset->Name, 47)} ({gearsetId})");
|
||||||
|
s.AppendLine($"Level {stats.Level} (CLvl {stats.CLvl})");
|
||||||
|
s.AppendLine($"Craftsmanship {stats.Craftsmanship}");
|
||||||
|
s.AppendLine($"Control {stats.Control}");
|
||||||
|
s.AppendLine($"CP {stats.CP}");
|
||||||
|
if (stats.IsSpecialist)
|
||||||
|
s.AppendLine($" + Specialist");
|
||||||
|
if (stats.HasSplendorousBuff)
|
||||||
|
s.AppendLine($" + Splendorous");
|
||||||
|
ImGui.Text(s.ToString());
|
||||||
ImGui.SameLine();
|
ImGui.SameLine();
|
||||||
if (ImGuiComponents.IconButton($"SwapGearset{gearset->ID}", FontAwesomeIcon.SyncAlt))
|
if (ImGuiComponents.IconButton($"SwapGearset{gearsetId}", FontAwesomeIcon.SyncAlt))
|
||||||
Chat.SendMessage($"/gearset change {gearset->ID + 1}");
|
Chat.SendMessage($"/gearset change {gearsetId}");
|
||||||
if (ImGui.IsItemHovered())
|
if (ImGui.IsItemHovered())
|
||||||
ImGui.SetTooltip($"Swap to gearset {gearset->ID + 1}");
|
ImGui.SetTooltip($"Swap to gearset {gearsetId}");
|
||||||
ImGui.Text($"{stats}");
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
{
|
void OnNewRecipe()
|
||||||
var classJob = (byte)Service.ClientState.LocalPlayer.ClassJob.Id;
|
{
|
||||||
|
startingQuality = 0;
|
||||||
if (!ClassJobUtils.IsClassJob(classJob, recipeClassJob))
|
|
||||||
return;
|
|
||||||
|
|
||||||
var container = InventoryManager.Instance()->GetInventoryContainer(InventoryType.EquippedItems);
|
|
||||||
if (container == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
var stats = Gearsets.CalculateCharacterStats(container, characterLevel, canUseManipulation);
|
|
||||||
ImGui.Text($"Currently Equipped");
|
|
||||||
ImGui.Text($"{stats}");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool DrawConditions()
|
public override bool DrawConditions()
|
||||||
@@ -112,16 +180,19 @@ public unsafe class CraftingLog : Window
|
|||||||
if (recipeEntry == null)
|
if (recipeEntry == null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
SelectedRecipeId = recipeEntry->RecipeId;
|
if (RecipeId != recipeEntry->RecipeId)
|
||||||
|
OnNewRecipe();
|
||||||
|
|
||||||
var recipe = LuminaSheets.RecipeSheet.GetRow(SelectedRecipeId);
|
RecipeId = recipeEntry->RecipeId;
|
||||||
|
|
||||||
|
var recipe = LuminaSheets.RecipeSheet.GetRow(RecipeId);
|
||||||
|
|
||||||
if (recipe == null)
|
if (recipe == null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
SelectedRecipe = recipe;
|
Recipe = recipe;
|
||||||
|
|
||||||
SelectedRecipeInfo = SimulatorWindow.CreateRecipeInfo(SelectedRecipe);
|
RecipeInfo = SimulatorWindow.CreateRecipeInfo(Recipe);
|
||||||
|
|
||||||
if (!Addon->Unk258->IsVisible)
|
if (!Addon->Unk258->IsVisible)
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
Reference in New Issue
Block a user