diff --git a/Resources/AnimationLockTime.json b/Resources/AnimationLockTime.json index e7d1a3b5b..0d1a7d235 100644 --- a/Resources/AnimationLockTime.json +++ b/Resources/AnimationLockTime.json @@ -140,8 +140,8 @@ "3596": 0.1, "3598": 0.1, "3599": 0.6, - "3600": 0.1, - "3601": 0.1, + "3600": 0.6, + "3601": 0.6, "3603": 0.6, "3606": 0.6, "3608": 0.6, @@ -204,7 +204,7 @@ "7433": 0.6, "7436": 0.6, "7439": 0.6, - "7442": 0.1, + "7442": 0.6, "7443": 0.6, "7447": 0.1, "7477": 0.6, diff --git a/RotationSolver.Basic/Data/IconSet.cs b/RotationSolver.Basic/Data/IconSet.cs index c971aba96..d68516525 100644 --- a/RotationSolver.Basic/Data/IconSet.cs +++ b/RotationSolver.Basic/Data/IconSet.cs @@ -74,6 +74,18 @@ public enum IconType : byte /// public static class IconSet { + /// + /// Drat Texture. + /// + /// + /// + public static void DrawTexture(this ITexture text, Vector2 size) + { + var texture = text.GetTexture(); + if (texture == null) return; + ImGui.Image(texture.ImGuiHandle, size); + } + /// /// Get Texture form texture. /// diff --git a/RotationSolver/Localization/Localization.json b/RotationSolver/Localization/Localization.json index bdc358ec1..347533f00 100644 --- a/RotationSolver/Localization/Localization.json +++ b/RotationSolver/Localization/Localization.json @@ -32,7 +32,7 @@ "ConfigWindow_HelpItem_Speed": "Open a window to speed up.", "ConfigWindow_HelpItem_EndSpecial": "To end this special duration before the set time.", "ConfigWindow_Helper_SwitchRotation": "Click to switch authors", - "ConfigWindow_Helper_GameVersion": "Game Version", + "ConfigWindow_Helper_GameVersion": "Game", "ConfigWindow_Helper_OpenSource": "Open the source code URL", "ConfigWindow_Helper_RunCommand": "Click to execute the command", "ConfigWindow_Helper_CopyCommand": "Right-click to copy the command", diff --git a/RotationSolver/Localization/Strings.cs b/RotationSolver/Localization/Strings.cs index bc5095298..dacab1eae 100644 --- a/RotationSolver/Localization/Strings.cs +++ b/RotationSolver/Localization/Strings.cs @@ -76,7 +76,7 @@ internal partial class Strings public string ConfigWindow_HelpItem_EndSpecial { get; set; } = "To end this special duration before the set time."; public string ConfigWindow_Helper_SwitchRotation { get; set; } = "Click to switch authors"; - public string ConfigWindow_Helper_GameVersion { get; set; } = "Game Version"; + public string ConfigWindow_Helper_GameVersion { get; set; } = "Game"; public string ConfigWindow_Helper_OpenSource { get; set; } = "Open the source code URL"; public string ConfigWindow_Helper_RunCommand { get; set; } = "Click to execute the command"; public string ConfigWindow_Helper_CopyCommand { get; set; } = "Right-click to copy the command"; diff --git a/RotationSolver/UI/ImguiTooltips.cs b/RotationSolver/UI/ImguiTooltips.cs index 1c13dfec3..2fdc78364 100644 --- a/RotationSolver/UI/ImguiTooltips.cs +++ b/RotationSolver/UI/ImguiTooltips.cs @@ -15,6 +15,12 @@ internal static class ImguiTooltips const string TOOLTIP_ID = "RotationSolver Tooltips"; + public static void HoveredTooltip(string text) + { + if (!ImGui.IsItemHovered()) return; + ShowTooltip(text); + } + public static void ShowTooltip(string text) { if(string.IsNullOrEmpty(text)) return; diff --git a/RotationSolver/UI/RotationConfigWindowNew.cs b/RotationSolver/UI/RotationConfigWindowNew.cs index 1d0f3e2f6..e2148dc1b 100644 --- a/RotationSolver/UI/RotationConfigWindowNew.cs +++ b/RotationSolver/UI/RotationConfigWindowNew.cs @@ -1,4 +1,8 @@ using Dalamud.Interface.Windowing; +using ECommons.ExcelServices; +using ECommons.GameHelpers; +using RotationSolver.Helpers; +using RotationSolver.Localization; using RotationSolver.Updaters; namespace RotationSolver.UI; @@ -6,7 +10,6 @@ namespace RotationSolver.UI; public class RotationConfigWindowNew : Window { private static float _scale => ImGuiHelpers.GlobalScale; - private static float _sideBarWidth => 100; public RotationConfigWindowNew() : base(nameof(RotationConfigWindowNew), 0, false) { @@ -26,12 +29,125 @@ public override void Draw() private void DrawSideBar() { - //var rotations = RotationUpdater.CustomRotations + if (ImGui.BeginChild("Rotation Solver Side bar", Vector2.Zero)) + { + var wholeWidth = ImGui.GetWindowSize().X; + + DrawHeader(wholeWidth); + + ImGui.Separator(); + + ImGui.EndChild(); + } + } + + private void DrawHeader(float wholeWidth) + { + var rotations = RotationUpdater.CustomRotations.FirstOrDefault(i => i.ClassJobIds.Contains((Job)Player.Object.ClassJob.Id))?.Rotations ?? Array.Empty(); + var rotation = RotationUpdater.RightNowRotation; + + var size = MathF.Max(_scale * MathF.Min(wholeWidth, _scale * 150), 100); + + var logo = IconSet.GetTexture("https://raw.githubusercontent.com/ArchiDog1998/RotationSolver/main/docs/RotationSolverIcon_128.png"); + + + if (logo != null) + { + DrawItemMiddle(() => + { + if (SilenceImageButton(logo.ImGuiHandle, Vector2.One * size)) + { + + } + }, wholeWidth, size); + + ImGui.Spacing(); + } + + var iconSize = _scale * 50; + var comboSize = ImGui.CalcTextSize(rotation.RotationName).X + _scale * 30; + size = comboSize + iconSize + ImGui.GetStyle().ItemSpacing.X; + + DrawItemMiddle(() => + { + var rotationIcon = rotation.GetTexture(); + if (rotationIcon != null && SilenceImageButton(rotationIcon.ImGuiHandle, Vector2.One * iconSize)) + { + + } + + ImGui.SameLine(); + + ImGui.BeginGroup(); + ImGui.SetNextItemWidth(comboSize); + ImGui.PushStyleColor(ImGuiCol.Text, rotation.GetColor()); + var isStartCombo = ImGui.BeginCombo("##RotationName:" + rotation.Name, rotation.RotationName); + ImGui.PopStyleColor(); + + if (isStartCombo) + { + foreach (var r in rotations) + { + ImGui.PushStyleColor(ImGuiCol.Text, r.GetColor()); + if (ImGui.Selectable(r.RotationName)) + { + Service.Config.RotationChoices[rotation.ClassJob.RowId] = r.GetType().FullName; + Service.Config.Save(); + } + if (ImGui.IsItemHovered()) + { + //showToolTip?.Invoke(r); + } + ImGui.PopStyleColor(); + } + ImGui.EndCombo(); + } + + var warning = !rotation.IsValid ? string.Format(LocalizationManager.RightLang.ConfigWindow_Rotation_InvalidRotation, + rotation.GetType().Assembly.GetInfo().Author) + : rotation.IsBeta() ? LocalizationManager.RightLang.ConfigWindow_Rotation_BetaRotation : string.Empty; + + warning = string.IsNullOrEmpty(warning) ? LocalizationManager.RightLang.ConfigWindow_Helper_SwitchRotation + : warning + "\n \n" + LocalizationManager.RightLang.ConfigWindow_Helper_SwitchRotation; + ImguiTooltips.HoveredTooltip(warning); + + ImGui.TextDisabled(" - " + LocalizationManager.RightLang.ConfigWindow_Helper_GameVersion + ": "); + ImGui.SameLine(); + ImGui.Text(rotation.GameVersion); + ImGui.EndGroup(); + + }, wholeWidth, size, true); + + } + + private static bool SilenceImageButton(IntPtr handle, Vector2 size) + { + ImGui.PushStyleColor(ImGuiCol.ButtonActive, 0); + ImGui.PushStyleColor(ImGuiCol.Button, 0); + + var padding = ImGui.GetStyle().FramePadding; + ImGui.GetStyle().FramePadding = Vector2.Zero; + + var result = ImGui.ImageButton(handle, size); + + ImGui.GetStyle().FramePadding = padding; + ImGui.PopStyleColor(2); + + return result; + } + + private static void DrawItemMiddle(Action drawAction, float wholeWidth, float width, bool leftAlign = false) + { + if (drawAction == null) return; + var distance = (wholeWidth - width) / 2; + if (leftAlign) distance = MathF.Max(distance, 0); + ImGui.SetCursorPosX(distance); + drawAction(); } private void DrawBody() { - if (ImGui.BeginChild("Action List", new Vector2(0f, -1f), true)) + if (ImGui.BeginChild("Rotation Solver Body")) { ImGui.EndChild(); } diff --git a/RotationSolver/Updaters/SocialUpdater.cs b/RotationSolver/Updaters/SocialUpdater.cs index b2c374e23..ef1665466 100644 --- a/RotationSolver/Updaters/SocialUpdater.cs +++ b/RotationSolver/Updaters/SocialUpdater.cs @@ -151,7 +151,7 @@ internal static async void UpdateSocial() #if DEBUG Svc.Chat.Print("Macro now."); #endif - Service.Config.DutyStart.AddMacro(); + //Service.Config.DutyStart.AddMacro(); await Task.Delay(new Random().Next(1000, 1500)); SayHelloToAuthor(); }