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

Commit

Permalink
fix: add a restore to default feature.
Browse files Browse the repository at this point in the history
  • Loading branch information
ArchiDog1998 committed Apr 5, 2023
1 parent 7386365 commit 85e1aaf
Show file tree
Hide file tree
Showing 8 changed files with 181 additions and 120 deletions.
1 change: 1 addition & 0 deletions RotationSolver.Basic/Service.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ public void Dispose()
Framework.Update -= Framework_Update;
}
public static PluginConfiguration Config { get; set; }
public static PluginConfiguration Default { get; } = new PluginConfiguration();

internal static unsafe FFXIVClientStructs.FFXIV.Client.Game.Character.BattleChara* RawPlayer
=> Control.Instance()->LocalPlayer;
Expand Down
2 changes: 2 additions & 0 deletions RotationSolver/Localization/Localization.json
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@
"ConfigWindow_Param_PositionalFeedback": "Positional error feedback",
"ConfigWindow_Param_DrawPositional": "Draw Positional on the screen",
"ConfigWindow_Param_DrawMeleeRange": "Draw the range of melee on the screen",
"ConfigWindow_Param_DrawMeleeOffset": "Draw the offset of melee on the screen",
"ConfigWindow_Param_ShowMoveTarget": "Show the pointing target of the move skill",
"ConfigWindow_Param_ShowTarget": "Show Target",
"ConfigWindow_Param_PositionalFeedbackDesc": "Attention: Positional anticipation is experimental, just for reference only.",
Expand Down Expand Up @@ -174,6 +175,7 @@
"ConfigWindow_Param_ConditionUp": "Up",
"ConfigWindow_Param_ConditionDown": "Down",
"ConfigWindow_Param_ConditionDelete": "Delete",
"ConfigWindow_Param_ResetToDefault": "Press left ctrl + shift and press right mouse button to reset this value",
"ConfigWindow_Control_OnlyShowWithHostileOrInDuty": "Only shown if there are enemies in or in duty",
"ConfigWindow_Control_ShowNextActionWindow": "Show Next Action Window",
"ConfigWindow_Control_ShowControlWindow": "Show Control Window",
Expand Down
1 change: 1 addition & 0 deletions RotationSolver/Localization/Strings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ internal partial class Strings
public string ConfigWindow_Param_ConditionUp { get; set; } = "Up";
public string ConfigWindow_Param_ConditionDown { get; set; } = "Down";
public string ConfigWindow_Param_ConditionDelete { get; set; } = "Delete";
public string ConfigWindow_Param_ResetToDefault { get; set; } = "Press left ctrl + shift and press right mouse button to reset this value";

public string ConfigWindow_Control_OnlyShowWithHostileOrInDuty { get; set; } = "Only shown if there are enemies in or in duty";
public string ConfigWindow_Control_ShowNextActionWindow { get; set; } = "Show Next Action Window";
Expand Down
2 changes: 1 addition & 1 deletion RotationSolver/UI/ControlWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public override void Draw()
ImGui.Text(DataCenter.TargetingType.ToName());

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

DrawNextAction(gcd, ability, width);
Expand Down
15 changes: 15 additions & 0 deletions RotationSolver/UI/ImGuiHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,21 @@ public static void HoveredString(string text, Action selected = null)
}
}

public static bool HoveredStringReset(string text)
{
if (ImGui.IsItemHovered())
{
if (string.IsNullOrEmpty(text)) text = string.Empty;
text += "\n \n" + LocalizationManager.RightLang.ConfigWindow_Param_ResetToDefault;
ImGui.SetTooltip(text);

return ImGui.IsMouseDown(ImGuiMouseButton.Right)
&& ImGui.IsKeyPressed(ImGuiKey.LeftShift)
&& ImGui.IsKeyPressed(ImGuiKey.LeftCtrl);
}
return false;
}

internal unsafe static bool DrawEditorList<T>(List<T> items, Action<T> draw)
{
ImGui.Indent();
Expand Down
46 changes: 23 additions & 23 deletions RotationSolver/UI/RotationConfigWindow_Control.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,93 +7,93 @@ internal partial class RotationConfigWindow
private void DrawControlTab()
{
DrawCheckBox(LocalizationManager.RightLang.ConfigWindow_Control_UseGamepadCommand,
ref Service.Config.UseGamepadCommand);
ref Service.Config.UseGamepadCommand, Service.Default.UseGamepadCommand);

DrawCheckBox(LocalizationManager.RightLang.ConfigWindow_Control_UseKeyboardCommand,
ref Service.Config.UseKeyboardCommand);
ref Service.Config.UseKeyboardCommand, Service.Default.UseKeyboardCommand);

ImGui.Separator();

if(Service.Config.ShowNextActionWindow || Service.Config.ShowCooldownWindow || Service.Config.ShowControlWindow)
{
DrawCheckBox(LocalizationManager.RightLang.ConfigWindow_Control_OnlyShowWithHostileOrInDuty,
ref Service.Config.OnlyShowWithHostileOrInDuty);
ref Service.Config.OnlyShowWithHostileOrInDuty, Service.Default.OnlyShowWithHostileOrInDuty);
}

DrawCheckBox(LocalizationManager.RightLang.ConfigWindow_Control_ShowNextActionWindow,
ref Service.Config.ShowNextActionWindow);
ref Service.Config.ShowNextActionWindow, Service.Default.ShowNextActionWindow);

DrawCheckBox(LocalizationManager.RightLang.ConfigWindow_Control_ShowCooldownWindow,
ref Service.Config.ShowCooldownWindow);
ref Service.Config.ShowCooldownWindow, Service.Default.ShowCooldownWindow);

if (Service.Config.ShowNextActionWindow || Service.Config.ShowCooldownWindow)
{
DrawColor4(LocalizationManager.RightLang.ConfigWindow_Control_InfoWindowBg,
ref Service.Config.InfoWindowBg);
ref Service.Config.InfoWindowBg, Service.Default.InfoWindowBg);

DrawCheckBox(LocalizationManager.RightLang.ConfigWindow_Control_IsInfoWindowNoInputs,
ref Service.Config.IsInfoWindowNoInputs);
ref Service.Config.IsInfoWindowNoInputs, Service.Default.IsInfoWindowNoInputs);

DrawCheckBox(LocalizationManager.RightLang.ConfigWindow_Control_IsInfoWindowNoMove,
ref Service.Config.IsInfoWindowNoMove);
ref Service.Config.IsInfoWindowNoMove, Service.Default.IsInfoWindowNoMove);

if (Service.Config.ShowCooldownWindow)
{
DrawCheckBox(LocalizationManager.RightLang.ConfigWindow_Control_ShowItemsCooldown,
ref Service.Config.ShowItemsCooldown);
ref Service.Config.ShowItemsCooldown, Service.Default.ShowItemsCooldown);

DrawCheckBox(LocalizationManager.RightLang.ConfigWindow_Control_ShowGCDCooldown,
ref Service.Config.ShowGCDCooldown);
ref Service.Config.ShowGCDCooldown, Service.Default.ShowGCDCooldown);

DrawCheckBox(LocalizationManager.RightLang.ConfigWindow_Control_UseOriginalCooldown,
ref Service.Config.UseOriginalCooldown);
ref Service.Config.UseOriginalCooldown, Service.Default.UseOriginalCooldown);

DrawIntNumber(LocalizationManager.RightLang.ConfigWindow_Control_CooldownActionOneLine, ref Service.Config.CooldownActionOneLine, min: 1, max: 30);
DrawIntNumber(LocalizationManager.RightLang.ConfigWindow_Control_CooldownActionOneLine, ref Service.Config.CooldownActionOneLine, Service.Default.CooldownActionOneLine, min: 1, max: 30);
}
}

ImGui.Separator();

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

if (!Service.Config.ShowControlWindow) return;

DrawCheckBox(LocalizationManager.RightLang.ConfigWindow_Control_IsInfoWindowNoInputs,
ref Service.Config.IsControlWindowLock);
ref Service.Config.IsControlWindowLock, Service.Default.IsControlWindowLock);

if (Service.Config.IsControlWindowLock)
{
DrawColor4(LocalizationManager.RightLang.ConfigWindow_Control_BackgroundColor,
ref Service.Config.ControlWindowLockBg);
ref Service.Config.ControlWindowLockBg, Service.Default.ControlWindowLockBg);
}
else
{
DrawColor4(LocalizationManager.RightLang.ConfigWindow_Control_BackgroundColor,
ref Service.Config.ControlWindowUnlockBg);
ref Service.Config.ControlWindowUnlockBg, Service.Default.ControlWindowUnlockBg);
}

DrawFloatNumber(LocalizationManager.RightLang.ConfigWindow_Control_ControlWindowGCDSize,
ref Service.Config.ControlWindowGCDSize, speed: 0.2f , max: 80);
ref Service.Config.ControlWindowGCDSize, Service.Default.ControlWindowGCDSize, speed: 0.2f , max: 80);

DrawFloatNumber(LocalizationManager.RightLang.ConfigWindow_Control_ControlWindow0GCDSize,
ref Service.Config.ControlWindow0GCDSize, speed: 0.2f, max: 80);

ref Service.Config.ControlWindow0GCDSize, Service.Default.ControlWindow0GCDSize, speed: 0.2f, max: 80);

DrawFloatNumber(LocalizationManager.RightLang.ConfigWindow_Control_ControlWindowNextSizeRatio,
ref Service.Config.ControlWindowNextSizeRatio);
ref Service.Config.ControlWindowNextSizeRatio, Service.Default.ControlWindowNextSizeRatio);
}

private static void DrawColor4(string name, ref Vector4 value, string description = "")
private static void DrawColor4(string name, ref Vector4 value, Vector4 @default, string description = "")
{
ImGui.SetNextItemWidth(210);
if (ImGui.ColorEdit4(name, ref value))
{
Service.Config.Save();
}
if (!string.IsNullOrEmpty(description) && ImGui.IsItemHovered())
if (ImGuiHelper.HoveredStringReset(description) && value != @default)
{
ImGui.SetTooltip(description);
value = @default;
Service.Config.Save();
}
}
}
Loading

0 comments on commit 85e1aaf

Please sign in to comment.