diff options
| author | Michael <[email protected]> | 2017-07-02 21:48:10 -0400 |
|---|---|---|
| committer | Michael <[email protected]> | 2017-07-02 21:48:10 -0400 |
| commit | 6f3a5cba2ea08ea6f442e2336b74f32f4bbc0604 (patch) | |
| tree | 9f138619a1cf4ebe7a7ece6c6a411adbe64843d6 /ShiftOS_TheReturn | |
| parent | 5d5f351138b55b27fe92690d824257b6b6e1a469 (diff) | |
| download | shiftos_thereturn-6f3a5cba2ea08ea6f442e2336b74f32f4bbc0604.tar.gz shiftos_thereturn-6f3a5cba2ea08ea6f442e2336b74f32f4bbc0604.tar.bz2 shiftos_thereturn-6f3a5cba2ea08ea6f442e2336b74f32f4bbc0604.zip | |
A day's worth of hell... which is turning into heaven.
Diffstat (limited to 'ShiftOS_TheReturn')
| -rw-r--r-- | ShiftOS_TheReturn/Desktop.cs | 9 | ||||
| -rw-r--r-- | ShiftOS_TheReturn/Localization.cs | 105 |
2 files changed, 64 insertions, 50 deletions
diff --git a/ShiftOS_TheReturn/Desktop.cs b/ShiftOS_TheReturn/Desktop.cs index fac5e6b..714d457 100644 --- a/ShiftOS_TheReturn/Desktop.cs +++ b/ShiftOS_TheReturn/Desktop.cs @@ -246,7 +246,14 @@ namespace ShiftOS.Engine public static void InvokeOnWorkerThread(Action act) { - _desktop.InvokeOnWorkerThread(act); + try + { + _desktop.InvokeOnWorkerThread(act); + } + catch + { + act?.Invoke(); + } } public static void ResetPanelButtons() diff --git a/ShiftOS_TheReturn/Localization.cs b/ShiftOS_TheReturn/Localization.cs index 8adfa5a..2414bd9 100644 --- a/ShiftOS_TheReturn/Localization.cs +++ b/ShiftOS_TheReturn/Localization.cs @@ -99,63 +99,65 @@ namespace ShiftOS.Engine public static string Parse(string original, Dictionary<string, string> replace) { - Dictionary<string, string> localizationStrings = new Dictionary<string, string>(); - - try { - localizationStrings = JsonConvert.DeserializeObject<Dictionary<string, string>>(_provider.GetCurrentTranscript()); - } - catch - { - localizationStrings = JsonConvert.DeserializeObject<Dictionary<string, string>>(Utils.ReadAllText(Paths.GetPath("english.local"))); //if no provider fall back to english - } - - foreach (var kv in localizationStrings.Where(x=>original.Contains(x.Key))) - { - original = original.Replace(kv.Key, kv.Value); // goes through and replaces all the localization blocks - } + Dictionary<string, string> localizationStrings = new Dictionary<string, string>(); - //string original2 = Parse(original); - string usernameReplace = ""; - string domainReplace = ""; - - // if the user has saved then store their username and systemname in these string variables please - if (SaveSystem.CurrentSave != null) - { try { - usernameReplace = SaveSystem.CurrentUser.Username; + localizationStrings = JsonConvert.DeserializeObject<Dictionary<string, string>>(_provider.GetCurrentTranscript()); } catch { - usernameReplace = "user"; + localizationStrings = JsonConvert.DeserializeObject<Dictionary<string, string>>(Utils.ReadAllText(Paths.GetPath("english.local"))); //if no provider fall back to english } - try + foreach (var kv in localizationStrings.Where(x => original.Contains(x.Key))) { - domainReplace = SaveSystem.CurrentSave.SystemName; + original = original.Replace(kv.Key, kv.Value); // goes through and replaces all the localization blocks } - catch + + //string original2 = Parse(original); + + string usernameReplace = ""; + string domainReplace = ""; + + // if the user has saved then store their username and systemname in these string variables please + if (SaveSystem.CurrentSave != null) { - domainReplace = "system"; + try + { + usernameReplace = SaveSystem.CurrentUser.Username; + } + catch + { + usernameReplace = "user"; + } + + try + { + domainReplace = SaveSystem.CurrentSave.SystemName; + } + catch + { + domainReplace = "system"; + } + } - - } - string namespaceReplace = ""; - string commandReplace = ""; + string namespaceReplace = ""; + string commandReplace = ""; - // if the user did a command in the terminal and it had a period in it then split it up into the part before the period and the part after and then store them into these two string variables please - if (TerminalBackend.latestCommmand != "" && TerminalBackend.latestCommmand.IndexOf('.') > -1) - { - namespaceReplace = TerminalBackend.latestCommmand.Split('.')[0]; - commandReplace = TerminalBackend.latestCommmand.Split('.')[1]; - } + // if the user did a command in the terminal and it had a period in it then split it up into the part before the period and the part after and then store them into these two string variables please + if (TerminalBackend.latestCommmand != "" && TerminalBackend.latestCommmand.IndexOf('.') > -1) + { + namespaceReplace = TerminalBackend.latestCommmand.Split('.')[0]; + commandReplace = TerminalBackend.latestCommmand.Split('.')[1]; + } - // if you see these then replace them with what you need to - Dictionary<string, string> defaultReplace = new Dictionary<string, string>() { + // if you see these then replace them with what you need to + Dictionary<string, string> defaultReplace = new Dictionary<string, string>() { {"%username", usernameReplace}, {"%domain", domainReplace}, {"%ns", namespaceReplace}, @@ -165,19 +167,24 @@ namespace ShiftOS.Engine #endif }; - // actually do the replacement - foreach (KeyValuePair<string, string> replacement in replace.Where(x => original.Contains(x.Key))) - { - original = original.Replace(replacement.Key, Parse(replacement.Value)); - } + // actually do the replacement + foreach (KeyValuePair<string, string> replacement in replace.Where(x => original.Contains(x.Key))) + { + original = original.Replace(replacement.Key, Parse(replacement.Value)); + } + + // do the replacement but default + foreach (KeyValuePair<string, string> replacement in defaultReplace.Where(x => original.Contains(x.Key))) + { + original = original.Replace(replacement.Key, replacement.Value); + } - // do the replacement but default - foreach (KeyValuePair<string, string> replacement in defaultReplace.Where(x => original.Contains(x.Key))) + return original; // returns the now replaced string + } + catch { - original = original.Replace(replacement.Key, replacement.Value); + return original; } - - return original; // returns the now replaced string } // a few things are defined here |
