Skip to content

Commit

Permalink
replace Boxed letters with alphabets
Browse files Browse the repository at this point in the history
  • Loading branch information
SlashNephy committed Apr 19, 2024
1 parent 498a949 commit 39df878
Show file tree
Hide file tree
Showing 15 changed files with 163 additions and 309 deletions.
43 changes: 0 additions & 43 deletions .github/workflows/ci-PowerUtils.yml

This file was deleted.

42 changes: 0 additions & 42 deletions .github/workflows/ci-Voiceroid2Talker.yml

This file was deleted.

42 changes: 41 additions & 1 deletion AetheryteLinkInChat/Solver/AetheryteSolver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Linq;
using System.Text.RegularExpressions;
using Dalamud.Divination.Common.Api.Dalamud;
using Dalamud.Game.Text;
using Dalamud.Game.Text.SeStringHandling;
using Dalamud.Game.Text.SeStringHandling.Payloads;
using Dalamud.Plugin.Services;
Expand Down Expand Up @@ -132,15 +133,54 @@ public void AppendGrandCompanyAetheryte(List<ITeleportPath> paths,

public World? DetectWorld(SeString message, World? currentWorld)
{
var text = string.Join(" ", message.Payloads.OfType<TextPayload>().Select(x => x.Text));

// trim texts within MapLinkPayload
const string linkPattern = ".*?\\)";
var rgx = new Regex(linkPattern);
var text = string.Join(" ", message.Payloads.OfType<TextPayload>().Select(x => x.Text));
text = rgx.Replace(text, "");
// replace Boxed letters with alphabets
text = text.Select(x => ReplaceSeIconChar(x)).ToString()!;

return worldSheet.Where(x => x.IsPublic)
.FirstOrDefault(x => text.Contains(x.Name.RawString, StringComparison.OrdinalIgnoreCase))
?? currentWorld;
}

private char ReplaceSeIconChar(char c)
{
return c switch
{
(char)SeIconChar.BoxedLetterA => 'A',
(char)SeIconChar.BoxedLetterB => 'B',
(char)SeIconChar.BoxedLetterC => 'C',
(char)SeIconChar.BoxedLetterD => 'D',
(char)SeIconChar.BoxedLetterE => 'E',
(char)SeIconChar.BoxedLetterF => 'F',
(char)SeIconChar.BoxedLetterG => 'G',
(char)SeIconChar.BoxedLetterH => 'H',
(char)SeIconChar.BoxedLetterI => 'I',
(char)SeIconChar.BoxedLetterJ => 'J',
(char)SeIconChar.BoxedLetterK => 'K',
(char)SeIconChar.BoxedLetterL => 'L',
(char)SeIconChar.BoxedLetterM => 'M',
(char)SeIconChar.BoxedLetterN => 'N',
(char)SeIconChar.BoxedLetterO => 'O',
(char)SeIconChar.BoxedLetterP => 'P',
(char)SeIconChar.BoxedLetterQ => 'Q',
(char)SeIconChar.BoxedLetterR => 'R',
(char)SeIconChar.BoxedLetterS => 'S',
(char)SeIconChar.BoxedLetterT => 'T',
(char)SeIconChar.BoxedLetterU => 'U',
(char)SeIconChar.BoxedLetterV => 'V',
(char)SeIconChar.BoxedLetterW => 'W',
(char)SeIconChar.BoxedLetterX => 'X',
(char)SeIconChar.BoxedLetterY => 'Y',
(char)SeIconChar.BoxedLetterZ => 'Z',
_ => c,
};
}

private IEnumerable<ITeleportPath[]> CalculateTeleportPaths(TerritoryType territoryType, Map map, uint depth = 0)
{
// 現在の探索深度が上限に達したら終了
Expand Down
28 changes: 0 additions & 28 deletions Calculator/Calculator.cs

This file was deleted.

16 changes: 0 additions & 16 deletions Calculator/Calculator.csproj

This file was deleted.

13 changes: 0 additions & 13 deletions Calculator/Calculator.json

This file was deleted.

22 changes: 0 additions & 22 deletions Calculator/packages.lock.json

This file was deleted.

6 changes: 0 additions & 6 deletions Divination.sln
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FaloopIntegration", "Faloop
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "InstanceIDViewer", "InstanceIDViewer\InstanceIDViewer.csproj", "{42E83F55-1774-4BBD-BED9-149252532234}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PowerUtils", "PowerUtils\PowerUtils.csproj", "{0D9BF128-A386-46E9-A042-AB9AAFC39282}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TwitterIntegration", "TwitterIntegration\TwitterIntegration.csproj", "{928BCFCF-38FF-442D-B8F8-0C4308EB6A36}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Voiceroid2Talker", "Voiceroid2Talker\Voiceroid2Talker.csproj", "{377EF695-D2F0-4A14-BD67-6B0CBAD78FCD}"
Expand Down Expand Up @@ -59,10 +57,6 @@ Global
{42E83F55-1774-4BBD-BED9-149252532234}.Debug|Any CPU.Build.0 = Debug|x64
{42E83F55-1774-4BBD-BED9-149252532234}.Release|Any CPU.ActiveCfg = Release|x64
{42E83F55-1774-4BBD-BED9-149252532234}.Release|Any CPU.Build.0 = Release|x64
{0D9BF128-A386-46E9-A042-AB9AAFC39282}.Debug|Any CPU.ActiveCfg = Debug|x64
{0D9BF128-A386-46E9-A042-AB9AAFC39282}.Debug|Any CPU.Build.0 = Debug|x64
{0D9BF128-A386-46E9-A042-AB9AAFC39282}.Release|Any CPU.ActiveCfg = Release|x64
{0D9BF128-A386-46E9-A042-AB9AAFC39282}.Release|Any CPU.Build.0 = Release|x64
{928BCFCF-38FF-442D-B8F8-0C4308EB6A36}.Debug|Any CPU.ActiveCfg = Debug|x64
{928BCFCF-38FF-442D-B8F8-0C4308EB6A36}.Debug|Any CPU.Build.0 = Debug|x64
{928BCFCF-38FF-442D-B8F8-0C4308EB6A36}.Release|Any CPU.ActiveCfg = Release|x64
Expand Down
71 changes: 71 additions & 0 deletions Horoscope/Modules/PowerSchemeCommand.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
using System;
using System.Runtime.InteropServices;
using Dalamud.Game.Command;
using Divination.Horoscope.Modules;

namespace Divination.Horoscope;

public class PowerSchemeCommand : IModule
{
public string Name => "/power Command";
public string Description => "Set active Windows power scheme.";

private const string CommandName = "/power";

public void Enable()
{
Horoscope.Instance.Dalamud.CommandManager.AddHandler(CommandName, new CommandInfo(OnDispatched)
{
HelpMessage = Description,
});
}

public void Disable()
{
Horoscope.Instance.Dalamud.CommandManager.RemoveHandler(CommandName);
}

private readonly Guid powerSaverSchemeId = Guid.Parse("a1841308-3541-4fab-bc81-f71556f20b4a");
private readonly Guid balancedSchemeId = Guid.Parse("381b4222-f694-41f0-9685-ff5bb260df2e");
private readonly Guid highPerformanceSchemeId = Guid.Parse("8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c");

private void OnDispatched(string _, string arguments)
{
switch (arguments)
{
case "power_saver":
case "save":
case "saving":
case "saver":
case "s":
SetActivePowerScheme(powerSaverSchemeId, "省電力");
break;
case "balanced":
case "balance":
case "b":
SetActivePowerScheme(balancedSchemeId, "バランス");
break;
case "high_performance":
case "performance":
case "perf":
case "p":
SetActivePowerScheme(highPerformanceSchemeId, "高パフォーマンス");
break;
default:
Horoscope.Instance.Divination.Chat.PrintError("引数が正しくありません。");
break;
}
}

private void SetActivePowerScheme(Guid schemeId, string name)
{
Win32Api.PowerSetActiveScheme(IntPtr.Zero, schemeId);
Horoscope.Instance.Divination.Chat.Print($"電源プランを「{name}」に設定しました。");
}

private static class Win32Api
{
[DllImport("PowrProf.dll", CharSet = CharSet.Unicode)]
public static extern uint PowerSetActiveScheme(IntPtr rootPowerKey, [MarshalAs(UnmanagedType.LPStruct)] Guid schemeGuid);
}
}
51 changes: 51 additions & 0 deletions Horoscope/Modules/TurnOffScreenCommand.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
using System.Runtime.InteropServices;
using System.Threading.Tasks;
using Dalamud.Game.Command;
using Divination.Horoscope.Modules;

namespace Divination.Horoscope;

public partial class TurnOffScreenCommand : IModule
{
public string Name => "/turnoff Command";
public string Description => "Turn off screen.";

private const string CommandName = "/turnoff";

public void Enable()
{
Horoscope.Instance.Dalamud.CommandManager.AddHandler(CommandName, new CommandInfo(OnDispatched)
{
HelpMessage = Description,
});
}

public void Disable()
{
Horoscope.Instance.Dalamud.CommandManager.RemoveHandler(CommandName);
}

private void OnDispatched(string _, string arguments)
{
Task.Run(async () =>
{
var seconds = int.TryParse(arguments, out var value) ? value : 5;
Horoscope.Instance.Divination.Chat.Print($"{seconds}秒後にディスプレイの電源がオフになります。");
await Task.Delay(seconds * 1000);
Win32Api.SendMessage(-1, Win32Api.WM_SYSCOMMAND, Win32Api.SC_MONITORPOWER, Win32Api.MONITOR_OFF);
});
}

private static partial class Win32Api
{
public const int WM_SYSCOMMAND = 0x112;
public const int SC_MONITORPOWER = 0xF170;
public const int MONITOR_OFF = 2;

[LibraryImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
public static partial bool SendMessage(int hWnd, int msg, int wParam, int lParam);
}
}
Loading

0 comments on commit 39df878

Please sign in to comment.