-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
replace Boxed letters with alphabets
- Loading branch information
1 parent
498a949
commit 39df878
Showing
15 changed files
with
163 additions
and
309 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
Oops, something went wrong.