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

Commit

Permalink
fix: add avarice not installed warning.
Browse files Browse the repository at this point in the history
  • Loading branch information
ArchiDog1998 committed Oct 10, 2023
1 parent 90b48c7 commit a4b8ca5
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 46 deletions.
1 change: 1 addition & 0 deletions RotationSolver/Commands/RSCommands_StateSpecialCommand.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using ECommons.DalamudServices;
using ECommons.GameHelpers;
using RotationSolver.Helpers;
using RotationSolver.Localization;
using RotationSolver.Updaters;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,34 +1,28 @@
using Dalamud.Game.Text.SeStringHandling;
using Dalamud.Game.Text.SeStringHandling.Payloads;
using Dalamud.Logging;
using Dalamud.Plugin;
using ECommons.DalamudServices;
using ECommons.Reflection;
using RotationSolver.Localization;

namespace RotationSolver;
namespace RotationSolver.Helpers;

internal static class SpeechHelper
{
static IDalamudPlugin _textToTalk = null;
static MethodInfo _say = null;
static object _manager = null;
static MethodInfo _stop = null;
static bool _showed = false;

internal static void Speak(string text)
{
if(_textToTalk == null)
if (_textToTalk == null)
{
if (!DalamudReflector.TryGetDalamudPlugin("TextToTalk", out _textToTalk))
{
if (!_showed)
{
_showed = true;
Svc.Chat.PrintError(LocalizationManager.RightLang.TextToTalkWarning);
}
return;
}
}

_say ??= _textToTalk?.GetType().GetRuntimeMethods().FirstOrDefault(m => m.Name == "Say");
_manager ??= _textToTalk?.GetType().GetRuntimeFields().FirstOrDefault(m => m.Name == "backendManager").GetValue(_textToTalk);
_stop ??= _manager?.GetType().GetRuntimeMethods().FirstOrDefault(m => m.Name == "CancelAllSpeech");
Expand All @@ -42,7 +36,7 @@ internal static void Speak(string text)
}
catch
{
_say?.Invoke(_textToTalk, new object[] { null, new SeString(new TextPayload("Rotation Solver")) , text, 1 });
_say?.Invoke(_textToTalk, new object[] { null, new SeString(new TextPayload("Rotation Solver")), text, 1 });
}
}
catch (Exception ex)
Expand Down
1 change: 1 addition & 0 deletions RotationSolver/Localization/Strings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -608,6 +608,7 @@ internal class Strings

public string HighEndWarning { get; set; } = "Please separately keybind damage reduction / shield cooldowns in case RS fails at a crucial moment in {0}!";
public string TextToTalkWarning { get; set; } = "You didn't install TextToTalk, please install it to make Rotation Solver say something for you!";
public string AvariceWarning { get; set; } = "It seems that you didn't installed Avarice. If you want to get the positional indicator from Rotation Solver, please install it.";

public string ClickingMistakeMessage { get; set; } = "OOOps! RS clicked the wrong action ({0})!";

Expand Down
6 changes: 1 addition & 5 deletions RotationSolver/RotationSolverPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using Dalamud.Game.ClientState.Conditions;
using Dalamud.Game.Text.SeStringHandling.Payloads;
using Dalamud.Interface.Windowing;
using Dalamud.Logging;
using Dalamud.Plugin;
using ECommons;
using ECommons.DalamudServices;
Expand All @@ -15,9 +14,6 @@
using RotationSolver.Localization;
using RotationSolver.UI;
using RotationSolver.Updaters;
using System.Drawing;
using System.Runtime.InteropServices;
using Module = ECommons.Module;

namespace RotationSolver;

Expand All @@ -37,7 +33,7 @@ public sealed class RotationSolverPlugin : IDalamudPlugin, IDisposable
public static DalamudLinkPayload HideWarningLinkPayload { get; private set; }
public RotationSolverPlugin(DalamudPluginInterface pluginInterface)
{
ECommonsMain.Init(pluginInterface, this, Module.DalamudReflector, Module.ObjectFunctions);
ECommonsMain.Init(pluginInterface, this, ECommons.Module.DalamudReflector, ECommons.Module.ObjectFunctions);
ThreadLoadImageHandler.TryGetIconTextureWrap(0, false, out _);
IconSet.InIt();

Expand Down
73 changes: 43 additions & 30 deletions RotationSolver/Updaters/MajorUpdater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ internal static class MajorUpdater
&& !Svc.Condition[ConditionFlag.BetweenAreas51]
&& Player.Available && !SocialUpdater.InPvp;

static bool _showed, _work;
static bool _showedWarning, _work;
static Exception _threadException;
static DateTime _lastUpdatedWork = DateTime.Now;

Expand All @@ -42,38 +42,13 @@ private unsafe static void FrameworkUpdate(IFramework framework)

return;
}
if ((int)Svc.ClientState.ClientLanguage == 4 && !_showed)
{
_showed = true;

var warning = "Rotation Solver 未进行国服适配并不提供相关支持! 建议使用国服的插件,如:";
Svc.Toasts.ShowError(warning + "AE Assist 2.0!");

var seString = new SeString(new TextPayload(warning)
, Svc.PluginInterface.AddChatLinkHandler(2, (id, str) =>
{
if (id == 2)
{
Util.OpenLink("http://qm.qq.com/cgi-bin/qm/qr?_wv=1027&k=EyT0BfZWCVq8v2yiMjSqcb4lEqYuaF_P&authKey=UJFoVZ3OljlBhSilXpeLKIIzofI4ZUjJfjuqCgr%2BiaT3Y6HmQFVbXZ5xBOlSv5yZ&noverify=0&group_code=552689154");
}
}),
new UIForegroundPayload(31),
new TextPayload("AE Assist 2.0"),
UIForegroundPayload.UIForegroundOff,
RawPayload.LinkTerminator,
new TextPayload("!"));

Svc.Chat.Print(new Dalamud.Game.Text.XivChatEntry()
{
Message = seString,
Type = Dalamud.Game.Text.XivChatType.ErrorMessage,
});
if (!_showedWarning)
{
_showedWarning = true;
ShowWarning();
}

#if DEBUG
//*(float*)((IntPtr)(void*)CameraManager.Instance()->Camera + 0x130) = 0;
#endif

try
{
SocialUpdater.UpdateSocial();
Expand Down Expand Up @@ -132,6 +107,44 @@ private unsafe static void FrameworkUpdate(IFramework framework)
}
}

private static void ShowWarning()
{
if ((int)Svc.ClientState.ClientLanguage == 4)
{
var warning = "Rotation Solver 未进行国服适配并不提供相关支持! 建议使用国服的插件,如:";
Svc.Toasts.ShowError(warning + "AE Assist 2.0!");

var seString = new SeString(new TextPayload(warning),
Svc.PluginInterface.AddChatLinkHandler(2, (id, str) =>
{
if (id == 2)
{
Util.OpenLink("http://qm.qq.com/cgi-bin/qm/qr?_wv=1027&k=EyT0BfZWCVq8v2yiMjSqcb4lEqYuaF_P&authKey=UJFoVZ3OljlBhSilXpeLKIIzofI4ZUjJfjuqCgr%2BiaT3Y6HmQFVbXZ5xBOlSv5yZ&noverify=0&group_code=552689154");
}
}),
new UIForegroundPayload(31),
new TextPayload("AE Assist 2.0"),
UIForegroundPayload.UIForegroundOff,
RawPayload.LinkTerminator,
new TextPayload("!"));

Svc.Chat.Print(new Dalamud.Game.Text.XivChatEntry()
{
Message = seString,
Type = Dalamud.Game.Text.XivChatType.ErrorMessage,
});
}

if (!Svc.PluginInterface.InstalledPlugins.Any(p => p.InternalName == "Avarice"))
{
Svc.Chat.PrintError(LocalizationManager.RightLang.AvariceWarning);
}
if (!Svc.PluginInterface.InstalledPlugins.Any(p => p.InternalName == "TextToTalk"))
{
Svc.Chat.PrintError(LocalizationManager.RightLang.TextToTalkWarning);
}
}

public static void Enable()
{
ActionSequencerUpdater.Enable(Svc.PluginInterface.ConfigDirectory.FullName + "\\Conditions");
Expand Down

0 comments on commit a4b8ca5

Please sign in to comment.