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

Commit

Permalink
fix: change the style of description.
Browse files Browse the repository at this point in the history
  • Loading branch information
ArchiDog1998 committed Feb 20, 2023
1 parent 7e96cd2 commit 0ea0c26
Show file tree
Hide file tree
Showing 13 changed files with 145 additions and 49 deletions.
59 changes: 42 additions & 17 deletions RotationSolver/Attributes/RotationDescAttribute.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
using ImGuiNET;
using Lumina.Excel.GeneratedSheets;
using RotationSolver.Actions;
using RotationSolver.Actions.BaseAction;
using RotationSolver.Data;
using RotationSolver.Helpers;
using RotationSolver.Localization;
using RotationSolver.Rotations.CustomRotation;
using System;
Expand Down Expand Up @@ -39,37 +41,60 @@ private RotationDescAttribute()

}

public void Display(ICustomRotation rotation)
public bool Display(ICustomRotation rotation)
{
ImGui.Columns(2);
ImGui.SetColumnWidth(0, 100);
ImGui.Text(DescType.ToName());
var acts = rotation.AllActions;

var allActions = Actions.Select(i => acts.FirstOrDefault(a => a.ID == (uint)i))
.Where(i => i != null);

bool hasDesc = !string.IsNullOrEmpty(Description);

if (!hasDesc && !allActions.Any()) return false;

ImGui.Columns(2);
ImGui.SetColumnWidth(0, 150);
ImGui.Text(DescType.ToName());

ImGui.NextColumn();

ImGui.TextWrapped(Description);
var acts = rotation.AllActions;
foreach (var item in Actions)
if (hasDesc)
{
var a = acts.FirstOrDefault(a => a.ID == (uint)item);
if (a == null) continue;
ImGui.Image(a.GetTexture().ImGuiHandle, new System.Numerics.Vector2(24, 24));
if (ImGui.IsItemHovered())
{
ImGui.SetTooltip(a.Name);
}
ImGui.SameLine();
ImGui.Text(Description);
ImGui.NewLine();
}

bool notStart = false;
foreach (var item in allActions)
{
if (item == null) continue;

if (notStart)
{
ImGui.SameLine();
ImGuiHelper.Spacing();
}

ImGui.Image(item.GetTexture().ImGuiHandle, new System.Numerics.Vector2(24, 24));
notStart = true;
}

ImGui.Columns();
ImGui.Columns(1);
return true;
}
public static IEnumerable<RotationDescAttribute[]> Merge(IEnumerable<RotationDescAttribute> rotationDescAttributes)
=> from r in rotationDescAttributes
where r is RotationDescAttribute
group r by r.DescType into gr
orderby gr.Key
select gr.ToArray();

public static RotationDescAttribute Merge(IEnumerable<RotationDescAttribute> rotationDescAttributes)
public static RotationDescAttribute MergeToOne(IEnumerable<RotationDescAttribute> rotationDescAttributes)
{
var result = new RotationDescAttribute();
foreach (var attr in rotationDescAttributes)
{
if(attr == null) continue;
if(!string.IsNullOrEmpty(attr.Description))
{
result.Description = attr.Description;
Expand Down
20 changes: 20 additions & 0 deletions RotationSolver/Data/VfxStruct.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using System.Numerics;
using System.Runtime.InteropServices;

#if DEBUG
namespace RotationSolver.Data;

[StructLayout(LayoutKind.Explicit)]
public unsafe struct VfxStruct
{
[FieldOffset(0x38)] public byte Flags;
[FieldOffset(0x50)] public Vector3 Position;
[FieldOffset(0x70)] public Vector3 Scale;

[FieldOffset(0x128)] public int ActorCaster;
[FieldOffset(0x130)] public int ActorTarget;

[FieldOffset(0x1B8)] public int StaticCaster;
[FieldOffset(0x1C0)] public int StaticTarget;
}
#endif
5 changes: 4 additions & 1 deletion RotationSolver/Helpers/ImguiHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,10 @@ public static void DrawEnableTexture<T>(this T texture, bool isSelected, Action
}
if (isSelected) ImGui.PopStyleColor();

showToolTip(desc);
if (ImGui.IsItemHovered())
{
showToolTip(desc);
}
}


Expand Down
12 changes: 8 additions & 4 deletions RotationSolver/Helpers/ReflectionHelper.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using RotationSolver.Localization;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Reflection;
Expand All @@ -22,16 +23,19 @@ where typeof(T).IsAssignableFrom(prop.PropertyType)
}

internal static MethodInfo[] GetStaticBoolMethodInfo(this Type type, Func<MethodInfo, bool> checks)
{
return type.GetAllMethodInfo().Where(m => checks(m) && m.ReturnType == typeof(bool) && m.IsStatic).ToArray();
}

internal static IEnumerable<MethodInfo> GetAllMethodInfo(this Type type)
{
if (type == null) return new MethodInfo[0];

var methods = from method in type.GetRuntimeMethods()
where method.IsStatic
&& !method.IsConstructor && method.ReturnType == typeof(bool)
&& checks(method)
where !method.IsConstructor
select method;

return methods.Union(type.BaseType.GetStaticBoolMethodInfo(checks)).ToArray();
return methods.Union(type.BaseType.GetAllMethodInfo());
}

internal static PropertyInfo GetPropertyInfo(this Type type, string name)
Expand Down
21 changes: 13 additions & 8 deletions RotationSolver/Localization/Localization.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"ConfigWindow_ActionItem_Description": "Modify the usage for each action.",
"ConfigWindow_HelpItem_Description": "In this window, you can see all Rotation Solver built-in commands for combat. ",
"Configwindow_HelpItem_AttackSmart": "Start attacking in smart mode(auto-targeting) when out of combat, otherwise switch the target according to the conditions.",
"Configwindow_HelpItem_AttackManual": "Start attacking in manual mode.",
"Configwindow_HelpItem_AttackManual": "Start attacking in manual mode. You need to choose the target manually.",
"Configwindow_HelpItem_AttackCancel": "Stop attacking. Remember to turn it off when not in use!",
"Configwindow_HelpItem_HealArea": "Open a window to use one or more AoE heal.",
"Configwindow_HelpItem_HealSingle": "Open a window to use one or more single heal.",
Expand Down Expand Up @@ -223,13 +223,18 @@
"TargetConditionType_StatusEnd": "Status End",
"TargetConditionType_StatusEndGCD": "Status End GCD",
"TargetConditionType_CastingAction": "Casting Action",
"DescType_Description": "Loop Description",
"DescType_BreakingAction": "Burst Skills",
"DescType_HealArea": "Range Healing",
"DescType_HealSingle": "Mono Healing",
"DescType_DefenseArea": "Range Defense",
"DescType_DefenseSingle": "Mono Defense",
"DescType_MoveAction": "Move Skills",
"DescType_BurstActions": "Burst Actions",
"DescType_MoveForwardGCD": "Move forward GCD",
"DescType_HealAreaGCD": "Range Healing GCD",
"DescType_HealSingleGCD": "Mono Healing GCD",
"DescType_DefenseAreaGCD": "Range Defense GCD",
"DescType_DefenseSingleGCD": "Mono Defense GCD",
"DescType_HealAreaAbility": "Range Healing Ability",
"DescType_HealSingleAbility": "Mono Healing Ability",
"DescType_DefenseAreaAbility": "Range Defense Ability",
"DescType_DefenseSingleAbility": "Mono Defense Ability",
"DescType_MoveForwardAbility": "Move forward Ability",
"DescType_MoveBackAbility": "Move back Ability",
"JobRole_None": "Gathering&Production",
"JobRole_Tank": "Tank",
"JobRole_Melee": "Melee",
Expand Down
2 changes: 1 addition & 1 deletion RotationSolver/Localization/Strings_Major.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ internal partial class Strings
= "Start attacking in smart mode(auto-targeting) when out of combat, otherwise switch the target according to the conditions.";

public string Configwindow_HelpItem_AttackManual { get; set; }
= "Start attacking in manual mode.";
= "Start attacking in manual mode. You need to choose the target manually.";

public string Configwindow_HelpItem_AttackCancel { get; set; }
= "Stop attacking. Remember to turn it off when not in use!";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ private IBaseAction[] GetBaseActions(Type type)
if (type == null) return new IBaseAction[0];

var acts = from prop in type.GetProperties()
where typeof(IBaseAction).IsAssignableFrom(prop.PropertyType)
where typeof(IBaseAction).IsAssignableFrom(prop.PropertyType) && !(prop.GetMethod?.IsPrivate ?? true)
select (IBaseAction)prop.GetValue(this) into act
orderby act.ID
where act is RoleAction role ? role.InRole(Job.GetJobRole()) : true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public bool IsEnabled

public BattleChara MoveTarget { get; private set; }

public virtual string Description { get; } = string.Empty;
public virtual string Description { get; } = "It seems that the author didn't write a description!";

/// <summary>
/// Description about the actions.
Expand Down
37 changes: 28 additions & 9 deletions RotationSolver/Rotations/CustomRotation/CustomRotation_Display.cs
Original file line number Diff line number Diff line change
@@ -1,41 +1,60 @@
using Dalamud.Interface;
using Dalamud.Interface.Colors;
using Dalamud.Utility;
using ImGuiNET;
using RotationSolver.Attributes;
using RotationSolver.Helpers;
using RotationSolver.Localization;
using RotationSolver.Timeline;
using RotationSolver.Windows.RotationConfigWindow;
using System.Linq;
using System.Reflection;

namespace RotationSolver.Rotations.CustomRotation
{
internal abstract partial class CustomRotation
{
const ImGuiWindowFlags flags =
ImGuiWindowFlags.Tooltip |
ImGuiWindowFlags.NoTitleBar |
ImGuiWindowFlags.NoMove |
ImGuiWindowFlags.NoResize |
ImGuiWindowFlags.NoSavedSettings |
ImGuiWindowFlags.AlwaysAutoResize;

public unsafe void Display(ICustomRotation[] rotations, bool canAddButton)
=> this.DrawEnableTexture(canAddButton, null,
text =>
{
ImGui.OpenPopup("Popup" + GetHashCode().ToString());
var id = "Popup" + GetHashCode().ToString();
if (ImGui.BeginPopup("Popup" + GetHashCode().ToString()))
ImGui.SetWindowPos(id, ImGui.GetIO().MousePos);
ImGui.SetNextWindowSizeConstraints(new System.Numerics.Vector2(400, 0), new System.Numerics.Vector2(1000, 1000));
if (ImGui.Begin(id, flags))
{
if(!string.IsNullOrEmpty(text))
if (!string.IsNullOrEmpty(text))
{
ImGui.TextWrapped(text);
ImGui.NewLine();
ImGui.TextColored(ImGuiColors.DalamudYellow, text);
}
var type = this.GetType();
RotationDescAttribute.Merge(type.GetCustomAttributes<RotationDescAttribute>())?.Display(this);
foreach (var m in type.GetMethods())
var attrs = type.GetCustomAttributes<RotationDescAttribute>().ToList();
foreach (var m in type.GetAllMethodInfo())
{
RotationDescAttribute.Merge(m.GetCustomAttributes<RotationDescAttribute>())?.Display(this);
attrs.Add(RotationDescAttribute.MergeToOne(m.GetCustomAttributes<RotationDescAttribute>()));
}
ImGui.EndPopup();
bool last = true;
foreach (var a in RotationDescAttribute.Merge(attrs))
{
if (last) ImGui.Separator();
last = RotationDescAttribute.MergeToOne(a)?.Display(this) ?? false;
}
ImGui.End();
}
}, () =>
{
if (!string.IsNullOrEmpty(RotationName) && rotations != null)
Expand Down
9 changes: 3 additions & 6 deletions RotationSolver/Rotations/Healer/AST/AST_Default.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,20 @@
using RotationSolver.Data;
using RotationSolver.Helpers;
using RotationSolver.Rotations.Basic;
using RotationSolver.Rotations.CustomRotation;
using RotationSolver.Updaters;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Linq;

namespace RotationSolver.Rotations.Healer.AST;

[Description("Some Rotation Description")]
[RotationDesc("Burst Info?")]
[RotationDesc("Burst Info?", ActionID.Divination)]
internal sealed class AST_Default : AST_Base
{
public override string GameVersion => "6.28";

public override string RotationName => "Default";

public override string Description => "This is a test description.";

private protected override IRotationConfigSet CreateConfiguration()
=> base.CreateConfiguration()
.SetFloat("UseEarthlyStarTime", 15, "Use the Earthly Star in Count down time", 4, 20);
Expand Down
1 change: 0 additions & 1 deletion RotationSolver/Timeline/ActionCondition.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ public void Draw(ICustomRotation combo)
ID = (ActionID)_action.ID;
});


ImGui.SameLine();

ConditionHelper.DrawIntEnum($"##Category{GetHashCode()}", ref ActionConditonType, EnumTranslations.ToName);
Expand Down
2 changes: 2 additions & 0 deletions RotationSolver/Windows/RotationConfigWindow_Help.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ private void DrawHelpTab()
ImGui.Separator();

StateCommandType.Cancel.DisplayCommandHelp(getHelp: EnumTranslations.ToHelp);

ImGui.Separator();
ImGui.Separator();

SpecialCommandType.EndSpecial.DisplayCommandHelp(getHelp: EnumTranslations.ToHelp);
Expand Down
22 changes: 22 additions & 0 deletions docs/basic-settings.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,25 @@ Click on the button on the `Help` is not efficiency. So you can right click on t

There is a brief macro function description.

Macros are divided into two categories. One is for state, the other is for special duration.

### State

This kind of macro will set a no-time-limit state. It contains three macros.

| Macro | Description |
| ---------------- | ------------------------------------------------------------ |
| /rotation Smart | Start attacking in smart mode(auto-targeting) when out of combat, otherwise switch the target according to the conditions. |
| /rotation Manual | Start attacking in manual mode. You need to choose the target manually. |
| /rotation Cancel | Stop attacking. Remember to turn it off when not in use! |

### Special Duration

This kind of macro will open a window for some special action to use. And the time is set here.

| Macro | Description |
| ----- | ----------- |
| | |



0 comments on commit 0ea0c26

Please sign in to comment.