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

Commit ec08cfa

Browse files
committed
Merge remote-tracking branch 'origin/Bug-fix-and-optimization'
2 parents 9016b0a + 336ed70 commit ec08cfa

15 files changed

+437
-937
lines changed

Interop/TranslationProvider.cs

Lines changed: 209 additions & 709 deletions
Large diffs are not rendered by default.

UI/Components/DASMElement.xaml.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ private void LoadFile(FileInfo fInfo)
5858
}
5959
catch (Exception e)
6060
{
61-
detailbox_.Text = Program.Translations.ErrorFileLoadProc + Environment.NewLine + Environment.NewLine + $"{Program.Translations.Details}: " + e.Message;
61+
detailbox_.Text = Program.Translations.GetLanguage("ErrorFileLoadProc") + Environment.NewLine + Environment.NewLine + $"{Program.Translations.GetLanguage("Details")}: " + e.Message;
6262
return;
6363
}
6464
renderFile();
@@ -280,7 +280,7 @@ private void renderCodeView(SmxCodeV1Section code, string name, int address)
280280
}
281281
catch (Exception e)
282282
{
283-
addDetailLine(Program.Translations.NotDissMethod, name, e.Message);
283+
addDetailLine(Program.Translations.GetLanguage("NotDissMethod"), name, e.Message);
284284
endDetailUpdate();
285285
return;
286286
}

UI/Components/EditorElement.xaml.cs

Lines changed: 27 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -288,8 +288,8 @@ private void fileWatcher_Changed(object sender, FileSystemEventArgs e)
288288
bool ReloadFile = false;
289289
if (_NeedsSave)
290290
{
291-
var result = MessageBox.Show(string.Format(Program.Translations.DFileChanged, _FullFilePath) + Environment.NewLine + Program.Translations.FileTryReload,
292-
Program.Translations.FileChanged, MessageBoxButton.YesNo, MessageBoxImage.Asterisk);
291+
var result = MessageBox.Show(string.Format(Program.Translations.GetLanguage("DFileChanged"), _FullFilePath) + Environment.NewLine + Program.Translations.GetLanguage("FileTryReload"),
292+
Program.Translations.GetLanguage("FileChanged"), MessageBoxButton.YesNo, MessageBoxImage.Asterisk);
293293
ReloadFile = (result == MessageBoxResult.Yes);
294294
}
295295
else //when the user didnt changed anything, we just reload the file since we are intelligent...
@@ -388,7 +388,7 @@ public void Save(bool Force = false)
388388
}
389389
catch (Exception e)
390390
{
391-
MessageBox.Show(Program.MainWindow, Program.Translations.DSaveError + Environment.NewLine + "(" + e.Message + ")", Program.Translations.SaveError,
391+
MessageBox.Show(Program.MainWindow, Program.Translations.GetLanguage("DSaveError") + Environment.NewLine + "(" + e.Message + ")", Program.Translations.GetLanguage("SaveError"),
392392
MessageBoxButton.OK, MessageBoxImage.Error);
393393
return;
394394
}
@@ -405,7 +405,7 @@ public void UpdateFontSize(double size, bool UpdateLineHeight = true)
405405
if (size > 2 && size < 31)
406406
{
407407
editor.FontSize = size;
408-
StatusLine_FontSize.Text = size.ToString("n0") + $" {Program.Translations.PtAbb}";
408+
StatusLine_FontSize.Text = size.ToString("n0") + $" {Program.Translations.GetLanguage("PtAbb")}";
409409
}
410410
if (UpdateLineHeight)
411411
{
@@ -492,7 +492,7 @@ public void MoveLine(bool down)
492492
}
493493
}
494494

495-
public void Close(bool ForcedToSave = false, bool CheckSavings = true)
495+
public async void Close(bool ForcedToSave = false, bool CheckSavings = true)
496496
{
497497
regularyTimer.Stop();
498498
regularyTimer.Close();
@@ -512,9 +512,10 @@ public void Close(bool ForcedToSave = false, bool CheckSavings = true)
512512
}
513513
else
514514
{
515-
var Result = Program.MainWindow.ShowMessageAsync($"{Program.Translations.SavingFile} '" + Parent.Title.Trim(new char[] { '*' }) + "'", "", MessageDialogStyle.AffirmativeAndNegative, Program.MainWindow.MetroDialogOptions);
516-
Result.Wait();
517-
if (Result.Result == MessageDialogResult.Affirmative)
515+
string title = $"{Program.Translations.GetLanguage("SavingFile")} '" + Parent.Title.Trim(new char[] { '*' }) + "'";
516+
string msg = "";
517+
MessageDialogResult Result = await Program.MainWindow.ShowMessageAsync(title, msg, MessageDialogStyle.AffirmativeAndNegative, Program.MainWindow.MetroDialogOptions);
518+
if (Result == MessageDialogResult.Affirmative)
518519
{
519520
Save();
520521
}
@@ -541,8 +542,8 @@ private void editor_TextChanged(object sender, EventArgs e)
541542

542543
private void Caret_PositionChanged(object sender, EventArgs e)
543544
{
544-
StatusLine_Coloumn.Text = $"{Program.Translations.ColAbb} {editor.TextArea.Caret.Column}";
545-
StatusLine_Line.Text = $"{Program.Translations.LnAbb} {editor.TextArea.Caret.Line}";
545+
StatusLine_Coloumn.Text = $"{Program.Translations.GetLanguage("ColAbb")} {editor.TextArea.Caret.Column}";
546+
StatusLine_Line.Text = $"{Program.Translations.GetLanguage("LnAbb")} {editor.TextArea.Caret.Line}";
546547
EvaluateIntelliSense();
547548
var result = bracketSearcher.SearchBracket(editor.Document, editor.CaretOffset);
548549
bracketHighlightRenderer.SetHighlight(result);
@@ -623,7 +624,7 @@ private void TextArea_TextEntered(object sender, TextCompositionEventArgs e)
623624

624625
private void TextArea_SelectionChanged(object sender, EventArgs e)
625626
{
626-
StatusLine_SelectionLength.Text = $"{Program.Translations.LenAbb} {editor.SelectionLength}";
627+
StatusLine_SelectionLength.Text = $"{Program.Translations.GetLanguage("LenAbb")} {editor.SelectionLength}";
627628
}
628629

629630
private void PrevMouseWheel(object sender, MouseWheelEventArgs e)
@@ -726,18 +727,23 @@ public void Language_Translate(bool Initial = false)
726727
{
727728
return;
728729
}
729-
MenuC_Undo.Header = Program.Translations.Undo;
730-
MenuC_Redo.Header = Program.Translations.Redo;
731-
MenuC_Cut.Header = Program.Translations.Cut;
732-
MenuC_Copy.Header = Program.Translations.Copy;
733-
MenuC_Paste.Header = Program.Translations.Paste;
734-
MenuC_SelectAll.Header = Program.Translations.SelectAll;
735-
CompileBox.Content = Program.Translations.Compile;
730+
MenuC_Undo.Header = Program.Translations.GetLanguage("Undo");
731+
732+
MenuC_Redo.Header = Program.Translations.GetLanguage("Redo");
733+
734+
MenuC_Cut.Header = Program.Translations.GetLanguage("Cut");
735+
736+
MenuC_Copy.Header = Program.Translations.GetLanguage("Copy");
737+
738+
MenuC_Paste.Header = Program.Translations.GetLanguage("Paste");
739+
740+
MenuC_SelectAll.Header = Program.Translations.GetLanguage("SelectAll");
741+
CompileBox.Content = Program.Translations.GetLanguage("Compile");
736742
if (!Initial)
737743
{
738-
StatusLine_Coloumn.Text = $"{Program.Translations.ColAbb} {editor.TextArea.Caret.Column}";
739-
StatusLine_Line.Text = $"{Program.Translations.LnAbb} {editor.TextArea.Caret.Line}";
740-
StatusLine_FontSize.Text = editor.FontSize.ToString("n0") + $" {Program.Translations.PtAbb}";
744+
StatusLine_Coloumn.Text = $"{Program.Translations.GetLanguage("ColAbb")} {editor.TextArea.Caret.Column}";
745+
StatusLine_Line.Text = $"{Program.Translations.GetLanguage("LnAbb")} {editor.TextArea.Caret.Line}";
746+
StatusLine_FontSize.Text = editor.FontSize.ToString("n0") + $" {Program.Translations.GetLanguage("PtAbb")}";
741747
}
742748
}
743749
}

UI/MainWindow.xaml.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ private void MetroWindow_Closing(object sender, System.ComponentModel.CancelEven
250250
{
251251
if (SaveUnsaved == null)
252252
{
253-
var result = MessageBox.Show(this, Program.Translations.SavingUFiles, Program.Translations.Saving, MessageBoxButton.YesNo, MessageBoxImage.Question);
253+
var result = MessageBox.Show(this, Program.Translations.GetLanguage("SavingUFiles"), Program.Translations.GetLanguage("Saving"), MessageBoxButton.YesNo, MessageBoxImage.Question);
254254
if (result == MessageBoxResult.Yes)
255255
{
256256
SaveUnsaved = true;
@@ -367,7 +367,7 @@ private void UpdateWindowTitle()
367367
}
368368
if (ServerIsRunning)
369369
{
370-
outString = $"{outString} ({Program.Translations.ServerRunning})";
370+
outString = $"{outString} ({Program.Translations.GetLanguage("ServerRunning")})";
371371
}
372372
this.Title = outString;
373373
}
@@ -394,8 +394,8 @@ private int GetLineInteger(string lineStr)
394394
return -1;
395395
}
396396

397-
private ObservableCollection<string> compileButtonDict = new ObservableCollection<string>() { Program.Translations.CompileAll, Program.Translations.CompileCurr };
398-
private ObservableCollection<string> actionButtonDict = new ObservableCollection<string>() { Program.Translations.Copy, Program.Translations.FTPUp, Program.Translations.StartServer };
399-
private ObservableCollection<string> findReplaceButtonDict = new ObservableCollection<string>() { Program.Translations.Replace, Program.Translations.ReplaceAll };
397+
private ObservableCollection<string> compileButtonDict = new ObservableCollection<string>() { Program.Translations.GetLanguage("CompileAll"), Program.Translations.GetLanguage("CompileCurr") };
398+
private ObservableCollection<string> actionButtonDict = new ObservableCollection<string>() { Program.Translations.GetLanguage("Copy"), Program.Translations.GetLanguage("FTPUp"), Program.Translations.GetLanguage("StartServer") };
399+
private ObservableCollection<string> findReplaceButtonDict = new ObservableCollection<string>() { Program.Translations.GetLanguage("Replace"), Program.Translations.GetLanguage("ReplaceAll") };
400400
}
401401
}

UI/MainWindowCommands.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ private void Command_New()
4949

5050
private void Command_Open()
5151
{
52-
OpenFileDialog ofd = new OpenFileDialog() { AddExtension = true, CheckFileExists = true, CheckPathExists = true, Filter = @"Sourcepawn Files (*.sp *.inc)|*.sp;*.inc|Sourcemod Plugins (*.smx)|*.smx|All Files (*.*)|*.*", Multiselect = true, Title = Program.Translations.OpenNewFile };
52+
OpenFileDialog ofd = new OpenFileDialog() { AddExtension = true, CheckFileExists = true, CheckPathExists = true, Filter = @"Sourcepawn Files (*.sp *.inc)|*.sp;*.inc|Sourcemod Plugins (*.smx)|*.smx|All Files (*.*)|*.*", Multiselect = true, Title = Program.Translations.GetLanguage("OpenNewFile") };
5353
var result = ofd.ShowDialog(this);
5454
if (result.Value)
5555
{
@@ -63,7 +63,7 @@ private void Command_Open()
6363
if (!AnyFileLoaded)
6464
{
6565
this.MetroDialogOptions.ColorScheme = MetroDialogColorScheme.Theme;
66-
this.ShowMessageAsync(Program.Translations.NoFileOpened, Program.Translations.NoFileOpenedCap, MessageDialogStyle.Affirmative, this.MetroDialogOptions);
66+
this.ShowMessageAsync(Program.Translations.GetLanguage("NoFileOpened"), Program.Translations.GetLanguage("NoFileOpenedCap"), MessageDialogStyle.Affirmative, this.MetroDialogOptions);
6767
}
6868
}
6969
}
@@ -85,7 +85,7 @@ private void Command_SaveAs()
8585
EditorElement ee = GetCurrentEditorElement();
8686
if (ee != null)
8787
{
88-
SaveFileDialog sfd = new SaveFileDialog() { AddExtension = true, Filter = @"Sourcepawn Files (*.sp *.inc)|*.sp;*.inc|All Files (*.*)|*.*", OverwritePrompt = true, Title = Program.Translations.SaveFileAs };
88+
SaveFileDialog sfd = new SaveFileDialog() { AddExtension = true, Filter = @"Sourcepawn Files (*.sp *.inc)|*.sp;*.inc|All Files (*.*)|*.*", OverwritePrompt = true, Title = Program.Translations.GetLanguage("SaveFileAs") };
8989
sfd.FileName = ee.Parent.Title.Trim(new char[] { '*' });
9090
var result = sfd.ShowDialog(this);
9191
if (result.Value)
@@ -151,7 +151,7 @@ private async void Command_CloseAll()
151151
else
152152
{ str.AppendLine(editors[i].Parent.Title.Trim(new char[] { '*' })); }
153153
}
154-
var Result = await this.ShowMessageAsync(Program.Translations.SaveFollow, str.ToString(), MessageDialogStyle.AffirmativeAndNegative, this.MetroDialogOptions);
154+
var Result = await this.ShowMessageAsync(Program.Translations.GetLanguage("SaveFollow"), str.ToString(), MessageDialogStyle.AffirmativeAndNegative, this.MetroDialogOptions);
155155
if (Result == MessageDialogResult.Affirmative)
156156
{
157157
ForceSave = true;
@@ -286,7 +286,7 @@ private async void Command_Decompile(MainWindow win)
286286
{
287287
OpenFileDialog ofd = new OpenFileDialog();
288288
ofd.Filter = "Sourcepawn Plugins (*.smx)|*.smx";
289-
ofd.Title = Program.Translations.ChDecomp;
289+
ofd.Title = Program.Translations.GetLanguage("ChDecomp");
290290
var result = ofd.ShowDialog();
291291
if (result.Value)
292292
{
@@ -298,7 +298,7 @@ private async void Command_Decompile(MainWindow win)
298298
ProgressDialogController task = null;
299299
if (win != null)
300300
{
301-
task = await this.ShowProgressAsync(Program.Translations.Decompiling, fInfo.FullName, false, this.MetroDialogOptions);
301+
task = await this.ShowProgressAsync(Program.Translations.GetLanguage("Decompiling"), fInfo.FullName, false, this.MetroDialogOptions);
302302
MainWindow.ProcessUITasks();
303303
}
304304
string destFile = fInfo.FullName + ".sp";

UI/MainWindowConfigHandler.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public void FillConfigMenu()
1818
ConfigMenu.Items.Add(item);
1919
}
2020
ConfigMenu.Items.Add(new Separator());
21-
MenuItem editItem = new MenuItem() { Header = Program.Translations.EditConfig };
21+
MenuItem editItem = new MenuItem() { Header = Program.Translations.GetLanguage("EditConfig") };
2222
editItem.Click += editItem_Click;
2323
ConfigMenu.Items.Add(editItem);
2424
}

UI/MainWindowFindReplaceHandler.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -172,15 +172,15 @@ private void Search()
172172
var location = editors[index].editor.Document.GetLocation(m.Index + addToOffset);
173173
editors[index].editor.ScrollTo(location.Line, location.Column);
174174
//FindResultBlock.Text = "Found in offset " + (m.Index + addToOffset).ToString() + " with length " + m.Length.ToString();
175-
FindResultBlock.Text = string.Format(Program.Translations.FoundInOff, m.Index + addToOffset, m.Length);
175+
FindResultBlock.Text = string.Format(Program.Translations.GetLanguage("FoundInOff"), m.Index + addToOffset, m.Length);
176176
break;
177177
}
178178
}
179179
}
180180
}
181181
if (!foundOccurence)
182182
{
183-
FindResultBlock.Text = Program.Translations.FoundNothing;
183+
FindResultBlock.Text = Program.Translations.GetLanguage("FoundNothing");
184184
}
185185
}
186186

@@ -238,15 +238,15 @@ private void Replace()
238238
editors[index].editor.Select(m.Index + addToOffset, result.Length);
239239
var location = editors[index].editor.Document.GetLocation(m.Index + addToOffset);
240240
editors[index].editor.ScrollTo(location.Line, location.Column);
241-
FindResultBlock.Text = string.Format(Program.Translations.ReplacedOff, MinHeight + addToOffset);
241+
FindResultBlock.Text = string.Format(Program.Translations.GetLanguage("ReplacedOff"), MinHeight + addToOffset);
242242
break;
243243
}
244244
}
245245
}
246246
}
247247
if (!foundOccurence)
248248
{
249-
FindResultBlock.Text = Program.Translations.FoundNothing;
249+
FindResultBlock.Text = Program.Translations.GetLanguage("FoundNothing");
250250
}
251251
}
252252

@@ -280,7 +280,7 @@ private void ReplaceAll()
280280
}
281281
}
282282
//FindResultBlock.Text = "Replaced " + count.ToString() + " occurences in " + fileCount.ToString() + " documents";
283-
FindResultBlock.Text = string.Format(Program.Translations.ReplacedOcc, count, fileCount);
283+
FindResultBlock.Text = string.Format(Program.Translations.GetLanguage("ReplacedOcc, count, fileCount"));
284284
}
285285

286286
private void Count()
@@ -298,15 +298,15 @@ private void Count()
298298
MatchCollection mc = regex.Matches(editors[i].editor.Text);
299299
count += mc.Count;
300300
}
301-
FindResultBlock.Text = count.ToString() + Program.Translations.OccFound;
301+
FindResultBlock.Text = count.ToString() + Program.Translations.GetLanguage("OccFound");
302302
}
303303

304304
private Regex GetSearchRegex()
305305
{
306306
string findString = FindBox.Text;
307307
if (string.IsNullOrEmpty(findString))
308308
{
309-
FindResultBlock.Text = Program.Translations.EmptyPatt;
309+
FindResultBlock.Text = Program.Translations.GetLanguage("EmptyPatt");
310310
return null;
311311
}
312312
Regex regex;
@@ -337,7 +337,7 @@ private Regex GetSearchRegex()
337337
{
338338
regex = new Regex(findString, regexOptions);
339339
}
340-
catch (Exception) { FindResultBlock.Text = Program.Translations.NoValidRegex; return null; }
340+
catch (Exception) { FindResultBlock.Text = Program.Translations.GetLanguage("NoValidRegex"); return null; }
341341
}
342342
return regex;
343343
}

UI/MainWindowMenuHandler.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,12 +244,12 @@ private void UpdateCheck_Click(object sender, RoutedEventArgs e)
244244
{
245245
if (status.GotException)
246246
{
247-
this.ShowMessageAsync(Program.Translations.FailedCheck, Program.Translations.ErrorUpdate + Environment.NewLine + $"{Program.Translations.Details}: " + status.ExceptionMessage
247+
this.ShowMessageAsync(Program.Translations.GetLanguage("FailedCheck"), Program.Translations.GetLanguage("ErrorUpdate") + Environment.NewLine + $"{Program.Translations.GetLanguage("Details")}: " + status.ExceptionMessage
248248
, MessageDialogStyle.Affirmative, this.MetroDialogOptions);
249249
}
250250
else
251251
{
252-
this.ShowMessageAsync(Program.Translations.VersUpToDate, string.Format(Program.Translations.VersionYour, Assembly.GetEntryAssembly().GetName().Version.ToString())
252+
this.ShowMessageAsync(Program.Translations.GetLanguage("VersUpToDate"), string.Format(Program.Translations.GetLanguage("VersionYour"), Assembly.GetEntryAssembly().GetName().Version.ToString())
253253
, MessageDialogStyle.Affirmative, this.MetroDialogOptions);
254254
}
255255
}

0 commit comments

Comments
 (0)