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

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
Hexer10 committed Mar 25, 2020
2 parents 9224659 + 0e5e281 commit 1f64d44
Show file tree
Hide file tree
Showing 17 changed files with 588 additions and 666 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -207,3 +207,7 @@ $RECYCLE.BIN/

# Windows shortcuts
*.lnk

# IDE FIles
/.idea/
*.iml
20 changes: 10 additions & 10 deletions Interop/TranslationProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public string GetLanguage(string langID)
{
return language[langID];
}
catch (Exception e)
catch (Exception)
{
throw new Exception($"{langID} is not a known language-phrase");
}
Expand Down Expand Up @@ -118,8 +118,8 @@ private void FillToEnglishDefaults()
language.Add("FoundInOff", "Found in offset {0} with length {1}");
language.Add("FoundNothing", "Found nothing");
language.Add("ReplacedOff", "Replaced in offset {0}");
language.Add("ReplacedOcc", "Replaced {0} occurences in {1} documents");
language.Add("OccFound", "occurences found");
language.Add("ReplacedOcc", "Replaced {0} occurrences in {1} documents");
language.Add("OccFound", "occurrences found");
language.Add("EmptyPatt", "Empty search pattern");
language.Add("NoValidRegex", "No valid regex pattern");
language.Add("FailedCheck", "Failed to check");
Expand Down Expand Up @@ -149,7 +149,7 @@ private void FillToEnglishDefaults()
language.Add("CloseAll", "Close all");
language.Add("Build", "Build");
language.Add("CopyPlugin", "Copy Plugins");
language.Add("SendRCon", "Senc RCon commands");
language.Add("SendRCon", "Send RCon commands");
language.Add("Config", "Configuration");
language.Add("Edit", "Edit");
language.Add("Undo", "Undo");
Expand All @@ -166,8 +166,8 @@ private void FillToEnglishDefaults()
language.Add("Tools", "Tools");
language.Add("Options", "Options");
language.Add("ParsedIncDir", "Parsed from include directory");
language.Add("OldAPIWeb", "Old API webside");
language.Add("NewAPIWeb", "New API webside");
language.Add("OldAPIWeb", "Old API website");
language.Add("NewAPIWeb", "New API website");
language.Add("Reformatter", "Syntax reformatter");
language.Add("ReformatCurr", "Reformat current");
language.Add("ReformatAll", "Reformat all");
Expand Down Expand Up @@ -206,7 +206,7 @@ private void FillToEnglishDefaults()
language.Add("PeopleInv", "People involved");
language.Add("Preview", "Preview");
language.Add("NewFile", "New file");
language.Add("ConfigWrongPars", "The config was not able to parse a sourcepawn definiton.");
language.Add("ConfigWrongPars", "The config was not able to parse a sourcepawn definition.");
language.Add("NoName", "no name");
language.Add("PosLen", "(pos: {0} - len: {1})");
language.Add("InheritedFrom", "inherited from");
Expand Down Expand Up @@ -264,15 +264,15 @@ private void FillToEnglishDefaults()
language.Add("OpenIncRec", "Open Includes Recursively");
language.Add("AutoUpdate", "Search automatically for updates");
language.Add("ShowToolbar", "Show toolbar");
language.Add("DynamicISAC", "Dynamic Autocompletition/Intellisense");
language.Add("DynamicISAC", "Dynamic Autocomplete/Intellisense");
language.Add("DarkTheme", "Dark theme");
language.Add("ThemeColor", "Theme Color");
language.Add("LanguageStr", "Language");
language.Add("Editor", "Editor");
language.Add("FontSize", "Font size");
language.Add("ScrollSpeed", "Scroll speed");
language.Add("WordWrap", "Word wrap");
language.Add("AggIndentation", "Agressive Indentation");
language.Add("AggIndentation", "Aggressive Indentation");
language.Add("ReformatAfterSem", "Reformatting line after semicolon");
language.Add("TabsToSpace", "Replace tabs with spaces");
language.Add("AutoCloseBrack", "Auto close brackets");
Expand All @@ -281,7 +281,7 @@ private void FillToEnglishDefaults()
language.Add("ShowTabs", "Show tabs");
language.Add("IndentationSize", "Indentation size");
language.Add("FontFamily", "Font");
language.Add("SyntaxHigh", "Syntaxhighlighting");
language.Add("SyntaxHigh", "Syntax Highlighting");
language.Add("HighDeprecat", "Highlight deprecated (<1.7) syntax");
language.Add("Compile", "Compile");
language.Add("AutoSaveMin", "Auto save (min)");
Expand Down
252 changes: 126 additions & 126 deletions Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ public static class Program
public static OptionsControl OptionsObject;
public static TranslationProvider Translations;
public static Config[] Configs;
public static int SelectedConfig = 0;
public static int SelectedConfig;

public static UpdateInfo UpdateStatus;

public static bool RCCKMade = false;
public static DiscordRpcClient discordClient = new DiscordRpcClient("692110664948514836");
public static bool RCCKMade;
public static readonly DiscordRpcClient discordClient = new DiscordRpcClient("692110664948514836");
public static Timestamps discordTime = Timestamps.Now;

[STAThread]
Expand All @@ -46,134 +46,136 @@ public static void Main(string[] args)
}
});
bool mutexReserved;
using (Mutex appMutex = new Mutex(true, "SpeditGlobalMutex", out mutexReserved))
using (new Mutex(true, "SpeditGlobalMutex", out mutexReserved))
{
if (mutexReserved)
{
bool ProgramIsNew = false;
if (mutexReserved)
{
#if !DEBUG
try
{
try
{
#endif
SplashScreen splashScreen = new SplashScreen("Resources/Icon256x.png");
splashScreen.Show(false, true);
Environment.CurrentDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
SplashScreen splashScreen = new SplashScreen("Resources/Icon256x.png");
splashScreen.Show(false, true);
Environment.CurrentDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) ?? throw new NullReferenceException();
#if !DEBUG
ProfileOptimization.SetProfileRoot(Environment.CurrentDirectory);
ProfileOptimization.StartProfile("Startup.Profile");
ProfileOptimization.SetProfileRoot(Environment.CurrentDirectory);
ProfileOptimization.StartProfile("Startup.Profile");
#endif
UpdateStatus = new UpdateInfo();
OptionsObject = OptionsControlIOObject.Load(out ProgramIsNew);
Translations = new TranslationProvider();
Translations.LoadLanguage(OptionsObject.Language, true);
for (int i = 0; i < args.Length; ++i)
{
if (args[i].ToLowerInvariant() == "-rcck") //ReCreateCryptoKey
{
OptionsObject.ReCreateCryptoKey();
MakeRCCKAlert();
}
}
Configs = ConfigLoader.Load();
for (int i = 0; i < Configs.Length; ++i)
{
if (Configs[i].Name == OptionsObject.Program_SelectedConfig)
{
Program.SelectedConfig = i;
break;
}
}
if (!OptionsObject.Program_UseHardwareAcceleration)
{
RenderOptions.ProcessRenderMode = System.Windows.Interop.RenderMode.SoftwareOnly;
}
UpdateStatus = new UpdateInfo();
OptionsObject = OptionsControlIOObject.Load(out var ProgramIsNew);
Translations = new TranslationProvider();
Translations.LoadLanguage(OptionsObject.Language, true);
for (int i = 0; i < args.Length; ++i)
{
if (args[i].ToLowerInvariant() == "-rcck") //ReCreateCryptoKey
{
OptionsObject.ReCreateCryptoKey();
MakeRCCKAlert();
}
}
Configs = ConfigLoader.Load();
for (int i = 0; i < Configs.Length; ++i)
{
if (Configs[i].Name == OptionsObject.Program_SelectedConfig)
{
Program.SelectedConfig = i;
break;
}
}
if (!OptionsObject.Program_UseHardwareAcceleration)
{
RenderOptions.ProcessRenderMode = System.Windows.Interop.RenderMode.SoftwareOnly;
}
#if !DEBUG
if (ProgramIsNew)
{
if (Translations.AvailableLanguageIDs.Length > 0)
{
splashScreen.Close(new TimeSpan(0, 0, 1));
var languageWindow = new UI.Interop.LanguageChooserWindow(Translations.AvailableLanguageIDs, Translations.AvailableLanguages);
languageWindow.ShowDialog();
string potentialSelectedLanguageID = languageWindow.SelectedID;
if (!string.IsNullOrWhiteSpace(potentialSelectedLanguageID))
{
OptionsObject.Language = potentialSelectedLanguageID;
Translations.LoadLanguage(potentialSelectedLanguageID);
}
splashScreen.Show(false, true);
}
}
if (ProgramIsNew)
{
if (Translations.AvailableLanguageIDs.Length > 0)
{
splashScreen.Close(new TimeSpan(0, 0, 1));
var languageWindow = new UI.Interop.LanguageChooserWindow(Translations.AvailableLanguageIDs, Translations.AvailableLanguages);
languageWindow.ShowDialog();
string potentialSelectedLanguageID = languageWindow.SelectedID;
if (!string.IsNullOrWhiteSpace(potentialSelectedLanguageID))
{
OptionsObject.Language = potentialSelectedLanguageID;
Translations.LoadLanguage(potentialSelectedLanguageID);
}
splashScreen.Show(false, true);
}
}
#endif
MainWindow = new MainWindow(splashScreen);
PipeInteropServer pipeServer = new PipeInteropServer(MainWindow);
pipeServer.Start();
MainWindow = new MainWindow(splashScreen);
PipeInteropServer pipeServer = new PipeInteropServer(MainWindow);
pipeServer.Start();
#if !DEBUG
}
catch (Exception e)
{
File.WriteAllText("CRASH_" + Environment.TickCount.ToString() + ".txt", BuildExceptionString(e, "SPEDIT LOADING"));
MessageBox.Show("An error occured while loading." + Environment.NewLine + "A crash report was written in the editor-directory.",
"Error while Loading",
MessageBoxButton.OK,
MessageBoxImage.Error);
Environment.Exit(Environment.ExitCode);
}
}
catch (Exception e)
{
File.WriteAllText("CRASH_" + Environment.TickCount.ToString() + ".txt", BuildExceptionString(e, "SPEDIT LOADING"));
MessageBox.Show("An error occured while loading." + Environment.NewLine + "A crash report was written in the editor-directory.",
"Error while Loading",
MessageBoxButton.OK,
MessageBoxImage.Error);
Environment.Exit(Environment.ExitCode);
}
#endif
Application app = new Application();
Application app = new Application();
#if !DEBUG
try
{
if (OptionsObject.Program_CheckForUpdates)
{
UpdateCheck.Check(true);
}
try
{
if (OptionsObject.Program_CheckForUpdates)
{
UpdateCheck.Check(true);
}
#endif
app.Startup += App_Startup;
app.Run(MainWindow);
OptionsControlIOObject.Save();
app.Startup += App_Startup;
app.Run(MainWindow);
OptionsControlIOObject.Save();
#if !DEBUG
}
catch (Exception e)
{
File.WriteAllText("CRASH_" + Environment.TickCount.ToString() + ".txt", BuildExceptionString(e, "SPEDIT MAIN"));
MessageBox.Show("An error occured." + Environment.NewLine + "A crash report was written in the editor-directory.",
"Error",
MessageBoxButton.OK,
MessageBoxImage.Error);
Environment.Exit(Environment.ExitCode);
}
}
catch (Exception e)
{
File.WriteAllText("CRASH_" + Environment.TickCount.ToString() + ".txt", BuildExceptionString(e, "SPEDIT MAIN"));
MessageBox.Show("An error occured." + Environment.NewLine + "A crash report was written in the editor-directory.",
"Error",
MessageBoxButton.OK,
MessageBoxImage.Error);
Environment.Exit(Environment.ExitCode);
}
#endif
}
else
{
try
{
StringBuilder sBuilder = new StringBuilder();
bool addedFiles = false;
for (int i = 0; i < args.Length; ++i)
{
if (!string.IsNullOrWhiteSpace(args[i]))
{
FileInfo fInfo = new FileInfo(args[i]);
if (fInfo.Exists)
{
string ext = fInfo.Extension.ToLowerInvariant().Trim(new char[] { '.', ' ' });
if (ext == "sp" || ext == "inc" || ext == "txt" || ext == "smx")
{
addedFiles = true;
sBuilder.Append(fInfo.FullName);
if ((i + 1) != args.Length)
{ sBuilder.Append("|"); }
}
}
}
}
if (addedFiles)
{ PipeInteropClient.ConnectToMasterPipeAndSendData(sBuilder.ToString()); }
}
catch (Exception) { } //dont fuck the user up with irrelevant data
}
}
else
{
try
{
StringBuilder sBuilder = new StringBuilder();
bool addedFiles = false;
for (int i = 0; i < args.Length; ++i)
{
if (!string.IsNullOrWhiteSpace(args[i]))
{
FileInfo fInfo = new FileInfo(args[i]);
if (fInfo.Exists)
{
string ext = fInfo.Extension.ToLowerInvariant().Trim(new char[] { '.', ' ' });
if (ext == "sp" || ext == "inc" || ext == "txt" || ext == "smx")
{
addedFiles = true;
sBuilder.Append(fInfo.FullName);
if ((i + 1) != args.Length)
{ sBuilder.Append("|"); }
}
}
}
}
if (addedFiles)
{ PipeInteropClient.ConnectToMasterPipeAndSendData(sBuilder.ToString()); }
}
catch (Exception)
{
// ignored
} //dont fuck the user up with irrelevant data
}
}
}

Expand Down Expand Up @@ -203,8 +205,7 @@ public static void ClearUpdateFiles()

private static void App_Startup(object sender, StartupEventArgs e)
{

Tuple<MahApps.Metro.AppTheme, MahApps.Metro.Accent> appStyle = MahApps.Metro.ThemeManager.DetectAppStyle(Application.Current);
MahApps.Metro.ThemeManager.DetectAppStyle(Application.Current);
MahApps.Metro.ThemeManager.ChangeAppStyle(Application.Current,
MahApps.Metro.ThemeManager.GetAccent("Green"),
MahApps.Metro.ThemeManager.GetAppTheme("BaseDark")); // or appStyle.Item1
Expand All @@ -220,11 +221,10 @@ private static string BuildExceptionString(Exception e, string SectionName)
outString.AppendLine("64 bit mode: " + ((Environment.Is64BitProcess) ? "TRUE" : "FALSE"));
outString.AppendLine("Dir: " + Environment.CurrentDirectory);
outString.AppendLine("Working Set: " + (Environment.WorkingSet / 1024).ToString() + " kb");
outString.AppendLine("Installed UI Culture: " + System.Globalization.CultureInfo.InstalledUICulture ?? "null");
outString.AppendLine("Current UI Culture: " + System.Globalization.CultureInfo.CurrentUICulture ?? "null");
outString.AppendLine("Current Culture: " + System.Globalization.CultureInfo.CurrentCulture ?? "null");
outString.AppendLine("Installed UI Culture: " + System.Globalization.CultureInfo.InstalledUICulture);
outString.AppendLine("Current UI Culture: " + System.Globalization.CultureInfo.CurrentUICulture);
outString.AppendLine("Current Culture: " + System.Globalization.CultureInfo.CurrentCulture);
outString.AppendLine();
Exception current = e;
int eNumber = 1;
for (; ; )
{
Expand All @@ -246,12 +246,12 @@ private static string BuildExceptionString(Exception e, string SectionName)
if (e.TargetSite != null)
{
outString.AppendLine("Targetsite Name:");
outString.AppendLine(e.TargetSite.Name ?? "null");
outString.AppendLine(e.TargetSite.Name);
}
e = e.InnerException;
eNumber++;
}
return (eNumber - 1).ToString() + Environment.NewLine + outString.ToString();
return (eNumber - 1) + Environment.NewLine + outString;
}
}
}
1 change: 1 addition & 0 deletions UI/Components/EditorElement.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,7 @@ public async void Close(bool ForcedToSave = false, bool CheckSavings = true)
}
}
Parent = null; //to prevent a ring depency which disables the GC from work
Program.MainWindow.UpdateWindowTitle();
}

private void editor_TextChanged(object sender, EventArgs e)
Expand Down
Loading

0 comments on commit 1f64d44

Please sign in to comment.