Skip to content

Commit

Permalink
Merge pull request az64#18 from ZoeyZolotova/FixOutputDirectory
Browse files Browse the repository at this point in the history
Fix outputted files to all be in the same user-selected directory.
  • Loading branch information
ZoeyZolotova authored May 9, 2019
2 parents 05e018f + 7b8f25f commit a100a3a
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 53 deletions.
2 changes: 1 addition & 1 deletion Build.cs
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ private void MakeROM(string InFile, string FileName, BackgroundWorker worker)
if (_outputVC)
{
worker.ReportProgress(98, "Building VC...");
ROMFuncs.BuildVC(ROM, VCDirectory, Settings.OutputWADFilename);
ROMFuncs.BuildVC(ROM, VCDirectory, Path.ChangeExtension(FileName, "wad"));
}
worker.ReportProgress(100, "Done!");

Expand Down
10 changes: 0 additions & 10 deletions Majora's Mask Randomiser.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,6 @@
<ApplicationIcon>200px_majoramask_rtw_icon.ico</ApplicationIcon>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.WindowsAPICodePack, Version=1.1.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>packages\Microsoft.WindowsAPICodePack-Core.1.1.0.2\lib\Microsoft.WindowsAPICodePack.dll</HintPath>
</Reference>
<Reference Include="Microsoft.WindowsAPICodePack.Shell, Version=1.1.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>packages\Microsoft.WindowsAPICodePack-Shell.1.1.0.0\lib\Microsoft.WindowsAPICodePack.Shell.dll</HintPath>
</Reference>
<Reference Include="Microsoft.WindowsAPICodePack.ShellExtensions, Version=1.1.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>packages\Microsoft.WindowsAPICodePack-Shell.1.1.0.0\lib\Microsoft.WindowsAPICodePack.ShellExtensions.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
Expand Down Expand Up @@ -725,7 +716,6 @@
<None Include="obj\link-3">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="packages.config" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
Expand Down
21 changes: 3 additions & 18 deletions Models/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,41 +11,26 @@ public class Settings

// General

/// <summary>
/// Indicates a N64 Rom to be randomized. Default true.
/// </summary>
public bool IsN64Rom { get; private set; } = true;

/// <summary>
/// Filepath to the input ROM
/// </summary>
public string InputRomFilename { get; set; }
public string InputROMFilename { get; set; }

/// <summary>
/// Path to the output directory where rom/vc are saved
/// Default Filename for the output ROM
/// </summary>
public string OutputDirectory { get; internal set; }
public string DefaultOutputROMFilename { get; set; }

/// <summary>
/// Filepath to the output ROM
/// </summary>
public string OutputROMFilename { get; set; }

/// <summary>
/// Filepath to the output ROM
/// </summary>
public string OutputWADFilename { get; set; }

/// <summary>
/// Generate spoiler log on randomizing
/// </summary>
public bool GenerateSpoilerLog { get; set; }

/// <summary>
///
/// </summary>
public bool WiiVirtualConsoleChannel { get; set; }

/// <summary>
/// Use Custom Item list for the logic.
/// </summary>
Expand Down
4 changes: 3 additions & 1 deletion Shuffle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -479,8 +479,10 @@ private void MakeSpoilerLog()
{
var settingsString = EncodeSettings();

var directory = Path.GetDirectoryName(Settings.OutputROMFilename);
var filename = $"{Path.GetFileNameWithoutExtension(Settings.OutputROMFilename)}_SpoilerLog.txt";

StreamWriter LogFile = new StreamWriter($"{Settings.OutputDirectory}\\SpoilerLog_{Settings.Seed}_{settingsString}.txt");
StreamWriter LogFile = new StreamWriter(Path.Combine(directory, filename));


if (Settings.RandomizeDungeonEntrances)
Expand Down
28 changes: 10 additions & 18 deletions fMain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
using System.IO;
using System.Reflection;
using System.Windows.Forms;
using Microsoft.WindowsAPICodePack.Dialogs;

namespace MMRando
{
Expand Down Expand Up @@ -102,27 +101,23 @@ private void bopen_Click(object sender, EventArgs e)
{
openROM.ShowDialog();

Settings.InputRomFilename = openROM.FileName;
tROMName.Text = Settings.InputRomFilename;
Settings.InputROMFilename = openROM.FileName;
tROMName.Text = Settings.InputROMFilename;
}

private void bRandomise_Click(object sender, EventArgs e)
{
if (!ValidateInputFile()) return;

var outputFolderDialog = new CommonOpenFileDialog
{
IsFolderPicker = true
};

if ((_outputROM || _outputVC) && outputFolderDialog.ShowDialog() != CommonFileDialogResult.Ok)

saveROM.FileName = Settings.DefaultOutputROMFilename;
if ((_outputROM || _outputVC) && saveROM.ShowDialog() != DialogResult.OK)
{
MessageBox.Show("No output directory selected; Nothing will be saved.",
"Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}

Settings.OutputDirectory = outputFolderDialog.FileName;
Settings.OutputROMFilename = saveROM.FileName;

EnableAllControls(false);
bgWorker.RunWorkerAsync();
Expand Down Expand Up @@ -564,8 +559,7 @@ private void UpdateOutputFilenames(string settings)
string appendSeed = Settings.GenerateSpoilerLog ? $"{Settings.Seed}_" : "";
string filename = $"MMR_{appendSeed}{settings}";

Settings.OutputROMFilename = filename + ".z64";
Settings.OutputWADFilename = filename + ".wad";
Settings.DefaultOutputROMFilename = filename + ".z64";
}

private string EncodeSettings()
Expand Down Expand Up @@ -677,16 +671,14 @@ private void TryRandomize(BackgroundWorker worker, DoWorkEventArgs e)
// Additional validation of preconditions
if (!ValidateInputFile()) return;

if (!ValidateROM(Settings.InputRomFilename))
if (!ValidateROM(Settings.InputROMFilename))
{
MessageBox.Show("Cannot verify input ROM is Majora's Mask (U).",
"Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}

MakeROM(Settings.InputRomFilename,
Path.Combine(Settings.OutputDirectory, Settings.OutputROMFilename),
worker);
MakeROM(Settings.InputROMFilename, Settings.OutputROMFilename, worker);

MessageBox.Show("Successfully built output ROM!",
"Success", MessageBoxButtons.OK, MessageBoxIcon.None);
Expand All @@ -698,7 +690,7 @@ private void TryRandomize(BackgroundWorker worker, DoWorkEventArgs e)
/// <returns></returns>
private bool ValidateInputFile()
{
if (!File.Exists(Settings.InputRomFilename))
if (!File.Exists(Settings.InputROMFilename))
{
MessageBox.Show("Input ROM not selected or doesn't exist, cannot generate output.",
"Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
Expand Down
5 changes: 0 additions & 5 deletions packages.config

This file was deleted.

0 comments on commit a100a3a

Please sign in to comment.