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

Commit 68f9380

Browse files
committed
Show uploading and rcon commands process while compiling
1 parent f186196 commit 68f9380

File tree

7 files changed

+75
-54
lines changed

7 files changed

+75
-54
lines changed

Interop/TranslationProvider.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -286,12 +286,15 @@ private void FillToEnglishDefaults()
286286
language.Add("IndentationSize", "Indentation size");
287287
language.Add("FontFamily", "Font");
288288
language.Add("SyntaxHigh", "Syntax Highlighting");
289-
language.Add("HighDeprecat", "Highlight deprecated (<1.7) syntax");
289+
language.Add("HighDeprecat", "Highlight deprecated (<1.7) syntax - NOT SUPPORTED");
290290
language.Add("Compile", "Compile");
291291
language.Add("AutoSaveMin", "Auto save (min)");
292292
language.Add("OBTextFile", "File Dir.");
293293
language.Add("OBTextConfig", "Config Dir.");
294294
language.Add("OBTextItem", "Item Dir.");
295-
}
295+
language.Add("CopyingFiles", "Copying files");
296+
language.Add("FTPUploading", "Uploading files");
297+
language.Add("RCONCommand", "Seconding RCON Commands");
298+
}
296299
}
297300
}

Spedit.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -524,7 +524,7 @@
524524
md ".\sourcepawn\errorfiles"
525525
md ".\nsis-plugins"
526526
C:\Windows\system32\xcopy ".\..\..\Resources\Misc\Templates\*.*" ".\sourcepawn\templates\*.*" /e /y /q
527-
C:\Windows\system32\xcopy ".\..\..\Resources\Misc\Configurations" ".\sourcepawn\configs" /e /y /q
527+
C:\Windows\system32\xcopy ".\..\..\Resources\Misc\Configurations" ".\sourcepawn\configs" /e /y /q /d
528528
copy ".\..\..\Resources\lang_0_spedit.xml" ".\lang_0_spedit.xml" /y
529529
copy ".\..\..\Deploy\SPEdit.nsi" ".\SPEdit.nsi" /y
530530
copy ".\..\..\Deploy\Compress.ps1" ".\Compress.ps1" /y

Spedit.sln.DotSettings

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
2+
<s:Boolean x:Key="/Default/UserDictionary/Words/=RCON/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>

UI/Components/EditorElement.xaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@
7272
</editor:TextEditor.ContextMenu>
7373
</editor:TextEditor>
7474
<CheckBox x:Name="CompileBox" HorizontalAlignment="Left" VerticalAlignment="Bottom" Margin="2,0,0,0" Content="Compile" Foreground="{DynamicResource BlackColorBrush}" />
75+
<TextBlock Name="StatusLine_Work" HorizontalAlignment="Left" VerticalAlignment="Bottom" Margin="100,0,0,0" Text="HERE" Foreground="{DynamicResource BlackColorBrush}" IsHitTestVisible="False" />
7576
<TextBlock Name="StatusLine_FontSize" HorizontalAlignment="Right" VerticalAlignment="Bottom" Margin="2" Text="14 pt" Foreground="{DynamicResource BlackColorBrush}" IsHitTestVisible="False" />
7677
<TextBlock Name="StatusLine_Coloumn" HorizontalAlignment="Right" VerticalAlignment="Bottom" Margin="2,2,100,2" Text="Col 0" Foreground="{DynamicResource BlackColorBrush}" IsHitTestVisible="False" />
7778
<TextBlock Name="StatusLine_Line" HorizontalAlignment="Right" VerticalAlignment="Bottom" Margin="2,2,200,2" Text="Ln 0" Foreground="{DynamicResource BlackColorBrush}" IsHitTestVisible="False" />

UI/Components/EditorElement.xaml.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -494,15 +494,14 @@ public async void Close(bool ForcedToSave = false, bool CheckSavings = true)
494494
{
495495
var title = $"{Program.Translations.GetLanguage("SavingFile")} '" + Parent.Title.Trim('*') +
496496
"'";
497-
var msg = "";
498-
var Result = await Program.MainWindow.ShowMessageAsync(title, msg,
497+
var Result = await Program.MainWindow.ShowMessageAsync(title, "",
499498
MessageDialogStyle.AffirmativeAndNegative, Program.MainWindow.MetroDialogOptions);
500499
if (Result == MessageDialogResult.Affirmative) Save();
501500
}
502501
}
503502

504503
Program.MainWindow.EditorsReferences.Remove(this);
505-
var childs = Program.MainWindow.DockingPaneGroup.Children;
504+
// var childs = Program.MainWindow.DockingPaneGroup.Children;
506505
// foreach (var c in childs) (c as LayoutDocumentPane)?.Children.Remove(Parent);
507506

508507
Parent = null; //to prevent a ring depency which disables the GC from work

UI/MainWindowSPCompiler.cs

Lines changed: 39 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using System.Text;
66
using System.Text.RegularExpressions;
77
using System.Threading;
8+
using System.Threading.Tasks;
89
using System.Windows;
910
using MahApps.Metro.Controls.Dialogs;
1011
using Spedit.Utils;
@@ -102,7 +103,7 @@ private async void Compile_SPScripts(bool All = true)
102103
}
103104

104105
var file = filesToCompile[i];
105-
progressTask.SetMessage(file);
106+
progressTask.SetMessage($"{file} ({i}/{compileCount}) ");
106107
ProcessUITasks();
107108
var fileInfo = new FileInfo(file);
108109
stringOutput.AppendLine(fileInfo.Name);
@@ -194,9 +195,30 @@ await this.ShowMessageAsync(Program.Translations.GetLanguage("SPCompNotStarted")
194195
{
195196
progressTask.SetProgress(1.0);
196197
CompileOutput.Text = stringOutput.ToString();
197-
if (c.AutoCopy) Copy_Plugins(true);
198-
if (c.AutoUpload) FTPUpload_Plugins();
199-
if (c.AutoRCON) Server_Query();
198+
if (c.AutoCopy)
199+
{
200+
progressTask.SetTitle(Program.Translations.GetLanguage("CopyingFiles"));
201+
progressTask.SetIndeterminate();
202+
await Task.Run(() => Copy_Plugins(true));
203+
progressTask.SetProgress(1.0);
204+
}
205+
206+
if (c.AutoUpload)
207+
{
208+
progressTask.SetTitle(Program.Translations.GetLanguage("FTPUploading"));
209+
progressTask.SetIndeterminate();
210+
await Task.Run(FTPUpload_Plugins);
211+
progressTask.SetProgress(1.0);
212+
}
213+
214+
if (c.AutoRCON)
215+
{
216+
progressTask.SetTitle(Program.Translations.GetLanguage("RCONCommand"));
217+
progressTask.SetIndeterminate();
218+
await Task.Run(Server_Query);
219+
progressTask.SetProgress(1.0);
220+
}
221+
200222
if (CompileOutputRow.Height.Value < 11.0) CompileOutputRow.Height = new GridLength(200.0);
201223
}
202224

@@ -248,11 +270,14 @@ private void Copy_Plugins(bool OvertakeOutString = false)
248270
}
249271

250272
if (copyCount == 0) stringOutput.AppendLine(Program.Translations.GetLanguage("NoFilesCopy"));
251-
if (OvertakeOutString)
252-
CompileOutput.AppendText(stringOutput.ToString());
253-
else
254-
CompileOutput.Text = stringOutput.ToString();
255-
if (CompileOutputRow.Height.Value < 11.0) CompileOutputRow.Height = new GridLength(200.0);
273+
Dispatcher.Invoke(() =>
274+
{
275+
if (OvertakeOutString)
276+
CompileOutput.AppendText(stringOutput.ToString());
277+
else
278+
CompileOutput.Text = stringOutput.ToString();
279+
if (CompileOutputRow.Height.Value < 11.0) CompileOutputRow.Height = new GridLength(200.0);
280+
});
256281
}
257282
}
258283
}
@@ -297,8 +322,11 @@ private void FTPUpload_Plugins()
297322
}
298323

299324
stringOutput.AppendLine(Program.Translations.GetLanguage("Done"));
300-
CompileOutput.Text = stringOutput.ToString();
301-
if (CompileOutputRow.Height.Value < 11.0) CompileOutputRow.Height = new GridLength(200.0);
325+
Dispatcher.Invoke(() =>
326+
{
327+
CompileOutput.Text = stringOutput.ToString();
328+
if (CompileOutputRow.Height.Value < 11.0) CompileOutputRow.Height = new GridLength(200.0);
329+
});
302330
}
303331

304332
private void Server_Start()

UI/MainWindowServerQuery.cs

Lines changed: 25 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
using System;
22
using System.Text;
3-
using System.Windows;
43
using System.Threading.Tasks;
5-
using Spedit.Interop;
4+
using System.Windows;
65
using QueryMaster;
76

87
namespace Spedit.UI
@@ -11,98 +10,87 @@ public partial class MainWindow
1110
{
1211
private void Server_Query()
1312
{
14-
Config c = Program.Configs[Program.SelectedConfig];
15-
if (string.IsNullOrWhiteSpace(c.RConIP) || string.IsNullOrWhiteSpace(c.RConCommands))
16-
{ return; }
17-
StringBuilder stringOutput = new StringBuilder();
13+
var c = Program.Configs[Program.SelectedConfig];
14+
if (string.IsNullOrWhiteSpace(c.RConIP) || string.IsNullOrWhiteSpace(c.RConCommands)) return;
15+
var stringOutput = new StringBuilder();
1816
try
1917
{
20-
EngineType type = EngineType.GoldSource;
21-
if (c.RConUseSourceEngine)
22-
{
23-
type = EngineType.Source;
24-
}
25-
using (Server server = ServerQuery.GetServerInstance(type, c.RConIP, c.RConPort, null))
18+
var type = EngineType.GoldSource;
19+
if (c.RConUseSourceEngine) type = EngineType.Source;
20+
using (var server = ServerQuery.GetServerInstance(type, c.RConIP, c.RConPort, null))
2621
{
2722
var serverInfo = server.GetInfo();
2823
stringOutput.AppendLine(serverInfo.Name);
2924
using (var rcon = server.GetControl(c.RConPassword))
3025
{
31-
string[] cmds = ReplaceRconCMDVariables(c.RConCommands).Split('\n');
26+
var cmds = ReplaceRconCMDVariables(c.RConCommands).Split('\n');
3227
foreach (var cmd in cmds)
3328
{
34-
Task t = Task.Run(() =>
29+
var t = Task.Run(() =>
3530
{
36-
string command = (cmd.Trim('\r')).Trim();
31+
var command = cmd.Trim('\r').Trim();
3732
if (!string.IsNullOrWhiteSpace(command))
38-
{
3933
stringOutput.AppendLine(rcon.SendCommand(command));
40-
}
4134
});
4235
t.Wait();
4336
}
4437
}
4538
}
39+
4640
stringOutput.AppendLine("Done");
4741
}
4842
catch (Exception e)
4943
{
5044
stringOutput.AppendLine("Error: " + e.Message);
5145
}
52-
CompileOutput.Text = stringOutput.ToString();
53-
if (CompileOutputRow.Height.Value < 11.0)
46+
47+
Dispatcher.Invoke(() =>
5448
{
55-
CompileOutputRow.Height = new GridLength(200.0);
56-
}
49+
CompileOutput.Text = stringOutput.ToString();
50+
if (CompileOutputRow.Height.Value < 11.0) CompileOutputRow.Height = new GridLength(200.0);
51+
});
5752
}
5853

5954
private string ReplaceRconCMDVariables(string input)
6055
{
61-
if (compiledFileNames.Count < 1)
62-
{ return input; }
56+
if (compiledFileNames.Count < 1) return input;
6357
if (input.IndexOf("{plugins_reload}", StringComparison.Ordinal) >= 0)
6458
{
65-
StringBuilder replacement = new StringBuilder();
59+
var replacement = new StringBuilder();
6660
replacement.AppendLine();
6761
foreach (var fileName in compiledFileNames)
68-
{
6962
replacement.Append("sm plugins reload " + StripSMXPostFix(fileName) + ";");
70-
}
7163
replacement.AppendLine();
7264
input = input.Replace("{plugins_reload}", replacement.ToString());
7365
}
66+
7467
if (input.IndexOf("{plugins_load}", StringComparison.Ordinal) >= 0)
7568
{
76-
StringBuilder replacement = new StringBuilder();
69+
var replacement = new StringBuilder();
7770
replacement.AppendLine();
7871
foreach (var fileName in compiledFileNames)
79-
{
8072
replacement.Append("sm plugins load " + StripSMXPostFix(fileName) + ";");
81-
}
8273
replacement.AppendLine();
8374
input = input.Replace("{plugins_load}", replacement.ToString());
8475
}
76+
8577
if (input.IndexOf("{plugins_unload}", StringComparison.Ordinal) >= 0)
8678
{
87-
StringBuilder replacement = new StringBuilder();
79+
var replacement = new StringBuilder();
8880
replacement.AppendLine();
8981
foreach (var fileName in compiledFileNames)
90-
{
9182
replacement.Append("sm plugins unload " + StripSMXPostFix(fileName) + ";");
92-
}
9383
replacement.AppendLine();
9484
input = input.Replace("{plugins_unload}", replacement.ToString());
9585
}
86+
9687
return input;
9788
}
9889

9990
private string StripSMXPostFix(string fileName)
10091
{
101-
if (fileName.EndsWith(".smx"))
102-
{
103-
return fileName.Substring(0, fileName.Length - 4);
104-
}
92+
if (fileName.EndsWith(".smx")) return fileName.Substring(0, fileName.Length - 4);
10593
return fileName;
10694
}
10795
}
108-
}
96+
}

0 commit comments

Comments
 (0)