[F] Revert

This commit is contained in:
Clansty
2025-09-15 23:04:09 +08:00
parent 9592771f52
commit 0c245008cb

View File

@@ -1,34 +1,30 @@
using System.Collections.Generic;
using System.Threading;
using AquaMai.Config.Attributes;
using HarmonyLib;
using IO;
using Manager.UserDatas;
namespace AquaMai.Mods.GameSettings;
[ConfigSection(
en: "Globally adjust A/B judgment or increase touch delay.",
zh: "全局调整 A/B 判或增加触摸延迟")]
en: "Globally adjust A/B judgment (unit same as in-game options) or increase touch delay.",
zh: "全局调整 A/B 判(单位和游戏里一样)或增加触摸延迟")]
public class JudgeAdjust
{
[ConfigEntry(
en: "Adjust A judgment (unit same as in-game options).",
zh: "调整 A 判(单位和游戏里一样)")]
en: "Adjust A judgment.",
zh: "调整 A 判")]
private static readonly double a = 0;
[ConfigEntry(
en: "Adjust B judgment (unit same as in-game options).",
zh: "调整 B 判(单位和游戏里一样)")]
en: "Adjust B judgment.",
zh: "调整 B 判")]
private static readonly double b = 0;
[ConfigEntry(
en: "Increase touch delay (ms) for 1P.",
zh: "增加触摸延迟单位是毫秒1P全新队列实现不会吃键")]
private static readonly uint touchDelay1P = 0;
[ConfigEntry(
en: "Increase touch delay (ms) for 2P.",
zh: "增加触摸延迟单位是毫秒2P全新队列实现不会吃键")]
private static readonly uint touchDelay2P = 0;
en: "Increase touch delay.",
zh: "增加触摸延迟(不建议使用)")]
private static readonly uint touchDelay = 0;
[HarmonyPostfix]
[HarmonyPatch(typeof(UserOption), "GetAdjustMSec")]
@@ -44,65 +40,11 @@ public class JudgeAdjust
__result += (float)b;
}
private static readonly Dictionary<uint, Queue<DelayedTouchData>> _delayedTouchData = new();
private static readonly object _lockObject = new object();
private struct DelayedTouchData
{
public ulong Data;
public uint Counter;
public long Timestamp;
}
[HarmonyPrefix]
[HarmonyPatch(typeof(Manager.InputManager), "SetNewTouchPanel")]
public static bool SetNewTouchPanel(uint index, ref ulong inputData, ref uint counter, ref bool __result)
[HarmonyPatch(typeof(NewTouchPanel), "Recv")]
public static void NewTouchPanelRecv()
{
var touchDelay = index switch
{
0 => touchDelay1P,
1 => touchDelay2P,
_ => 0u,
};
if (touchDelay <= 0)
{
return true;
}
lock (_lockObject)
{
var currentTime = System.DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
var dequeueCount = 0;
if(!_delayedTouchData.ContainsKey(index))
{
_delayedTouchData[index] = new Queue<DelayedTouchData>();
}
_delayedTouchData[index].Enqueue(new DelayedTouchData
{
Data = inputData,
Counter = counter,
Timestamp = currentTime,
});
var ret = false;
foreach (var data in _delayedTouchData[index])
{
if (currentTime - data.Timestamp < touchDelay) break;
ret = true;
dequeueCount++;
inputData = data.Data;
counter = data.Counter;
}
for (var i = 0; i < dequeueCount; i++)
{
_delayedTouchData[index].Dequeue();
}
return ret;
}
if (touchDelay <= 0) return;
Thread.Sleep((int)touchDelay);
}
}
}