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

Commit

Permalink
fix: wrong actions message.
Browse files Browse the repository at this point in the history
  • Loading branch information
ArchiDog1998 committed Jul 6, 2023
1 parent a96f9c0 commit 731694e
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 35 deletions.
2 changes: 1 addition & 1 deletion RotationSolver/Commands/RSCommands_Actions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public static void DoAction()

if (wrong)
{
Svc.Toasts.ShowError(LocalizationManager.RightLang.ClickingMistakeMessage);
Svc.Toasts.ShowError(string.Format(LocalizationManager.RightLang.ClickingMistakeMessage, nextAction));
ControlWindow.Wrong = nextAction;
ControlWindow.DidTime = DateTime.Now;
}
Expand Down
6 changes: 4 additions & 2 deletions RotationSolver/Localization/Localization.json
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,9 @@
"ConfigWindow_Param_HostileDesc": "You can set the logic of hostile target selection to allow flexibility in switching the logic of selecting hostile in battle.",
"ConfigWindow_Param_AddOne": "Add One",
"ConfigWindow_Param_HostileCondition": "Hostile target selection condition",
"ConfigWindow_Param_ResetToDefault": "click to reset this value",
"ConfigWindow_Param_ResetToDefault": "Click to reset this value.",
"ConfigWindow_Param_ResetToDefaultWait": "Please wait for a second.",
"ConfigWindow_Param_ResetToDefaultSure": "Are you sure to reset this value?",
"ConfigWindow_Action_ShowOnCDWindow": "Show on CD window",
"ConfigWindow_Control_OnlyShowWithHostileOrInDuty": "Only shown if there are enemies in or in duty",
"ConfigWindow_Control_ShowNextActionWindow": "Show Next Action Window",
Expand Down Expand Up @@ -429,5 +431,5 @@
"HighEndBan": "{0} can not be used in High-end Duty!",
"TextToTalkWarning": "You didn't install TextToTalk, please install it to make Rotation Solver say something for you!",
"WhiteListDownloadingFailed": "Failed to load white List. Click to retry.",
"ClickingMistakeMessage": "OOOps! RS clicked the wrong action!"
"ClickingMistakeMessage": "OOOps! RS clicked the wrong action ({0})!"
}
6 changes: 4 additions & 2 deletions RotationSolver/Localization/Strings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,9 @@ internal partial class Strings
public string ConfigWindow_Param_HostileDesc { get; set; } = "You can set the logic of hostile target selection to allow flexibility in switching the logic of selecting hostile in battle.";
public string ConfigWindow_Param_AddOne { get; set; } = "Add One";
public string ConfigWindow_Param_HostileCondition { get; set; } = "Hostile target selection condition";
public string ConfigWindow_Param_ResetToDefault { get; set; } = "click to reset this value";
public string ConfigWindow_Param_ResetToDefault { get; set; } = "Click to reset this value.";
public string ConfigWindow_Param_ResetToDefaultWait { get; set; } = "Please wait for a second.";
public string ConfigWindow_Param_ResetToDefaultSure { get; set; } = "Are you sure to reset this value?";

public string ConfigWindow_Action_ShowOnCDWindow { get; set; } = "Show on CD window";

Expand Down Expand Up @@ -621,5 +623,5 @@ internal partial class Strings

public string WhiteListDownloadingFailed { get; set; } = "Failed to load white List. Click to retry.";

public string ClickingMistakeMessage { get; set; } = "OOOps! RS clicked the wrong action!";
public string ClickingMistakeMessage { get; set; } = "OOOps! RS clicked the wrong action ({0})!";
}
61 changes: 31 additions & 30 deletions RotationSolver/UI/ImGuiHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Dalamud.Utility;
using ECommons.DalamudServices;
using FFXIVClientStructs.FFXIV.Client.Game;
using Newtonsoft.Json.Linq;
using RotationSolver.Basic.Configuration;
using RotationSolver.Commands;
using RotationSolver.Helpers;
Expand Down Expand Up @@ -128,23 +129,47 @@ public static bool IconButton(FontAwesomeIcon icon, string name, string descript
static string _undoName;
static DateTime _lastTime;
public static void UndoValue<T>(string name, ref T value, T @default, Action otherThing = null)
{
if (UndoValue(name))
{
otherThing?.Invoke();
value = @default;
Service.Config.Save();
}
}

public static void UndoValue<T>(string name, ref T value1, T default1, ref T value2, T default2, Action otherThing = null)
{
if (UndoValue(name))
{
otherThing?.Invoke();
value1 = default1;
value2 = default2;
Service.Config.Save();
}
}

static bool UndoValue(string name)
{
ImGui.SameLine();
Spacing();

bool isLast = name == _undoName && DateTime.Now - _lastTime < TimeSpan.FromSeconds(2);
bool isTime = DateTime.Now - _lastTime > TimeSpan.FromSeconds(0.5);

bool result = false;

if (isLast) ImGui.PushStyleColor(ImGuiCol.Text, isTime ? ImGuiColors.HealerGreen : ImGuiColors.DPSRed);
if (IconButton(isLast ? FontAwesomeIcon.Check : FontAwesomeIcon.Undo, $"#{name}: Undo",
LocalizationManager.RightLang.ConfigWindow_Param_ResetToDefault)
!isTime ? LocalizationManager.RightLang.ConfigWindow_Param_ResetToDefaultWait :
isLast ? LocalizationManager.RightLang.ConfigWindow_Param_ResetToDefaultSure
: LocalizationManager.RightLang.ConfigWindow_Param_ResetToDefault)
&& isTime)
{
if (isLast)
{
otherThing?.Invoke();
value = @default;
Service.Config.Save();
result = true;
_lastTime = DateTime.MinValue;
}
else
{
Expand All @@ -153,33 +178,9 @@ public static void UndoValue<T>(string name, ref T value, T @default, Action oth
}
}
if (isLast) ImGui.PopStyleColor();

}

public static void UndoValue<T>(string name, ref T value1, T default1, ref T value2, T default2, Action otherThing = null)
{
ImGui.SameLine();

if (IconButton(FontAwesomeIcon.Undo, $"#{name}: Undo",
LocalizationManager.RightLang.ConfigWindow_Param_ResetToDefault)
&& ImGui.IsKeyPressed(ImGuiKey.LeftCtrl))
{
otherThing?.Invoke();
value1 = default1;
value2 = default2;
Service.Config.Save();
}
return result;
}

//public static Vector2 IconButtonSize(FontAwesomeIcon icon, string name)
//{
// ImGui.PushFont(UiBuilder.IconFont);
// var result = ImGui.CalcTextSize($"{icon.ToIconString()}##{name}");
// ImGui.PopFont();
// return result;
//}


public static void HoveredString(string text, Action selected = null)
{
if (ImGui.IsItemHovered())
Expand Down

0 comments on commit 731694e

Please sign in to comment.