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 next action window.
Browse files Browse the repository at this point in the history
  • Loading branch information
ArchiDog1998 committed Mar 21, 2023
1 parent 8e8b850 commit b7e017e
Show file tree
Hide file tree
Showing 11 changed files with 46 additions and 29 deletions.
2 changes: 2 additions & 0 deletions RotationSolver.Basic/Configuration/PluginConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,8 @@ public class PluginConfiguration : IPluginConfiguration

public Vector4 ControlWindowLockBg = new Vector4(0, 0, 0, 0.6f);
public Vector4 ControlWindowUnlockBg = new Vector4(0, 0, 0, 0.9f);
public Vector4 NextActionWindowBg = new Vector4(0, 0, 0, 0.4f);

public float ControlWindowGCDSize = 40;
public float ControlWindow0GCDSize = 30;
public float ControlWindowNextSizeRatio = 1.5f;
Expand Down
2 changes: 1 addition & 1 deletion RotationSolver.Basic/Data/IconSet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public static void Dispose()
{
foreach (var item in _textures.Values)
{
item.Dispose();
item?.Dispose();
}
}

Expand Down
6 changes: 4 additions & 2 deletions RotationSolver/Localization/Localization.json
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@
"ConfigWindow_Param_MoveTowardsScreenDesc": "Using movement actions towards the object in the center of the screen, otherwise toward the facing object.",
"ConfigWindow_Param_RaiseAll": "Raise all (include passerby)",
"ConfigWindow_Param_TargetFriendly": "Target all for friendly actions(include passerby)",
"ConfigWindow_Param_RaiseBrinkofDeath": "Raise player even has Brink of Death",
"ConfigWindow_Param_RaiseBrinkOfDeath": "Raise player even has Brink of Death",
"ConfigWindow_Param_MoveAreaActionFarthest": "Moving Area Ability to farthest",
"ConfigWindow_Param_MoveAreaActionFarthestDesc": "Move to the furthest position from character's face direction.",
"ConfigWindow_Param_Hostile": "Hostile",
Expand All @@ -172,16 +172,18 @@
"ConfigWindow_Param_ConditionUp": "Up",
"ConfigWindow_Param_ConditionDown": "Down",
"ConfigWindow_Param_ConditionDelete": "Delete",
"ConfigWindow_Control_ShowNextActionWindow": "Show Next Action Window",
"ConfigWindow_Control_ShowControlWindow": "Show Control Window",
"ConfigWindow_Control_UseKeyboardCommand": "Use Keyboard Command",
"ConfigWindow_Control_UseGamepadCommand": "Use GamePad Command",
"ConfigWindow_Control_ControlShowCooldown": "Show action's cooldown",
"ConfigWindow_Control_IsControlWindowLock": "Lock",
"ConfigWindow_Control_BackgroundColor": "Control Window's Background",
"ConfigWindow_Control_NextActionWindowBg": "Next Action Window's Background",
"ConfigWindow_Control_ControlWindowGCDSize": "GCD icon size",
"ConfigWindow_Control_ControlWindow0GCDSize": "0GCD icon size",
"ConfigWindow_Control_ControlWindowNextSizeRatio": "Next Action Size Ratio",
"ConfigWindow_Control_ResetButtonOrKeyCommand": "Right click to reset the gamepad button or key board key.\nHold Left Ctrl and right click to clear the key setting.",
"ConfigWindow_Control_ResetButtonOrKeyCommand": "Right click to reset the gamepad button or key board key.\nHold Left Ctrl and middle click to clear the key setting.",
"ConfigWindow_Control_NeedToEnable": " (Need to enable)",
"Timeline_DragdropDescription": "Drag&drop to move,Ctrl+Alt+RightClick to delete.",
"Timeline_SearchBar": "Search Bar",
Expand Down
1 change: 1 addition & 0 deletions RotationSolver/Localization/Strings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ internal partial class Strings
public string ConfigWindow_Control_ControlShowCooldown { get; set; } = "Show action's cooldown";
public string ConfigWindow_Control_IsControlWindowLock { get; set; } = "Lock";
public string ConfigWindow_Control_BackgroundColor { get; set; } = "Control Window's Background";
public string ConfigWindow_Control_NextActionWindowBg { get; set; } = "Next Action 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
2 changes: 2 additions & 0 deletions RotationSolver/RotationSolver.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@

<ItemGroup>
<ProjectReference Include="..\RotationSolver.Basic\RotationSolver.Basic.csproj" />
<ProjectReference Include="..\RotationSolver.Default\RotationSolver.Default.csproj" />
<ProjectReference Include="..\RotationSolver.Old\RotationSolver.Old.csproj" />

<EmbeddedResource Include="Localization\*.json" Exclude="Localization\Localization.json" />

Expand Down
12 changes: 3 additions & 9 deletions RotationSolver/UI/ControlWindow.cs
Original file line number Diff line number Diff line change
@@ -1,19 +1,13 @@
using Dalamud.Interface;
using Dalamud.Interface.Colors;
using Dalamud.Interface.Colors;
using Dalamud.Interface.Windowing;
using Dalamud.Logging;
using FFXIVClientStructs.FFXIV.Client.Game;
using ImGuiNET;
using ImGuiScene;
using RotationSolver.Basic;
using RotationSolver.Basic.Actions;
using RotationSolver.Basic.Data;
using RotationSolver.Basic.Helpers;
using RotationSolver.Commands;
using RotationSolver.Localization;
using RotationSolver.Updaters;
using System;
using System.Buffers.Text;
using System.Numerics;

namespace RotationSolver.UI;
Expand Down Expand Up @@ -41,14 +35,14 @@ public override void PreDraw()
Flags |= ImGuiWindowFlags.NoResize | ImGuiWindowFlags.NoMove;
}

ImGui.PushStyleVar(ImGuiStyleVar.WindowPadding, new Vector2(0, 0));
//ImGui.PushStyleVar(ImGuiStyleVar.WindowPadding, new Vector2(0, 0));
ImGui.PushStyleVar(ImGuiStyleVar.WindowBorderSize, 0);
}

public override void PostDraw()
{
ImGui.PopStyleColor();
ImGui.PopStyleVar(2);
ImGui.PopStyleVar();
base.PostDraw();
}

Expand Down
35 changes: 22 additions & 13 deletions RotationSolver/UI/NextActionWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,7 @@
using RotationSolver.Basic;
using RotationSolver.Basic.Helpers;
using RotationSolver.Updaters;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;

namespace RotationSolver.UI;

Expand All @@ -25,11 +20,25 @@ internal class NextActionWindow : Window
public NextActionWindow()
: base(nameof(NextActionWindow), BaseFlags
| ImGuiWindowFlags.AlwaysAutoResize
| ImGuiWindowFlags.NoResize
| ImGuiWindowFlags.NoInputs)
| ImGuiWindowFlags.NoResize)
{
}

public override void PreDraw()
{
ImGui.PushStyleColor(ImGuiCol.WindowBg, Service.Config.NextActionWindowBg);

//ImGui.PushStyleVar(ImGuiStyleVar.WindowPadding, new Vector2(0, 0));
ImGui.PushStyleVar(ImGuiStyleVar.WindowBorderSize, 0);
}

public override void PostDraw()
{
ImGui.PopStyleColor();
ImGui.PopStyleVar();
base.PostDraw();
}

public override void Draw()
{
var width = Service.Config.ControlWindowGCDSize * Service.Config.ControlWindowNextSizeRatio;
Expand All @@ -44,7 +53,7 @@ public static unsafe void DrawGcdCooldown(float width, bool drawTittle)

if(drawTittle)
{
var str = remain.ToString("F2") + "s";
var str = $"{remain:F2}s / {group->Total:F2}s";
ImGui.SetCursorPosX(ImGui.GetCursorPosX() + width / 2 - ImGui.CalcTextSize(str).X / 2);
ImGui.Text(str);
}
Expand All @@ -59,23 +68,23 @@ public static unsafe void DrawGcdCooldown(float width, bool drawTittle)
foreach (var value in CalculateValue(total, interval))
{
if (value < DataCenter.CastingTotal) continue;
var pt = cursor + new Vector2(total, 0) * value / total;
var pt = cursor + new Vector2(width, 0) * value / total;

ImGui.GetWindowDrawList().AddLine(pt, pt + new Vector2(0, height),
ImGui.GetWindowDrawList().AddLine(pt, pt + new Vector2(0, height),
ImGui.ColorConvertFloat4ToU32(ImGuiColors.DalamudRed));
}
}

static float[] CalculateValue(float total, float interval)
{
if(interval <= 0 || total <= 0 || interval <= total) return new float[0];
if(interval <= 0 || total <= 0 || total <= interval) return new float[0];

var count = (int)(total / interval);
var result = new List<float>(count);
var result = new List<float>();

if(count > 1)
{
for (int i = 1; i < count; i++)
for (int i = 1; i < count-1; i++)
{
result.Add(i * interval);
}
Expand Down
6 changes: 6 additions & 0 deletions RotationSolver/UI/RotationConfigWindow_Control.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ private void DrawControlTab()
DrawCheckBox(LocalizationManager.RightLang.ConfigWindow_Control_ShowNextActionWindow,
ref Service.Config.ShowNextActionWindow);

if (Service.Config.ShowNextActionWindow)
{
DrawColor4(LocalizationManager.RightLang.ConfigWindow_Control_NextActionWindowBg,
ref Service.Config.NextActionWindowBg);
}

DrawCheckBox(LocalizationManager.RightLang.ConfigWindow_Control_ShowControlWindow,
ref Service.Config.ShowControlWindow);

Expand Down
1 change: 1 addition & 0 deletions RotationSolver/UI/RotationConfigWindow_Debug.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ private void DrawDebugTab()

ImGui.PushStyleVar(ImGuiStyleVar.ItemSpacing, new Vector2(0f, 5f));


if (ImGui.BeginTabBar("Debug Items"))
{
DrawParamTabItem("Status", DrawStatus);
Expand Down
4 changes: 2 additions & 2 deletions RotationSolver/Updaters/ActionUpdater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,8 @@ internal static unsafe void UpdateWeaponTime()
var castTotal = player.TotalCastTime;

var weaponTotal = instance->GetRecastTime(ActionType.Spell, 11);
castTotal = Math.Max(castTotal + 0.1f, weaponTotal);
if (player.IsCasting) weaponTotal = castTotal;
if (castTotal > 0) castTotal += 0.1f;
if (player.IsCasting) weaponTotal = Math.Max(castTotal, weaponTotal);

DataCenter.WeaponElapsed = instance->GetRecastTimeElapsed(ActionType.Spell, 11);
DataCenter.WeaponRemain = DataCenter.WeaponElapsed == 0 ? player.TotalCastTime - player.CurrentCastTime
Expand Down
4 changes: 2 additions & 2 deletions RotationSolver/Updaters/SocialUpdater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ internal static async void UpdateSocial()
await Task.Delay(new Random().Next(3000, 5000));

#if DEBUG
Service.ChatGui.PrintError("Macro now.");
Service.ChatGui.Print("Macro now.");
#endif
Service.Config.DutyStart.AddMacro();
await Task.Delay(new Random().Next(1000, 1500));
Expand All @@ -129,7 +129,7 @@ private static async void SayHelloToAuthor()
}

#if DEBUG
Service.ChatGui.PrintError("Author Time");
Service.ChatGui.Print("Author Time");
#else
Service.TargetManager.SetTarget(author);
Service.SubmitToChat($"/{_macroToAuthor[new Random().Next(_macroToAuthor.Count)]} <t>");
Expand Down

0 comments on commit b7e017e

Please sign in to comment.