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

Commit

Permalink
fix: fix some bug with next action window.
Browse files Browse the repository at this point in the history
  • Loading branch information
ArchiDog1998 committed Mar 21, 2023
1 parent b7e017e commit 55956ea
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 21 deletions.
3 changes: 2 additions & 1 deletion RotationSolver.Basic/Configuration/PluginConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,9 @@ public class PluginConfiguration : IPluginConfiguration
public MacroInfo DutyEnd { get; set; } = new MacroInfo();

public bool ShowControlWindow = false;
public bool ShowNextActionWindow = false;
public bool IsControlWindowLock = false;
public bool ShowNextActionWindow = false;
public bool IsNextActionWindowLock = false;
public bool UseKeyboardCommand = false;
public bool UseGamepadCommand = false;

Expand Down
2 changes: 1 addition & 1 deletion RotationSolver/Localization/Localization.json
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@
"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_IsWindowLock": "Lock",
"ConfigWindow_Control_BackgroundColor": "Control Window's Background",
"ConfigWindow_Control_NextActionWindowBg": "Next Action Window's Background",
"ConfigWindow_Control_ControlWindowGCDSize": "GCD icon size",
Expand Down
2 changes: 1 addition & 1 deletion RotationSolver/Localization/Strings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ internal partial class Strings
public string ConfigWindow_Control_UseKeyboardCommand { get; set; } = "Use Keyboard Command";
public string ConfigWindow_Control_UseGamepadCommand { get; set; } = "Use GamePad Command";
public string ConfigWindow_Control_ControlShowCooldown { get; set; } = "Show action's cooldown";
public string ConfigWindow_Control_IsControlWindowLock { get; set; } = "Lock";
public string ConfigWindow_Control_IsWindowLock { 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";
Expand Down
10 changes: 8 additions & 2 deletions RotationSolver/RotationSolverPlugin.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using Dalamud.Game.ClientState.Conditions;
using Dalamud.Interface.Windowing;
using Dalamud.Plugin;
using Newtonsoft.Json;
Expand Down Expand Up @@ -106,7 +107,12 @@ internal static void OpenConfigWindow()

internal static void UpdateDisplayWindow()
{
_controlWindow.IsOpen = MajorUpdater.IsValid && Service.Config.ShowControlWindow;
_nextActionWindow.IsOpen = MajorUpdater.IsValid && Service.Config.ShowNextActionWindow;
var isValid = MajorUpdater.IsValid
&& !Service.Conditions[ConditionFlag.OccupiedInCutSceneEvent]
&& !Service.Conditions[ConditionFlag.BetweenAreas]
&& !Service.Conditions[ConditionFlag.BetweenAreas51];

_controlWindow.IsOpen = isValid && Service.Config.ShowControlWindow;
_nextActionWindow.IsOpen = isValid && Service.Config.ShowNextActionWindow;
}
}
12 changes: 9 additions & 3 deletions RotationSolver/UI/ControlWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,14 @@ namespace RotationSolver.UI;

internal class ControlWindow : Window
{
public const ImGuiWindowFlags BaseFlags = ImGuiWindowFlags.NoScrollbar
| ImGuiWindowFlags.NoCollapse
| ImGuiWindowFlags.NoTitleBar
| ImGuiWindowFlags.NoNav
| ImGuiWindowFlags.NoScrollWithMouse;

public ControlWindow()
: base(nameof(ControlWindow), NextActionWindow.BaseFlags)
: base(nameof(ControlWindow), BaseFlags)
{
Size = new Vector2(540f, 490f);
SizeCondition = ImGuiCond.FirstUseEver;
Expand All @@ -28,7 +34,7 @@ public override void PreDraw()
: Service.Config.ControlWindowUnlockBg;
ImGui.PushStyleColor(ImGuiCol.WindowBg, bgColor);

Flags = NextActionWindow.BaseFlags;
Flags = BaseFlags;

if (Service.Config.IsControlWindowLock)
{
Expand Down Expand Up @@ -61,7 +67,7 @@ public override void Draw()

ImGui.SameLine();

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

ImGui.NextColumn();
Expand Down
25 changes: 13 additions & 12 deletions RotationSolver/UI/NextActionWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,24 @@ namespace RotationSolver.UI;

internal class NextActionWindow : Window
{
public const ImGuiWindowFlags BaseFlags = ImGuiWindowFlags.NoScrollbar
| ImGuiWindowFlags.NoCollapse
| ImGuiWindowFlags.NoTitleBar
| ImGuiWindowFlags.NoNav
| ImGuiWindowFlags.NoScrollWithMouse;

const ImGuiWindowFlags BaseFlags = ControlWindow.BaseFlags
| ImGuiWindowFlags.AlwaysAutoResize
| ImGuiWindowFlags.NoResize;
public NextActionWindow()
: base(nameof(NextActionWindow), BaseFlags
| ImGuiWindowFlags.AlwaysAutoResize
| ImGuiWindowFlags.NoResize)
: base(nameof(NextActionWindow), BaseFlags)
{
}

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

Flags = BaseFlags;
if (Service.Config.IsNextActionWindowLock)
{
Flags |= ImGuiWindowFlags.NoInputs;
}

//ImGui.PushStyleVar(ImGuiStyleVar.WindowPadding, new Vector2(0, 0));
ImGui.PushStyleVar(ImGuiStyleVar.WindowBorderSize, 0);
}
Expand All @@ -50,17 +51,17 @@ public static unsafe void DrawGcdCooldown(float width, bool drawTittle)
{
var group = ActionManager.Instance()->GetRecastGroupDetail(ActionHelper.GCDCooldownGroup - 1);
var remain = group->Total - group->Elapsed;
var total = DataCenter.WeaponTotal;

if(drawTittle)
if (drawTittle)
{
var str = $"{remain:F2}s / {group->Total:F2}s";
var str = $"{remain:F2}s / {total:F2}s";
ImGui.SetCursorPosX(ImGui.GetCursorPosX() + width / 2 - ImGui.CalcTextSize(str).X / 2);
ImGui.Text(str);
}

var cursor = ImGui.GetCursorPos() + ImGui.GetWindowPos();
var height = Service.Config.ControlProgressHeight;
var total = DataCenter.WeaponTotal;
var interval = Service.Config.AbilitiesInterval;

ImGui.ProgressBar(group->Elapsed / group->Total, new Vector2(width, height), string.Empty);
Expand Down
7 changes: 6 additions & 1 deletion RotationSolver/UI/RotationConfigWindow_Control.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,19 @@ private void DrawControlTab()
{
DrawColor4(LocalizationManager.RightLang.ConfigWindow_Control_NextActionWindowBg,
ref Service.Config.NextActionWindowBg);

DrawCheckBox(LocalizationManager.RightLang.ConfigWindow_Control_IsWindowLock,
ref Service.Config.IsNextActionWindowLock);
}

ImGui.Separator();

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

if (!Service.Config.ShowControlWindow) return;

DrawCheckBox(LocalizationManager.RightLang.ConfigWindow_Control_IsControlWindowLock,
DrawCheckBox(LocalizationManager.RightLang.ConfigWindow_Control_IsWindowLock,
ref Service.Config.IsControlWindowLock);

DrawCheckBox(LocalizationManager.RightLang.ConfigWindow_Control_ControlShowCooldown,
Expand Down

0 comments on commit 55956ea

Please sign in to comment.