Skip to content

Commit

Permalink
Customizable triggers for JSON output file. Close #46
Browse files Browse the repository at this point in the history
  • Loading branch information
dram55 committed Aug 8, 2019
1 parent 6b1de2b commit 9694d21
Show file tree
Hide file tree
Showing 10 changed files with 549 additions and 4 deletions.
12 changes: 12 additions & 0 deletions MarioMaker2OCR/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,18 @@
<setting name="WarpWorldEnabled" serializeAs="String">
<value>False</value>
</setting>
<setting name="jsonClearOnExit" serializeAs="String">
<value>False</value>
</setting>
<setting name="jsonClearOnSkip" serializeAs="String">
<value>False</value>
</setting>
<setting name="jsonClearOnGameover" serializeAs="String">
<value>False</value>
</setting>
<setting name="jsonClearOnStop" serializeAs="String">
<value>False</value>
</setting>
</MarioMaker2OCR.Properties.Settings>
<WebcamOCR.Properties.Settings>
<setting name="OutputFolder" serializeAs="String">
Expand Down
18 changes: 18 additions & 0 deletions MarioMaker2OCR/Form1.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 24 additions & 2 deletions MarioMaker2OCR/Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
using System.Diagnostics;
using System.Text.RegularExpressions;


namespace MarioMaker2OCR
{
public partial class Form1 : Form
Expand Down Expand Up @@ -240,6 +241,8 @@ private void stopButton_Click(object sender, EventArgs e)
processor = null;
}
BeginInvoke(new MethodInvoker(() => unlockForm()));
if (JsonSettings.ClearOnStop)
clearJsonFile();
}

private void lockForm()
Expand Down Expand Up @@ -388,10 +391,17 @@ private void VideoProcessor_BlackScreen(object sender, VideoProcessor.BlackScree
SMMServer.BroadcastEvent(evt.Key);

// Even though this will get sent on exiting after a clear, it only matters if a entry is active, and after marking it as a win it goes inactive.
if(evt.Key == "exit" && Properties.Settings.Default.WarpWorldEnabled)
if(evt.Key == "exit")
{
WarpWorld?.lose();
if (Properties.Settings.Default.WarpWorldEnabled)
WarpWorld?.lose();
if (JsonSettings.ClearOnExit)
clearJsonFile();
}
if (evt.Key == "skip" && JsonSettings.ClearOnSkip)
clearJsonFile();
if (evt.Key == "gameover" && JsonSettings.ClearOnGameover)
clearJsonFile();
}
}
}
Expand Down Expand Up @@ -561,9 +571,21 @@ private void selectOutputFolderToolStripMenuItem_Click(object sender, EventArgs
}

private void clearFileToolStripMenuItem_Click(object sender, EventArgs e)
{
clearJsonFile();
}

private void clearJsonFile()
{
Level emptyLevel = new Level();
writeLevelToFile(emptyLevel);
}

private void settingsToolStripMenuItem1_Click(object sender, EventArgs e)
{
FormJsonSettings jsonSettings = new FormJsonSettings();
jsonSettings.ShowDialog();
jsonSettings.BringToFront();
}
}
}
180 changes: 180 additions & 0 deletions MarioMaker2OCR/FormJsonSettings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

39 changes: 39 additions & 0 deletions MarioMaker2OCR/FormJsonSettings.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
using System;
using System.Windows.Forms;
using MarioMaker2OCR.Objects;

namespace MarioMaker2OCR
{
public partial class FormJsonSettings : Form
{
public FormJsonSettings()
{
InitializeComponent();
loadCheckboxStateFromSettings();
}

private void loadCheckboxStateFromSettings()
{
exitCheckbox.Checked = JsonSettings.ClearOnExit;
gameoverCheckbox.Checked = JsonSettings.ClearOnGameover;
skipCheckbox.Checked = JsonSettings.ClearOnSkip;
stopCaptureCheckbox.Checked = JsonSettings.ClearOnStop;
}

// Save
private void button1_Click(object sender, EventArgs e)
{
JsonSettings.ClearOnExit = exitCheckbox.Checked;
JsonSettings.ClearOnGameover = gameoverCheckbox.Checked;
JsonSettings.ClearOnSkip = skipCheckbox.Checked;
JsonSettings.ClearOnStop = stopCaptureCheckbox.Checked;
this.Close();
}

// Cancel
private void button2_Click(object sender, EventArgs e)
{
this.Close();
}
}
}
Loading

0 comments on commit 9694d21

Please sign in to comment.