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

Commit

Permalink
fix: moved the condition set drawing position.
Browse files Browse the repository at this point in the history
  • Loading branch information
ArchiDog1998 committed Oct 21, 2023
1 parent fe9f19e commit b7b0568
Show file tree
Hide file tree
Showing 7 changed files with 88 additions and 81 deletions.
5 changes: 3 additions & 2 deletions RotationSolver.Basic/Data/IconSet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,11 @@ public static bool GetTexture(uint id, out IDalamudTextureWrap texture, uint @de
/// </summary>
/// <param name="path"></param>
/// <param name="texture"></param>
/// <param name="loadingIcon"></param>
/// <returns></returns>
public static bool GetTexture(string path, out IDalamudTextureWrap texture)
public static bool GetTexture(string path, out IDalamudTextureWrap texture, bool loadingIcon = false)
=> ThreadLoadImageHandler.TryGetTextureWrap(path, out texture)
|| ThreadLoadImageHandler.TryGetTextureWrap("ui/uld/image2.tex", out texture)
|| loadingIcon && ThreadLoadImageHandler.TryGetTextureWrap("ui/uld/image2.tex", out texture)
|| ThreadLoadImageHandler.TryGetIconTextureWrap(0, false, out texture); // loading pics.

private static readonly Dictionary<uint, uint> _actionIcons = new();
Expand Down
7 changes: 5 additions & 2 deletions RotationSolver.Basic/DataCenter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ namespace RotationSolver.Basic;

internal static class DataCenter
{
/// <summary>
/// This one never be null.
/// </summary>
public static MajorConditionSet RightSet
{
get
Expand All @@ -30,11 +33,11 @@ public static MajorConditionSet RightSet
Service.Config.SetValue(PluginConfigInt.ActionSequencerIndex, index);
}

return ConditionSets.ElementAt(index);
return ConditionSets[index];
}
}

internal static IEnumerable<MajorConditionSet> ConditionSets { get; set; } = Array.Empty<MajorConditionSet>();
internal static MajorConditionSet[] ConditionSets { get; set; } = Array.Empty<MajorConditionSet>();

/// <summary>
/// Only recorded 15s hps.
Expand Down
3 changes: 2 additions & 1 deletion RotationSolver/Localization/Localization.json
Original file line number Diff line number Diff line change
Expand Up @@ -560,5 +560,6 @@
"ConfigWindow_Auto_MoveBackConditionSet": "Move Back Forced Condition",
"ConfigWindow_Auto_AntiKnockbackConditionSet": "Anti Knockback Forced Condition",
"ConfigWindow_Auto_BurstConditionSet": "Burst Forced Condition",
"ConfigWindow_Auto_SpeedConditionSet": "Speed Forced Condition"
"ConfigWindow_Auto_SpeedConditionSet": "Speed Forced Condition",
"ConfigWindow_ConditionSetDesc": "The Condition set you chose, click to modify."
}
1 change: 1 addition & 0 deletions RotationSolver/Localization/Strings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -783,5 +783,6 @@ internal class Strings
public string ConfigWindow_Auto_AntiKnockbackConditionSet { get; set; } = "Anti Knockback Forced Condition";
public string ConfigWindow_Auto_BurstConditionSet { get; set; } = "Burst Forced Condition";
public string ConfigWindow_Auto_SpeedConditionSet { get; set; } = "Speed Forced Condition";
public string ConfigWindow_ConditionSetDesc { get; set; } = "The Condition set you chose, click to modify.";

}
4 changes: 2 additions & 2 deletions RotationSolver/UI/ConditionDrawer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ internal static void DrawCondition(bool? tag)

if (!tag.HasValue)
{
if (IconSet.GetTexture("ui/uld/image2.tex", out var texture) || IconSet.GetTexture(0u, out texture))
if (IconSet.GetTexture("ui/uld/image2.tex", out var texture, true) || IconSet.GetTexture(0u, out texture))
{
ImGui.Image(texture.ImGuiHandle, Vector2.One * size);
}
}
else
{
if (IconSet.GetTexture("ui/uld/readycheck_hr1.tex", out var texture))
if (IconSet.GetTexture("ui/uld/readycheck_hr1.tex", out var texture, true))
{
ImGui.Image(texture.ImGuiHandle, Vector2.One * size,
new Vector2(tag.Value ? 0 : 0.5f, 0),
Expand Down
71 changes: 70 additions & 1 deletion RotationSolver/UI/RotationConfigWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,70 @@ public override void Draw()
}
}

private void DrawConditionSet()
{
var set = DataCenter.RightSet;

const string popUpId = "Right Set Popup";
if (ImGui.Selectable(set.Name, false, ImGuiSelectableFlags.None, new Vector2(0, 20)))
{
ImGui.OpenPopup(popUpId);
}
ImguiTooltips.HoveredTooltip(LocalizationManager.RightLang.ConfigWindow_ConditionSetDesc);

using (var popup = ImRaii.Popup(popUpId))
{
if (popup.Success)
{
var combos = DataCenter.ConditionSets;
for (int i = 0; i < combos.Length; i++)
{
void DeleteFile()
{
ActionSequencerUpdater.Delete(combos[i].Name);
}

if (combos[i].Name == set.Name)
{
ImGuiHelper.SetNextWidthWithName(set.Name);
ImGui.InputText("##MajorConditionSet", ref set.Name, 100);
}
else
{
var key = "Condition Set At " + i.ToString();
ImGuiHelper.DrawHotKeysPopup(key, string.Empty, (LocalizationManager.RightLang.ConfigWindow_List_Remove, DeleteFile, new string[] { "Delete" }));


if (ImGui.Selectable(combos[i].Name))
{
Service.Config.SetValue(PluginConfigInt.ActionSequencerIndex, i);
}

ImGuiHelper.ExecuteHotKeysPopup(key, string.Empty, string.Empty, false,
(DeleteFile, new Dalamud.Game.ClientState.Keys.VirtualKey[] { Dalamud.Game.ClientState.Keys.VirtualKey.DELETE }));
}
}

ImGui.PushFont(UiBuilder.IconFont);

ImGui.PushStyleColor(ImGuiCol.Text, ImGuiColors.HealerGreen);
if (ImGui.Selectable(FontAwesomeIcon.Plus.ToIconString()))
{
ActionSequencerUpdater.AddNew();
}
ImGui.PopStyleColor();

if (ImGui.Selectable(FontAwesomeIcon.FileDownload.ToIconString()))
{
ActionSequencerUpdater.LoadFiles();
}

ImGui.PopFont();
ImguiTooltips.HoveredTooltip(LocalizationManager.RightLang.ActionSequencer_Load);
}
}
}

private void DrawSideBar()
{
using var child = ImRaii.Child("Rotation Solver Side bar", -Vector2.One, false, ImGuiWindowFlags.NoScrollbar);
Expand All @@ -130,6 +194,11 @@ private void DrawSideBar()

if (wholeWidth > JOB_ICON_WIDTH * Scale)
{
DrawConditionSet();

ImGui.Separator();
ImGui.Spacing();

ImGui.SetNextItemWidth(wholeWidth);
SearchingBox();

Expand Down Expand Up @@ -1307,7 +1376,7 @@ private static unsafe void DrawActions()
ImGui.Separator();
}

ActionSequencerUpdater.DrawHeader(30 * Scale);
ImGui.TextWrapped(LocalizationManager.RightLang.ConfigWindow_Actions_ConditionDescription);
_sequencerList?.Draw();
}
}
Expand Down
78 changes: 5 additions & 73 deletions RotationSolver/Updaters/ActionSequencerUpdater.cs
Original file line number Diff line number Diff line change
@@ -1,19 +1,11 @@
using Dalamud.Interface.Colors;
using ECommons.ImGuiMethods;
using RotationSolver.Basic.Configuration;
using RotationSolver.Basic.Configuration.Conditions;
using RotationSolver.Localization;
using RotationSolver.UI;
using RotationSolver.Basic.Configuration.Conditions;

namespace RotationSolver.Updaters;

internal class ActionSequencerUpdater
{
static string _actionSequencerFolder;


public static string[] ConditionSetsName => DataCenter.ConditionSets?.Select(s => s.Name).ToArray() ?? Array.Empty<string>();

public static void UpdateActionSequencerAction()
{
if (DataCenter.ConditionSets == null) return;
Expand Down Expand Up @@ -82,77 +74,17 @@ public static void LoadFiles()
DataCenter.ConditionSets = MajorConditionSet.Read(_actionSequencerFolder);
}

private static void AddNew()
public static void AddNew()
{
if (!DataCenter.ConditionSets.Any(c => c.IsUnnamed))
{
DataCenter.ConditionSets = DataCenter.ConditionSets.Append(new MajorConditionSet());
DataCenter.ConditionSets = DataCenter.ConditionSets.Append(new MajorConditionSet()).ToArray();
}
}

private static void Delete(string name)
public static void Delete(string name)
{
DataCenter.ConditionSets = DataCenter.ConditionSets.Where(c => c.Name != name);
DataCenter.ConditionSets = DataCenter.ConditionSets.Where(c => c.Name != name).ToArray();
File.Delete(_actionSequencerFolder + $"\\{name}.json");
}

public static void DrawHeader(float width)
{
var set = DataCenter.RightSet;
bool hasSet = set != null;

if (hasSet)
{
ImGuiHelper.SetNextWidthWithName(set.Name);
ImGui.InputText("##MajorConditionSet", ref set.Name, 100);

ImGui.SameLine();
}

var combos = ConditionSetsName;
ImGui.SetNextItemWidth(width);

if(ImGui.BeginCombo("##MajorConditionCombo", ""))
{
for (int i = 0; i < combos.Length; i++)
{
void DeleteFile()
{
Delete(combos[i]);
}

var key = "Condition Set At " + i.ToString();

ImGuiHelper.DrawHotKeysPopup(key, string.Empty, (LocalizationManager.RightLang.ConfigWindow_List_Remove, DeleteFile, new string[] { "Delete" }));


if (ImGui.Selectable(combos[i]))
{
Service.Config.SetValue(PluginConfigInt.ActionSequencerIndex, i);
}

ImGuiHelper.ExecuteHotKeysPopup(key, string.Empty, string.Empty, false,
(DeleteFile, new Dalamud.Game.ClientState.Keys.VirtualKey[] { Dalamud.Game.ClientState.Keys.VirtualKey.DELETE }));
}

ImGui.PushStyleColor(ImGuiCol.Text, ImGuiColors.HealerGreen);
ImGui.PushFont(UiBuilder.IconFont);
if (ImGui.Selectable(FontAwesomeIcon.Plus.ToIconString()))
{
AddNew();
}
ImGui.PopFont();
ImGui.PopStyleColor();
ImGui.EndCombo();
}

ImGui.SameLine();
if (ImGuiEx.IconButton(FontAwesomeIcon.FileDownload, "##LoadTheConditions"))
{
LoadFiles();
}
ImguiTooltips.HoveredTooltip(LocalizationManager.RightLang.ActionSequencer_Load);

ImGui.TextWrapped(LocalizationManager.RightLang.ConfigWindow_Actions_ConditionDescription);
}
}

0 comments on commit b7b0568

Please sign in to comment.