Skip to content

Commit

Permalink
RecipeNote layout changes
Browse files Browse the repository at this point in the history
  • Loading branch information
WorkingRobot committed Nov 5, 2023
1 parent e07617f commit a44b15a
Showing 1 changed file with 34 additions and 50 deletions.
84 changes: 34 additions & 50 deletions Craftimizer/Windows/RecipeNote.cs
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,6 @@ public override void Draw()
{
if (table)
{
ImGui.TableSetupColumn("col1", ImGuiTableColumnFlags.WidthFixed, 0);
ImGui.TableSetupColumn("col2", ImGuiTableColumnFlags.WidthFixed, 0);
ImGui.TableNextColumn();
DrawCharacterStats();
ImGui.TableNextColumn();
Expand All @@ -216,46 +214,35 @@ public override void Draw()

ImGui.Separator();

using (var table = ImRaii.Table("macros", 1, ImGuiTableFlags.SizingStretchSame))
var panelWidth = availWidth - ImGui.GetStyle().ItemSpacing.X * 2;
using (var panel = ImGuiUtils.GroupPanel("Best Saved Macro", panelWidth, out _))
{
if (table)
var stepsPanelWidthOffset = ImGui.GetContentRegionAvail().X - panelWidth;
if (BestSavedMacro is { } savedMacro)
{
ImGui.TableNextColumn();

availWidth -= ImGui.GetStyle().ItemSpacing.X * 2;
using (var panel = ImGuiUtils.GroupPanel("Best Saved Macro", availWidth, out _))
{
var stepsAvailWidthOffset = ImGui.GetContentRegionAvail().X - availWidth;
if (BestSavedMacro is { } savedMacro)
{
ImGuiUtils.TextCentered(savedMacro.Item1.Name, availWidth);
DrawMacro((savedMacro.Item1.Actions, savedMacro.Item2), a => { savedMacro.Item1.ActionEnumerable = a; Service.Configuration.Save(); }, stepsAvailWidthOffset, true);
}
else
{
ImGui.Text("");
DrawMacro(null, null, stepsAvailWidthOffset, true);
}
}
ImGuiUtils.TextCentered(savedMacro.Item1.Name, panelWidth);
DrawMacro((savedMacro.Item1.Actions, savedMacro.Item2), a => { savedMacro.Item1.ActionEnumerable = a; Service.Configuration.Save(); }, stepsPanelWidthOffset, true);
}
else
DrawMacro(null, null, stepsPanelWidthOffset, true);
}

using (var panel = ImGuiUtils.GroupPanel("Suggested Macro", availWidth, out _))
{
var stepsAvailWidthOffset = ImGui.GetContentRegionAvail().X - availWidth;
if (BestSuggestedMacro is { } suggestedMacro)
DrawMacro((suggestedMacro.Actions, suggestedMacro.State), null, stepsAvailWidthOffset, false);
else
DrawMacro(null, null, stepsAvailWidthOffset, false);
}
using (var panel = ImGuiUtils.GroupPanel("Suggested Macro", panelWidth, out _))
{
var stepsPanelWidthOffset = ImGui.GetContentRegionAvail().X - panelWidth;
if (BestSuggestedMacro is { } suggestedMacro)
DrawMacro((suggestedMacro.Actions, suggestedMacro.State), null, stepsPanelWidthOffset, false);
else
DrawMacro(null, null, stepsPanelWidthOffset, false);
}

ImGuiHelpers.ScaledDummy(5);
ImGuiHelpers.ScaledDummy(5);

if (ImGui.Button("View Saved Macros", new(-1, 0)))
Service.Plugin.OpenMacroListWindow();
if (ImGui.Button("View Saved Macros", new(availWidth, 0)))
Service.Plugin.OpenMacroListWindow();

if (ImGui.Button("Open in Simulator", new(-1, 0)))
Service.Plugin.OpenMacroEditor(CharacterStats!, RecipeData!, new(Service.ClientState.LocalPlayer!.StatusList), Enumerable.Empty<ActionType>(), null);
}
}
if (ImGui.Button("Open in Simulator", new(availWidth, 0)))
Service.Plugin.OpenMacroEditor(CharacterStats!, RecipeData!, new(Service.ClientState.LocalPlayer!.StatusList), Enumerable.Empty<ActionType>(), null);
}

private void DrawCharacterStats()
Expand Down Expand Up @@ -440,26 +427,25 @@ private void DrawCharacterStats()
break;
case CraftableStatus.OK:
{
using var table = ImRaii.Table("characterStats", 2, ImGuiTableFlags.NoHostExtendX);
using var table = ImRaii.Table("characterStats", 2);
if (table)
{
ImGui.TableSetupColumn("ccol1", ImGuiTableColumnFlags.WidthFixed, 100);
ImGui.TableSetupColumn("ccol2", ImGuiTableColumnFlags.WidthStretch);
ImGui.TableSetupColumn("", ImGuiTableColumnFlags.WidthFixed, 100);

ImGui.TableNextColumn();
ImGui.Text("Craftsmanship");
ImGui.TableNextColumn();
ImGui.Text($"{CharacterStats!.Craftsmanship}");
ImGuiUtils.TextRight($"{CharacterStats!.Craftsmanship}");

ImGui.TableNextColumn();
ImGui.Text("Control");
ImGui.TableNextColumn();
ImGui.Text($"{CharacterStats.Control}");
ImGuiUtils.TextRight($"{CharacterStats.Control}");

ImGui.TableNextColumn();
ImGui.Text("CP");
ImGui.TableNextColumn();
ImGui.Text($"{CharacterStats.CP}");
ImGuiUtils.TextRight($"{CharacterStats.CP}");
}
}
break;
Expand Down Expand Up @@ -532,23 +518,22 @@ private void DrawRecipeStats()
using var table = ImRaii.Table("recipeStats", 2);
if (table)
{
ImGui.TableSetupColumn("rcol1", ImGuiTableColumnFlags.WidthFixed, 100);
ImGui.TableSetupColumn("rcol2", ImGuiTableColumnFlags.WidthStretch);
ImGui.TableSetupColumn("", ImGuiTableColumnFlags.WidthFixed, 100);

ImGui.TableNextColumn();
ImGui.Text("Progress");
ImGui.TableNextColumn();
ImGui.Text($"{RecipeData.RecipeInfo.MaxProgress}");
ImGuiUtils.TextRight($"{RecipeData.RecipeInfo.MaxProgress}");

ImGui.TableNextColumn();
ImGui.Text("Quality");
ImGui.TableNextColumn();
ImGui.Text($"{RecipeData.RecipeInfo.MaxQuality}");
ImGuiUtils.TextRight($"{RecipeData.RecipeInfo.MaxQuality}");

ImGui.TableNextColumn();
ImGui.Text("Durability");
ImGui.TableNextColumn();
ImGui.Text($"{RecipeData.RecipeInfo.MaxDurability}");
ImGuiUtils.TextRight($"{RecipeData.RecipeInfo.MaxDurability}");
}
}

Expand Down Expand Up @@ -709,11 +694,10 @@ private static void DrawRequiredStatsTable(int current, int required)
if (current >= required)
throw new ArgumentOutOfRangeException(nameof(current));

using var table = ImRaii.Table("requiredStats", 2, ImGuiTableFlags.NoHostExtendX);
using var table = ImRaii.Table("requiredStats", 2);
if (table)
{
ImGui.TableSetupColumn("ccol1", ImGuiTableColumnFlags.WidthFixed, 100);
ImGui.TableSetupColumn("ccol2", ImGuiTableColumnFlags.WidthStretch);
ImGui.TableSetupColumn("", ImGuiTableColumnFlags.WidthFixed, 100);

ImGui.TableNextColumn();
ImGui.Text("Current");
Expand Down

0 comments on commit a44b15a

Please sign in to comment.