1+ using System . Text . Json . Serialization ;
2+ using Semver ;
3+
4+ namespace OpenShock . ShockOSC . MigrationInstaller . OldSchema ;
5+
6+ public sealed class ShockOscConfig
7+ {
8+ public OscConf Osc { get ; set ; } = new ( ) ;
9+ public BehaviourConf Behaviour { get ; set ; } = new ( ) ;
10+ public OpenShockConf OpenShock { get ; set ; } = new ( ) ;
11+ public ChatboxConf Chatbox { get ; set ; } = new ( ) ;
12+ public IDictionary < Guid , Group > Groups { get ; set ; } = new Dictionary < Guid , Group > ( ) ;
13+
14+ public AppConfig App { get ; set ; } = new ( ) ;
15+ }
16+
17+ public sealed class AppConfig
18+ {
19+ public bool CloseToTray { get ; set ; } = true ;
20+ public bool DiscordPreview { get ; set ; } = false ;
21+
22+ public UpdateChannel UpdateChannel { get ; set ; } = UpdateChannel . Release ;
23+ public SemVersion ? LastIgnoredVersion { get ; set ; } = null ;
24+ }
25+
26+ public enum UpdateChannel
27+ {
28+ Release ,
29+ PreRelease
30+ }
31+
32+
33+ public sealed class BehaviourConf : SharedBehaviourConfig
34+ {
35+ public uint HoldTime { get ; set ; } = 250 ;
36+ public bool DisableWhileAfk { get ; set ; } = true ;
37+ public bool ForceUnmute { get ; set ; }
38+ }
39+
40+ public enum BoneAction
41+ {
42+ None = 0 ,
43+ Shock = 1 ,
44+ Vibrate = 2 ,
45+ Sound = 3
46+ }
47+
48+ public class JsonRange < T > where T : struct
49+ {
50+ public required T Min { get ; set ; }
51+ public required T Max { get ; set ; }
52+ }
53+
54+ public sealed class OpenShockConf
55+ {
56+ public Uri Backend { get ; set ; } = new ( "https://api.openshock.app" ) ;
57+ public string Token { get ; set ; } = "" ;
58+ public IReadOnlyDictionary < Guid , ShockerConf > Shockers { get ; set ; } = new Dictionary < Guid , ShockerConf > ( ) ;
59+
60+ public sealed class ShockerConf
61+ {
62+ public bool Enabled { get ; set ; } = true ;
63+ }
64+ }
65+
66+ public sealed class OscConf
67+ {
68+ public bool Hoscy { get ; set ; } = false ;
69+ public ushort HoscySendPort { get ; set ; } = 9001 ;
70+ public bool QuestSupport { get ; set ; } = false ;
71+ public bool OscQuery { get ; set ; } = true ;
72+ public ushort OscSendPort { get ; set ; } = 9000 ;
73+ public ushort OscReceivePort { get ; set ; } = 9001 ;
74+ }
75+
76+
77+ public class SharedBehaviourConfig
78+ {
79+ public bool RandomIntensity { get ; set ; }
80+ public bool RandomDuration { get ; set ; }
81+
82+ public JsonRange < ushort > DurationRange { get ; set ; } = new JsonRange < ushort > { Min = 1000 , Max = 5000 } ;
83+ public JsonRange < byte > IntensityRange { get ; set ; } = new JsonRange < byte > { Min = 1 , Max = 30 } ;
84+ public byte FixedIntensity { get ; set ; } = 50 ;
85+ public ushort FixedDuration { get ; set ; } = 2000 ;
86+
87+ public uint CooldownTime { get ; set ; } = 5000 ;
88+
89+ public BoneAction WhileBoneHeld { get ; set ; } = BoneAction . Vibrate ;
90+ public BoneAction WhenBoneReleased { get ; set ; } = BoneAction . Shock ;
91+
92+ public uint ? BoneHeldDurationLimit { get ; set ; } = null ;
93+ }
94+
95+ public sealed class Group : SharedBehaviourConfig
96+ {
97+ public required string Name { get ; set ; }
98+ public IList < Guid > Shockers { get ; set ; } = new List < Guid > ( ) ;
99+ public bool OverrideIntensity { get ; set ; }
100+ public bool OverrideDuration { get ; set ; }
101+ public bool OverrideCooldownTime { get ; set ; }
102+
103+ public bool OverrideBoneHeldAction { get ; set ; }
104+ public bool OverrideBoneReleasedAction { get ; set ; }
105+
106+ public bool OverrideBoneHeldDurationLimit { get ; set ; }
107+ }
108+
109+ public sealed class ChatboxConf
110+ {
111+ public bool Enabled { get ; set ; } = true ;
112+ public string Prefix { get ; set ; } = "[ShockOSC] " ;
113+ public bool DisplayRemoteControl { get ; set ; } = true ;
114+
115+ public bool TimeoutEnabled { get ; set ; } = true ;
116+ public uint Timeout { get ; set ; } = 5000 ;
117+
118+ [ JsonIgnore ]
119+ public TimeSpan TimeoutTimeSpan
120+ {
121+ get => TimeSpan . FromMilliseconds ( Timeout ) ;
122+ set => Timeout = ( uint ) value . TotalMilliseconds ;
123+ }
124+
125+ public HoscyMessageType HoscyType { get ; set ; } = HoscyMessageType . Message ;
126+
127+ public string IgnoredKillSwitchActive { get ; set ; } = "Ignoring Shock, kill switch is active" ;
128+ public string IgnoredAfk { get ; set ; } = "Ignoring Shock, user is afk" ;
129+
130+ public IDictionary < ControlType , ControlTypeConf > Types { get ; set ; } =
131+ new Dictionary < ControlType , ControlTypeConf >
132+ {
133+ {
134+ ControlType . Stop , new ControlTypeConf
135+ {
136+ Enabled = true ,
137+ Local = "⏸ '{GroupName}'" ,
138+ Remote = "⏸ '{ShockerName}' by {Name}" ,
139+ RemoteWithCustomName = "⏸ '{ShockerName}' by {CustomName} [{Name}]"
140+ }
141+ } ,
142+ {
143+ ControlType . Shock , new ControlTypeConf
144+ {
145+ Enabled = true ,
146+ Local = "⚡ '{GroupName}' {Intensity}%:{DurationSeconds}s" ,
147+ Remote = "⚡ '{ShockerName}' {Intensity}%:{DurationSeconds}s by {Name}" ,
148+ RemoteWithCustomName =
149+ "⚡ '{ShockerName}' {Intensity}%:{DurationSeconds}s by {CustomName} [{Name}]"
150+ }
151+ } ,
152+ {
153+ ControlType . Vibrate , new ControlTypeConf
154+ {
155+ Enabled = true ,
156+ Local = "〜 '{GroupName}' {Intensity}%:{DurationSeconds}s" ,
157+ Remote = "〜 '{ShockerName}' {Intensity}%:{DurationSeconds}s by {Name}" ,
158+ RemoteWithCustomName =
159+ "〜 '{ShockerName}' {Intensity}%:{DurationSeconds}s by {CustomName} [{Name}]"
160+ }
161+ } ,
162+ {
163+ ControlType . Sound , new ControlTypeConf
164+ {
165+ Enabled = true ,
166+ Local = "🔈 '{GroupName}' {Intensity}%:{DurationSeconds}s" ,
167+ Remote = "🔈 '{ShockerName}' {Intensity}%:{DurationSeconds}s by {Name}" ,
168+ RemoteWithCustomName =
169+ "🔈 '{ShockerName}' {Intensity}%:{DurationSeconds}s by {CustomName} [{Name}]"
170+ }
171+ }
172+ } ;
173+
174+ public sealed class ControlTypeConf
175+ {
176+ public required bool Enabled { get ; set ; }
177+ public required string Local { get ; set ; }
178+ public required string Remote { get ; set ; }
179+ public required string RemoteWithCustomName { get ; set ; }
180+ }
181+
182+ public enum HoscyMessageType
183+ {
184+ Message ,
185+ Notification
186+ }
187+ }
0 commit comments