-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathPluginBehavior.cs
More file actions
128 lines (110 loc) · 4.72 KB
/
Copy pathPluginBehavior.cs
File metadata and controls
128 lines (110 loc) · 4.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
using System;
using UnityEngine;
using Utage;
namespace TSKHook;
public class PluginBehavior : MonoBehaviour
{
private static readonly float WaitTime = 1.0f;
private static readonly float CtrlWaitTime = 0.1f;
public static bool IsGameSpeedChanged { get; set; }
public static float CurrentGameSpeed { get; set; }
private static float LastGSExecuteTime { get; set; }
private static float LastFPSExecuteTime { get; set; }
private static float LastSkipExecuteTime { get; set; }
private void Update()
{
if (Input.GetKeyDown(KeyCode.F8))
{
CurrentGameSpeed = Time.timeScale + (float)TSKConfig.Speed;
Time.timeScale += (float)TSKConfig.Speed;
IsGameSpeedChanged = (int)Time.timeScale != 1;
LastGSExecuteTime = Time.deltaTime;
var currSpeed = Time.timeScale.ToString();
var text = "Game speed increased. Current: " + currSpeed + "x";
Plugin.Global.Log.LogInfo(text);
Notification.Popup("Game Speed", text);
}
if (Input.GetKeyDown(KeyCode.F7))
{
CurrentGameSpeed = Time.timeScale - (float)TSKConfig.Speed;
Time.timeScale -= (float)TSKConfig.Speed;
IsGameSpeedChanged = (int)Time.timeScale != 1;
LastGSExecuteTime = Time.deltaTime;
var currSpeed = Time.timeScale.ToString();
var text = "Game speed decreased. Current: " + currSpeed + "x";
Plugin.Global.Log.LogInfo(text);
Notification.Popup("Game Speed", text);
}
if (Input.GetKeyDown(KeyCode.F6))
{
CurrentGameSpeed = 1.0f;
Time.timeScale = 1.0f;
IsGameSpeedChanged = (int)Time.timeScale != 1;
var currSpeed = Time.timeScale.ToString();
var text = "Game speed restored. Current: " + currSpeed + "x";
Plugin.Global.Log.LogInfo(text);
Notification.Popup("Game Speed", text);
}
if (Input.GetKeyDown(KeyCode.F5))
{
CurrentGameSpeed = 0.0f;
Time.timeScale = 0.0f;
IsGameSpeedChanged = (int)Time.timeScale != 1;
LastGSExecuteTime = Time.deltaTime;
var currSpeed = Time.timeScale.ToString();
var text = "Game speed freezed. Current: " + currSpeed + "x";
Plugin.Global.Log.LogInfo(text);
Notification.Popup("Game Speed", text);
}
if (Input.GetKeyDown(KeyCode.F10))
{
Translation.chapterDicts = new();
Plugin.Global.Log.LogInfo("[Translator] cache cleared.");
Notification.Popup("Translation", "Translation cache cleared.");
}
if (Input.GetKeyDown(KeyCode.F11))
{
TSKConfig.TranslationEnabled = !TSKConfig.TranslationEnabled;
Plugin.Global.Log.LogInfo("Translation: " + (TSKConfig.TranslationEnabled ? "Enabled" : "Disabled"));
Notification.Popup("Translation", TSKConfig.TranslationEnabled ? "Enabled" : "Disabled");
}
if (Input.GetKeyDown(KeyCode.F12))
{
var username = Environment.UserName;
var timeFormat = DateTime.Now.ToString("yyyyMMdd_HHmmssff");
var location = string.Format("C:\\Users\\{0}\\Pictures\\tsk_{1}.png", username, timeFormat);
ScreenCapture.CaptureScreenshot(location);
Notification.SsPopup(location);
}
if (Input.GetKeyDown(KeyCode.F1))
{
TSKConfig.Read();
Window.Init();
Plugin.Global.Log.LogInfo("[Config] reloaded.");
}
LastSkipExecuteTime += Time.deltaTime;
if (LastSkipExecuteTime >= CtrlWaitTime && Input.GetKey(KeyCode.LeftControl) || LastSkipExecuteTime >= CtrlWaitTime && Input.GetKey(KeyCode.RightControl))
{
LastSkipExecuteTime = 0.0f;
AdvEngine advEngine = FindObjectOfType<AdvEngine>() as AdvEngine;
if (advEngine != null)
{
advEngine.page.EndPage();
}
}
LastGSExecuteTime += Time.deltaTime;
if (IsGameSpeedChanged && LastGSExecuteTime >= WaitTime && Time.timeScale != CurrentGameSpeed)
{
LastGSExecuteTime = 0.0f;
Time.timeScale = CurrentGameSpeed;
Plugin.Global.Log.LogInfo("Game speed changed. Reset to: " + CurrentGameSpeed + "x");
}
LastFPSExecuteTime += Time.deltaTime;
if (TSKConfig.FPS > 60 && LastFPSExecuteTime >= WaitTime && Application.targetFrameRate < TSKConfig.FPS)
{
LastFPSExecuteTime = 0.0f;
Application.targetFrameRate = TSKConfig.FPS;
Plugin.Global.Log.LogInfo("FPS changed. Reset to: " + TSKConfig.FPS);
}
}
}