mirror of
https://github.com/MewoLab/AquaDX.git
synced 2026-02-09 13:47:26 +08:00
更新了配置文件格式,原有的配置文件将被自动无缝迁移,详情请见新的配置文件中的注释(例外:`SlideJudgeTweak` 不再默认启用) 旧配置文件将被重命名备份,如果更新到此版本遇到 Bug 请联系我们 Updated configuration file schema. The old config file will be migrated automatically and seamlessly. See the comments in the new configuration file for details. (Except for `SlideJudgeTweak` is no longer enabled by default) Your old configuration file will be renamed as a backup. If you encounter any bug with this version, please contact us.
69 lines
1.9 KiB
C#
69 lines
1.9 KiB
C#
using System;
|
|
using System.Diagnostics;
|
|
using AquaMai.Config.Attributes;
|
|
using HarmonyLib;
|
|
using Process;
|
|
|
|
namespace AquaMai.Mods.Fancy;
|
|
|
|
[ConfigSection(
|
|
en: "Triggers for executing commands at certain events.",
|
|
zh: "在一定时机执行命令的触发器")]
|
|
public class Triggers
|
|
{
|
|
[ConfigEntry(
|
|
en: "Execute some command on game idle.",
|
|
zh: """
|
|
在游戏闲置的时候执行指定的命令脚本
|
|
比如说可以在游戏闲置是降低显示器的亮度
|
|
""")]
|
|
private static readonly string execOnIdle = "";
|
|
|
|
[ConfigEntry(
|
|
en: "Execute some command on game start.",
|
|
zh: "在玩家登录的时候执行指定的命令脚本")]
|
|
private static readonly string execOnEntry = "";
|
|
|
|
[HarmonyPrefix]
|
|
[HarmonyPatch(typeof(AdvertiseProcess), "OnStart")]
|
|
public static void AdvertiseProcessPreStart()
|
|
{
|
|
if (!string.IsNullOrWhiteSpace(execOnIdle))
|
|
{
|
|
Exec(execOnIdle);
|
|
}
|
|
}
|
|
|
|
[HarmonyPrefix]
|
|
[HarmonyPatch(typeof(EntryProcess), "OnStart")]
|
|
public static void EntryProcessPreStart()
|
|
{
|
|
if (!string.IsNullOrWhiteSpace(execOnEntry))
|
|
{
|
|
Exec(execOnEntry);
|
|
}
|
|
}
|
|
|
|
[HarmonyPrefix]
|
|
[HarmonyPatch(typeof(MusicSelectProcess), "OnStart")]
|
|
public static void MusicSelectProcessPreStart()
|
|
{
|
|
if (!string.IsNullOrWhiteSpace(execOnEntry))
|
|
{
|
|
Exec(execOnEntry);
|
|
}
|
|
}
|
|
|
|
private static void Exec(string command)
|
|
{
|
|
var process = new System.Diagnostics.Process();
|
|
process.StartInfo.FileName = "cmd.exe";
|
|
process.StartInfo.Arguments = "/c " + command;
|
|
process.StartInfo.UseShellExecute = true;
|
|
process.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
|
|
process.StartInfo.WorkingDirectory = Environment.CurrentDirectory;
|
|
|
|
process.Start();
|
|
}
|
|
}
|