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

Commit

Permalink
fix: add a DM button for sending Hash to Archi.
Browse files Browse the repository at this point in the history
  • Loading branch information
ArchiDog1998 committed Sep 27, 2023
1 parent 1d8f367 commit 0efd7fd
Show file tree
Hide file tree
Showing 8 changed files with 51 additions and 29 deletions.
2 changes: 1 addition & 1 deletion Resources/UsersHash.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[
"kkCy7C/6qMb8yhX+VQByCA=="
"Cs5AdOZTzkt2xdRfVaLw9Q=="
]
3 changes: 0 additions & 3 deletions RotationSolver/Helpers/RotationLoadContext.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
using System.Runtime.Loader;

using Dalamud.Logging;
using Dalamud.Plugin;

using FFXIVClientStructs.Interop;

using Lumina.Excel;
using Lumina.Excel.CustomSheets;

Expand Down
2 changes: 2 additions & 0 deletions RotationSolver/Localization/ConfigTranslation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,8 @@ internal static class ConfigTranslation
PluginConfigBool.MoveTowardsScreenCenter => LocalizationManager.RightLang.ConfigWindow_Param_MoveTowardsScreenDesc,
PluginConfigBool.MoveAreaActionFarthest => LocalizationManager.RightLang.ConfigWindow_Param_MoveAreaActionFarthestDesc,

PluginConfigBool.SayHelloToUsers => LocalizationManager.RightLang.ConfigWindow_Basic_SayHelloToUsersDesc,

PluginConfigBool.AutoOpenChest => "Because of the feature in pandora, there is an issue the treasure chest cannot be opened in some cases, I find the code from roll for loot. Once Pandora fixed that, this feature will be deleted.",
_ => string.Empty,
};
Expand Down
6 changes: 5 additions & 1 deletion RotationSolver/Localization/Localization.json
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,7 @@
"ConfigWindow_List_NoHostilesName": "The name of the enemy that you don't want to be targeted",
"ConfigWindow_List_NoProvokeName": "The name of the enemy that you don't want to be provoked",
"ConfigWindow_Basic_AutoSwitch": "Auto Switch",
"ConfigWindow_Basic_Others": "Others",
"ConfigWindow_Basic_Timer": "Timer",
"ConfigWindow_UI_Windows": "Windows",
"ConfigWindow_UI_Overlay": "Overlay",
Expand Down Expand Up @@ -522,5 +523,8 @@
"ConfigWindow_Actions_TTK": "TTK that this action needs the target be.",
"ConfigWindow_Actions_HealRatio": "The HP ratio to auto heal",
"ConfigWindow_Actions_ConditionDescription": "Forced Conditions have a higher priority. If Forced Conditions are met, Disabled Condition will be ignored.",
"ConfigWindow_Auto_UseResourcesAction": "Use actions that use resources"
"ConfigWindow_Auto_UseResourcesAction": "Use actions that use resources",
"ConfigWindow_Auto_HealthForAutoDefense": "HP Ratio about defense single of Tanks",
"ConfigWindow_Basic_SayHelloToUsers": "Say hello to the users of Rotation Solver.",
"ConfigWindow_Basic_SayHelloToUsersDesc": "It can only be disabled for users, not authors and contributors.\nIf you want to be greeted by other users, please DM ArchiTed in Discord Server with your Hash!"
}
1 change: 1 addition & 0 deletions RotationSolver/Localization/Strings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -748,4 +748,5 @@ internal class Strings
public string ConfigWindow_Auto_UseResourcesAction { get; set; } = "Use actions that use resources";
public string ConfigWindow_Auto_HealthForAutoDefense { get; set; } = "HP Ratio about defense single of Tanks";
public string ConfigWindow_Basic_SayHelloToUsers { get; set; } = "Say hello to the users of Rotation Solver.";
public string ConfigWindow_Basic_SayHelloToUsersDesc { get; set; } = "It can only be disabled for users, not authors and contributors.\nIf you want to be greeted by other users, please DM ArchiTed in Discord Server with your Hash!";
}
4 changes: 0 additions & 4 deletions RotationSolver/UI/RotationConfigWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2068,10 +2068,6 @@ private static void DrawDebug()
searchable?.Draw(Job);
}

var str = SocialUpdater.EncryptString(Player.Object);
ImGui.SetNextItemWidth(ImGui.CalcTextSize(str).X + 10);
ImGui.InputText("That is your HASH", ref str, 100);

if (!Player.Available || !Service.Config.GetValue(PluginConfigBool.InDebug)) return;

_debugHeader?.Draw();
Expand Down
45 changes: 34 additions & 11 deletions RotationSolver/UI/RotationConfigWindow_Config.cs
Original file line number Diff line number Diff line change
@@ -1,19 +1,24 @@
using Dalamud.Game.ClientState.Keys;
using Dalamud.Interface.Colors;
using Dalamud.Utility;
using ECommons.GameHelpers;
using ECommons.ImGuiMethods;
using RotationSolver.Basic.Configuration;
using RotationSolver.Helpers;
using RotationSolver.Localization;
using RotationSolver.UI.SearchableConfigs;
using RotationSolver.UI.SearchableSettings;
using RotationSolver.Updaters;

namespace RotationSolver.UI;

public partial class RotationConfigWindow
{
private static char[] _splitChar = new char[] { ' ', ',', '、', '.', '。' };
internal static float Similarity(string text, string key)
{
var chars = text.Split(new char[] { ' ', ',', '、', '.', '。' }, StringSplitOptions.RemoveEmptyEntries);
var keys = key.Split(new char[] { ' ', ',', '、', '.', '。' }, StringSplitOptions.RemoveEmptyEntries);
var chars = text.Split(_splitChar, StringSplitOptions.RemoveEmptyEntries);
var keys = key.Split(_splitChar, StringSplitOptions.RemoveEmptyEntries);

var startWithCount = chars.Count(i => keys.Any(k => i.StartsWith(k, StringComparison.OrdinalIgnoreCase)));

Expand Down Expand Up @@ -82,13 +87,7 @@ private static void DrawBasic()
{
{ () => LocalizationManager.RightLang.ConfigWindow_Basic_Timer, DrawBasicTimer },
{ () => LocalizationManager.RightLang.ConfigWindow_Basic_AutoSwitch, DrawBasicAutoSwitch },
{ () => LocalizationManager.RightLang.ConfigWindow_Basic_Others, () =>
{
foreach (var searchable in _basicParamsSearchable)
{
searchable?.Draw(Job);
}
} },
{ () => LocalizationManager.RightLang.ConfigWindow_Basic_Others, DrawBasicOthers },
});

private static readonly uint PING_COLOR = ImGui.ColorConvertFloat4ToU32(ImGuiColors.ParsedGreen);
Expand Down Expand Up @@ -265,6 +264,30 @@ private static void DrawBasicAutoSwitch()
}
}

private static void DrawBasicOthers()
{
foreach (var searchable in _basicParamsSearchable)
{
searchable?.Draw(Job);
}

var str = SocialUpdater.EncryptString(Player.Object);
ImGui.SetNextItemWidth(ImGui.CalcTextSize(str).X + 10);
ImGui.InputText("That is your HASH:", ref str, 100);

if (!DownloadHelper.ContributorsHash.Contains(str)
&& !DownloadHelper.UsersHash.Contains(str)
&& !RotationUpdater.AuthorHashes.ContainsKey(str))
{
if (ImGui.Button("DM your Hash to ArchiTed for being greeted."))
{
ImGui.SetClipboardText(str);
Notify.Success($"Your hash \"{str}\" copied to clipboard.");
Util.OpenLink("https://discord.com/users/1007293294100877322");
}
}
}

private static readonly ISearchable[] _basicTimer = new ISearchable[]
{
new DragFloatSearchPlugin(PluginConfigFloat.ActionAhead, 0.002f),
Expand All @@ -288,11 +311,11 @@ private static void DrawBasicAutoSwitch()

new CheckBoxSearchPlugin(PluginConfigBool.UseWorkTask),

new CheckBoxSearchPlugin(PluginConfigBool.SayHelloToUsers),

new DragFloatSearchPlugin(PluginConfigFloat.MistakeRatio, 0.002f),

new DragFloatRangeSearchPlugin(PluginConfigFloat.NotInCombatDelayMin, PluginConfigFloat.NotInCombatDelayMax, 0.002f),

new CheckBoxSearchPlugin(PluginConfigBool.SayHelloToUsers),
};

private static readonly ISearchable[] _basicSwitchTurnOn = new ISearchable[]
Expand Down
17 changes: 8 additions & 9 deletions RotationSolver/Updaters/SocialUpdater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ internal class SocialUpdater

private static readonly HashSet<string> saidAuthors = new();


static bool _canSaying = false;
public static TerritoryType[] HighEndDuties { get; private set; } = Array.Empty<TerritoryType>();

Expand Down Expand Up @@ -143,15 +142,12 @@ internal static async void UpdateSocial()
Service.Config.GlobalConfig.DutyStart.AddMacro();
await Task.Delay(new Random().Next(1000, 1500));

if (Service.Config.GetValue(Basic.Configuration.PluginConfigBool.SayHelloToUsers))
{
SayHelloToParticipants();
}
SayHelloToUsers();
}
}

private static readonly ChatEntityComparer _comparer = new ChatEntityComparer();
private static async void SayHelloToParticipants()
private static async void SayHelloToUsers()
{
var players = DataCenter.AllianceMembers.OfType<PlayerCharacter>()
#if DEBUG
Expand All @@ -174,9 +170,12 @@ private static async void SayHelloToParticipants()
.Where(p => DownloadHelper.ContributorsHash.Contains(p.Item2))
.Select(p => new ContributorChatEntity(p.player)), _comparer);

entities = entities.Union(players
.Where(p => DownloadHelper.UsersHash.Contains(p.Item2))
.Select(p => new UserChatEntity(p.player)), _comparer);
if (Service.Config.GetValue(Basic.Configuration.PluginConfigBool.SayHelloToUsers))
{
entities = entities.Union(players
.Where(p => DownloadHelper.UsersHash.Contains(p.Item2))
.Select(p => new UserChatEntity(p.player)), _comparer);
}

foreach (var entity in entities)
{
Expand Down

0 comments on commit 0efd7fd

Please sign in to comment.