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

Commit

Permalink
fix: add an image to illustrate the timer.
Browse files Browse the repository at this point in the history
  • Loading branch information
ArchiDog1998 committed Aug 20, 2023
1 parent 72dfde2 commit 872997c
Show file tree
Hide file tree
Showing 13 changed files with 200 additions and 465 deletions.
439 changes: 0 additions & 439 deletions Images/HowAndWhenToClick.svg

This file was deleted.

3 changes: 2 additions & 1 deletion Resources/HostileCastingArea.json
Original file line number Diff line number Diff line change
Expand Up @@ -374,5 +374,6 @@
32112,
32114,
31727,
33018
33018,
7946
]
2 changes: 1 addition & 1 deletion RotationSolver.Basic/Configuration/Configs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ [Serializable] public class GlobalConfig

{ PluginConfigVector4.TargetColor, new (1f, 0.2f, 0f, 0.8f)},
{ PluginConfigVector4.SubTargetColor, new (1f, 0.9f, 0f, 0.8f)},
{ PluginConfigVector4.ControlWindowLockBg, new (0, 0, 0, 0.5f)},
{ PluginConfigVector4.ControlWindowLockBg, new (0, 0, 0, 0.55f)},
{ PluginConfigVector4.ControlWindowUnlockBg, new (0, 0, 0, 0.75f)},
{ PluginConfigVector4.InfoWindowBg, new (0, 0, 0, 0.4f)},
});
Expand Down
1 change: 0 additions & 1 deletion RotationSolver.sln
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
Resources\downloadList.json = Resources\downloadList.json
manifest.json = manifest.json
UpdateDownloads.ts = UpdateDownloads.ts
Resources\whiteList.json = Resources\whiteList.json
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RotationSolver.Basic", "RotationSolver.Basic\RotationSolver.Basic.csproj", "{140CC27C-0923-4183-9C30-26A7BDEBE606}"
Expand Down
8 changes: 7 additions & 1 deletion RotationSolver/Localization/Localization.json
Original file line number Diff line number Diff line change
Expand Up @@ -490,5 +490,11 @@
"ConfigWindow_Searching": "Searching...",
"ConfigWindow_UI_HideWarning": "Hide Warning",
"ConfigWindow_Auto_BeneficialAreaStrategy": "Beneficial area strategy",
"ConfigWindow_About_OpenConfigFolder": "Open Config Folder"
"ConfigWindow_About_OpenConfigFolder": "Open Config Folder",
"ConfigWindow_Basic_AnimationLockTime": "The Animation lock time from individual actions. Here is 0.6s for example.",
"ConfigWindow_Basic_Ping": "The ping time.\nIn RS, it means the time from sending the action request to receiving the using success message from the server.",
"ConfigWindow_Basic_IdealClickingTime": "The ideal click time.",
"ConfigWindow_Basic_RealClickingTime": "The real click time.",
"ConfigWindow_Basic_ClickingDuration": "The clicking duration, RS will try to click at this duration.",
"ConfigWindow_Basic_WeaponDelay": "This is the clipping time.\nGCD is over. However, RS forgets to click the next action."
}
7 changes: 6 additions & 1 deletion RotationSolver/Localization/Strings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -709,5 +709,10 @@ internal partial class Strings
public string ConfigWindow_UI_HideWarning { get; set; } = "Hide Warning";
public string ConfigWindow_Auto_BeneficialAreaStrategy { get; set; } = "Beneficial area strategy";
public string ConfigWindow_About_OpenConfigFolder { get; set; } = "Open Config Folder";

public string ConfigWindow_Basic_AnimationLockTime { get; set; } = "The Animation lock time from individual actions. Here is 0.6s for example.";
public string ConfigWindow_Basic_Ping { get; set; } = "The ping time.\nIn RS, it means the time from sending the action request to receiving the using success message from the server.";
public string ConfigWindow_Basic_IdealClickingTime { get; set; } = "The ideal click time.";
public string ConfigWindow_Basic_RealClickingTime { get; set; } = "The real click time.";
public string ConfigWindow_Basic_ClickingDuration { get; set; } = "The clicking duration, RS will try to click at this duration.";
public string ConfigWindow_Basic_WeaponDelay { get; set; } = "This is the clipping time.\nGCD is over. However, RS forgets to click the next action.";
}
16 changes: 8 additions & 8 deletions RotationSolver/UI/ImGuiHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -235,8 +235,8 @@ internal static void DrawActionOverlay(Vector2 cursor, float width, float percen

//Out Size is 88, 96
//Inner Size is 82, 82
ImGui.Image(cover.ImGuiHandle, new Vector2(pixPerUnit * 88, pixPerUnit * 96),
start, start + step);
ImGui.Image(cover.ImGuiHandle, new Vector2(pixPerUnit * 88, pixPerUnit * 94),
start, start + new Vector2(88f / cover.Width, 94f / cover.Height));
}
}
else if (percent < 1)
Expand All @@ -253,8 +253,8 @@ internal static void DrawActionOverlay(Vector2 cursor, float width, float percen

//Out Size is 88, 96
//Inner Size is 82, 82
ImGui.Image(cover.ImGuiHandle, new Vector2(pixPerUnit * 88, pixPerUnit * 96),
start, start + step);
ImGui.Image(cover.ImGuiHandle, new Vector2(pixPerUnit * 88, pixPerUnit * 94),
start, start + new Vector2(88f / cover.Width, 94f / cover.Height));
}
}
else
Expand All @@ -266,9 +266,9 @@ internal static void DrawActionOverlay(Vector2 cursor, float width, float percen

//Out Size is 88, 96
//Inner Size is 82, 82
ImGui.Image(cover.ImGuiHandle, new Vector2(pixPerUnit * 88, pixPerUnit * 96),
ImGui.Image(cover.ImGuiHandle, new Vector2(pixPerUnit * 88, pixPerUnit * 94),
new Vector2(4f / cover.Width, 0f / cover.Height),
new Vector2(92f / cover.Width, 96f / cover.Height));
new Vector2(92f / cover.Width, 94f / cover.Height));
}
}

Expand All @@ -285,8 +285,8 @@ internal static void DrawActionOverlay(Vector2 cursor, float width, float percen

//Out Size is 88, 96
//Inner Size is 82, 82
ImGui.Image(cover.ImGuiHandle, new Vector2(pixPerUnit * 88, pixPerUnit * 96),
start, start + step);
ImGui.Image(cover.ImGuiHandle, new Vector2(pixPerUnit * 88, pixPerUnit * 94),
start, start + new Vector2(88f / cover.Width, 94f / cover.Height));
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion RotationSolver/UI/RotationConfigWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -697,7 +697,7 @@ private static void DrawRotation()
private static uint ChangeAlpha(uint color)
{
var c = ImGui.ColorConvertU32ToFloat4(color);
c.W = 0.5f;
c.W = 0.55f;
return ImGui.ColorConvertFloat4ToU32(c);
}

Expand Down Expand Up @@ -1439,6 +1439,7 @@ private static void DrawRotationsGitHub()

DrawGitHubBadge(userName, repository, fileName, center: true);
ImGui.Spacing();
ImGui.Separator();
}

int removeIndex = -1;
Expand Down
163 changes: 159 additions & 4 deletions RotationSolver/UI/RotationConfigWindow_Config.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
using Dalamud.Game.ClientState.Keys;
using Dalamud.Interface.Colors;
using ECommons.ImGuiMethods;
using ImGuiNET;
using RotationSolver.Basic.Configuration;
using RotationSolver.Localization;
using RotationSolver.UI.SearchableConfigs;
using RotationSolver.UI.SearchableSettings;
using System.Net.NetworkInformation;

namespace RotationSolver.UI;

Expand Down Expand Up @@ -90,13 +93,163 @@ private static void DrawBasic()
} },
});

private static readonly uint PING_COLOR = ImGui.ColorConvertFloat4ToU32(ImGuiColors.ParsedGreen);
private static readonly uint LOCK_TIME_COLOR = ImGui.ColorConvertFloat4ToU32(ImGuiColors.ParsedBlue);
private static readonly uint WEAPON_DELAY_COLOR = ImGui.ColorConvertFloat4ToU32(ImGuiColors.ParsedGold);
private static readonly uint IDEAL_CLICK_TIME_COLOR = ImGui.ColorConvertFloat4ToU32(new Vector4(0.8f, 0f, 0f, 1f));
private static readonly uint CLICK_TIME_COLOR = ImGui.ColorConvertFloat4ToU32(ImGuiColors.ParsedPink);
private static readonly uint ADVANCE_TIME_COLOR = ImGui.ColorConvertFloat4ToU32(ImGuiColors.DalamudYellow);
private static readonly uint ADVANCE_ABILITY_TIME_COLOR = ImGui.ColorConvertFloat4ToU32(ImGuiColors.ParsedOrange);
const float gcdSize = 50, ogcdSize = 40, pingHeight = 12, spacingHeight = 8;

private static void AddPingLockTime(ImDrawListPtr drawList, Vector2 lineStart, float sizePerTime, float ping, float animationLockTime, float advanceTime, uint color, float clickTime)
{
var size = new Vector2(ping * sizePerTime, pingHeight);
drawList.AddRectFilled(lineStart, lineStart + size, ChangeAlpha(PING_COLOR));
if (ImGuiHelper.IsInRect(lineStart, size))
{
ImguiTooltips.ShowTooltip(LocalizationManager.RightLang.ConfigWindow_Basic_Ping);
}

var rectStart = lineStart + new Vector2(ping * sizePerTime, 0);
size = new Vector2(animationLockTime * sizePerTime, pingHeight);
drawList.AddRectFilled(rectStart, rectStart + size, ChangeAlpha(LOCK_TIME_COLOR));
if (ImGuiHelper.IsInRect(rectStart, size))
{
ImguiTooltips.ShowTooltip(LocalizationManager.RightLang.ConfigWindow_Basic_AnimationLockTime);
}

drawList.AddLine(lineStart - new Vector2(0, spacingHeight), lineStart + new Vector2(0, pingHeight * 2 + spacingHeight / 2), IDEAL_CLICK_TIME_COLOR, 1.5f);

rectStart = lineStart + new Vector2(-advanceTime * sizePerTime, pingHeight);
size = new Vector2(advanceTime * sizePerTime, pingHeight);
drawList.AddRectFilled(rectStart, rectStart + size, ChangeAlpha(color));
if (ImGuiHelper.IsInRect(rectStart, size))
{
ImguiTooltips.ShowTooltip(() =>
{
ImGui.TextWrapped(LocalizationManager.RightLang.ConfigWindow_Basic_ClickingDuration);

ImGui.Separator();

ImGui.TextColored(ImGui.ColorConvertU32ToFloat4( IDEAL_CLICK_TIME_COLOR),
LocalizationManager.RightLang.ConfigWindow_Basic_IdealClickingTime);

ImGui.TextColored(ImGui.ColorConvertU32ToFloat4(CLICK_TIME_COLOR),
LocalizationManager.RightLang.ConfigWindow_Basic_RealClickingTime);
});
}

float time = 0;
while (time < advanceTime)
{
var start = lineStart + new Vector2((time - advanceTime) * sizePerTime, 0);
drawList.AddLine(start + new Vector2(0, pingHeight), start + new Vector2(0, pingHeight * 2 + spacingHeight), CLICK_TIME_COLOR, 2.5f);

time += clickTime;
}
}
private static void DrawBasicTimer()
{
var gcdTime = DataCenter.WeaponTotal;
if (gcdTime == 0) gcdTime = 2.5f;
var wholeWidth = ImGui.GetWindowWidth();
var ping = DataCenter.Ping;

ImGui.PushFont(ImGuiHelper.GetFont(14));
ImGui.PushStyleColor(ImGuiCol.Text, ImGui.ColorConvertFloat4ToU32(ImGuiColors.DalamudYellow));
var infoText = $"GCD: {gcdTime:F2}s Ping: {ping:F2}s";
var infoSize = ImGui.CalcTextSize(infoText);

ImGuiHelper.DrawItemMiddle(() =>
{
ImGui.Text(infoText);
}, wholeWidth, infoSize.X);
ImGui.PopStyleColor();
ImGui.PopFont();

var actionAhead = Service.Config.GetValue(PluginConfigFloat.ActionAhead);
var minAbilityAhead = Service.Config.GetValue(PluginConfigFloat.MinLastAbilityAdvanced);
var animationLockTime = DataCenter.MinAnimationLock;
var weaponDelay = (Service.Config.GetValue(PluginConfigFloat.WeaponDelayMin) + Service.Config.GetValue(PluginConfigFloat.WeaponDelayMax))/2;
var clickingDelay = (Service.Config.GetValue(PluginConfigFloat.ClickingDelayMin) + Service.Config.GetValue(PluginConfigFloat.ClickingDelayMax))/2;

var drawList = ImGui.GetWindowDrawList();
ImGui.Spacing();
var startCursorPt = ImGui.GetCursorPos();
var windowsPos = ImGui.GetWindowPos();

var sizePerTime = (wholeWidth - gcdSize) / (gcdTime + weaponDelay + actionAhead);

var lineStart = windowsPos + startCursorPt + new Vector2(sizePerTime * actionAhead, gcdSize + spacingHeight);
ImGuiHelper.DrawActionOverlay(startCursorPt + new Vector2(sizePerTime * actionAhead, 0), gcdSize, 0);
ImGuiHelper.DrawActionOverlay(startCursorPt + new Vector2(wholeWidth - gcdSize, 0), gcdSize, 0);

AddPingLockTime(drawList, lineStart, sizePerTime, ping, animationLockTime, actionAhead, ADVANCE_TIME_COLOR, clickingDelay);
var start = lineStart + new Vector2(gcdTime * sizePerTime, 0);
var rectSize = new Vector2(weaponDelay * sizePerTime, pingHeight);
drawList.AddRectFilled(start, start + rectSize, WEAPON_DELAY_COLOR);
drawList.AddRect(start, start + rectSize, uint.MaxValue, 0, ImDrawFlags.Closed, 2);
if (ImGuiHelper.IsInRect(start, rectSize))
{
ImguiTooltips.ShowTooltip(LocalizationManager.RightLang.ConfigWindow_Basic_WeaponDelay);
}
drawList.AddLine(lineStart + new Vector2((gcdTime + weaponDelay) * sizePerTime, -spacingHeight), lineStart + new Vector2((gcdTime + weaponDelay) * sizePerTime,
pingHeight * 2 + spacingHeight), IDEAL_CLICK_TIME_COLOR, 2);

ImGui.PushFont(ImGuiHelper.GetFont(20));
const string gcdText = "GCD";
var size = ImGui.CalcTextSize(gcdText);
ImGui.SetCursorPos(startCursorPt + new Vector2(sizePerTime * actionAhead + (gcdSize - size.X) / 2, (gcdSize - size.Y) / 2));
ImGui.Text(gcdText);
ImGui.SetCursorPos(startCursorPt + new Vector2(wholeWidth - gcdSize + (gcdSize - size.X) / 2, (gcdSize - size.Y) / 2));
ImGui.Text(gcdText);
ImGui.PopFont();

ImGui.PushFont(ImGuiHelper.GetFont(14));
const string ogcdText = "Off-\nGCD";
size = ImGui.CalcTextSize(ogcdText);
ImGui.PopFont();

var timeStep = ping + animationLockTime;
var time = timeStep;
while (time < gcdTime - timeStep)
{
var isLast = time + 2 * timeStep > gcdTime;
if (isLast)
{
time = gcdTime - timeStep;
}

ImGuiHelper.DrawActionOverlay(startCursorPt + new Vector2(sizePerTime * (actionAhead + time), 0), ogcdSize, 0);
ImGui.SetCursorPos(startCursorPt + new Vector2(sizePerTime * (actionAhead + time) + (ogcdSize - size.X) / 2, (ogcdSize - size.Y) / 2));

ImGui.PushFont(ImGuiHelper.GetFont(14));
ImGui.Text(ogcdText);
ImGui.PopFont();

var ogcdStart = lineStart + new Vector2(time * sizePerTime, 0);
AddPingLockTime(drawList, ogcdStart, sizePerTime, ping, animationLockTime,
isLast ? MathF.Max(minAbilityAhead, actionAhead) : actionAhead, isLast ? ADVANCE_ABILITY_TIME_COLOR : ADVANCE_TIME_COLOR, clickingDelay);

time += timeStep;
}

ImGui.SetCursorPosY(startCursorPt.Y + gcdSize + pingHeight * 2 + 2 * spacingHeight + ImGui.GetStyle().ItemSpacing.Y);

ImGui.Spacing();

foreach (var searchable in _basicTimer)
{
searchable?.Draw(Job);
}

ImGui.Separator();

foreach (var searchable in _basicTimerOthers)
{
searchable?.Draw(Job);
}
}

private static void DrawBasicAutoSwitch()
Expand All @@ -118,15 +271,17 @@ private static void DrawBasicAutoSwitch()
{
new DragFloatSearchPlugin(PluginConfigFloat.ActionAhead, 0.002f),
new DragFloatSearchPlugin(PluginConfigFloat.MinLastAbilityAdvanced, 0.002f),
new DragFloatSearchPlugin(PluginConfigFloat.SpecialDuration, 1f),
new DragFloatSearchPlugin(PluginConfigFloat.CountDownAhead, 0.002f),
new DragFloatSearchPlugin(PluginConfigFloat.MaxPing, 0.002f),

new DragFloatRangeSearchPlugin(PluginConfigFloat.WeaponDelayMin, PluginConfigFloat.WeaponDelayMax, 0.002f),

new DragFloatRangeSearchPlugin(PluginConfigFloat.ClickingDelayMin, PluginConfigFloat.ClickingDelayMax, 0.002f),
};

private static readonly ISearchable[] _basicTimerOthers = new ISearchable[]
{
new DragFloatSearchPlugin(PluginConfigFloat.SpecialDuration, 1f),
new DragFloatSearchPlugin(PluginConfigFloat.CountDownAhead, 0.002f),
};

private static readonly ISearchable[] _basicParamsSearchable = new ISearchable[]
{
new CheckBoxSearchPlugin(PluginConfigBool.ToggleManual),
Expand Down
5 changes: 4 additions & 1 deletion RotationSolver/UI/SearchableConfigs/DragFloatRangeSearch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,12 @@ internal class DragFloatRangeSearchPlugin : DragFloatRangeSearch
public override LinkDescription[] Tooltips => _configMin.ToAction();


public DragFloatRangeSearchPlugin(PluginConfigFloat configMin, PluginConfigFloat configMax, float speed)
public DragFloatRangeSearchPlugin(PluginConfigFloat configMin, PluginConfigFloat configMax, float speed, uint color = 0)
: base((float)(configMin.GetAttribute<DefaultAttribute>()?.Min ?? 0f), (float)(configMin.GetAttribute<DefaultAttribute>()?.Max ?? 1f), speed)
{
_configMin = configMin;
_configMax = configMax;
Color = color;
}

public override void ResetToDefault(Job job)
Expand Down Expand Up @@ -132,7 +133,9 @@ protected override void DrawMain(Job job)

if (IsJob) DrawJobIcon();
ImGui.SameLine();
if (Color != 0) ImGui.PushStyleColor(ImGuiCol.Text, Color);
ImGui.TextWrapped(Name);
if (Color != 0) ImGui.PopStyleColor();
if (ImGui.IsItemHovered()) ShowTooltip(job, false);
}
}
7 changes: 6 additions & 1 deletion RotationSolver/UI/SearchableConfigs/DragFloatSearch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,11 @@ internal class DragFloatSearchPlugin : DragFloatSearch

public override string Command => _config.ToCommand();

public DragFloatSearchPlugin(PluginConfigFloat config, float speed)
public DragFloatSearchPlugin(PluginConfigFloat config, float speed, uint color = 0)
:base((float)(config.GetAttribute<DefaultAttribute>()?.Min ?? 0f), (float)(config.GetAttribute<DefaultAttribute>()?.Max ?? 1f), speed)
{
_config = config;
Color = color;
}

public override void ResetToDefault(Job job)
Expand Down Expand Up @@ -106,7 +107,11 @@ protected override void DrawMain(Job job)
if (IsJob) DrawJobIcon();

ImGui.SameLine();

if (Color != 0) ImGui.PushStyleColor(ImGuiCol.Text, Color);
ImGui.TextWrapped(Name);
if (Color != 0) ImGui.PopStyleColor();

if (ImGui.IsItemHovered()) ShowTooltip(job, false);
}
}
7 changes: 3 additions & 4 deletions RotationSolver/UI/SearchableConfigs/Searchable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ internal abstract class Searchable : ISearchable
private string Popup_Key => "Rotation Solver RightClicking: " + ID;
protected virtual bool IsJob => false;

public uint Color { get; set; } = 0;

/// <summary>
/// Only these job roles can get this setting.
/// </summary>
Expand Down Expand Up @@ -83,7 +85,7 @@ public unsafe void Draw(Job job)
protected void ShowTooltip(Job job, bool showHand = true)
{
var showDesc = !string.IsNullOrEmpty(Description);
if (showDesc || Tooltips != null)
if (showDesc || Tooltips != null && Tooltips.Length > 0)
{
ImguiTooltips.ShowTooltip(() =>
{
Expand All @@ -107,9 +109,6 @@ protected void ShowTooltip(Job job, bool showHand = true)
ImGuiHelper.ReactPopup(Popup_Key, Command, () => ResetToDefault(job), showHand);
}




protected static void DrawJobIcon()
{
ImGui.SameLine();
Expand Down
Loading

0 comments on commit 872997c

Please sign in to comment.