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

Commit 3d71913

Browse files
committed
Squashed commit of the following:
commit 9efc67b Author: Maxi Jabase <[email protected]> Date: Wed Mar 2 12:17:01 2022 -0300 Squashed commit of the following: commit 08de973 Author: Maxi Jabase <[email protected]> Date: Wed Mar 2 01:29:50 2022 -0300 cleaned AboutWindow a bit (WIP) commit b80600f Author: Maxi Jabase <[email protected]> Date: Wed Mar 2 01:29:22 2022 -0300 remove all interpolated shit in translation strings commit dbea2fd Author: Maxi Jabase <[email protected]> Date: Tue Mar 1 21:18:55 2022 -0300 refactored the search window commit 70ecf63 Author: Maxi Jabase <[email protected]> Date: Tue Mar 1 21:18:39 2022 -0300 fixed a search setting not getting saved commit 59970f3 Author: Maxi Jabase <[email protected]> Date: Sat Feb 26 16:32:22 2022 -0300 added some titles, phrases and x:Name to grids commit 7e02048 Author: Maxi Jabase <[email protected]> Date: Sat Feb 26 15:55:57 2022 -0300 improved fallback method for missing phrases commit 7d1949b Author: Maxi Jabase <[email protected]> Date: Sat Feb 26 15:39:26 2022 -0300 added 'reload language' button next to language box in settings commit 24c318d Author: Maxi Jabase <[email protected]> Date: Sat Feb 26 15:39:09 2022 -0300 add more missing translations commit 6ce26e2 Author: Maxi Jabase <[email protected]> Date: Sat Feb 26 04:05:28 2022 -0300 fixed action on close box items translations commit 418face Author: Maxi Jabase <[email protected]> Date: Sat Feb 26 03:43:50 2022 -0300 fixed OB context menu items not being translated commit 8ead90a Author: Maxi Jabase <[email protected]> Date: Sat Feb 26 00:41:03 2022 -0300 add some missing translations commit 95b1843 Merge: 83b256d 3ec6ff5 Author: Maxi Jabase <[email protected]> Date: Fri Feb 25 17:50:23 2022 -0300 Merge branch 'ongoing' into translations-fixes commit 83b256d Merge: 28b3f69 3f30444 Author: Maxi Jabase <[email protected]> Date: Tue Feb 22 12:43:29 2022 -0300 Merge branch 'ongoing' into translations-fixes commit 28b3f69 Author: Maxi Jabase <[email protected]> Date: Sun Feb 20 16:17:34 2022 -0300 removed more hardcoded strings + added some phrases commit 3ec6ff5 Merge: 8dc4a43 3f30444 Author: Mattia <[email protected]> Date: Fri Feb 25 16:42:18 2022 +0100 Merge remote-tracking branch 'origin/ongoing' into ongoing commit 8dc4a43 Author: Mattia <[email protected]> Date: Fri Feb 25 16:42:13 2022 +0100 Better MethodMaps autocomplete commit 3f30444 Author: Maxi Jabase <[email protected]> Date: Tue Feb 22 12:43:03 2022 -0300 don't add XML comments to translations dictionary commit 8217db5 Author: Mattia <[email protected]> Date: Tue Feb 22 14:50:13 2022 +0100 Implement CTRL+SPACE to trigger the AC + ESC to close the tooltip commit 2bbb2cd Author: Mattia <[email protected]> Date: Sun Feb 20 14:27:44 2022 +0100 Fix methods AutoComplete + Implement parsing of included ".sp" files commit 058d8c8 Author: Maxi Jabase <[email protected]> Date: Sun Feb 20 01:21:15 2022 -0300 removed all hardcoded strings and if-default-dont-translate feature commit c8b6264 Author: Mattia <[email protected]> Date: Sat Feb 19 17:25:15 2022 +0100 Remove unused import commit 1286548 Author: Mattia <[email protected]> Date: Sat Feb 19 17:16:23 2022 +0100 Only show the methods of variable type commit 59f45ce Author: Mattia <[email protected]> Date: Sat Feb 19 13:42:27 2022 +0100 More IntelliSense cleanup commit b923823 Author: Mattia <[email protected]> Date: Sat Feb 19 00:54:24 2022 +0100 More IntelliSense cleanup commit 52dd22d Merge: f2c6e46 377041a Author: Maxi Jabase <[email protected]> Date: Fri Feb 18 13:46:35 2022 -0300 Merge branch 'ongoing' of https://github.com/SPCodeOrg/SPCode into ongoing commit 377041a Author: Mattia <[email protected]> Date: Fri Feb 18 16:43:28 2022 +0100 Clean up AutoComplete and IntelliSense commit f2c6e46 Merge: 3f9aa48 6696f0a Author: Maxi Jabase <[email protected]> Date: Thu Feb 17 17:22:28 2022 -0300 Merge branch 'ongoing' of https://github.com/SPCodeOrg/SPCode into ongoing commit 6696f0a Author: Mattia <[email protected]> Date: Thu Feb 17 18:33:25 2022 +0100 Fix preprocessor autocomplete commit 3f9aa48 Author: Maxi Jabase <[email protected]> Date: Thu Feb 17 11:03:19 2022 -0300 fixed close lower grid button missing commit 359762e Author: Mattia <[email protected]> Date: Thu Feb 17 13:37:01 2022 +0100 Better naming commit 552aa15 Merge: 78bb2b5 815577d Author: Mattia <[email protected]> Date: Thu Feb 17 13:31:03 2022 +0100 Merge remote-tracking branch 'origin/ongoing' into ongoing commit 78bb2b5 Author: Mattia <[email protected]> Date: Thu Feb 17 13:30:56 2022 +0100 Implement PreProcessor statements auto-complete commit 815577d Author: Maxi Jabase <[email protected]> Date: Thu Feb 17 01:50:56 2022 -0300 add highlighting to keyword 'operator' commit c960925 Author: Mattia <[email protected]> Date: Thu Feb 17 02:24:00 2022 +0100 Minor cleanup commit ed070bc Author: Maxi Jabase <[email protected]> Date: Wed Feb 16 22:09:34 2022 -0300 improved exception handling when parsing translations commit 48adf8e Author: Mattia <[email protected]> Date: Thu Feb 17 01:55:46 2022 +0100 Implement enum struct highlighting + Auto-complete for local variables commit ccc6c14 Author: Mattia <[email protected]> Date: Wed Feb 16 22:19:02 2022 +0100 Merge SearchBoxTextChanged function
1 parent f800885 commit 3d71913

36 files changed

+1682
-1239
lines changed

Interop/TranslationProvider.cs

Lines changed: 32 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ public class TranslationProvider
1515
{
1616
public List<string> AvailableLanguageIDs = new();
1717
public List<string> AvailableLanguages = new();
18-
public bool IsDefault = true;
1918

2019
private readonly string _tempDir = Paths.GetTempDirectory();
2120
private readonly string _translationsDir = Paths.GetTranslationsDirectory();
2221
private static readonly Dictionary<string, string> _langDictionary = new(StringComparer.OrdinalIgnoreCase);
22+
private static readonly Dictionary<string, string> _defaultDictionary = new(StringComparer.OrdinalIgnoreCase);
2323
private Release _latestVersion;
2424

2525
public TranslationProvider()
@@ -45,7 +45,18 @@ public TranslationProvider()
4545
/// <returns></returns>
4646
public static string Translate(string phrase)
4747
{
48-
return _langDictionary.ContainsKey(phrase) ? _langDictionary[phrase] : "<empty>";
48+
if (_langDictionary.ContainsKey(phrase))
49+
{
50+
return _langDictionary[phrase];
51+
}
52+
else if (_defaultDictionary.ContainsKey(phrase))
53+
{
54+
return _defaultDictionary[phrase];
55+
}
56+
else
57+
{
58+
return $"<{phrase}>";
59+
}
4960
}
5061

5162
/// <summary>
@@ -55,14 +66,14 @@ public static string Translate(string phrase)
5566
/// <param name="initial">Whether this was the startup initial method call</param>
5667
public void LoadLanguage(string lang, bool initial = false)
5768
{
58-
// This is probably the first boot ever
69+
_langDictionary.Clear();
5970
if (lang == string.Empty)
6071
{
72+
// This is probably the first boot ever
6173
lang = Constants.DefaultLanguageID;
6274
Program.OptionsObject.Language = lang;
6375
}
6476
lang = lang.Trim().ToLowerInvariant();
65-
IsDefault = (string.IsNullOrEmpty(lang) || lang.ToLowerInvariant() == Constants.DefaultLanguageID) && initial;
6677
var doc = new XmlDocument();
6778

6879
try
@@ -73,13 +84,10 @@ public void LoadLanguage(string lang, bool initial = false)
7384
doc.Load(Path.Combine(_translationsDir, Constants.DefaultTranslationsFile));
7485
foreach (XmlNode node in doc.ChildNodes[0].ChildNodes)
7586
{
76-
_langDictionary.Add(node.Name, node.InnerText);
77-
}
78-
79-
// Return if the attempted language to load is the default one
80-
if (lang == Constants.DefaultLanguageID)
81-
{
82-
return;
87+
if (node.NodeType != XmlNodeType.Comment)
88+
{
89+
_defaultDictionary.Add(node.Name, node.InnerText);
90+
}
8391
}
8492
}
8593

@@ -97,7 +105,10 @@ public void LoadLanguage(string lang, bool initial = false)
97105
// Replace existing keys with the ones available in this file
98106
foreach (XmlNode node in doc.ChildNodes[0].ChildNodes)
99107
{
100-
_langDictionary[node.Name] = node.InnerText;
108+
if (node.NodeType != XmlNodeType.Comment)
109+
{
110+
_langDictionary.Add(node.Name, node.InnerText);
111+
}
101112
}
102113
}
103114
}
@@ -112,10 +123,10 @@ public void LoadLanguage(string lang, bool initial = false)
112123
/// </summary>
113124
public void ParseTranslationFiles()
114125
{
115-
try
126+
var filesDir = Directory.GetFiles(_translationsDir).Where(x => x.EndsWith(".xml"));
127+
foreach (var file in filesDir)
116128
{
117-
var filesDir = Directory.GetFiles(_translationsDir).Where(x => x.EndsWith(".xml"));
118-
foreach (var file in filesDir)
129+
try
119130
{
120131
// Create wrapper
121132
var fInfo = new FileInfo(file);
@@ -135,11 +146,12 @@ public void ParseTranslationFiles()
135146
AvailableLanguages.Add(langName);
136147
AvailableLanguageIDs.Add(langID);
137148
}
138-
}
139-
catch (Exception ex)
140-
{
141-
MessageBox.Show($"There was a problem while parsing the translation files.\n" +
142-
$"Details: {ex.Message}");
149+
catch (Exception ex)
150+
{
151+
MessageBox.Show($"There was a problem while parsing the translation file '{file}'.\n" +
152+
$"Details: {ex.Message}");
153+
continue;
154+
}
143155
}
144156
}
145157

SourcepawnCondenser/CondenserTest/MainWindow.xaml.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,8 @@ private void TextBox_TextChanged(object sender, TextChangedEventArgs e)
125125
}
126126
termTree.Items.Add(dItem);
127127

128-
var cItem = new TreeViewItem() { Header = "constants (" + def.Constants.Count + ")", IsExpanded = expand };
129-
foreach (var cn in def.Constants)
128+
var cItem = new TreeViewItem() { Header = "constants (" + def.ConstVariables.Count + ")", IsExpanded = expand };
129+
foreach (var cn in def.ConstVariables)
130130
{
131131
var item = new TreeViewItem() { Header = cn.Name, IsExpanded = expand };
132132
item.Tag = cn;
@@ -226,7 +226,7 @@ private void TextBox_TextChanged(object sender, TextChangedEventArgs e)
226226
}
227227
termTree.Items.Add(eItem);
228228

229-
var vItem = new TreeViewItem() { Header = "Variables (" + def.Constants.Count + ")", IsExpanded = expand };
229+
var vItem = new TreeViewItem() { Header = "Variables (" + def.ConstVariables.Count + ")", IsExpanded = expand };
230230
foreach (var v in def.Variables)
231231
{
232232
var item = new TreeViewItem() { Header = v.Name, IsExpanded = expand };

SourcepawnCondenser/SourcepawnCondenser/CondenserFunctions/SMConstantConsumer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ private int ConsumeSMConstant()
2727

2828
if (!string.IsNullOrWhiteSpace(constantName))
2929
{
30-
def.Constants.Add(new SMConstant
30+
def.ConstVariables.Add(new SMConstant
3131
{
3232
Index = startIndex,
3333
Length = t[i].Index - startIndex,

SourcepawnCondenser/SourcepawnCondenser/CondenserFunctions/SMFunctionConsumer.cs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,11 @@ public static List<SMVariable> ConsumeSMVariableLocal(Token[] t, string FileName
315315
{
316316
while (position < length)
317317
{
318+
if (t[position].Kind != TokenKind.Identifier)
319+
{
320+
position++;
321+
continue;
322+
}
318323
var startIndex = t[position].Index;
319324

320325
var varType = t[position].Value;
@@ -430,10 +435,10 @@ public static List<SMVariable> ConsumeSMVariableLocal(Token[] t, string FileName
430435
continueNext = true;
431436
break;
432437
// Assign var match: "int x = 5"
433-
case TokenKind.Assignment when (t[position + 3].Kind == TokenKind.Number ||
438+
case TokenKind.Assignment when t[position + 3].Kind == TokenKind.Number ||
434439
t[position + 3].Kind == TokenKind.Quote ||
435-
t[position + 3].Kind == TokenKind.Identifier)
436-
&& t[position + 4].Kind == TokenKind.Semicolon:
440+
t[position + 3].Kind == TokenKind.Identifier ||
441+
t[position + 3].Kind == TokenKind.New:
437442
variables.Add(new SMVariable
438443
{
439444
Index = startIndex,

0 commit comments

Comments
 (0)