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

Commit 6ab5d88

Browse files
committed
added "don't output file" checkbox when compiling
1 parent ba9c5ca commit 6ab5d88

File tree

3 files changed

+31
-13
lines changed

3 files changed

+31
-13
lines changed

UI/Components/EditorElement/EditorElement.xaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565
</editor:TextEditor.ContextMenu>
6666
</editor:TextEditor>
6767
<CheckBox x:Name="CompileBox" HorizontalAlignment="Left" VerticalAlignment="Bottom" Margin="2,0,0,0" Content="Compile" Foreground="{DynamicResource BlackColorBrush}" />
68+
<CheckBox x:Name="DontCreateFileBox" HorizontalAlignment="Left" VerticalAlignment="Bottom" Margin="92,0,0,0" Foreground="{DynamicResource BlackColorBrush}" />
6869
<TextBlock Name="StatusLine_FontSize" HorizontalAlignment="Right" VerticalAlignment="Bottom" Margin="2" Text="14 pt" Foreground="{DynamicResource BlackColorBrush}" IsHitTestVisible="False" />
6970
<TextBlock Name="StatusLine_Column" HorizontalAlignment="Right" VerticalAlignment="Bottom" Margin="2,2,100,2" Text="Col 0" Foreground="{DynamicResource BlackColorBrush}" IsHitTestVisible="False" />
7071
<TextBlock Name="StatusLine_Offset" HorizontalAlignment="Right" VerticalAlignment="Bottom" Margin="0,0,151,2" Foreground="{DynamicResource BlackColorBrush}" IsHitTestVisible="False" />

UI/Components/EditorElement/EditorElement.xaml.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1021,6 +1021,7 @@ public void Language_Translate(bool Initial = false)
10211021
MenuC_Paste.Header = Translate("Paste");
10221022
MenuC_SelectAll.Header = Translate("SelectAll");
10231023
CompileBox.Content = Translate("Compile");
1024+
DontCreateFileBox.Content = Translate("DontOutputFile");
10241025
if (!Initial)
10251026
{
10261027
StatusLine_Column.Text =

UI/MainWindow/MainWindowSPCompiler.cs

Lines changed: 29 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ private async void Compile_SPScripts(bool compileAll = true)
7070
var SpCompFound = false;
7171
var PressedEscape = false;
7272
var hadError = false;
73+
var dontCreateFile = false;
7374
TotalErrors = 0;
7475
TotalWarnings = 0;
7576
CurrentErrorString = string.Empty;
@@ -172,11 +173,24 @@ await this.ShowMessageAsync(Translate("Error"),
172173
process.StartInfo.CreateNoWindow = true;
173174
process.StartInfo.FileName = spCompInfo.FullName;
174175

175-
var destinationFileName = ShortenScriptFileName(fileInfo.Name) + ".smx";
176-
var outFile = Path.Combine(fileInfo.DirectoryName, destinationFileName);
177-
if (File.Exists(outFile))
176+
dontCreateFile = ee.DontCreateFileBox.IsChecked.HasValue && ee.DontCreateFileBox.IsChecked.Value;
177+
string outFile;
178+
string destinationFileName;
179+
if (dontCreateFile)
178180
{
179-
File.Delete(outFile);
181+
outFile = "NUL";
182+
destinationFileName = string.Empty;
183+
}
184+
else
185+
{
186+
destinationFileName = ShortenScriptFileName(fileInfo.Name) + ".smx";
187+
outFile = Path.Combine(fileInfo.DirectoryName, destinationFileName);
188+
if (File.Exists(outFile))
189+
{
190+
File.Delete(outFile);
191+
}
192+
ExecuteCommandLine(currentConfig.PreCmd, fileInfo.DirectoryName, currentConfig.CopyDirectory,
193+
fileInfo.FullName, fileInfo.Name, outFile, destinationFileName);
180194
}
181195

182196
var errorFile = $@"{fileInfo.DirectoryName}\error_{Environment.TickCount}_{file.GetHashCode():X}_{i}.txt";
@@ -197,8 +211,7 @@ await this.ShowMessageAsync(Translate("Error"),
197211
"\"" + fileInfo.FullName + "\" -o=\"" + outFile + "\" -e=\"" + errorFile + "\"" +
198212
includeStr + " -O=" + currentConfig.OptimizeLevel + " -v=" + currentConfig.VerboseLevel;
199213
ProgressTask.SetProgress((i + 1 - 0.5d) / compileCount);
200-
var execResult = ExecuteCommandLine(currentConfig.PreCmd, fileInfo.DirectoryName, currentConfig.CopyDirectory,
201-
fileInfo.FullName, fileInfo.Name, outFile, destinationFileName);
214+
202215

203216
ProcessUITasks();
204217

@@ -212,7 +225,7 @@ await this.ShowMessageAsync(Translate("Error"),
212225
await ProgressTask.CloseAsync();
213226
await this.ShowMessageAsync(Translate("Error"),
214227
"The SourcePawn compiler has crashed.\n" +
215-
"Try again, or file an issue at the SourcePawn GitHub repository describing your steps that lead to this instance in detail.\n" +
228+
"Try again, or file an issue at the SourcePawn GitHub repository describing your steps that led to this instance in detail.\n" +
216229
$"Exit code: {process.ExitCode:X}", MessageDialogStyle.Affirmative,
217230
MetroDialogOptions);
218231
LoggingControl.LogAction($"Compiler crash detected, file: {fileInfo.Name}", 2);
@@ -286,15 +299,18 @@ await this.ShowMessageAsync(Translate("SPCompNotStarted"),
286299
compiledSuccess++;
287300
}
288301

289-
if (File.Exists(outFile))
302+
if (!dontCreateFile && File.Exists(outFile))
290303
{
291304
CompiledFiles.Add(outFile);
292305
NonUploadedFiles.Add(outFile);
293306
CompiledFileNames.Add(destinationFileName);
294307
}
295308

296-
var execResult_Post = ExecuteCommandLine(currentConfig.PostCmd, fileInfo.DirectoryName,
297-
currentConfig.CopyDirectory, fileInfo.FullName, fileInfo.Name, outFile, destinationFileName);
309+
if (!dontCreateFile)
310+
{
311+
ExecuteCommandLine(currentConfig.PostCmd, fileInfo.DirectoryName,
312+
currentConfig.CopyDirectory, fileInfo.FullName, fileInfo.Name, outFile, destinationFileName);
313+
}
298314

299315
ProgressTask.SetProgress((double)(i + 1) / compileCount);
300316
ProcessUITasks();
@@ -312,23 +328,23 @@ await this.ShowMessageAsync(Translate("SPCompNotStarted"),
312328
if (!PressedEscape)
313329
{
314330
ProgressTask.SetProgress(1.0);
315-
if (currentConfig.AutoCopy)
331+
if (currentConfig.AutoCopy && !dontCreateFile)
316332
{
317333
ProgressTask.SetTitle(Translate("CopyingFiles") + "...");
318334
ProgressTask.SetIndeterminate();
319335
await Task.Run(() => Copy_Plugins());
320336
ProgressTask.SetProgress(1.0);
321337
}
322338

323-
if (currentConfig.AutoUpload)
339+
if (currentConfig.AutoUpload && !dontCreateFile)
324340
{
325341
ProgressTask.SetTitle(Translate("FTPUploading") + "...");
326342
ProgressTask.SetIndeterminate();
327343
await Task.Run(FTPUpload_Plugins);
328344
ProgressTask.SetProgress(1.0);
329345
}
330346

331-
if (currentConfig.AutoRCON)
347+
if (currentConfig.AutoRCON && !dontCreateFile)
332348
{
333349
ProgressTask.SetTitle(Translate("RCONCommand") + "...");
334350
ProgressTask.SetIndeterminate();

0 commit comments

Comments
 (0)