Skip to content
This repository has been archived by the owner on Aug 28, 2024. It is now read-only.

Commit

Permalink
fix: align the icons.
Browse files Browse the repository at this point in the history
  • Loading branch information
ArchiDog1998 committed Aug 17, 2023
1 parent 07fc813 commit 0ca796e
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 25 deletions.
1 change: 1 addition & 0 deletions RotationSolver/ActionSequencer/ActionCondition.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ public void Draw(ICustomRotation rotation)
if(!ImGui.IsPopupOpen(popUpKey)) ImGui.OpenPopup(popUpKey);
}
RotationConfigWindow.DrawActionOverlay(cursor, ConditionHelper.IconSize, 1);
ImguiTooltips.HoveredTooltip(name);
}

ImGui.SameLine();
Expand Down
9 changes: 6 additions & 3 deletions RotationSolver/ActionSequencer/ConditionHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,15 @@ internal static void SearchItemsReflection<T>(string popId, string name, ref str
}
}

public static float IconSize => 32 * ImGuiHelpers.GlobalScale;
private int count = 15;
public static void ActionSelectorPopUp(string popUpId, CollapsingHeaderGroup group, ICustomRotation rotation, Action<IAction> action)
public static float IconSizeRaw => ImGuiHelpers.GetButtonSize("H").Y;
public static float IconSize => IconSizeRaw * ImGuiHelpers.GlobalScale;
private const int count = 8;
public static void ActionSelectorPopUp(string popUpId, CollapsingHeaderGroup group, ICustomRotation rotation, Action<IAction> action, Action others = null)
{
if (group != null && ImGui.BeginPopup(popUpId))
{
others?.Invoke();

group.ClearCollapsingHeader();

foreach (var pair in RotationUpdater.GroupActions(rotation.AllBaseActions))
Expand Down
18 changes: 7 additions & 11 deletions RotationSolver/ActionSequencer/ConditionSet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,13 @@ public void Draw(ICustomRotation rotation)

ImGui.SameLine();

if(ImGui.Button((IsAnd ? "&" : "|") + $"##Rule{GetHashCode()}"))
if(ImGui.Button((IsAnd ? "&&" : "||") + $"##Rule{GetHashCode()}"))
{
IsAnd = !IsAnd;
}

ImGui.Spacing();

ImGui.Indent();

for(int i = 0; i < Conditions.Count; i++)
{
ICondition condition = Conditions[i];
Expand All @@ -52,7 +50,7 @@ void Up()
void Down()
{
Conditions.RemoveAt(i);
Conditions.Insert(Math.Min(Conditions.Count - 1, i + 1), condition);
Conditions.Insert(Math.Min(Conditions.Count, i + 1), condition);
}

var key = $"Condition Pop Up: {condition.GetHashCode()}";
Expand All @@ -74,7 +72,6 @@ void Down()
condition.Draw(rotation);
}

ImGui.Unindent();
ImGui.EndGroup();
}

Expand Down Expand Up @@ -107,23 +104,22 @@ private void AddOneCondition<T>(string name) where T : ICondition

internal static void DrawCondition(bool? tag)
{
const float size = 32;
float size = ConditionHelper.IconSize * (1 + 8 / 82);

if (!tag.HasValue)
{
if (IconSet.GetTexture("ui/uld/image2.tex", out var texture) || IconSet.GetTexture(0u, out texture))
{
ImGui.Image(texture.ImGuiHandle, Vector2.One * size * ImGuiHelpers.GlobalScale);
ImGui.Image(texture.ImGuiHandle, Vector2.One * size);
}
}
else
{
if (IconSet.GetTexture("ui/uld/readycheck_hr1.tex", out var texture))
{
var offset = new Vector2(1 / 12f, 1 / 6f);
ImGui.Image(texture.ImGuiHandle, Vector2.One * size * ImGuiHelpers.GlobalScale,
new Vector2(tag.Value ? 0 : 0.5f, 0) + offset,
new Vector2(tag.Value ? 0.5f : 1, 1) - offset);
ImGui.Image(texture.ImGuiHandle, Vector2.One * size,
new Vector2(tag.Value ? 0 : 0.5f, 0),
new Vector2(tag.Value ? 0.5f : 1, 1));
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions RotationSolver/ActionSequencer/MajorConditionSet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public void DrawCondition(uint id, ICustomRotation rotation)
if (conditionSet == null) return;

ConditionSet.DrawCondition(conditionSet.IsTrue(rotation));
ImGui.SameLine();
conditionSet?.Draw(rotation);
}

Expand All @@ -37,6 +38,7 @@ public void DrawDisabledCondition(uint id, ICustomRotation rotation)
if (conditionSet == null) return;

ConditionSet.DrawCondition(conditionSet.IsTrue(rotation));
ImGui.SameLine();
conditionSet?.Draw(rotation);
}

Expand Down
21 changes: 18 additions & 3 deletions RotationSolver/ActionSequencer/TargetCondition.cs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,22 @@ public void Draw(ICustomRotation rotation)

var popUpKey = "Target Condition Pop Up" + GetHashCode().ToString();

ConditionHelper.ActionSelectorPopUp(popUpKey, _actionsList, rotation, item => ID = (ActionID)item.ID);
ConditionHelper.ActionSelectorPopUp(popUpKey, _actionsList, rotation, item => ID = (ActionID)item.ID, ()=>
{
if (ImGui.Selectable(LocalizationManager.RightLang.ActionSequencer_Target))
{
_action = null;
ID = ActionID.None;
IsTarget = true;
}

if (ImGui.Selectable(LocalizationManager.RightLang.ActionSequencer_Player))
{
_action = null;
ID = ActionID.None;
IsTarget = false;
}
});

if (_action != null ? ( _action.GetTexture(out var icon) || IconSet.GetTexture(4, out icon))
: IconSet.GetTexture(IsTarget ? 16u : 18u, out icon))
Expand Down Expand Up @@ -194,14 +209,14 @@ public void Draw(ICustomRotation rotation)
{
Status = status;
StatusId = (StatusID)Status.RowId;
});
}, size: ConditionHelper.IconSizeRaw);

void DrawStatusIcon()
{
if (IconSet.GetTexture(Status?.Icon ?? 16220, out var icon)
|| IconSet.GetTexture(16220, out icon))
{
if (RotationConfigWindow.NoPaddingNoColorImageButton(icon.ImGuiHandle, new Vector2(24, 32) * ImGuiHelpers.GlobalScale, GetHashCode().ToString()))
if (RotationConfigWindow.NoPaddingNoColorImageButton(icon.ImGuiHandle, new Vector2(ConditionHelper.IconSize * 3 / 4, ConditionHelper.IconSize) * ImGuiHelpers.GlobalScale, GetHashCode().ToString()))
{
if (!ImGui.IsPopupOpen(popupId)) ImGui.OpenPopup(popupId);
}
Expand Down
5 changes: 4 additions & 1 deletion RotationSolver/Localization/Localization.json
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,7 @@
"ConfigWindow_List_Actions": "Actions",
"ConfigWindow_List_Territories": "Territories",
"ConfigWindow_List_StatusNameOrId": "Status name or id",
"ConfigWindow_Actions_MemberName": "Member Name",
"ConfigWindow_List_AddStatus": "Add Status",
"ConfigWindow_List_Remove": "Remove",
"ConfigWindow_List_ActionNameOrId": "Action name or id",
Expand Down Expand Up @@ -480,5 +481,7 @@
"ConfigWindow_Tab_Auto": "About some general actions' usage and conditions.",
"ConfigWindow_Tab_Target": "The way to find the targets, hostiles or friends.",
"ConfigWindow_Tab_Extra": "Some features shouldn't be included by RS.",
"ConfigWindow_List_AddPosition": "Add One territory position"
"ConfigWindow_List_AddPosition": "Add One territory position",
"ConfigWindow_Actions_MoveUp": "Move Up",
"ConfigWindow_Actions_MoveDown": "Move Down"
}
2 changes: 1 addition & 1 deletion RotationSolver/UI/CollapsingHeaderGroup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public void Draw()
ImGui.Separator();
var selected = index == _openedIndex;
ImGui.PushFont(ImGuiHelper.GetFont(HeaderSize));
var changed = ImGui.Selectable(name, selected);
var changed = ImGui.Selectable(name, selected, ImGuiSelectableFlags.DontClosePopups);
ImGui.PopFont();
if (ImGui.IsItemHovered())
{
Expand Down
11 changes: 5 additions & 6 deletions RotationSolver/UI/RotationConfigWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
using RotationSolver.UI.SearchableConfigs;
using RotationSolver.UI.SearchableSettings;
using RotationSolver.Updaters;
using System;
using System.Diagnostics;
using GAction = Lumina.Excel.GeneratedSheets.Action;

Expand Down Expand Up @@ -711,8 +710,6 @@ private static void DrawRotationDescription()
if (notStart)
{
ImGui.SameLine();
ImGui.Text(" ");
ImGui.SameLine();
}

if(item.GetTexture(out var texture))
Expand Down Expand Up @@ -1473,7 +1470,7 @@ private static void DrawStatusList(string name, HashSet<uint> statuses, Status[]
}
}

internal static void StatusPopUp(string popupId, Status[] allStatus, ref string searching, Action<Status> clicked, uint notLoadId = 10100)
internal static void StatusPopUp(string popupId, Status[] allStatus, ref string searching, Action<Status> clicked, uint notLoadId = 10100, float size = 32)
{
if (ImGui.BeginPopup(popupId))
{
Expand All @@ -1484,7 +1481,7 @@ internal static void StatusPopUp(string popupId, Status[] allStatus, ref string

if (ImGui.BeginChild("Rotation Solver Add Status", new Vector2(-1, 400 * _scale)))
{
var count = Math.Max(1, (int)MathF.Floor(ImGui.GetWindowWidth() / (24 * _scale + ImGui.GetStyle().ItemSpacing.X)));
var count = Math.Max(1, (int)MathF.Floor(ImGui.GetWindowWidth() / (size * 3 / 4 * _scale + ImGui.GetStyle().ItemSpacing.X)));
var index = 0;

var searchingKey = searching;
Expand All @@ -1497,7 +1494,7 @@ internal static void StatusPopUp(string popupId, Status[] allStatus, ref string
{
ImGui.SameLine();
}
if (NoPaddingNoColorImageButton(texture.ImGuiHandle, new Vector2(24, 32) * _scale, "Adding" + status.RowId.ToString()))
if (NoPaddingNoColorImageButton(texture.ImGuiHandle, new Vector2(size * 3 / 4, size) * _scale, "Adding" + status.RowId.ToString()))
{
clicked?.Invoke(status);
ImGui.CloseCurrentPopup();
Expand Down Expand Up @@ -2110,6 +2107,8 @@ internal static void DrawActionOverlay(Vector2 cursor, float width, float percen
start, start + step);
}
}

ImGui.SetCursorPosY(cursor.Y);
}
#endregion

Expand Down

0 comments on commit 0ca796e

Please sign in to comment.