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

Commit

Permalink
fix: add more infomation on control window.
Browse files Browse the repository at this point in the history
  • Loading branch information
ArchiDog1998 committed Mar 23, 2023
1 parent 0fc9396 commit 503182b
Show file tree
Hide file tree
Showing 9 changed files with 113 additions and 40 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ If you have any questions about usage, please check the [Wiki](https://archidog1

> 不能限制任何人自由分发此软件,不论是否收费!如已有限制,请删除!
该链接为个人研发的最后一版的源代码[AutoAttack](https://github.com/ArchiDog1998/RotationSolver/tree/1e28211c8b447423f8e11cd3126ae1aa1ef08dc6)

### 插件简要历程

| 时间 | 事件 |
Expand Down
2 changes: 1 addition & 1 deletion RotationSolver.Basic/Configuration/PluginConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ public class PluginConfiguration : IPluginConfiguration
public bool UseKeyboardCommand = false;
public bool UseGamepadCommand = false;
public bool ShowItemsCooldown = false;
public int CooldownActionOneLine = 14;
public int CooldownActionOneLine = 15;

public Vector4 ControlWindowLockBg = new Vector4(0, 0, 0, 0.6f);
public Vector4 ControlWindowUnlockBg = new Vector4(0, 0, 0, 0.9f);
Expand Down
2 changes: 1 addition & 1 deletion RotationSolver.Basic/DataCenter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public static TargetHostileType GetTargetHostileType(ClassJob classJob)

public static unsafe ActionID LastComboAction => (ActionID)ActionManager.Instance()->Combo.Action;
public static unsafe float ComboTime => ActionManager.Instance()->Combo.Timer;
internal static TargetingType TargetingType
public static TargetingType TargetingType
{
get
{
Expand Down
2 changes: 1 addition & 1 deletion RotationSolver/Localization/Localization.json
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@
"ConfigWindow_Control_ShowItemsCooldown": "Show Items' Cooldown",
"ConfigWindow_Control_CooldownActionOneLine": "The count of cooldown actions in one line.",
"ConfigWindow_Control_BackgroundColor": "Control Window's Background",
"ConfigWindow_Control_InfoWindowBg": "Next Action Window's Background",
"ConfigWindow_Control_InfoWindowBg": "Info Window's Background",
"ConfigWindow_Control_ControlWindowGCDSize": "GCD icon size",
"ConfigWindow_Control_ControlWindow0GCDSize": "0GCD icon size",
"ConfigWindow_Control_ControlWindowNextSizeRatio": "Next Action Size Ratio",
Expand Down
2 changes: 1 addition & 1 deletion RotationSolver/Localization/Strings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ internal partial class Strings

public string ConfigWindow_Control_CooldownActionOneLine { get; set; } = "The count of cooldown actions in one line.";
public string ConfigWindow_Control_BackgroundColor { get; set; } = "Control Window's Background";
public string ConfigWindow_Control_InfoWindowBg { get; set; } = "Next Action Window's Background";
public string ConfigWindow_Control_InfoWindowBg { get; set; } = "Info Window's Background";
public string ConfigWindow_Control_ControlWindowGCDSize { get; set; } = "GCD icon size";
public string ConfigWindow_Control_ControlWindow0GCDSize { get; set; } = "0GCD icon size";
public string ConfigWindow_Control_ControlWindowNextSizeRatio { get; set; } = "Next Action Size Ratio";
Expand Down
3 changes: 2 additions & 1 deletion RotationSolver/RotationSolverPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,8 @@ internal static void UpdateDisplayWindow()
var isValid = MajorUpdater.IsValid
&& !Service.Conditions[ConditionFlag.OccupiedInCutSceneEvent]
&& !Service.Conditions[ConditionFlag.BetweenAreas]
&& !Service.Conditions[ConditionFlag.BetweenAreas51];
&& !Service.Conditions[ConditionFlag.BetweenAreas51]
&& !Service.Conditions[ConditionFlag.OccupiedInQuestEvent];

_controlWindow.IsOpen = isValid && Service.Config.ShowControlWindow;
_nextActionWindow.IsOpen = isValid && Service.Config.ShowNextActionWindow;
Expand Down
79 changes: 74 additions & 5 deletions RotationSolver/UI/ControlWindow.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Dalamud.Interface.Colors;
using Dalamud.Interface;
using Dalamud.Interface.Colors;
using Dalamud.Interface.Windowing;
using ImGuiNET;
using ImGuiScene;
Expand Down Expand Up @@ -57,18 +58,23 @@ public override void Draw()
ImGui.Columns(2, "Control Bolder", false);
ImGui.SetColumnWidth(0, DrawNextAction() + ImGui.GetStyle().ColumnsMinSpacing * 2);

DrawCommandAction(61822, StateCommandType.Smart, ImGuiColors.DPSRed);

ImGui.SameLine();

DrawCommandAction(61751, StateCommandType.Manual, ImGuiColors.DPSRed);


ImGui.SameLine();
DrawCommandAction(61764, StateCommandType.Cancel, ImGuiColors.DalamudWhite2);

DrawCommandAction(61822, StateCommandType.Smart, ImGuiColors.DPSRed);

ImGui.SameLine();

ImGui.BeginGroup();

ImGui.Text(DataCenter.TargetingType.ToName());

RotationConfigWindow.DrawCheckBox(LocalizationManager.RightLang.ConfigWindow_Control_IsWindowLock,
ref Service.Config.IsControlWindowLock);
ImGui.EndGroup();

ImGui.NextColumn();

Expand All @@ -80,6 +86,7 @@ public override void Draw()
private static void DrawSpecials()
{
var rotation = RotationUpdater.RightNowRotation;

DrawCommandAction(rotation?.ActionHealAreaGCD, rotation?.ActionHealAreaAbility,
SpecialCommandType.HealArea, ImGuiColors.HealerGreen);

Expand Down Expand Up @@ -126,6 +133,14 @@ private static void DrawSpecials()

DrawCommandAction(rotation?.AntiKnockbackAbility,
SpecialCommandType.AntiKnockback, ImGuiColors.DalamudWhite2);

ImGui.Text(DataCenter.RightNowTargetToHostileType switch
{
TargetHostileType.AllTargetsCanAttack => LocalizationManager.RightLang.ConfigWindow_Param_TargetToHostileType1,
TargetHostileType.TargetsHaveTargetOrAllTargetsCanAttack => LocalizationManager.RightLang.ConfigWindow_Param_TargetToHostileType2,
TargetHostileType.TargetsHaveTarget => LocalizationManager.RightLang.ConfigWindow_Param_TargetToHostileType3,
_ => string.Empty,
});
}

static void DrawCommandAction(IAction gcd, IAction ability, SpecialCommandType command, Vector4 color)
Expand All @@ -136,6 +151,8 @@ static void DrawCommandAction(IAction gcd, IAction ability, SpecialCommandType c
var str = command.ToString();
var strWidth = ImGui.CalcTextSize(str).X;

var pos = ImGui.GetCursorPos();
ImGui.BeginGroup();
ImGui.BeginGroup();
ImGui.SetCursorPosX(ImGui.GetCursorPosX() + Math.Max(0, width / 2 - strWidth / 2));
ImGui.TextColored(color, str);
Expand All @@ -149,6 +166,22 @@ static void DrawCommandAction(IAction gcd, IAction ability, SpecialCommandType c
ImGui.SameLine();
DrawIAction(GetTexture(ability).ImGuiHandle, baseId + nameof(ability), abilityW, command, help);
ImGui.EndGroup();

if (DataCenter.SpecialType == command)
{
var size = ImGui.GetItemRectSize();
var winPos = ImGui.GetWindowPos();

HighLight(winPos + pos, size);

if(DataCenter.SpecialTimeLeft > 0)
{
var time = DataCenter.SpecialTimeLeft.ToString("F2") + "s";
var strSize = ImGui.CalcTextSize(time);
CooldownWindow.TextShade(winPos + pos + size - strSize, time);
}
}
ImGui.EndGroup();
}

static void DrawCommandAction(IAction ability, SpecialCommandType command, Vector4 color)
Expand All @@ -168,6 +201,8 @@ static void DrawCommandAction(TextureWrap texture, SpecialCommandType command, V
var str = command.ToString();
var strWidth = ImGui.CalcTextSize(str).X;

var pos = ImGui.GetCursorPos();
ImGui.BeginGroup();
ImGui.BeginGroup();
ImGui.SetCursorPosX(ImGui.GetCursorPosX() + Math.Max(0, width / 2 - strWidth / 2));
ImGui.TextColored(color, str);
Expand All @@ -178,6 +213,22 @@ static void DrawCommandAction(TextureWrap texture, SpecialCommandType command, V
ImGui.SetCursorPosX(ImGui.GetCursorPosX() + Math.Max(0, strWidth / 2 - width / 2));
DrawIAction(texture.ImGuiHandle, baseId, abilityW, command, help);
ImGui.EndGroup();

if (DataCenter.SpecialType == command)
{
var size = ImGui.GetItemRectSize();
var winPos = ImGui.GetWindowPos();

HighLight(winPos + pos, size);

if (DataCenter.SpecialTimeLeft > 0)
{
var time = DataCenter.SpecialTimeLeft.ToString("F2") + "s";
var strSize = ImGui.CalcTextSize(time);
CooldownWindow.TextShade(winPos + pos + size - strSize, time);
}
}
ImGui.EndGroup();
}

static void DrawCommandAction(uint iconId, StateCommandType command, Vector4 color)
Expand All @@ -187,6 +238,7 @@ static void DrawCommandAction(uint iconId, StateCommandType command, Vector4 col
var str = command.ToString();
var strWidth = ImGui.CalcTextSize(str).X;

var pos = ImGui.GetCursorPos();
ImGui.BeginGroup();
ImGui.SetCursorPosX(ImGui.GetCursorPosX() + Math.Max(0, width / 2 - strWidth / 2));
ImGui.TextColored(color, str);
Expand All @@ -197,8 +249,25 @@ static void DrawCommandAction(uint iconId, StateCommandType command, Vector4 col
ImGui.SetCursorPosX(ImGui.GetCursorPosX() + Math.Max(0, strWidth / 2 - width / 2));
DrawIAction(IconSet.GetTexture(iconId).ImGuiHandle, baseId, abilityW, command, help);
ImGui.EndGroup();

if (DataCenter.StateType == command)
{
var size = ImGui.GetItemRectSize();
var winPos = ImGui.GetWindowPos();

HighLight(winPos + pos, size);
}
}

static readonly uint highLight = ImGui.ColorConvertFloat4ToU32(ImGuiColors.DalamudGrey);
static void HighLight(Vector2 pt, Vector2 size)
{
var offset = ImGui.GetStyle().ItemSpacing / 2;
ImGui.GetWindowDrawList().AddRect(pt - offset, pt + size + offset,
highLight, 5, ImDrawFlags.RoundCornersAll, 2);
}


static string GetHelp(SpecialCommandType command)
{
var help = command.ToHelp() + "\n ";
Expand Down
19 changes: 10 additions & 9 deletions RotationSolver/UI/CooldownWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@ public override void Draw()
}
}

static readonly uint black = ImGui.ColorConvertFloat4ToU32(new Vector4(0, 0, 0, 1));
static readonly uint white = ImGui.ColorConvertFloat4ToU32(new Vector4(1, 1, 1, 1));
static readonly uint progressCol = ImGui.ColorConvertFloat4ToU32(new Vector4(0.6f, 0.6f, 0.6f, 0.6f));
private static void DrawActionCooldown(IAction act)
{
Expand Down Expand Up @@ -78,7 +76,7 @@ private static void DrawActionCooldown(IAction act)
var strSize = ImGui.CalcTextSize(time);
var fontPos = new Vector2(pos.X + width / 2 - strSize.X / 2, pos.Y + width / 2 - strSize.Y / 2) + winPos;

TextShade(fontPos, time, 1.5f, white, black);
TextShade(fontPos, time);
}

if (act.EnoughLevel && act is IBaseAction bAct && bAct.MaxCharges > 1)
Expand All @@ -92,12 +90,15 @@ private static void DrawActionCooldown(IAction act)
ImGui.EndGroup();
}

static void TextShade(Vector2 pos, string text, float width, uint fore, uint background)
static readonly uint black = ImGui.ColorConvertFloat4ToU32(new Vector4(0, 0, 0, 1));
static readonly uint white = ImGui.ColorConvertFloat4ToU32(new Vector4(1, 1, 1, 1));

public static void TextShade(Vector2 pos, string text, float width = 1.5f)
{
ImGui.GetWindowDrawList().AddText(pos - new Vector2(0, width), background, text);
ImGui.GetWindowDrawList().AddText(pos - new Vector2(0, -width), background, text);
ImGui.GetWindowDrawList().AddText(pos - new Vector2(width, 0), background, text);
ImGui.GetWindowDrawList().AddText(pos - new Vector2(-width, 0), background, text);
ImGui.GetWindowDrawList().AddText(pos, fore, text);
ImGui.GetWindowDrawList().AddText(pos - new Vector2(0, width), black, text);
ImGui.GetWindowDrawList().AddText(pos - new Vector2(0, -width), black, text);
ImGui.GetWindowDrawList().AddText(pos - new Vector2(width, 0), black, text);
ImGui.GetWindowDrawList().AddText(pos - new Vector2(-width, 0), black, text);
ImGui.GetWindowDrawList().AddText(pos, white, text);
}
}
42 changes: 21 additions & 21 deletions RotationSolver/Updaters/MajorUpdater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,33 +9,33 @@ internal static class MajorUpdater
{
public static bool IsValid => Service.Conditions.Any() && Service.Player != null;

//#if DEBUG
// private static readonly Dictionary<int, bool> _valus = new Dictionary<int, bool>();
//#endif
#if DEBUG
private static readonly Dictionary<int, bool> _valus = new Dictionary<int, bool>();
#endif

private static void FrameworkUpdate(Framework framework)
{
RotationSolverPlugin.UpdateDisplayWindow();
if (!IsValid) return;

//#if DEBUG
// //Get changed condition.
// string[] enumNames = Enum.GetNames(typeof(Dalamud.Game.ClientState.Conditions.ConditionFlag));
// int[] indexs = (int[])Enum.GetValues(typeof(Dalamud.Game.ClientState.Conditions.ConditionFlag));
// if (enumNames.Length == indexs.Length)
// {
// for (int i = 0; i < enumNames.Length; i++)
// {
// string key = enumNames[i];
// bool newValue = Service.Conditions[(Dalamud.Game.ClientState.Conditions.ConditionFlag)indexs[i]];
// if (_valus.ContainsKey(i) && _valus[i] != newValue && indexs[i] != 48 && indexs[i] != 27)
// {
// Service.ToastGui.ShowQuest(indexs[i].ToString() + " " + key + ": " + newValue.ToString());
// }
// _valus[i] = newValue;
// }
// }
//#endif
#if DEBUG
//Get changed condition.
string[] enumNames = Enum.GetNames(typeof(Dalamud.Game.ClientState.Conditions.ConditionFlag));
int[] indexs = (int[])Enum.GetValues(typeof(Dalamud.Game.ClientState.Conditions.ConditionFlag));
if (enumNames.Length == indexs.Length)
{
for (int i = 0; i < enumNames.Length; i++)
{
string key = enumNames[i];
bool newValue = Service.Conditions[(Dalamud.Game.ClientState.Conditions.ConditionFlag)indexs[i]];
if (_valus.ContainsKey(i) && _valus[i] != newValue && indexs[i] != 48 && indexs[i] != 27)
{
//Service.ToastGui.ShowQuest(indexs[i].ToString() + " " + key + ": " + newValue.ToString());
}
_valus[i] = newValue;
}
}
#endif

try
{
Expand Down

0 comments on commit 503182b

Please sign in to comment.