This repository was archived by the owner on May 6, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathSetting.cs
More file actions
154 lines (132 loc) · 4.53 KB
/
Setting.cs
File metadata and controls
154 lines (132 loc) · 4.53 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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
using IpcLibrary;
using ManiaRTRender.Utils;
using Sync.Tools;
using Sync.Tools.ConfigurationAttribute;
using System;
namespace ManiaRTRender
{
namespace ORTDPSetting
{
class SettingIni : IConfigurable
{
[Integer(MinValue = 1, MaxValue = 10000)]
public ConfigurationElement ListenInterval
{
set
{
ManiaRTRenderPlugin.Logger.I($"ORTDP's ListenInterval: {value}");
Setting.ORTDPListenInterval = int.Parse(value);
}
get => Setting.ORTDPListenInterval.ToString();
}
public void onConfigurationLoad()
{
Setting.SyncConfig(false);
}
public void onConfigurationReload()
{
}
public void onConfigurationSave()
{
}
}
}
class SettingIni : IConfigurable
{
[Integer(MinValue = 1, MaxValue = 40, RequireRestart = true)]
public ConfigurationElement Speed
{
set => Setting.Speed = int.Parse(value);
get => Setting.Speed.ToString();
}
[Integer(MinValue = 0, MaxValue = 480, RequireRestart = true)]
public ConfigurationElement FPS
{
set => Setting.FPS = int.Parse(value);
get => Setting.FPS.ToString();
}
[Integer(RequireRestart = true)]
public ConfigurationElement NoteHeight
{
set => Setting.NoteHeight = int.Parse(value);
get => Setting.NoteHeight.ToString();
}
[Integer(RequireRestart = true)]
public ConfigurationElement HitHeight
{
set => Setting.HitHeight = int.Parse(value);
get => Setting.HitHeight.ToString();
}
[Integer(RequireRestart = true)]
public ConfigurationElement NoteStrokeWidth
{
set => Setting.NoteStrokeWidth = int.Parse(value);
get => Setting.NoteStrokeWidth.ToString();
}
[String(RequireRestart = true)]
public ConfigurationElement BackgroundPicture
{
set => Setting.BackgroundPicture = value;
get => Setting.BackgroundPicture;
}
[String(RequireRestart = true)]
public ConfigurationElement BackgroundPictureInPlaying
{
set => Setting.BackgroundPictureInPlaying = value;
get => Setting.BackgroundPictureInPlaying;
}
[Float(MinValue = 0.0f, MaxValue = 1.0f)]
public ConfigurationElement RateSmoothFactor
{
set => Setting.RateSmoothFactor = float.Parse(value);
get => Setting.RateSmoothFactor.ToString();
}
public void onConfigurationLoad()
{
Setting.SyncConfig(true);
}
public void onConfigurationReload()
{
}
public void onConfigurationSave()
{
}
}
class Setting
{
public static int Speed = 25;
public static int FPS = 0;
public static int NoteHeight = 40;
public static int HitHeight = 5;
public static int NoteStrokeWidth = 3;
public static int ServerSleepPerCycle = 8;
public static float RateSmoothFactor = 0.8f;
public static string BackgroundPicture = "";
public static string BackgroundPictureInPlaying = "";
public static bool IsVSync => FPS == 0;
public static int ORTDPListenInterval = 100;
private static bool SettingLoaded = false;
private static bool ORTDPLoaded = false;
public static void SyncConfig(bool isSetting)
{
if (isSetting) SettingLoaded = true;
else ORTDPLoaded = true;
if (!SettingLoaded || !ORTDPLoaded) return;
RemoteConfig remoteConfig = new RemoteConfig
{
FPS = Setting.FPS,
HitHeight = Setting.HitHeight,
NoteHeight = Setting.NoteHeight,
NoteStrokeWidth = Setting.NoteStrokeWidth,
ORTDPListenInterval = Setting.ORTDPListenInterval,
Speed = Setting.Speed,
BackgroundPicture = Setting.BackgroundPicture,
BackgroundPictureInPlaying = Setting.BackgroundPictureInPlaying,
Loaded = true
};
byte[] buff = new byte[65536];
int length = remoteConfig.Write(ref buff, 0);
SerializeUtils.Save(RemoteConfig.ID, ref buff, length);
}
}
}