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

Commit

Permalink
fix: add tooltip for some button.
Browse files Browse the repository at this point in the history
  • Loading branch information
ArchiDog1998 committed May 1, 2023
1 parent 9c3a60f commit 61a3cb7
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions RotationSolver/UI/ImGuiHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,26 @@ public static void DrawEnableTexture<T>(this T texture, bool isSelected, Action
ImGui.PopStyleVar();
}

public static bool IconButton(FontAwesomeIcon icon, string name)
public static bool IconButton(FontAwesomeIcon icon, string name, string description = null)
{
ImGui.PushFont(UiBuilder.IconFont);
var result = ImGui.Button($"{icon.ToIconString()}##{name}");
ImGui.PopFont();
HoveredString(description ?? icon switch
{
FontAwesomeIcon.Coffee => "Donate",
FontAwesomeIcon.History => "ChangeLog",
FontAwesomeIcon.Book => "Wiki / Help",
FontAwesomeIcon.HandPaper => "Support",
FontAwesomeIcon.Code => "Source Code",
FontAwesomeIcon.ArrowUp => "Move Up",
FontAwesomeIcon.ArrowDown => "Move Down",
FontAwesomeIcon.Ban => "Delete",
FontAwesomeIcon.Plus => "Add",
FontAwesomeIcon.Download => "Download",
FontAwesomeIcon.FileDownload => "Local load",
_ => null,
});
return result;
}

Expand Down Expand Up @@ -484,15 +499,15 @@ public unsafe static void Display(this ICustomRotation rotation, ICustomRotation
{
ImGui.SameLine();
Spacing();
if (IconButton(FontAwesomeIcon.Undo, $"#{rotation.GetHashCode()}Undo"))
if (IconButton(FontAwesomeIcon.Undo, $"#{rotation.GetHashCode()}Undo",
LocalizationManager.RightLang.ConfigWindow_Rotation_ResetToDefault))
{
if (Service.Config.RotationsConfigurations.TryGetValue(rotation.Job.RowId, out var jobDict)
&& jobDict.ContainsKey(rotation.GetType().FullName))
{
jobDict.Remove(rotation.GetType().FullName);
}
}
HoveredString(LocalizationManager.RightLang.ConfigWindow_Rotation_ResetToDefault);
}

var link = rotation.GetType().GetCustomAttribute<SourceCodeAttribute>();
Expand Down

0 comments on commit 61a3cb7

Please sign in to comment.