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

Commit

Permalink
fix: make the cooldown number font size could be changed.
Browse files Browse the repository at this point in the history
  • Loading branch information
ArchiDog1998 committed Apr 5, 2023
1 parent 99255fe commit ef6a377
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 20 deletions.
1 change: 1 addition & 0 deletions RotationSolver.Basic/Configuration/PluginConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ public class PluginConfiguration : IPluginConfiguration
public bool ShowGCDCooldown = false;
public bool UseOriginalCooldown = true;
public int CooldownActionOneLine = 15;
public float CooldownFontSize = 24;

public Vector4 ControlWindowLockBg = new Vector4(0, 0, 0, 0.6f);
public Vector4 ControlWindowUnlockBg = new Vector4(0, 0, 0, 0.9f);
Expand Down
1 change: 1 addition & 0 deletions RotationSolver/Localization/Localization.json
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@
"ConfigWindow_Control_ShowGCDCooldown": "Show GCD' Cooldown",
"ConfigWindow_Control_UseOriginalCooldown": "Show Original Cooldown",
"ConfigWindow_Control_CooldownActionOneLine": "The count of cooldown actions in one line.",
"ConfigWindow_Control_CooldownFontSize": "Change the cooldown font size.",
"ConfigWindow_Control_BackgroundColor": "Control Window's Background",
"ConfigWindow_Control_InfoWindowBg": "Info Window's Background",
"ConfigWindow_Control_ControlWindowGCDSize": "GCD icon size",
Expand Down
1 change: 1 addition & 0 deletions RotationSolver/Localization/Strings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ internal partial class Strings
public string ConfigWindow_Control_ShowGCDCooldown { get; set; } = "Show GCD' Cooldown";
public string ConfigWindow_Control_UseOriginalCooldown { get; set; } = "Show Original Cooldown";
public string ConfigWindow_Control_CooldownActionOneLine { get; set; } = "The count of cooldown actions in one line.";
public string ConfigWindow_Control_CooldownFontSize { get; set; } = "Change the cooldown font size.";
public string ConfigWindow_Control_BackgroundColor { get; set; } = "Control Window's Background";
public string ConfigWindow_Control_InfoWindowBg { get; set; } = "Info Window's Background";
public string ConfigWindow_Control_ControlWindowGCDSize { get; set; } = "GCD icon size";
Expand Down
3 changes: 3 additions & 0 deletions RotationSolver/UI/CooldownWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,14 @@ private static void DrawActionCooldown(IAction act)

ImGui.GetWindowDrawList().AddLine(startPos, startPos + new Vector2(0, size.Y), black);
}

ImGui.PushFont(ImGuiHelper.GetFont(Service.Config.CooldownFontSize));
string time = recast == 0 ? "0" : ((int)(recast - elapsed % recast) + 1).ToString();
var strSize = ImGui.CalcTextSize(time);
var fontPos = new Vector2(pos.X + size.X / 2 - strSize.X / 2, pos.Y + size.Y / 2 - strSize.Y / 2) + winPos;

TextShade(fontPos, time);
ImGui.PopFont();
}

if (act.EnoughLevel && act is IBaseAction bAct && bAct.MaxCharges > 1)
Expand Down
9 changes: 9 additions & 0 deletions RotationSolver/UI/ImGuiHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -791,4 +791,13 @@ public static void Display(this RotationDescAttribute attr, ICustomRotation rota
}
ImGui.Unindent(ATTR_INDENT);
}

public static ImFontPtr GetFont(float size)
{
var style = new Dalamud.Interface.GameFonts.GameFontStyle(Dalamud.Interface.GameFonts.GameFontStyle.GetRecommendedFamilyAndSize(Dalamud.Interface.GameFonts.GameFontFamily.Axis, size));
var font = Service.Interface.UiBuilder.GetGameFontHandle(style).ImFont;
font.Scale = size / style.BaseSizePt;

return font;
}
}
43 changes: 23 additions & 20 deletions RotationSolver/UI/RotationConfigWindow_Control.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ private void DrawControlTab()
ref Service.Config.UseOriginalCooldown, Service.Default.UseOriginalCooldown);

DrawIntNumber(LocalizationManager.RightLang.ConfigWindow_Control_CooldownActionOneLine, ref Service.Config.CooldownActionOneLine, Service.Default.CooldownActionOneLine, min: 1, max: 30);

DrawFloatNumber(LocalizationManager.RightLang.ConfigWindow_Control_CooldownFontSize, ref Service.Config.CooldownFontSize, Service.Default.CooldownFontSize, min: 9.6f, max: 96);
}
}

Expand All @@ -57,30 +59,31 @@ private void DrawControlTab()
DrawCheckBox(LocalizationManager.RightLang.ConfigWindow_Control_ShowControlWindow,
ref Service.Config.ShowControlWindow, Service.Default.ShowControlWindow);

if (!Service.Config.ShowControlWindow) return;

DrawCheckBox(LocalizationManager.RightLang.ConfigWindow_Control_IsInfoWindowNoInputs,
ref Service.Config.IsControlWindowLock, Service.Default.IsControlWindowLock);

if (Service.Config.IsControlWindowLock)
if (Service.Config.ShowControlWindow)
{
DrawColor4(LocalizationManager.RightLang.ConfigWindow_Control_BackgroundColor,
ref Service.Config.ControlWindowLockBg, Service.Default.ControlWindowLockBg);
}
else
{
DrawColor4(LocalizationManager.RightLang.ConfigWindow_Control_BackgroundColor,
ref Service.Config.ControlWindowUnlockBg, Service.Default.ControlWindowUnlockBg);
}
DrawCheckBox(LocalizationManager.RightLang.ConfigWindow_Control_IsInfoWindowNoInputs,
ref Service.Config.IsControlWindowLock, Service.Default.IsControlWindowLock);

DrawFloatNumber(LocalizationManager.RightLang.ConfigWindow_Control_ControlWindowGCDSize,
ref Service.Config.ControlWindowGCDSize, Service.Default.ControlWindowGCDSize, speed: 0.2f , max: 80);
if (Service.Config.IsControlWindowLock)
{
DrawColor4(LocalizationManager.RightLang.ConfigWindow_Control_BackgroundColor,
ref Service.Config.ControlWindowLockBg, Service.Default.ControlWindowLockBg);
}
else
{
DrawColor4(LocalizationManager.RightLang.ConfigWindow_Control_BackgroundColor,
ref Service.Config.ControlWindowUnlockBg, Service.Default.ControlWindowUnlockBg);
}

DrawFloatNumber(LocalizationManager.RightLang.ConfigWindow_Control_ControlWindowGCDSize,
ref Service.Config.ControlWindowGCDSize, Service.Default.ControlWindowGCDSize, speed: 0.2f, max: 80);

DrawFloatNumber(LocalizationManager.RightLang.ConfigWindow_Control_ControlWindow0GCDSize,
ref Service.Config.ControlWindow0GCDSize, Service.Default.ControlWindow0GCDSize, speed: 0.2f, max: 80);
DrawFloatNumber(LocalizationManager.RightLang.ConfigWindow_Control_ControlWindow0GCDSize,
ref Service.Config.ControlWindow0GCDSize, Service.Default.ControlWindow0GCDSize, speed: 0.2f, max: 80);

DrawFloatNumber(LocalizationManager.RightLang.ConfigWindow_Control_ControlWindowNextSizeRatio,
ref Service.Config.ControlWindowNextSizeRatio, Service.Default.ControlWindowNextSizeRatio);
DrawFloatNumber(LocalizationManager.RightLang.ConfigWindow_Control_ControlWindowNextSizeRatio,
ref Service.Config.ControlWindowNextSizeRatio, Service.Default.ControlWindowNextSizeRatio);
}
}

private static void DrawColor4(string name, ref Vector4 value, Vector4 @default, string description = "")
Expand Down
1 change: 1 addition & 0 deletions RotationSolver/UI/RotationConfigWindow_Major.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Dalamud.Interface.Windowing;
using ImGuiNET;
using RotationSolver.Localization;

namespace RotationSolver.UI;
Expand Down

0 comments on commit ef6a377

Please sign in to comment.