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

Commit

Permalink
fix: ui new ui header.
Browse files Browse the repository at this point in the history
  • Loading branch information
ArchiDog1998 committed Jul 29, 2023
1 parent 80f2af4 commit 6958894
Show file tree
Hide file tree
Showing 7 changed files with 143 additions and 9 deletions.
6 changes: 3 additions & 3 deletions Resources/AnimationLockTime.json
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
12 changes: 12 additions & 0 deletions RotationSolver.Basic/Data/IconSet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,18 @@ public enum IconType : byte
/// </summary>
public static class IconSet
{
/// <summary>
/// Drat Texture.
/// </summary>
/// <param name="text"></param>
/// <param name="size"></param>
public static void DrawTexture(this ITexture text, Vector2 size)
{
var texture = text.GetTexture();
if (texture == null) return;
ImGui.Image(texture.ImGuiHandle, size);
}

/// <summary>
/// Get Texture form texture.
/// </summary>
Expand Down
2 changes: 1 addition & 1 deletion RotationSolver/Localization/Localization.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion RotationSolver/Localization/Strings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
6 changes: 6 additions & 0 deletions RotationSolver/UI/ImguiTooltips.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
122 changes: 119 additions & 3 deletions RotationSolver/UI/RotationConfigWindowNew.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
using Dalamud.Interface.Windowing;
using ECommons.ExcelServices;
using ECommons.GameHelpers;
using RotationSolver.Helpers;
using RotationSolver.Localization;
using RotationSolver.Updaters;

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)
{
Expand All @@ -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<ICustomRotation>();
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();
}
Expand Down
2 changes: 1 addition & 1 deletion RotationSolver/Updaters/SocialUpdater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down

0 comments on commit 6958894

Please sign in to comment.