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

Commit

Permalink
fix: add fps show, and change the param layout.
Browse files Browse the repository at this point in the history
  • Loading branch information
ArchiDog1998 committed Feb 2, 2023
1 parent 8dfbf6c commit 4c4bd29
Show file tree
Hide file tree
Showing 5 changed files with 86 additions and 42 deletions.
1 change: 1 addition & 0 deletions RotationSolver/Configuration/PluginConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ public class PluginConfiguration : IPluginConfiguration

public bool UseWorkTask = true;
public int WorkTaskDelay = 20;
public bool ShowWorkTaskFPS = true;

public bool UseStopCasting = true;

Expand Down
5 changes: 5 additions & 0 deletions RotationSolver/Localization/Strings_Major.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ internal partial class Strings
public string Configwindow_Param_WorkTaskDelay { get; set; } = "Set the work task delay in millisecond. Smaller, more precise, more resource-intensive";

public string Configwindow_Param_Display { get; set; } = "Display";
public string Configwindow_Param_Sound { get; set; } = "Sound";
public string Configwindow_Param_Advanced { get; set; } = "Advanced";
public string Configwindow_Param_PoslockCasting { get; set; } = "Lock the movement when casting.";
public string Configwindow_Param_UseStopCasting { get; set; } = "Use stopping casting when target is dead.";
public string Configwindow_Param_PoslockModifier { get; set; } = "Set the modifier key to unlock the movement temporary";
Expand All @@ -141,6 +143,9 @@ internal partial class Strings
public string Configwindow_Params_LocationWrongTextDesc { get; set; } = "How do you want to be scolded if you have a positional error ?!";
public string Configwindow_Param_SayOutStateChanged { get; set; } = "Saying the state changes out";
public string Configwindow_Param_ShowInfoOnDtr { get; set; } = "Display plugin state on dtrbar";

public string Configwindow_Param_ShowWorkTaskFPS { get; set; } = "Display Task FPS on dtrbar";

public string Configwindow_Param_ShowInfoOnToast { get; set; } = "Display plugin state changed on toast";
public string Configwindow_Param_Action { get; set; } = "Action";
public string Configwindow_Param_UseAOEWhenManual { get; set; } = "Use AOE actions in manual mode";
Expand Down
23 changes: 23 additions & 0 deletions RotationSolver/Updaters/MajorUpdater.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Dalamud.Game;
using RotationSolver.Commands;
using System;
using System.Threading.Tasks;

namespace RotationSolver.Updaters;
Expand Down Expand Up @@ -43,6 +44,10 @@ private static void FrameworkUpdate(Framework framework)
}

static bool _work = true;
static DateTime _lastUpdate = DateTime.MinValue;
static readonly TimeSpan _oneSecond = TimeSpan.FromSeconds(1);
static int _frameCount = 0;
public static string FrameCount { get; private set; }
public static void Enable()
{
Service.Framework.Update += FrameworkUpdate;
Expand All @@ -58,11 +63,29 @@ public static void Enable()

UpdateWork();
Task.Delay(Service.Configuration.WorkTaskDelay);

CalculateFPS();
}
});
MovingUpdater.Enable();
}

private static void CalculateFPS()
{
var now = DateTime.Now;
var span = now - _lastUpdate;
if (span > _oneSecond)
{
FrameCount = (_frameCount / span.TotalSeconds).ToString("F2");
_lastUpdate = now;
_frameCount = 0;
}
else
{
_frameCount++;
}
}

private static void UpdateWork()
{
PreviewUpdater.UpdateCastBarState();
Expand Down
11 changes: 8 additions & 3 deletions RotationSolver/Updaters/PreviewUpdater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,21 @@ internal static void UpdatePreview()
static string _showValue;
private static void UpdateEntry()
{
if (Service.Configuration.ShowInfoOnDtr && RSCommands.EntryString != null)
var showStr = RSCommands.EntryString;
if (Service.Configuration.ShowWorkTaskFPS)
{
showStr += " " + MajorUpdater.FrameCount + "Hz";
}
if (Service.Configuration.ShowInfoOnDtr && showStr != null)
{
if (_dtrEntry == null)
{
_dtrEntry = Service.DtrBar.Get("Rotation Solver");
}
if(!_dtrEntry.Shown) _dtrEntry.Shown = true;
if(_showValue != RSCommands.EntryString)
if(_showValue != showStr)
{
_showValue = RSCommands.EntryString;
_showValue = showStr;
_dtrEntry.Text = new SeString(
new IconPayload(BitmapFontIcon.DPS),
new TextPayload(_showValue)
Expand Down
88 changes: 49 additions & 39 deletions RotationSolver/Windows/RotationConfigWindow_Param.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,12 @@ private void DrawParamTab()
DrawParamTabItem(LocalizationManager.RightLang.Configwindow_Param_Basic, DrawParamBasic);
DrawParamTabItem(LocalizationManager.RightLang.Configwindow_Param_Delay, DrawParamDelay);
DrawParamTabItem(LocalizationManager.RightLang.Configwindow_Param_Display, DrawParamDisplay);
DrawParamTabItem(LocalizationManager.RightLang.Configwindow_Param_Sound, DrawParamSound);
DrawParamTabItem(LocalizationManager.RightLang.Configwindow_Param_Action, DrawParamAction);
DrawParamTabItem(LocalizationManager.RightLang.Configwindow_Param_Conditon, DrawParamCondition);
DrawParamTabItem(LocalizationManager.RightLang.Configwindow_Param_Target, DrawParamTarget);
DrawParamTabItem(LocalizationManager.RightLang.Configwindow_Param_Hostile, DrawParamHostile);
DrawParamTabItem(LocalizationManager.RightLang.Configwindow_Param_Advanced, DrawParamAdvanced);

ImGui.EndTabBar();
}
Expand Down Expand Up @@ -109,6 +111,43 @@ private void DrawParamDelay()
}
}

private void DrawParamSound()
{
DrawIntNumber(LocalizationManager.RightLang.Configwindow_Params_VoiceVolume,
ref Service.Configuration.VoiceVolume, max: 100);

DrawCheckBox(LocalizationManager.RightLang.Configwindow_Param_SayOutStateChanged,
ref Service.Configuration.SayOutStateChanged);


DrawCheckBox(LocalizationManager.RightLang.Configwindow_Param_SayPositional,
ref Service.Configuration.SayPotional);

DrawInputText(LocalizationManager.RightLang.Configwindow_Param_PositionaErrorText,
ref Service.Configuration.PositionalErrorText, 100,
LocalizationManager.RightLang.Configwindow_Params_LocationWrongTextDesc);
}

private void DrawParamAdvanced()
{
DrawCheckBox(LocalizationManager.RightLang.Configwindow_Param_PoslockCasting,
ref Service.Configuration.PoslockCasting);

if (Service.Configuration.PoslockCasting)
{
ImGui.SameLine();
ImGuiHelper.Spacing();

DrawCombo(LocalizationManager.RightLang.Configwindow_Param_PoslockModifier,
ref Service.Configuration.PoslockModifier, EnumTranslations.ToName,
ConfigurationHelper.Keys,
LocalizationManager.RightLang.Configwindow_Param_PoslockDescription);
}

DrawCheckBox(LocalizationManager.RightLang.Configwindow_Param_UseStopCasting,
ref Service.Configuration.UseStopCasting);
}

private void DrawParamDisplay()
{
var useOverlayWindow = Service.Configuration.UseOverlayWindow;
Expand Down Expand Up @@ -155,63 +194,34 @@ private void DrawParamDisplay()
}

DrawCheckBox(LocalizationManager.RightLang.Configwindow_Param_KeyBoardNoise,
ref Service.Configuration.KeyBoardNoise);

ImGui.Separator();

DrawCheckBox(LocalizationManager.RightLang.Configwindow_Param_CastingDisplay,
ref Service.Configuration.CastingDisplay);


DrawCheckBox(LocalizationManager.RightLang.Configwindow_Param_PoslockCasting,
ref Service.Configuration.PoslockCasting);

if (Service.Configuration.PoslockCasting)
{
ImGui.SameLine();
ImGuiHelper.Spacing();

DrawCombo(LocalizationManager.RightLang.Configwindow_Param_PoslockModifier,
ref Service.Configuration.PoslockModifier, EnumTranslations.ToName,
ConfigurationHelper.Keys,
LocalizationManager.RightLang.Configwindow_Param_PoslockDescription);
}

DrawCheckBox(LocalizationManager.RightLang.Configwindow_Param_UseStopCasting,
ref Service.Configuration.UseStopCasting);

ImGui.Separator();

DrawCheckBox(LocalizationManager.RightLang.Configwindow_Param_SayOutStateChanged,
ref Service.Configuration.SayOutStateChanged);
ref Service.Configuration.KeyBoardNoise);

DrawCheckBox(LocalizationManager.RightLang.Configwindow_Param_ShowInfoOnDtr,
ref Service.Configuration.ShowInfoOnDtr);

DrawCheckBox(LocalizationManager.RightLang.Configwindow_Param_ShowInfoOnToast,
ref Service.Configuration.ShowInfoOnToast);

if (Service.Configuration.ShowInfoOnDtr && Service.Configuration.UseWorkTask)
{
DrawCheckBox(LocalizationManager.RightLang.Configwindow_Param_ShowWorkTaskFPS,
ref Service.Configuration.ShowWorkTaskFPS);
}

ImGui.Spacing();

DrawCheckBox(LocalizationManager.RightLang.Configwindow_Param_CastingDisplay,
ref Service.Configuration.CastingDisplay);

DrawCheckBox(LocalizationManager.RightLang.Configwindow_Param_FlytextPositional,
ref Service.Configuration.FlytextPositional);

DrawCheckBox(LocalizationManager.RightLang.Configwindow_Param_SayPositional,
ref Service.Configuration.SayPotional);

if (useOverlayWindow)
{
DrawCheckBox(LocalizationManager.RightLang.Configwindow_Param_PositionalFeedback,
ref Service.Configuration.PositionalFeedback,
LocalizationManager.RightLang.Configwindow_Param_PositionalFeedbackDesc);
}

DrawIntNumber(LocalizationManager.RightLang.Configwindow_Params_VoiceVolume,
ref Service.Configuration.VoiceVolume, max: 100);

DrawInputText(LocalizationManager.RightLang.Configwindow_Param_PositionaErrorText,
ref Service.Configuration.PositionalErrorText, 100,
LocalizationManager.RightLang.Configwindow_Params_LocationWrongTextDesc);
}

private void DrawParamAction()
Expand Down

0 comments on commit 4c4bd29

Please sign in to comment.