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

Commit 1f64d44

Browse files
committed
Merge remote-tracking branch 'origin/master'
2 parents 9224659 + 0e5e281 commit 1f64d44

17 files changed

+588
-666
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,3 +207,7 @@ $RECYCLE.BIN/
207207

208208
# Windows shortcuts
209209
*.lnk
210+
211+
# IDE FIles
212+
/.idea/
213+
*.iml

Interop/TranslationProvider.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public string GetLanguage(string langID)
2626
{
2727
return language[langID];
2828
}
29-
catch (Exception e)
29+
catch (Exception)
3030
{
3131
throw new Exception($"{langID} is not a known language-phrase");
3232
}
@@ -118,8 +118,8 @@ private void FillToEnglishDefaults()
118118
language.Add("FoundInOff", "Found in offset {0} with length {1}");
119119
language.Add("FoundNothing", "Found nothing");
120120
language.Add("ReplacedOff", "Replaced in offset {0}");
121-
language.Add("ReplacedOcc", "Replaced {0} occurences in {1} documents");
122-
language.Add("OccFound", "occurences found");
121+
language.Add("ReplacedOcc", "Replaced {0} occurrences in {1} documents");
122+
language.Add("OccFound", "occurrences found");
123123
language.Add("EmptyPatt", "Empty search pattern");
124124
language.Add("NoValidRegex", "No valid regex pattern");
125125
language.Add("FailedCheck", "Failed to check");
@@ -149,7 +149,7 @@ private void FillToEnglishDefaults()
149149
language.Add("CloseAll", "Close all");
150150
language.Add("Build", "Build");
151151
language.Add("CopyPlugin", "Copy Plugins");
152-
language.Add("SendRCon", "Senc RCon commands");
152+
language.Add("SendRCon", "Send RCon commands");
153153
language.Add("Config", "Configuration");
154154
language.Add("Edit", "Edit");
155155
language.Add("Undo", "Undo");
@@ -166,8 +166,8 @@ private void FillToEnglishDefaults()
166166
language.Add("Tools", "Tools");
167167
language.Add("Options", "Options");
168168
language.Add("ParsedIncDir", "Parsed from include directory");
169-
language.Add("OldAPIWeb", "Old API webside");
170-
language.Add("NewAPIWeb", "New API webside");
169+
language.Add("OldAPIWeb", "Old API website");
170+
language.Add("NewAPIWeb", "New API website");
171171
language.Add("Reformatter", "Syntax reformatter");
172172
language.Add("ReformatCurr", "Reformat current");
173173
language.Add("ReformatAll", "Reformat all");
@@ -206,7 +206,7 @@ private void FillToEnglishDefaults()
206206
language.Add("PeopleInv", "People involved");
207207
language.Add("Preview", "Preview");
208208
language.Add("NewFile", "New file");
209-
language.Add("ConfigWrongPars", "The config was not able to parse a sourcepawn definiton.");
209+
language.Add("ConfigWrongPars", "The config was not able to parse a sourcepawn definition.");
210210
language.Add("NoName", "no name");
211211
language.Add("PosLen", "(pos: {0} - len: {1})");
212212
language.Add("InheritedFrom", "inherited from");
@@ -264,15 +264,15 @@ private void FillToEnglishDefaults()
264264
language.Add("OpenIncRec", "Open Includes Recursively");
265265
language.Add("AutoUpdate", "Search automatically for updates");
266266
language.Add("ShowToolbar", "Show toolbar");
267-
language.Add("DynamicISAC", "Dynamic Autocompletition/Intellisense");
267+
language.Add("DynamicISAC", "Dynamic Autocomplete/Intellisense");
268268
language.Add("DarkTheme", "Dark theme");
269269
language.Add("ThemeColor", "Theme Color");
270270
language.Add("LanguageStr", "Language");
271271
language.Add("Editor", "Editor");
272272
language.Add("FontSize", "Font size");
273273
language.Add("ScrollSpeed", "Scroll speed");
274274
language.Add("WordWrap", "Word wrap");
275-
language.Add("AggIndentation", "Agressive Indentation");
275+
language.Add("AggIndentation", "Aggressive Indentation");
276276
language.Add("ReformatAfterSem", "Reformatting line after semicolon");
277277
language.Add("TabsToSpace", "Replace tabs with spaces");
278278
language.Add("AutoCloseBrack", "Auto close brackets");
@@ -281,7 +281,7 @@ private void FillToEnglishDefaults()
281281
language.Add("ShowTabs", "Show tabs");
282282
language.Add("IndentationSize", "Indentation size");
283283
language.Add("FontFamily", "Font");
284-
language.Add("SyntaxHigh", "Syntaxhighlighting");
284+
language.Add("SyntaxHigh", "Syntax Highlighting");
285285
language.Add("HighDeprecat", "Highlight deprecated (<1.7) syntax");
286286
language.Add("Compile", "Compile");
287287
language.Add("AutoSaveMin", "Auto save (min)");

Program.cs

Lines changed: 126 additions & 126 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@ public static class Program
2121
public static OptionsControl OptionsObject;
2222
public static TranslationProvider Translations;
2323
public static Config[] Configs;
24-
public static int SelectedConfig = 0;
24+
public static int SelectedConfig;
2525

2626
public static UpdateInfo UpdateStatus;
2727

28-
public static bool RCCKMade = false;
29-
public static DiscordRpcClient discordClient = new DiscordRpcClient("692110664948514836");
28+
public static bool RCCKMade;
29+
public static readonly DiscordRpcClient discordClient = new DiscordRpcClient("692110664948514836");
3030
public static Timestamps discordTime = Timestamps.Now;
3131

3232
[STAThread]
@@ -46,134 +46,136 @@ public static void Main(string[] args)
4646
}
4747
});
4848
bool mutexReserved;
49-
using (Mutex appMutex = new Mutex(true, "SpeditGlobalMutex", out mutexReserved))
49+
using (new Mutex(true, "SpeditGlobalMutex", out mutexReserved))
5050
{
51-
if (mutexReserved)
52-
{
53-
bool ProgramIsNew = false;
51+
if (mutexReserved)
52+
{
5453
#if !DEBUG
55-
try
56-
{
54+
try
55+
{
5756
#endif
58-
SplashScreen splashScreen = new SplashScreen("Resources/Icon256x.png");
59-
splashScreen.Show(false, true);
60-
Environment.CurrentDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
57+
SplashScreen splashScreen = new SplashScreen("Resources/Icon256x.png");
58+
splashScreen.Show(false, true);
59+
Environment.CurrentDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) ?? throw new NullReferenceException();
6160
#if !DEBUG
62-
ProfileOptimization.SetProfileRoot(Environment.CurrentDirectory);
63-
ProfileOptimization.StartProfile("Startup.Profile");
61+
ProfileOptimization.SetProfileRoot(Environment.CurrentDirectory);
62+
ProfileOptimization.StartProfile("Startup.Profile");
6463
#endif
65-
UpdateStatus = new UpdateInfo();
66-
OptionsObject = OptionsControlIOObject.Load(out ProgramIsNew);
67-
Translations = new TranslationProvider();
68-
Translations.LoadLanguage(OptionsObject.Language, true);
69-
for (int i = 0; i < args.Length; ++i)
70-
{
71-
if (args[i].ToLowerInvariant() == "-rcck") //ReCreateCryptoKey
72-
{
73-
OptionsObject.ReCreateCryptoKey();
74-
MakeRCCKAlert();
75-
}
76-
}
77-
Configs = ConfigLoader.Load();
78-
for (int i = 0; i < Configs.Length; ++i)
79-
{
80-
if (Configs[i].Name == OptionsObject.Program_SelectedConfig)
81-
{
82-
Program.SelectedConfig = i;
83-
break;
84-
}
85-
}
86-
if (!OptionsObject.Program_UseHardwareAcceleration)
87-
{
88-
RenderOptions.ProcessRenderMode = System.Windows.Interop.RenderMode.SoftwareOnly;
89-
}
64+
UpdateStatus = new UpdateInfo();
65+
OptionsObject = OptionsControlIOObject.Load(out var ProgramIsNew);
66+
Translations = new TranslationProvider();
67+
Translations.LoadLanguage(OptionsObject.Language, true);
68+
for (int i = 0; i < args.Length; ++i)
69+
{
70+
if (args[i].ToLowerInvariant() == "-rcck") //ReCreateCryptoKey
71+
{
72+
OptionsObject.ReCreateCryptoKey();
73+
MakeRCCKAlert();
74+
}
75+
}
76+
Configs = ConfigLoader.Load();
77+
for (int i = 0; i < Configs.Length; ++i)
78+
{
79+
if (Configs[i].Name == OptionsObject.Program_SelectedConfig)
80+
{
81+
Program.SelectedConfig = i;
82+
break;
83+
}
84+
}
85+
if (!OptionsObject.Program_UseHardwareAcceleration)
86+
{
87+
RenderOptions.ProcessRenderMode = System.Windows.Interop.RenderMode.SoftwareOnly;
88+
}
9089
#if !DEBUG
91-
if (ProgramIsNew)
92-
{
93-
if (Translations.AvailableLanguageIDs.Length > 0)
94-
{
95-
splashScreen.Close(new TimeSpan(0, 0, 1));
96-
var languageWindow = new UI.Interop.LanguageChooserWindow(Translations.AvailableLanguageIDs, Translations.AvailableLanguages);
97-
languageWindow.ShowDialog();
98-
string potentialSelectedLanguageID = languageWindow.SelectedID;
99-
if (!string.IsNullOrWhiteSpace(potentialSelectedLanguageID))
100-
{
101-
OptionsObject.Language = potentialSelectedLanguageID;
102-
Translations.LoadLanguage(potentialSelectedLanguageID);
103-
}
104-
splashScreen.Show(false, true);
105-
}
106-
}
90+
if (ProgramIsNew)
91+
{
92+
if (Translations.AvailableLanguageIDs.Length > 0)
93+
{
94+
splashScreen.Close(new TimeSpan(0, 0, 1));
95+
var languageWindow = new UI.Interop.LanguageChooserWindow(Translations.AvailableLanguageIDs, Translations.AvailableLanguages);
96+
languageWindow.ShowDialog();
97+
string potentialSelectedLanguageID = languageWindow.SelectedID;
98+
if (!string.IsNullOrWhiteSpace(potentialSelectedLanguageID))
99+
{
100+
OptionsObject.Language = potentialSelectedLanguageID;
101+
Translations.LoadLanguage(potentialSelectedLanguageID);
102+
}
103+
splashScreen.Show(false, true);
104+
}
105+
}
107106
#endif
108-
MainWindow = new MainWindow(splashScreen);
109-
PipeInteropServer pipeServer = new PipeInteropServer(MainWindow);
110-
pipeServer.Start();
107+
MainWindow = new MainWindow(splashScreen);
108+
PipeInteropServer pipeServer = new PipeInteropServer(MainWindow);
109+
pipeServer.Start();
111110
#if !DEBUG
112-
}
113-
catch (Exception e)
114-
{
115-
File.WriteAllText("CRASH_" + Environment.TickCount.ToString() + ".txt", BuildExceptionString(e, "SPEDIT LOADING"));
116-
MessageBox.Show("An error occured while loading." + Environment.NewLine + "A crash report was written in the editor-directory.",
117-
"Error while Loading",
118-
MessageBoxButton.OK,
119-
MessageBoxImage.Error);
120-
Environment.Exit(Environment.ExitCode);
121-
}
111+
}
112+
catch (Exception e)
113+
{
114+
File.WriteAllText("CRASH_" + Environment.TickCount.ToString() + ".txt", BuildExceptionString(e, "SPEDIT LOADING"));
115+
MessageBox.Show("An error occured while loading." + Environment.NewLine + "A crash report was written in the editor-directory.",
116+
"Error while Loading",
117+
MessageBoxButton.OK,
118+
MessageBoxImage.Error);
119+
Environment.Exit(Environment.ExitCode);
120+
}
122121
#endif
123-
Application app = new Application();
122+
Application app = new Application();
124123
#if !DEBUG
125-
try
126-
{
127-
if (OptionsObject.Program_CheckForUpdates)
128-
{
129-
UpdateCheck.Check(true);
130-
}
124+
try
125+
{
126+
if (OptionsObject.Program_CheckForUpdates)
127+
{
128+
UpdateCheck.Check(true);
129+
}
131130
#endif
132-
app.Startup += App_Startup;
133-
app.Run(MainWindow);
134-
OptionsControlIOObject.Save();
131+
app.Startup += App_Startup;
132+
app.Run(MainWindow);
133+
OptionsControlIOObject.Save();
135134
#if !DEBUG
136-
}
137-
catch (Exception e)
138-
{
139-
File.WriteAllText("CRASH_" + Environment.TickCount.ToString() + ".txt", BuildExceptionString(e, "SPEDIT MAIN"));
140-
MessageBox.Show("An error occured." + Environment.NewLine + "A crash report was written in the editor-directory.",
141-
"Error",
142-
MessageBoxButton.OK,
143-
MessageBoxImage.Error);
144-
Environment.Exit(Environment.ExitCode);
145-
}
135+
}
136+
catch (Exception e)
137+
{
138+
File.WriteAllText("CRASH_" + Environment.TickCount.ToString() + ".txt", BuildExceptionString(e, "SPEDIT MAIN"));
139+
MessageBox.Show("An error occured." + Environment.NewLine + "A crash report was written in the editor-directory.",
140+
"Error",
141+
MessageBoxButton.OK,
142+
MessageBoxImage.Error);
143+
Environment.Exit(Environment.ExitCode);
144+
}
146145
#endif
147-
}
148-
else
149-
{
150-
try
151-
{
152-
StringBuilder sBuilder = new StringBuilder();
153-
bool addedFiles = false;
154-
for (int i = 0; i < args.Length; ++i)
155-
{
156-
if (!string.IsNullOrWhiteSpace(args[i]))
157-
{
158-
FileInfo fInfo = new FileInfo(args[i]);
159-
if (fInfo.Exists)
160-
{
161-
string ext = fInfo.Extension.ToLowerInvariant().Trim(new char[] { '.', ' ' });
162-
if (ext == "sp" || ext == "inc" || ext == "txt" || ext == "smx")
163-
{
164-
addedFiles = true;
165-
sBuilder.Append(fInfo.FullName);
166-
if ((i + 1) != args.Length)
167-
{ sBuilder.Append("|"); }
168-
}
169-
}
170-
}
171-
}
172-
if (addedFiles)
173-
{ PipeInteropClient.ConnectToMasterPipeAndSendData(sBuilder.ToString()); }
174-
}
175-
catch (Exception) { } //dont fuck the user up with irrelevant data
176-
}
146+
}
147+
else
148+
{
149+
try
150+
{
151+
StringBuilder sBuilder = new StringBuilder();
152+
bool addedFiles = false;
153+
for (int i = 0; i < args.Length; ++i)
154+
{
155+
if (!string.IsNullOrWhiteSpace(args[i]))
156+
{
157+
FileInfo fInfo = new FileInfo(args[i]);
158+
if (fInfo.Exists)
159+
{
160+
string ext = fInfo.Extension.ToLowerInvariant().Trim(new char[] { '.', ' ' });
161+
if (ext == "sp" || ext == "inc" || ext == "txt" || ext == "smx")
162+
{
163+
addedFiles = true;
164+
sBuilder.Append(fInfo.FullName);
165+
if ((i + 1) != args.Length)
166+
{ sBuilder.Append("|"); }
167+
}
168+
}
169+
}
170+
}
171+
if (addedFiles)
172+
{ PipeInteropClient.ConnectToMasterPipeAndSendData(sBuilder.ToString()); }
173+
}
174+
catch (Exception)
175+
{
176+
// ignored
177+
} //dont fuck the user up with irrelevant data
178+
}
177179
}
178180
}
179181

@@ -203,8 +205,7 @@ public static void ClearUpdateFiles()
203205

204206
private static void App_Startup(object sender, StartupEventArgs e)
205207
{
206-
207-
Tuple<MahApps.Metro.AppTheme, MahApps.Metro.Accent> appStyle = MahApps.Metro.ThemeManager.DetectAppStyle(Application.Current);
208+
MahApps.Metro.ThemeManager.DetectAppStyle(Application.Current);
208209
MahApps.Metro.ThemeManager.ChangeAppStyle(Application.Current,
209210
MahApps.Metro.ThemeManager.GetAccent("Green"),
210211
MahApps.Metro.ThemeManager.GetAppTheme("BaseDark")); // or appStyle.Item1
@@ -220,11 +221,10 @@ private static string BuildExceptionString(Exception e, string SectionName)
220221
outString.AppendLine("64 bit mode: " + ((Environment.Is64BitProcess) ? "TRUE" : "FALSE"));
221222
outString.AppendLine("Dir: " + Environment.CurrentDirectory);
222223
outString.AppendLine("Working Set: " + (Environment.WorkingSet / 1024).ToString() + " kb");
223-
outString.AppendLine("Installed UI Culture: " + System.Globalization.CultureInfo.InstalledUICulture ?? "null");
224-
outString.AppendLine("Current UI Culture: " + System.Globalization.CultureInfo.CurrentUICulture ?? "null");
225-
outString.AppendLine("Current Culture: " + System.Globalization.CultureInfo.CurrentCulture ?? "null");
224+
outString.AppendLine("Installed UI Culture: " + System.Globalization.CultureInfo.InstalledUICulture);
225+
outString.AppendLine("Current UI Culture: " + System.Globalization.CultureInfo.CurrentUICulture);
226+
outString.AppendLine("Current Culture: " + System.Globalization.CultureInfo.CurrentCulture);
226227
outString.AppendLine();
227-
Exception current = e;
228228
int eNumber = 1;
229229
for (; ; )
230230
{
@@ -246,12 +246,12 @@ private static string BuildExceptionString(Exception e, string SectionName)
246246
if (e.TargetSite != null)
247247
{
248248
outString.AppendLine("Targetsite Name:");
249-
outString.AppendLine(e.TargetSite.Name ?? "null");
249+
outString.AppendLine(e.TargetSite.Name);
250250
}
251251
e = e.InnerException;
252252
eNumber++;
253253
}
254-
return (eNumber - 1).ToString() + Environment.NewLine + outString.ToString();
254+
return (eNumber - 1) + Environment.NewLine + outString;
255255
}
256256
}
257257
}

UI/Components/EditorElement.xaml.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -532,6 +532,7 @@ public async void Close(bool ForcedToSave = false, bool CheckSavings = true)
532532
}
533533
}
534534
Parent = null; //to prevent a ring depency which disables the GC from work
535+
Program.MainWindow.UpdateWindowTitle();
535536
}
536537

537538
private void editor_TextChanged(object sender, EventArgs e)

0 commit comments

Comments
 (0)