Skip to content

Commit 0c24500

Browse files
committed
[F] Revert
1 parent 9592771 commit 0c24500

File tree

1 file changed

+16
-74
lines changed

1 file changed

+16
-74
lines changed
Lines changed: 16 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,30 @@
1-
using System.Collections.Generic;
1+
using System.Threading;
22
using AquaMai.Config.Attributes;
33
using HarmonyLib;
4+
using IO;
45
using Manager.UserDatas;
56

67
namespace AquaMai.Mods.GameSettings;
78

89
[ConfigSection(
9-
en: "Globally adjust A/B judgment or increase touch delay.",
10-
zh: "全局调整 A/B 判或增加触摸延迟")]
10+
en: "Globally adjust A/B judgment (unit same as in-game options) or increase touch delay.",
11+
zh: "全局调整 A/B 判(单位和游戏里一样)或增加触摸延迟")]
1112
public class JudgeAdjust
1213
{
1314
[ConfigEntry(
14-
en: "Adjust A judgment (unit same as in-game options).",
15-
zh: "调整 A 判(单位和游戏里一样)")]
15+
en: "Adjust A judgment.",
16+
zh: "调整 A 判")]
1617
private static readonly double a = 0;
1718

1819
[ConfigEntry(
19-
en: "Adjust B judgment (unit same as in-game options).",
20-
zh: "调整 B 判(单位和游戏里一样)")]
20+
en: "Adjust B judgment.",
21+
zh: "调整 B 判")]
2122
private static readonly double b = 0;
2223

2324
[ConfigEntry(
24-
en: "Increase touch delay (ms) for 1P.",
25-
zh: "增加触摸延迟,单位是毫秒(1P)全新队列实现,不会吃键")]
26-
private static readonly uint touchDelay1P = 0;
27-
28-
[ConfigEntry(
29-
en: "Increase touch delay (ms) for 2P.",
30-
zh: "增加触摸延迟,单位是毫秒(2P)全新队列实现,不会吃键")]
31-
private static readonly uint touchDelay2P = 0;
25+
en: "Increase touch delay.",
26+
zh: "增加触摸延迟(不建议使用)")]
27+
private static readonly uint touchDelay = 0;
3228

3329
[HarmonyPostfix]
3430
[HarmonyPatch(typeof(UserOption), "GetAdjustMSec")]
@@ -44,65 +40,11 @@ public static void GetJudgeTimingFrame(ref float __result)
4440
__result += (float)b;
4541
}
4642

47-
private static readonly Dictionary<uint, Queue<DelayedTouchData>> _delayedTouchData = new();
48-
private static readonly object _lockObject = new object();
49-
50-
private struct DelayedTouchData
51-
{
52-
public ulong Data;
53-
public uint Counter;
54-
public long Timestamp;
55-
}
56-
5743
[HarmonyPrefix]
58-
[HarmonyPatch(typeof(Manager.InputManager), "SetNewTouchPanel")]
59-
public static bool SetNewTouchPanel(uint index, ref ulong inputData, ref uint counter, ref bool __result)
44+
[HarmonyPatch(typeof(NewTouchPanel), "Recv")]
45+
public static void NewTouchPanelRecv()
6046
{
61-
var touchDelay = index switch
62-
{
63-
0 => touchDelay1P,
64-
1 => touchDelay2P,
65-
_ => 0u,
66-
};
67-
if (touchDelay <= 0)
68-
{
69-
return true;
70-
}
71-
72-
lock (_lockObject)
73-
{
74-
var currentTime = System.DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
75-
var dequeueCount = 0;
76-
77-
if(!_delayedTouchData.ContainsKey(index))
78-
{
79-
_delayedTouchData[index] = new Queue<DelayedTouchData>();
80-
}
81-
82-
_delayedTouchData[index].Enqueue(new DelayedTouchData
83-
{
84-
Data = inputData,
85-
Counter = counter,
86-
Timestamp = currentTime,
87-
});
88-
89-
var ret = false;
90-
foreach (var data in _delayedTouchData[index])
91-
{
92-
if (currentTime - data.Timestamp < touchDelay) break;
93-
ret = true;
94-
dequeueCount++;
95-
96-
inputData = data.Data;
97-
counter = data.Counter;
98-
}
99-
100-
for (var i = 0; i < dequeueCount; i++)
101-
{
102-
_delayedTouchData[index].Dequeue();
103-
}
104-
105-
return ret;
106-
}
47+
if (touchDelay <= 0) return;
48+
Thread.Sleep((int)touchDelay);
10749
}
108-
}
50+
}

0 commit comments

Comments
 (0)