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

Commit

Permalink
fix: fixed some bugs.
Browse files Browse the repository at this point in the history
  • Loading branch information
ArchiDog1998 committed Jan 20, 2023
1 parent ca971fc commit 6b72c87
Show file tree
Hide file tree
Showing 22 changed files with 108 additions and 75 deletions.
2 changes: 1 addition & 1 deletion RotationSolver/Actions/BaseAction/BaseAction_BasicInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ internal virtual EnemyPositional EnermyPositonal
{
get
{
if (StatusHelper.ActionLocations.TryGetValue((ActionID)ID, out var location))
if (ConfigurationHelper.ActionLocations.TryGetValue((ActionID)ID, out var location))
{
return location.Loc;
}
Expand Down
5 changes: 4 additions & 1 deletion RotationSolver/Actions/BaseAction/BaseAction_Display.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ namespace RotationSolver.Actions.BaseAction
{
internal partial class BaseAction
{
public unsafe void Display(bool IsActive) => this.DrawEnableTexture(IsActive, () => RotationConfigWindow.ActiveAction = this, otherThing: () =>
public unsafe void Display(bool IsActive) => this.DrawEnableTexture(IsActive, () =>
{
if (IsTimeline) RotationConfigWindow.ActiveAction = this;
}, otherThing: () =>
{
if (IsTimeline) OtherCommandType.Actions.DisplayCommandHelp($"{this}-{5}",
type => string.Format(LocalizationManager.RightLang.Configwindow_Helper_InsertCommand, this));
Expand Down
9 changes: 6 additions & 3 deletions RotationSolver/Actions/BaseAction/BaseAction_Target.cs
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ private bool TargetDeath(out BattleChara target)
private bool TargetHostile(float range, bool mustUse, int aoeCount, out BattleChara target)
{
//如果不用自动找目标,那就直接返回。
if (RSCommands.StateType != StateCommandType.Manual)
if (RSCommands.StateType == StateCommandType.Manual)
{
if (Service.TargetManager.Target is BattleChara b && b.CanAttack() && b.DistanceToPlayer() <= range)
{
Expand Down Expand Up @@ -294,8 +294,11 @@ private bool TargetHostileManual(BattleChara b, bool mustUse, int aoeCount, out
{
target = b;

//目标已有充足的Debuff
if (!CheckStatus(b ?? Service.ClientState.LocalPlayer, mustUse)) return false;
//No need to dot.
if (TargetStatus != null && !ObjectHelper.CanDot(b)) return false;

//Already has status.
if (!CheckStatus(b, mustUse)) return false;

return true;
}
Expand Down
1 change: 0 additions & 1 deletion RotationSolver/Commands/RSCommands_Actions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ internal static unsafe void DoAnAction(bool isGCD)
if (nextAction == null) return;
if (!isGCD && nextAction is BaseAction act1 && act1.IsRealGCD) return;


if (nextAction.Use())
{
if (Service.Configuration.KeyBoardNoise) PreviewUpdater.PulseAtionBar(nextAction.AdjustedID);
Expand Down
8 changes: 7 additions & 1 deletion RotationSolver/Commands/RSCommands_OtherCommand.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using RotationSolver.Actions.BaseAction;
using RotationSolver.Data;
using RotationSolver.Helpers;
using RotationSolver.Localization;
using RotationSolver.Rotations.CustomRotation;
Expand Down Expand Up @@ -92,7 +93,12 @@ private static void DoActionCommand(string str)
}
NextActs = NextActs.OrderBy(i => i.deadTime).ToList();

Service.ChatGui.Print(string.Format(LocalizationManager.RightLang.Commands_InsertAction, time, act.Name));
Service.ToastGui.ShowQuest(string.Format(LocalizationManager.RightLang.Commands_InsertAction, time),
new Dalamud.Game.Gui.Toast.QuestToastOptions()
{
IconId = act.IconID,
});

return;
}
}
Expand Down
6 changes: 3 additions & 3 deletions RotationSolver/Commands/RSCommands_StateSpecialCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ private static void UpdateToast()
});
}

internal static void ResetSpecial() => DoSpecialCommandType(SpecialCommandType.EndSpecial);
internal static void ResetSpecial() => DoSpecialCommandType(SpecialCommandType.EndSpecial, false);

private static void DoStateCommandType(StateCommandType stateType) => DoOneCommandType(stateType, EnumTranslations.ToSayout, role =>
{
Expand All @@ -53,13 +53,13 @@ private static void DoStateCommandType(StateCommandType stateType) => DoOneComma
UpdateToast();
});

private static void DoSpecialCommandType(SpecialCommandType specialType) => DoOneCommandType(specialType, EnumTranslations.ToSayout, role =>
private static void DoSpecialCommandType(SpecialCommandType specialType, bool sayout = true) => DoOneCommandType(specialType, sayout ? EnumTranslations.ToSayout : (s, r) => string.Empty, role =>
{
_specialType = specialType;
_specialString = specialType.ToSpecialString(role);

_specialStateStartTime = specialType == SpecialCommandType.EndSpecial ? DateTime.MinValue : DateTime.Now;
UpdateToast();
if(sayout) UpdateToast();
});

private static void DoOneCommandType<T>(T type, Func<T, JobRole, string> sayout, Action<JobRole> doingSomething)
Expand Down
2 changes: 1 addition & 1 deletion RotationSolver/Configuration/PluginConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class PluginConfiguration : IPluginConfiguration
{
public int Version { get; set; } = 6;

public int VoiceVolume = 80;
public int VoiceVolume = 100;
public SortedSet<string> DisabledCombos { get; private set; } = new SortedSet<string>();
public SortedSet<uint> DiabledActions { get; private set; } = new SortedSet<uint>();
public List<ActionEventInfo> Events { get; private set; } = new List<ActionEventInfo>();
Expand Down
13 changes: 10 additions & 3 deletions RotationSolver/Helpers/ConditionHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,17 +61,24 @@ internal static bool DrawDragInt(string name, ref int value)
return ImGui.DragInt(name, ref value);
}

internal static bool DrawCheckBox(string name, ref int value)
internal static bool DrawCheckBox(string name, ref int value, string desc = "")
{
ImGui.SameLine();

var @bool = value != 0;

var result = false;
if (ImGui.Checkbox(name, ref @bool))
{
value = @bool ? 1 : 0;
return true;
result = true;
}
if(!string.IsNullOrEmpty(desc) && ImGui.IsItemHovered())
{
ImGui.SetTooltip(desc);
}
return false;

return result;
}
}
}
20 changes: 20 additions & 0 deletions RotationSolver/Helpers/ConfigurationHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,26 @@ namespace RotationSolver.Helpers;

internal static class ConfigurationHelper
{
public record LocationInfo(EnemyPositional Loc, byte[] Tags);
public static readonly SortedList<ActionID, LocationInfo> ActionLocations = new SortedList<ActionID, LocationInfo>()
{
{ActionID.FangandClaw, new( EnemyPositional.Side, new byte[] { 13, 10 })},
{ActionID.WheelingThrust, new(EnemyPositional.Back, new byte[] { 10, 13 }) },
{ActionID.ChaosThrust, new(EnemyPositional.Back, new byte[] { 61, 28 }) },
{ActionID.ChaoticSpring, new(EnemyPositional.Back, new byte[] { 66, 28 }) },
{ActionID.Demolish, new(EnemyPositional.Back, new byte[] { 46, 60 }) },
{ActionID.SnapPunch, new(EnemyPositional.Side, new byte[] { 19, 21 }) },
{ActionID.TrickAttack, new(EnemyPositional.Back, new byte[] { 25 }) },
{ActionID.AeolianEdge,new( EnemyPositional.Back, new byte[] { 30, 68 }) },
{ActionID.ArmorCrush, new(EnemyPositional.Side, new byte[] { 30, 66 }) },
{ActionID.Suiton, new(EnemyPositional.Back, new byte[] { }) },
{ActionID.Gibbet, new(EnemyPositional.Side , new byte[] { 11 })},
{ActionID.Gallows, new(EnemyPositional.Back, new byte[] { 11 }) },
{ActionID.Gekko, new(EnemyPositional.Back , new byte[] { 68, 29, 72 })},
{ActionID.Kasha, new(EnemyPositional.Side, new byte[] { 29, 68, 72 }) },
};


public static readonly string[] AuthorKeys = new string[]
{
"Ig4lHXUohMZNIeheUtAtRg==",
Expand Down
2 changes: 1 addition & 1 deletion RotationSolver/Helpers/ImguiHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public static void DrawEnableTexture<T>(this T texture, bool isSelected, Action
}
if (isSelected) ImGui.PopStyleColor();

HoveredString(desc, selected);
HoveredString(desc);
}


Expand Down
19 changes: 0 additions & 19 deletions RotationSolver/Helpers/StatusHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,6 @@ namespace RotationSolver.Helpers;

internal static class StatusHelper
{
public record LocationInfo(EnemyPositional Loc, byte[] Tags);
public static readonly SortedList<ActionID, LocationInfo> ActionLocations = new SortedList<ActionID, LocationInfo>()
{
{ActionID.FangandClaw, new( EnemyPositional.Side, new byte[] { 13, 10 })},
{ActionID.WheelingThrust, new(EnemyPositional.Back, new byte[] { 10, 13 }) },
{ActionID.ChaosThrust, new(EnemyPositional.Back, new byte[] { 61, 28 }) },
{ActionID.ChaoticSpring, new(EnemyPositional.Back, new byte[] { 66, 28 }) },
{ActionID.Demolish, new(EnemyPositional.Back, new byte[] { 46, 60 }) },
{ActionID.SnapPunch, new(EnemyPositional.Side, new byte[] { 19, 21 }) },
{ActionID.TrickAttack, new(EnemyPositional.Back, new byte[] { 25 }) },
{ActionID.AeolianEdge,new( EnemyPositional.Back, new byte[] { 30, 68 }) },
{ActionID.ArmorCrush, new(EnemyPositional.Side, new byte[] { 30, 66 }) },
{ActionID.Suiton, new(EnemyPositional.Back, new byte[] { }) },
{ActionID.Gibbet, new(EnemyPositional.Side , new byte[] { 11 })},
{ActionID.Gallows, new(EnemyPositional.Back, new byte[] { 11 }) },
{ActionID.Gekko, new(EnemyPositional.Back , new byte[] { 68, 29, 72 })},
{ActionID.Kasha, new(EnemyPositional.Side, new byte[] { 29, 68, 72 }) },
};

public static StatusID[] SheildStatus { get; } = new StatusID[]
{
StatusID.Grit, StatusID.RoyalGuard, StatusID.IronWill, StatusID.Defiance
Expand Down
4 changes: 2 additions & 2 deletions RotationSolver/Localization/EnumTranslations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,8 @@ internal static class EnumTranslations

internal static string ToSayout(this StateCommandType type, JobRole role) => type switch
{
StateCommandType.Smart => "Start Smart " + RSCommands.TargetingType.ToName(),
StateCommandType.Manual => "Start Manual",
StateCommandType.Smart => "Smart " + RSCommands.TargetingType.ToName(),
StateCommandType.Manual => "Manual",
StateCommandType.Cancel => "Cancel",
_ => string.Empty,
};
Expand Down
12 changes: 2 additions & 10 deletions RotationSolver/Localization/Strings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ internal class Strings
public string Commands_ChangeRotationConfig { get; set; } = "Modify {0} to {1}";
public string Commands_CannotFindRotationConfig { get; set; } = "Failed to find the config in this rotation, please check it.";

public string Commands_InsertAction { get; set; } = "Will use skill \"{1}\" within {0}s";
public string Commands_InsertAction { get; set; } = "Will use it within {0}s";

public string Commands_InsertActionFailure { get; set; } = "Can not find the action, please check the action name.";
public string Commands_OpenSettings { get; set; } = "The settings interface has been opened";
Expand Down Expand Up @@ -184,17 +184,12 @@ internal class Strings
#endregion

#region ScriptWindow
public string Scriptwindow_Author { get; set; } = "Author";
public string Scriptwindow_OpenSourceFile { get; set; } = "Open Source File";
public string Scriptwindow_Save { get; set; } = "Save";
public string Scriptwindow_DragdropDescription { get; set; } = "Drag&drop to move,Ctrl+Alt+RightClick to delete.";
public string Scriptwindow_SearchBar { get; set; } = "Search Bar";
public string Scriptwindow_MustUse { get; set; } = "MustUse";
public string Scriptwindow_MustUseDesc { get; set; } = "Skip AOE and Buff.";
public string Scriptwindow_Empty { get; set; } = "UseUp";
public string Scriptwindow_EmptyDesc { get; set; } = "UseUp or Skip Combo";
public string Scriptwindow_Return { get; set; } = "Return condition";
public string Scriptwindow_ActionConditionsDescription { get; set; } = "Description";
public string Scriptwindow_AbilityRemain { get; set; } = "Ability Remains";
public string Scriptwindow_AbilityRemainDesc { get; set; } = "Use this action while how many abilities remain. Set it to zero to ignore.";
public string Scriptwindow_AdjustID { get; set; } = "AdjustID";
Expand All @@ -204,9 +199,6 @@ internal class Strings
public string Scriptwindow_AddActionDesc { get; set; } = "Add Action";
public string Scriptwindow_AddFunctionDesc { get; set; } = "Add Function,total {0}.";
public string Scriptwindow_ComboSetAuthorDefault { get; set; } = "Unknown";
public string Scriptwindow_CountDown { get; set; } = "CountDown";
public string Scriptwindow_CountDownDesc { get; set; } = "The actions need to use in the countdown.";
public string Scriptwindow_CountDownSetDesc { get; set; } = "Input the actions need to use in the countdown into the box below.";
public string Scriptwindow_Can { get; set; } = "Can";
public string Scriptwindow_Cannot { get; set; } = "Cannot";
public string Scriptwindow_Is { get; set; } = "Is";
Expand All @@ -229,7 +221,7 @@ internal class Strings
#region Actions
public string Action_Friendly { get; set; } = "Support";
public string Action_Attack { get; set; } = "Attack";
public string Action_WrongLocation { get; set; } = "要打{0}!";
public string Action_WrongLocation { get; set; } = "Positional {0}!";

#endregion

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
using Dalamud.Interface;
using Dalamud.Utility;
using ImGuiNET;
using Lumina.Data.Parsing;
using RotationSolver.Helpers;
using RotationSolver.Localization;
using RotationSolver.SigReplacers;
using System;
using System.Collections.Generic;
using System.Linq;
Expand Down Expand Up @@ -54,6 +56,21 @@ public unsafe void Display(ICustomRotation[] rotations, bool canAddButton) => th
Util.OpenLink(url);
}
ImGuiHelper.HoveredString(LocalizationManager.RightLang.Configwindow_Helper_OpenSource);
}, () => Configs.Draw(canAddButton));
}, () =>
{
int isAllTargetAsHostile = (byte)IconReplacer.GetTargetHostileType(Job);
ImGui.SetNextItemWidth(300);
if (ImGui.Combo(LocalizationManager.RightLang.Configwindow_Params_RightNowTargetToHostileType + $"##HostileType{GetHashCode()}", ref isAllTargetAsHostile, new string[]
{
LocalizationManager.RightLang.Configwindow_Params_TargetToHostileType1,
LocalizationManager.RightLang.Configwindow_Params_TargetToHostileType2,
LocalizationManager.RightLang.Configwindow_Params_TargetToHostileType3,
}, 3))
{
Service.Configuration.TargetToHostileTypes[Job.RowId] = (byte)isAllTargetAsHostile;
Service.Configuration.Save();
}
Configs.Draw(canAddButton);
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,7 @@ private IAction Invoke()
if (Service.Configuration.SayPotional) Watcher.Speak(positional);
if (Service.Configuration.FlytextPositional) Service.ToastGui.ShowQuest(" " + positional, new Dalamud.Game.Gui.Toast.QuestToastOptions()
{
IconId = Service.DataManager.GetExcelSheet<Lumina.Excel.GeneratedSheets.Action>().GetRow(
(uint)Service.IconReplacer.OriginalHook((ActionID)GcdAction.ID)).Icon,
IconId = GcdAction.IconID,
});
OverlayWindow.EnemyLocationTarget = GcdAction.Target;
OverlayWindow.ShouldPositional = GcdAction.EnermyPositonal;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,11 +162,4 @@ protected static bool EndAfter(float remain, float remainNeed)
&& types[0].ParameterType == typeof(bool)
&& types[1].ParameterType == typeof(IAction[]);
});

public MethodInfo[] AllOther => GetType().GetStaticBoolMethodInfo(m =>
{
var types = m.GetParameters();
return types.Length == 1
&& types[0].IsOut;
});
}
1 change: 0 additions & 1 deletion RotationSolver/Rotations/CustomRotation/ICustomRotation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ internal interface ICustomRotation : ITexture, IEnable

MethodInfo[] AllTimes { get; }
MethodInfo[] AllLast { get; }
MethodInfo[] AllOther { get; }
MethodInfo[] AllGCDs { get; }

bool TryInvoke(out IAction newAction);
Expand Down
14 changes: 9 additions & 5 deletions RotationSolver/SigReplacers/Watcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,17 +113,21 @@ private static unsafe void RecordAction(GameObject tar, Action action, byte flag
}

#if DEBUG
if (flag != 0) Service.ChatGui.Print($"{action.Name}, {flag}");
if (flag != 0)
{
Service.FlyTextGui.AddFlyText(Dalamud.Game.Gui.FlyText.FlyTextKind.NamedIcon, 0, 0, 0, "Flag:" + flag.ToString(), "",
ImGui.GetColorU32(new Vector4(0.4f, 0, 0, 1)), 0, action.Icon);
}
#endif

//事后骂人!
if (Service.Configuration.PositionalFeedback
&& StatusHelper.ActionLocations.TryGetValue(id, out var loc)
&& ConfigurationHelper.ActionLocations.TryGetValue(id, out var loc)
&& loc.Tags.Length > 0 && !loc.Tags.Contains(flag))
{
//Todo: Damage Icon should be something intersting.
Service.FlyTextGui.AddFlyText(Dalamud.Game.Gui.FlyText.FlyTextKind.NamedIcon, 0, 0, 0, string.Format(LocalizationManager.RightLang.Action_WrongLocation, loc.Loc.ToName()), "",
ImGui.GetColorU32(new Vector4(0.4f, 0, 0, 1)), action.Icon, 0);
var str = string.Format(LocalizationManager.RightLang.Action_WrongLocation, loc.Loc.ToName());
Service.FlyTextGui.AddFlyText(Dalamud.Game.Gui.FlyText.FlyTextKind.NamedIcon, 0, 0, 0, str, "",
ImGui.GetColorU32(new Vector4(0.4f, 0, 0, 1)), 0, action.Icon);
if (!string.IsNullOrEmpty(Service.Configuration.PositionalErrorText))
{
Speak(Service.Configuration.PositionalErrorText);
Expand Down
4 changes: 2 additions & 2 deletions RotationSolver/Timeline/ActionCondition.cs
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,8 @@ public void Draw(ICustomRotation combo)

case ActionConditonType.ShouldUse:

ConditionHelper.DrawCheckBox($"{LocalizationManager.RightLang.Scriptwindow_MustUse}##MustUse{GetHashCode()}", ref Param1);
ConditionHelper.DrawCheckBox($"{LocalizationManager.RightLang.Scriptwindow_Empty}##MustUse{GetHashCode()}", ref Param2);
ConditionHelper.DrawCheckBox($"{LocalizationManager.RightLang.Scriptwindow_MustUse}##MustUse{GetHashCode()}", ref Param1, LocalizationManager.RightLang.Scriptwindow_MustUseDesc);
ConditionHelper.DrawCheckBox($"{LocalizationManager.RightLang.Scriptwindow_Empty}##MustUse{GetHashCode()}", ref Param2, LocalizationManager.RightLang.Scriptwindow_EmptyDesc);
break;

case ActionConditonType.CurrentCharges:
Expand Down
Loading

0 comments on commit 6b72c87

Please sign in to comment.