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

Commit

Permalink
fix: fix the toast and some command bugs.
Browse files Browse the repository at this point in the history
  • Loading branch information
ArchiDog1998 committed Jan 20, 2023
1 parent c2611e9 commit 6bebf14
Show file tree
Hide file tree
Showing 11 changed files with 43 additions and 34 deletions.
2 changes: 1 addition & 1 deletion RotationSolver/Actions/BaseAction/BaseAction_Display.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ internal partial class BaseAction
{
public unsafe void Display(bool IsActive) => this.DrawEnableTexture(IsActive, () => RotationConfigWindow.ActiveAction = this, otherThing: () =>
{
if (IsTimeline) OtherCommandType.Actions.DisplayCommandHelp($"Insert{this}-{5}",
if (IsTimeline) OtherCommandType.Actions.DisplayCommandHelp($"{this}-{5}",
type => string.Format(LocalizationManager.RightLang.Configwindow_Helper_InsertCommand, this));

#if DEBUG
Expand Down
6 changes: 1 addition & 5 deletions RotationSolver/Commands/RSCommands_BasicInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,7 @@ internal static void Enable()

private static void OnCommand(string command, string arguments)
{
string[] array = arguments.Split();

if (!array.Any()) return;

DoOneCommand(array[0]);
DoOneCommand(arguments);
}

private static void DoOneCommand(string str)
Expand Down
2 changes: 1 addition & 1 deletion RotationSolver/Commands/RSCommands_Display.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ internal static void DisplayCommandHelp<T>(this T command, string extraCommand =
}
if (ImGui.IsItemHovered())
{
ImGui.SetTooltip($"{LocalizationManager.RightLang.Configwindow_Helper_RunCommand}: {command}\n{LocalizationManager.RightLang.Configwindow_Helper_CopyCommand}: {command}");
ImGui.SetTooltip($"{LocalizationManager.RightLang.Configwindow_Helper_RunCommand}: {cmdStr}\n{LocalizationManager.RightLang.Configwindow_Helper_CopyCommand}: {cmdStr}");

if (ImGui.IsMouseDown(ImGuiMouseButton.Right))
{
Expand Down
1 change: 0 additions & 1 deletion RotationSolver/Commands/RSCommands_OtherCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ private static void DoRotationCommand(ICustomRotation customCombo, string str)
{
if(config.DoCommand(configs, str))
{
//Say out.
Service.ChatGui.Print(string.Format(LocalizationManager.RightLang.Commands_ChangeRotationConfig,
config.DisplayName, configs.GetDisplayString(config.Name)));

Expand Down
12 changes: 12 additions & 0 deletions RotationSolver/Commands/RSCommands_StateSpecialCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,16 @@ internal static partial class RSCommands
internal static string EntryString =>
_stateString + (SpecialTimeLeft < 0 ? string.Empty : $" - {_specialString}: {SpecialTimeLeft:F2}s");

private static void UpdateToast()
{
if (!Service.Configuration.ShowInfoOnToast) return;

Service.ToastGui.ShowQuest(" " + EntryString, new Dalamud.Game.Gui.Toast.QuestToastOptions()
{
IconId = 101,
});
}

internal static void ResetSpecial() => DoSpecialCommandType(SpecialCommandType.EndSpecial);

private static void DoStateCommandType(StateCommandType stateType)
Expand All @@ -42,6 +52,7 @@ private static void DoStateCommandType(StateCommandType stateType)
StateType = stateType;

_stateString = stateType.ToStateString(role);
UpdateToast();
});
}

Expand All @@ -53,6 +64,7 @@ private static void DoSpecialCommandType(SpecialCommandType specialType)

_specialString = specialType.ToSpecialString(role);
_specialStateStartTime = DateTime.Now;
UpdateToast();
});
}

Expand Down
2 changes: 1 addition & 1 deletion RotationSolver/Configuration/PluginConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public class PluginConfiguration : IPluginConfiguration
public bool ChangeTargetForFate = true;
public bool MoveTowardsScreenCenter = true;

public bool SayOutStateChanged = false;
public bool SayOutStateChanged = true;

public bool ShowInfoOnDtr = true;

Expand Down
37 changes: 20 additions & 17 deletions RotationSolver/Helpers/ImguiHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,49 +22,48 @@ public static void DrawEnableTexture<T>(this T texture, bool isSelected, Action
{
ImGui.PushStyleVar(ImGuiStyleVar.FramePadding, new Vector2(3f, 3f));

ImGui.Columns(2, texture.Name, false);

var t = texture.GetTexture();

ImGui.SetColumnWidth(0, t.Width + 5);

ImGui.Image(t.ImGuiHandle, new Vector2(t.Width, t.Height));

var able = texture as IEnable;

var desc = able?.Description;
HoveredString(desc);
ImGui.SameLine();
Spacing();

HoveredString(desc, selected);

if(ImGui.Selectable(texture.Name, isSelected))
{
selected?.Invoke();
}
HoveredString(desc);
ImGui.NextColumn();

bool enable = false;
if (able != null)
{
ImGui.SameLine();
Spacing();

if (isSelected) ImGui.PushStyleColor(ImGuiCol.Text, ImGui.ColorConvertFloat4ToU32(ImGuiColors.DalamudYellow));
enable = able.IsEnabled;
if (ImGui.Checkbox("##" + texture.Name, ref enable))
if (ImGui.Checkbox($"{texture.Name}##{texture.Name}", ref enable))
{
able.IsEnabled = enable;
Service.Configuration.Save();
}
HoveredString(desc);
if (isSelected) ImGui.PopStyleColor();

HoveredString(desc, selected);
}


additonalHeader?.Invoke();

if (enable)
{
ImGui.Indent(t.Width);
ImGui.Indent(20);
ImGui.PushStyleVar(ImGuiStyleVar.FramePadding, new Vector2(1f, 1f));
otherThing?.Invoke();
ImGui.PopStyleVar();
ImGui.Unindent();
ImGui.Unindent(20);
}
ImGui.Columns(1);

ImGui.PopStyleVar();
}
Expand All @@ -79,11 +78,15 @@ public static bool IconButton(FontAwesomeIcon icon, string name)
//ImGuiComponents.IconButton(icon)
}

public static void HoveredString(string text)
public static void HoveredString(string text, Action selected = null)
{
if (ImGui.IsItemHovered())
{
if (!string.IsNullOrEmpty(text)) ImGui.SetTooltip(text);
if (ImGui.IsMouseDown(ImGuiMouseButton.Left))
{
selected?.Invoke();
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,13 @@ public unsafe void Display(ICustomRotation[] rotations, bool canAddButton) => th
}

ImGui.SameLine();
ImGui.TextDisabled(" - " + LocalizationManager.RightLang.Configwindow_Helper_GameVersion + ": ");
ImGui.TextDisabled(" - " + LocalizationManager.RightLang.Configwindow_Helper_GameVersion + ": ");
ImGui.SameLine();
ImGui.Text(GameVersion);
ImGui.SameLine();
ImGuiHelper.Spacing();

if(ImGuiHelper.IconButton(FontAwesomeIcon.Globe, GetHashCode().ToString()))
if (ImGuiHelper.IconButton(FontAwesomeIcon.Globe, GetHashCode().ToString()))
{
var url = @"https://github.com/ArchiDog1998/RotationSolver/blob/main/" + GetType().FullName.Replace(".", @"/") + ".cs";

Expand Down
2 changes: 1 addition & 1 deletion RotationSolver/Updaters/PreviewUpdater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ private static void UpdateEntry()
{
if (dtrEntry == null)
{
dtrEntry = Service.DtrBar.Get("Auto Attack");
dtrEntry = Service.DtrBar.Get("Rotation Solver");
}
dtrEntry.Shown = true;
dtrEntry.Text = new SeString(
Expand Down
1 change: 0 additions & 1 deletion RotationSolver/Windows/RotationConfigWindow_Action.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ private void DrawActionList()
{
ImGui.PushStyleVar(ImGuiStyleVar.ItemSpacing, new Vector2(0f, 5f));


if (ImGui.BeginChild("Action List", new Vector2(0f, -1f), true))
{
foreach (var pair in IconReplacer.RightRotationBaseActions.GroupBy(a => a.CateName).OrderBy(g => g.Key))
Expand Down
6 changes: 2 additions & 4 deletions RotationSolver/Windows/RotationConfigWindow_Help.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,28 +14,26 @@ private void DrawHelpTab()
{
ImGui.Text(LocalizationManager.RightLang.ConfigWindow_HelpItem_Description);

ImGui.PushStyleColor(ImGuiCol.Button, ImGuiColors.ParsedGreen);
ImGui.SameLine();

if (ImGui.Button("Github"))
{
Util.OpenLink("https://github.com/ArchiDog1998/RotationSolver");
}

ImGui.SameLine();
ImGuiHelper.Spacing();

if (ImGui.Button("Discord"))
{
Util.OpenLink("https://discord.gg/4fECHunam9");
}

ImGui.SameLine();
ImGuiHelper.Spacing();

if (ImGui.Button("Wiki"))
{
Util.OpenLink("https://archidog1998.github.io/RotationSolver/");
}
ImGui.PopStyleColor();

if (ImGui.BeginChild("Help Infomation", new Vector2(0f, -1f), true))
{
Expand Down

0 comments on commit 6bebf14

Please sign in to comment.