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

Commit

Permalink
fix: add unit description for all units!
Browse files Browse the repository at this point in the history
  • Loading branch information
ArchiDog1998 committed Nov 7, 2023
1 parent 56b6968 commit 540a836
Show file tree
Hide file tree
Showing 8 changed files with 91 additions and 17 deletions.
2 changes: 1 addition & 1 deletion ECommons
1 change: 1 addition & 0 deletions Resources/RotationSolverRecord.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"ClickingCount": 56901,
"SayingHelloCount": 0,
"SaidUsers": [
"Ig4lHXUohMZNIeheUtAtRg=="
]
Expand Down
7 changes: 4 additions & 3 deletions RotationSolver.Basic/Configuration/Configs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ public enum PluginConfigBool : byte
public enum PluginConfigFloat : byte
{
[Default(30f, 0f, 600f), Unit(ConfigUnitType.Seconds)] AutoOffAfterCombatTime,
[Default(3f, 0f, 8f), Unit(ConfigUnitType.Ratio)] DrawingHeight,
[Default(3f, 0f, 8f), Unit(ConfigUnitType.Yalms)] DrawingHeight,
[Default(0.2f, 0.005f, 0.05f), Unit(ConfigUnitType.Yalms)] SampleLength,
[Default(45f, 0f, 90f), Unit(ConfigUnitType.Degree)] AngleOfVisionCone,

Expand Down Expand Up @@ -449,10 +449,10 @@ public enum PluginConfigFloat : byte

[Default(8f, 0f, 30f), Unit(ConfigUnitType.Seconds)] AutoHealTimeToKill,
[Default(0.5f, 0f, 10f), Unit(ConfigUnitType.Pixels)] HostileIconHeight,
[Default(1f, 0.1f, 10f), Unit(ConfigUnitType.Pixels)] HostileIconSize,
[Default(1f, 0.1f, 10f), Unit(ConfigUnitType.Ratio)] HostileIconSize,

[Default(1f, 0f, 3f), Unit(ConfigUnitType.Pixels)] StateIconHeight,
[Default(1f, 0.2f, 10f), Unit(ConfigUnitType.Pixels)] StateIconSize,
[Default(1f, 0.2f, 10f), Unit(ConfigUnitType.Ratio)] StateIconSize,

[Default(0.02f, 0f, 1f), Unit(ConfigUnitType.Seconds)] MinUpdatingTime,
[Default(0.15f), Unit(ConfigUnitType.Ratio)] HealthForGuard,
Expand Down Expand Up @@ -490,6 +490,7 @@ public DefaultAttribute(object @default, object min = null, object max = null)

public enum ConfigUnitType : byte
{
None,
Seconds,
Degree,
Yalms,
Expand Down
9 changes: 8 additions & 1 deletion RotationSolver/Localization/Localization.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
"ConfigWindow_Param_MovingTargetColor": "Prompt box color of moving target",
"ConfigWindow_Param_TargetColor": "Target color",
"ConfigWindow_Param_SubTargetColor": "Sub-target color",
"ConfigWindow_Param_DrawingHeight": "The height of the next ability that will be used icon.",
"ConfigWindow_Param_DrawingHeight": "The height of the drawing things.",
"ConfigWindow_Param_SampleLength": "Drawing smoothness.",
"ConfigWindow_Param_KeyBoardNoise": "Simulate the effect of pressing abilities",
"ConfigWindow_Param_KeyBoardNoiseTimes": "Effect times",
Expand Down Expand Up @@ -135,6 +135,7 @@
"ConfigWindow_Param_HealWhenNothingTodoBelow": "When their minimum HP%% is lower than this.",
"ConfigWindow_Param_HealWhenNothingTodoDelay": "The delay of this type of healing.",
"ConfigWindow_Param_HealthForDyingTank": "Set the HP%% for tank to use invulnerability",
"ConfigWindow_Param_HealthForGuard": "Set the HP%% for using Guard.",
"ConfigWindow_Param_MeleeRangeOffset": "Melee Range action using offset",
"ConfigWindow_Param_RightNowTargetToHostileType": "Engage settings",
"ConfigWindow_Param_TargetToHostileType1": "All targets that are in range for any abilities",
Expand Down Expand Up @@ -275,6 +276,11 @@
"TargetConditionType_ObjectEffect": "Object Effect",
"TargetConditionType_Vfx": "Vfx",
"TargetConditionType_IsNull": "Is Null",
"ConfigUnitType_Seconds": "Time Unit, in seconds.",
"ConfigUnitType_Degree": "Angle Unit, in degree.",
"ConfigUnitType_Pixels": "Display Unit, in piexels.",
"ConfigUnitType_Yalms": "Distance Unit, in yalms.",
"ConfigUnitType_Ratio": "Ratio Unit, in percents.",
"TerritoryConditionType_TerritoryContentType": "Territory Content Type",
"TerritoryConditionType_TerritoryName": "Territory Name",
"TerritoryConditionType_DutyName": "Duty Name",
Expand Down Expand Up @@ -530,6 +536,7 @@
"ConfigWindow_Basic_ClickingDuration": "The clicking duration, RS will try to click at this moment.",
"ConfigWindow_Basic_WeaponDelay": "This is the clipping time.\nGCD is over. However, RS forgets to click the next action.",
"ConfigWindow_About_ClickingCount": "Rotation Solver helped you by clicking actions {0:N0} times.",
"ConfigWindow_About_SayHelloCount": "You have sayed hello to other users {0:N0} times!",
"ConfigWindow_Auto_AutoHealTimeToKill": "Stop healing when time to kill is lower then...",
"ConfigWindow_UI_ShowHostiles": "Show the hostile target icon",
"ConfigWindow_UI_HostileIconHeight": "Hostile Icon height from position",
Expand Down
11 changes: 10 additions & 1 deletion RotationSolver/Localization/Strings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ internal class Strings
public string ConfigWindow_Param_MovingTargetColor { get; set; } = "Prompt box color of moving target";
public string ConfigWindow_Param_TargetColor { get; set; } = "Target color";
public string ConfigWindow_Param_SubTargetColor { get; set; } = "Sub-target color";
public string ConfigWindow_Param_DrawingHeight { get; set; } = "The height of the next ability that will be used icon.";
public string ConfigWindow_Param_DrawingHeight { get; set; } = "The height of the drawing things.";
public string ConfigWindow_Param_SampleLength { get; set; } = "Drawing smoothness.";
public string ConfigWindow_Param_KeyBoardNoise { get; set; } = "Simulate the effect of pressing abilities";
public string ConfigWindow_Param_KeyBoardNoiseTimes { get; set; } = "Effect times";
Expand Down Expand Up @@ -395,6 +395,15 @@ internal class Strings

#endregion

#region COnfigUnitType
public string ConfigUnitType_Seconds { get; set; } = "Time Unit, in seconds.";
public string ConfigUnitType_Degree { get; set; } = "Angle Unit, in degree.";
public string ConfigUnitType_Pixels { get; set; } = "Display Unit, in piexels.";
public string ConfigUnitType_Yalms { get; set; } = "Distance Unit, in yalms.";
public string ConfigUnitType_Ratio { get; set; } = "Ratio Unit, in percents.";

#endregion

#region TerritoryConditionType
public string TerritoryConditionType_TerritoryContentType { get; set; } = "Territory Content Type";
public string TerritoryConditionType_TerritoryName { get; set; } = "Territory Name";
Expand Down
14 changes: 11 additions & 3 deletions RotationSolver/UI/SearchableConfigs/DragFloatRangeSearch.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Dalamud.Utility;
using ECommons.Configuration;
using ECommons.ExcelServices;
using RotationSolver.Basic.Configuration;
using RotationSolver.Localization;
Expand All @@ -19,7 +20,8 @@ internal class DragFloatRangeSearchJob : DragFloatRangeSearch
protected override bool IsJob => true;

public DragFloatRangeSearchJob(JobConfigFloat configMin, JobConfigFloat configMax, float speed)
: base((float)(configMin.GetAttribute<DefaultAttribute>()?.Min ?? 0f), (float)(configMin.GetAttribute<DefaultAttribute>()?.Max ?? 1f), speed)
: base((float)(configMin.GetAttribute<DefaultAttribute>()?.Min ?? 0f), (float)(configMin.GetAttribute<DefaultAttribute>()?.Max ?? 1f), speed,
configMin.GetAttribute<UnitAttribute>()?.UnitType ?? ConfigUnitType.None)
{
_configMin = configMin;
_configMax = configMax;
Expand Down Expand Up @@ -66,7 +68,7 @@ internal class DragFloatRangeSearchPlugin : DragFloatRangeSearch


public DragFloatRangeSearchPlugin(PluginConfigFloat configMin, PluginConfigFloat configMax, float speed, uint color = 0)
: base((float)(configMin.GetAttribute<DefaultAttribute>()?.Min ?? 0f), (float)(configMin.GetAttribute<DefaultAttribute>()?.Max ?? 1f), speed)
: base((float)(configMin.GetAttribute<DefaultAttribute>()?.Min ?? 0f), (float)(configMin.GetAttribute<DefaultAttribute>()?.Max ?? 1f), speed, configMin.GetAttribute<UnitAttribute>()?.UnitType ?? ConfigUnitType.None)
{
_configMin = configMin;
_configMax = configMax;
Expand Down Expand Up @@ -105,13 +107,15 @@ internal abstract class DragFloatRangeSearch : Searchable
public float Min { get; init; }
public float Max { get; init; }
public float Speed { get; init; }
public ConfigUnitType Unit { get; init; }

public sealed override string Command => "";

public DragFloatRangeSearch(float min, float max, float speed)
public DragFloatRangeSearch(float min, float max, float speed, ConfigUnitType unit)
{
Min = min; Max = max;
Speed = speed;
Unit = unit;
}

protected abstract float GetMinValue(Job job);
Expand All @@ -123,13 +127,17 @@ protected override void DrawMain(Job job)
var minValue = GetMinValue(job);
var maxValue = GetMaxValue(job);
ImGui.SetNextItemWidth(Scale * DRAG_WIDTH);

if (ImGui.DragFloatRange2($"##Config_{ID}{GetHashCode()}", ref minValue, ref maxValue, Speed, Min, Max))
{
SetMinValue(job, Math.Min(minValue, maxValue));
SetMaxValue(job, Math.Max(minValue, maxValue));
}

if (ImGui.IsItemHovered()) ShowTooltip(job);

DrawUnitType(Unit);

if (IsJob) DrawJobIcon();
ImGui.SameLine();
if (Color != 0) ImGui.PushStyleColor(ImGuiCol.Text, Color);
Expand Down
33 changes: 26 additions & 7 deletions RotationSolver/UI/SearchableConfigs/DragFloatSearch.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Dalamud.Utility;
using Dalamud.Interface.Colors;
using Dalamud.Utility;
using ECommons.ExcelServices;
using RotationSolver.Basic.Configuration;
using RotationSolver.Localization;
Expand All @@ -21,7 +22,8 @@ internal class DragFloatSearchJob : DragFloatSearch
protected override bool IsJob => true;

public DragFloatSearchJob(JobConfigFloat config, float speed)
: base((float)(config.GetAttribute<DefaultAttribute>()?.Min ?? 0f), (float)(config.GetAttribute<DefaultAttribute>()?.Max ?? 1f), speed)
: base((float)(config.GetAttribute<DefaultAttribute>()?.Min ?? 0f), (float)(config.GetAttribute<DefaultAttribute>()?.Max ?? 1f), speed,
config.GetAttribute<UnitAttribute>()?.UnitType ?? ConfigUnitType.None)
{
_config = config;
}
Expand Down Expand Up @@ -58,7 +60,8 @@ internal class DragFloatSearchPlugin : DragFloatSearch
public override string Command => _config.ToCommand();

public DragFloatSearchPlugin(PluginConfigFloat config, float speed, uint color = 0)
: base((float)(config.GetAttribute<DefaultAttribute>()?.Min ?? 0f), (float)(config.GetAttribute<DefaultAttribute>()?.Max ?? 1f), speed)
: base((float)(config.GetAttribute<DefaultAttribute>()?.Min ?? 0f), (float)(config.GetAttribute<DefaultAttribute>()?.Max ?? 1f), speed,
config.GetAttribute<UnitAttribute>()?.UnitType ?? ConfigUnitType.None)
{
_config = config;
Color = color;
Expand Down Expand Up @@ -86,25 +89,41 @@ internal abstract class DragFloatSearch : Searchable
public float Min { get; init; }
public float Max { get; init; }
public float Speed { get; init; }
public ConfigUnitType Unit { get; init; }

public DragFloatSearch(float min, float max, float speed)
public DragFloatSearch(float min, float max, float speed, ConfigUnitType unit)
{
Min = min; Max = max;
Speed = speed;
Unit = unit;
}
protected abstract float GetValue(Job job);
protected abstract void SetValue(Job job, float value);
protected override void DrawMain(Job job)
{
var value = GetValue(job);
ImGui.SetNextItemWidth(Scale * DRAG_WIDTH);
if (ImGui.DragFloat($"##Config_{ID}{GetHashCode()}", ref value, Speed, Min, Max))
if(Unit == ConfigUnitType.Ratio)
{
SetValue(job, value);
var v = (int)value * 100;
if (ImGui.SliderInt($"##Config_{ID}{GetHashCode()}", ref v, (int)(Min * 100), (int)(Max * 100)))
{
SetValue(job, v / 100f);
}
}
else
{
if (ImGui.DragFloat($"##Config_{ID}{GetHashCode()}", ref value, Speed, Min, Max))
{
SetValue(job, value);
}
}

if (ImGui.IsItemHovered()) ShowTooltip(job);

if (IsJob) DrawJobIcon();
DrawUnitType(Unit);

if (IsJob) DrawJobIcon();

ImGui.SameLine();

Expand Down
31 changes: 30 additions & 1 deletion RotationSolver/UI/SearchableConfigs/Searchable.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
using Dalamud.Interface.Utility;
using Dalamud.Interface.Colors;
using Dalamud.Interface.Utility;
using ECommons.DalamudServices;
using ECommons.ExcelServices;
using Lumina.Excel.GeneratedSheets;
using RotationSolver.Basic.Configuration;
using RotationSolver.Localization;
using RotationSolver.UI.SearchableSettings;

Expand Down Expand Up @@ -230,4 +232,31 @@ protected static void DrawJobIcon()
ImguiTooltips.HoveredTooltip(LocalizationManager.RightLang.ConfigWindow_Configs_JobConfigTip);
}
}

protected static void DrawUnitType(ConfigUnitType unit)
{
var unitName = unit switch
{
ConfigUnitType.Seconds => "(s)",
ConfigUnitType.Degree => "(°)",
ConfigUnitType.Pixels => "(p)",
ConfigUnitType.Yalms => "(y)",
ConfigUnitType.Ratio => "(%%)",
_ => string.Empty,
};

ImGui.SameLine();
ImGui.TextColored(ImGuiColors.DalamudViolet, unitName);

var desc = unit switch
{
ConfigUnitType.Seconds => LocalizationManager.RightLang.ConfigUnitType_Seconds,
ConfigUnitType.Degree => LocalizationManager.RightLang.ConfigUnitType_Degree,
ConfigUnitType.Pixels => LocalizationManager.RightLang.ConfigUnitType_Pixels,
ConfigUnitType.Yalms => LocalizationManager.RightLang.ConfigUnitType_Yalms,
ConfigUnitType.Ratio => LocalizationManager.RightLang.ConfigUnitType_Ratio,
_ => string.Empty,
};
ImguiTooltips.HoveredTooltip(desc);
}
}

0 comments on commit 540a836

Please sign in to comment.