Skip to content
This repository was archived by the owner on Sep 11, 2023. It is now read-only.

Commit 172b7cb

Browse files
committed
Add option to disable discord rpc. Closes #31
1 parent 6f9deee commit 172b7cb

File tree

5 files changed

+619
-451
lines changed

5 files changed

+619
-451
lines changed

Interop/OptionsControl.cs

Lines changed: 149 additions & 138 deletions
Original file line numberDiff line numberDiff line change
@@ -6,184 +6,187 @@
66

77
namespace Spcode //leave this here instead of .Interop because of reasons...
88
{
9-
[Serializable]
9+
[Serializable]
1010
public class OptionsControl
1111
{
1212
public static int SVersion = 11;
13-
public int Version = 11;
14-
15-
public byte[] Program_CryptoKey = null;
16-
public bool Program_UseHardwareSalts = true;
17-
18-
public bool Program_UseHardwareAcceleration = true;
13+
public bool Editor_AgressiveIndentation = true;
14+
public bool Editor_AutoCloseBrackets = true;
15+
public bool Editor_AutoCloseStringChars = true;
16+
public bool Editor_AutoSave;
17+
public int Editor_AutoSaveInterval = 5 * 60;
18+
public string Editor_FontFamily = "Consolas";
19+
public double Editor_FontSize = 16.0;
20+
public int Editor_IndentationSize = 4;
21+
public bool Editor_ReformatLineAfterSemicolon = true;
22+
public bool Editor_ReplaceTabsToWhitespace;
23+
public double Editor_ScrollLines = 4.0;
24+
public bool Editor_ShowSpaces;
25+
public bool Editor_ShowTabs;
1926

20-
public bool Program_CheckForUpdates = true;
27+
public bool Editor_WordWrap = false;
2128

22-
public string Program_SelectedConfig = string.Empty;
29+
public string Language = string.Empty;
2330

24-
public bool Program_OpenCustomIncludes = false;
25-
public bool Program_OpenIncludesRecursively = false;
31+
public string[] LastOpenFiles = new string[0];
2632

27-
public bool Program_DynamicISAC = true;
33+
public string Program_AccentColor = "Red";
2834

29-
public string Program_AccentColor = "Red";
30-
public string Program_Theme = "BaseDark";
35+
public bool Program_CheckForUpdates = true;
3136

32-
public string Program_ObjectBrowserDirectory = string.Empty;
33-
public double Program_ObjectbrowserWidth = 300.0;
37+
public byte[] Program_CryptoKey;
38+
public bool Program_DiscordPresence = true;
3439

35-
public bool UI_Animations = true;
36-
public bool UI_ShowToolBar = false;
40+
public bool Program_DynamicISAC = true;
3741

38-
public bool Editor_WordWrap = false;
39-
public double Editor_FontSize = 16.0;
40-
public string Editor_FontFamily = "Consolas";
41-
public double Editor_ScrollLines = 4.0;
42-
public bool Editor_AgressiveIndentation = true;
43-
public bool Editor_ReformatLineAfterSemicolon = true;
44-
public bool Editor_ReplaceTabsToWhitespace = false;
45-
public bool Editor_AutoCloseBrackets = true;
46-
public bool Editor_AutoCloseStringChars = true;
47-
public bool Editor_ShowSpaces = false;
48-
public bool Editor_ShowTabs = false;
49-
public int Editor_IndentationSize = 4;
50-
public bool Editor_AutoSave = false;
51-
public int Editor_AutoSaveInterval = 5 * 60;
42+
public string Program_ObjectBrowserDirectory = string.Empty;
43+
public double Program_ObjectbrowserWidth = 300.0;
5244

53-
public string[] LastOpenFiles = new string[0];
45+
public bool Program_OpenCustomIncludes = false;
46+
public bool Program_OpenIncludesRecursively = false;
5447

55-
public bool SH_HighlightDeprecateds = true;
48+
public string Program_SelectedConfig = string.Empty;
49+
public string Program_Theme = "BaseDark";
5650

57-
public string Language = string.Empty;
51+
public bool Program_UseHardwareAcceleration = true;
52+
public bool Program_UseHardwareSalts = true;
53+
public SerializeableColor SH_Chars = new SerializeableColor(0xFF, 0xD6, 0x9C, 0x85);
5854

5955
public SerializeableColor SH_Comments = new SerializeableColor(0xFF, 0x57, 0xA6, 0x49);
6056
public SerializeableColor SH_CommentsMarker = new SerializeableColor(0xFF, 0xFF, 0x20, 0x20);
61-
public SerializeableColor SH_Strings = new SerializeableColor(0xFF, 0xF4, 0x6B, 0x6C);
62-
public SerializeableColor SH_PreProcessor = new SerializeableColor(0xFF, 0x7E, 0x7E, 0x7E);
63-
public SerializeableColor SH_Types = new SerializeableColor(0xFF, 0x28, 0x90, 0xB0); //56 9C D5
64-
public SerializeableColor SH_TypesValues = new SerializeableColor(0xFF, 0x56, 0x9C, 0xD5);
65-
public SerializeableColor SH_Keywords = new SerializeableColor(0xFF, 0x56, 0x9C, 0xD5);
57+
public SerializeableColor SH_Constants = new SerializeableColor(0xFF, 0xBC, 0x62, 0xC5);
6658
public SerializeableColor SH_ContextKeywords = new SerializeableColor(0xFF, 0x56, 0x9C, 0xD5);
67-
public SerializeableColor SH_Chars = new SerializeableColor(0xFF, 0xD6, 0x9C, 0x85);
68-
public SerializeableColor SH_UnkownFunctions = new SerializeableColor(0xFF, 0x45, 0x85, 0xC5);
69-
public SerializeableColor SH_Numbers = new SerializeableColor(0xFF, 0x97, 0x97, 0x97);
70-
public SerializeableColor SH_SpecialCharacters = new SerializeableColor(0xFF, 0x8F, 0x8F, 0x8F);
7159
public SerializeableColor SH_Deprecated = new SerializeableColor(0xFF, 0xFF, 0x00, 0x00);
72-
public SerializeableColor SH_Constants = new SerializeableColor(0xFF, 0xBC, 0x62, 0xC5);
7360
public SerializeableColor SH_Functions = new SerializeableColor(0xFF, 0x56, 0x9C, 0xD5);
61+
62+
public bool SH_HighlightDeprecateds = true;
63+
public SerializeableColor SH_Keywords = new SerializeableColor(0xFF, 0x56, 0x9C, 0xD5);
7464
public SerializeableColor SH_Methods = new SerializeableColor(0xFF, 0x3B, 0xC6, 0x7E);
65+
public SerializeableColor SH_Numbers = new SerializeableColor(0xFF, 0x97, 0x97, 0x97);
66+
public SerializeableColor SH_PreProcessor = new SerializeableColor(0xFF, 0x7E, 0x7E, 0x7E);
67+
public SerializeableColor SH_SpecialCharacters = new SerializeableColor(0xFF, 0x8F, 0x8F, 0x8F);
68+
public SerializeableColor SH_Strings = new SerializeableColor(0xFF, 0xF4, 0x6B, 0x6C);
69+
public SerializeableColor SH_Types = new SerializeableColor(0xFF, 0x28, 0x90, 0xB0); //56 9C D5
70+
public SerializeableColor SH_TypesValues = new SerializeableColor(0xFF, 0x56, 0x9C, 0xD5);
71+
public SerializeableColor SH_UnkownFunctions = new SerializeableColor(0xFF, 0x45, 0x85, 0xC5);
72+
73+
public bool UI_Animations = true;
74+
public bool UI_ShowToolBar;
75+
public int Version = 11;
7576

7677
public void FillNullToDefaults()
7778
{
78-
if (this.Program_CryptoKey == null)
79-
{
80-
this.ReCreateCryptoKey();
81-
}
82-
if (OptionsControl.SVersion > this.Version)
79+
if (Program_CryptoKey == null) ReCreateCryptoKey();
80+
81+
if (SVersion > Version)
8382
{
84-
Program.ClearUpdateFiles();
85-
if (Version < 2)
86-
{
87-
this.UI_ShowToolBar = false;
88-
}
89-
if (Version < 3)
90-
{
91-
this.Editor_ReformatLineAfterSemicolon = true;
92-
this.Editor_ScrollLines = 4.0;
93-
this.Program_CheckForUpdates = true;
94-
}
95-
if (Version < 4)
96-
{
97-
this.Editor_ReplaceTabsToWhitespace = false;
98-
}
99-
if (Version < 5)
100-
{
101-
this.Program_DynamicISAC = true;
102-
}
103-
if (Version < 7)
104-
{
105-
this.Program_AccentColor = "Red";
106-
this.Program_Theme = "BaseDark";
107-
NormalizeSHColors();
108-
}
109-
if (Version < 8)
110-
{
111-
Editor_AutoCloseBrackets = true;
112-
}
113-
if (Version < 9)
114-
{
115-
Editor_AutoCloseStringChars = true;
116-
Editor_ShowSpaces = false;
117-
Editor_ShowTabs = false;
118-
Editor_IndentationSize = 4;
119-
Language = "";
120-
Program_ObjectBrowserDirectory = string.Empty;
121-
Program_ObjectbrowserWidth = 300.0;
122-
Editor_AutoSave = false;
123-
Editor_AutoSaveInterval = 5 * 60;
124-
this.ReCreateCryptoKey();
125-
Program.MakeRCCKAlert();
83+
Program.ClearUpdateFiles();
84+
if (Version < 2) UI_ShowToolBar = false;
85+
86+
if (Version < 3)
87+
{
88+
Editor_ReformatLineAfterSemicolon = true;
89+
Editor_ScrollLines = 4.0;
90+
Program_CheckForUpdates = true;
12691
}
127-
if (Version < 10)
92+
93+
if (Version < 4) Editor_ReplaceTabsToWhitespace = false;
94+
95+
if (Version < 5) Program_DynamicISAC = true;
96+
97+
if (Version < 7)
12898
{
129-
Program_UseHardwareSalts = true;
99+
Program_AccentColor = "Red";
100+
Program_Theme = "BaseDark";
101+
NormalizeSHColors();
130102
}
131-
if (Version < 11)
103+
104+
if (Version < 8) Editor_AutoCloseBrackets = true;
105+
106+
if (Version < 9)
132107
{
133-
if (this.Program_AccentColor == "Cyan")
134-
this.Program_AccentColor = "Blue";
108+
Editor_AutoCloseStringChars = true;
109+
Editor_ShowSpaces = false;
110+
Editor_ShowTabs = false;
111+
Editor_IndentationSize = 4;
112+
Language = "";
113+
Program_ObjectBrowserDirectory = string.Empty;
114+
Program_ObjectbrowserWidth = 300.0;
115+
Editor_AutoSave = false;
116+
Editor_AutoSaveInterval = 5 * 60;
117+
ReCreateCryptoKey();
118+
Program.MakeRCCKAlert();
135119
}
120+
121+
if (Version < 10) Program_UseHardwareSalts = true;
122+
123+
if (Version < 11)
124+
if (Program_AccentColor == "Cyan")
125+
Program_AccentColor = "Blue";
126+
136127
//new Optionsversion - reset new fields to default
137-
this.Version = OptionsControl.SVersion; //then Update Version afterwars
128+
Version = SVersion; //then Update Version afterwars
138129
}
139130
}
140131

141132
public void ReCreateCryptoKey()
142133
{
143-
byte[] buffer = new byte[16];
144-
using (RNGCryptoServiceProvider cryptoRandomProvider = new RNGCryptoServiceProvider()) //generate global unique cryptokey
134+
var buffer = new byte[16];
135+
using (var cryptoRandomProvider = new RNGCryptoServiceProvider()
136+
) //generate global unique cryptokey
145137
{
146138
cryptoRandomProvider.GetBytes(buffer);
147139
}
148-
this.Program_CryptoKey = buffer;
140+
141+
Program_CryptoKey = buffer;
149142
}
150143

151-
private void NormalizeSHColors()
152-
{
153-
SH_Comments = new SerializeableColor(0xFF, 0x57, 0xA6, 0x49);
154-
SH_CommentsMarker = new SerializeableColor(0xFF, 0xFF, 0x20, 0x20);
155-
SH_Strings = new SerializeableColor(0xFF, 0xF4, 0x6B, 0x6C);
156-
SH_PreProcessor = new SerializeableColor(0xFF, 0x7E, 0x7E, 0x7E);
157-
SH_Types = new SerializeableColor(0xFF, 0x28, 0x90, 0xB0); //56 9C D5
158-
SH_TypesValues = new SerializeableColor(0xFF, 0x56, 0x9C, 0xD5);
159-
SH_Keywords = new SerializeableColor(0xFF, 0x56, 0x9C, 0xD5);
160-
SH_ContextKeywords = new SerializeableColor(0xFF, 0x56, 0x9C, 0xD5);
161-
SH_Chars = new SerializeableColor(0xFF, 0xD6, 0x9C, 0x85);
162-
SH_UnkownFunctions = new SerializeableColor(0xFF, 0x45, 0x85, 0xC5);
163-
SH_Numbers = new SerializeableColor(0xFF, 0x97, 0x97, 0x97);
164-
SH_SpecialCharacters = new SerializeableColor(0xFF, 0x8F, 0x8F, 0x8F);
165-
SH_Deprecated = new SerializeableColor(0xFF, 0xFF, 0x00, 0x00);
166-
SH_Constants = new SerializeableColor(0xFF, 0xBC, 0x62, 0xC5);
167-
SH_Functions = new SerializeableColor(0xFF, 0x56, 0x9C, 0xD5);
168-
SH_Methods = new SerializeableColor(0xFF, 0x3B, 0xC6, 0x7E);
169-
}
144+
private void NormalizeSHColors()
145+
{
146+
SH_Comments = new SerializeableColor(0xFF, 0x57, 0xA6, 0x49);
147+
SH_CommentsMarker = new SerializeableColor(0xFF, 0xFF, 0x20, 0x20);
148+
SH_Strings = new SerializeableColor(0xFF, 0xF4, 0x6B, 0x6C);
149+
SH_PreProcessor = new SerializeableColor(0xFF, 0x7E, 0x7E, 0x7E);
150+
SH_Types = new SerializeableColor(0xFF, 0x28, 0x90, 0xB0); //56 9C D5
151+
SH_TypesValues = new SerializeableColor(0xFF, 0x56, 0x9C, 0xD5);
152+
SH_Keywords = new SerializeableColor(0xFF, 0x56, 0x9C, 0xD5);
153+
SH_ContextKeywords = new SerializeableColor(0xFF, 0x56, 0x9C, 0xD5);
154+
SH_Chars = new SerializeableColor(0xFF, 0xD6, 0x9C, 0x85);
155+
SH_UnkownFunctions = new SerializeableColor(0xFF, 0x45, 0x85, 0xC5);
156+
SH_Numbers = new SerializeableColor(0xFF, 0x97, 0x97, 0x97);
157+
SH_SpecialCharacters = new SerializeableColor(0xFF, 0x8F, 0x8F, 0x8F);
158+
SH_Deprecated = new SerializeableColor(0xFF, 0xFF, 0x00, 0x00);
159+
SH_Constants = new SerializeableColor(0xFF, 0xBC, 0x62, 0xC5);
160+
SH_Functions = new SerializeableColor(0xFF, 0x56, 0x9C, 0xD5);
161+
SH_Methods = new SerializeableColor(0xFF, 0x3B, 0xC6, 0x7E);
162+
}
170163
}
171164

172165
[Serializable]
173166
public class SerializeableColor
174167
{
168+
public byte A;
169+
public byte B;
170+
public byte G;
171+
public byte R;
172+
175173
public SerializeableColor(byte _A, byte _R, byte _G, byte _B)
176174
{
177-
A = _A; R = _R; G = _G; B = _B;
175+
A = _A;
176+
R = _R;
177+
G = _G;
178+
B = _B;
178179
}
179-
public byte A = 0x00;
180-
public byte R = 0x00;
181-
public byte G = 0x00;
182-
public byte B = 0x00;
180+
183181
public static implicit operator SerializeableColor(Color c)
184-
{ return new SerializeableColor(c.A, c.R, c.G, c.B ); }
182+
{
183+
return new SerializeableColor(c.A, c.R, c.G, c.B);
184+
}
185+
185186
public static implicit operator Color(SerializeableColor c)
186-
{ return Color.FromArgb(c.A, c.R, c.G, c.B); }
187+
{
188+
return Color.FromArgb(c.A, c.R, c.G, c.B);
189+
}
187190
}
188191

189192
public static class OptionsControlIOObject
@@ -193,13 +196,16 @@ public static void Save()
193196
try
194197
{
195198
var formatter = new BinaryFormatter();
196-
using (FileStream fileStream = new FileStream("options_0.dat", FileMode.Create, FileAccess.ReadWrite, FileShare.None))
199+
using (var fileStream = new FileStream("options_0.dat", FileMode.Create, FileAccess.ReadWrite,
200+
FileShare.None))
197201
{
198202
formatter.Serialize(fileStream, Program.OptionsObject);
199203
var test = Program.OptionsObject;
200204
}
201205
}
202-
catch (Exception) { }
206+
catch (Exception)
207+
{
208+
}
203209
}
204210

205211
public static OptionsControl Load(out bool ProgramIsNew)
@@ -210,25 +216,30 @@ public static OptionsControl Load(out bool ProgramIsNew)
210216
{
211217
object deserializedOptionsObj;
212218
var formatter = new BinaryFormatter();
213-
using (FileStream fileStream = new FileStream("options_0.dat", FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
219+
using (var fileStream = new FileStream("options_0.dat", FileMode.Open, FileAccess.Read,
220+
FileShare.ReadWrite))
214221
{
215222
deserializedOptionsObj = formatter.Deserialize(fileStream);
216223
}
217-
OptionsControl oc = (OptionsControl)deserializedOptionsObj;
224+
225+
var oc = (OptionsControl) deserializedOptionsObj;
218226
oc.FillNullToDefaults();
219-
ProgramIsNew = false;
220-
return oc;
227+
ProgramIsNew = false;
228+
return oc;
221229
}
222230
}
223-
catch (Exception) { }
224-
OptionsControl oco = new OptionsControl();
231+
catch (Exception)
232+
{
233+
}
234+
235+
var oco = new OptionsControl();
225236
oco.ReCreateCryptoKey();
226237
#if DEBUG
227-
ProgramIsNew = false;
238+
ProgramIsNew = false;
228239
#else
229240
ProgramIsNew = true;
230241
#endif
231-
return oco;
242+
return oco;
232243
}
233244
}
234-
}
245+
}

0 commit comments

Comments
 (0)