Skip to content

Commit

Permalink
Easy pack fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
rebelvg committed Apr 14, 2018
1 parent 3eea664 commit 6b919be
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 15 deletions.
13 changes: 13 additions & 0 deletions KlpqMusicConfigurator/KlpqMusicConfigurator/Form1.Designer.cs

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

68 changes: 53 additions & 15 deletions KlpqMusicConfigurator/KlpqMusicConfigurator/Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public async Task<string> GenerateConfig()
return finalConfig;
}

private async void button1_Click(object sender, EventArgs e)
private void button1_Click(object sender, EventArgs e)
{
VistaFolderBrowserDialog chosenFolder = new VistaFolderBrowserDialog();
chosenFolder.Description = "Select folder...";
Expand Down Expand Up @@ -154,10 +154,6 @@ private async void button1_Click(object sender, EventArgs e)
if (!listView2.Items.Cast<ListViewItem>().Select(A => A.Text).Contains(theme))
listView2.Items.Add(theme);
}

string finalConfig = await GenerateConfig();

richTextBox1.Text = finalConfig;
}
}

Expand All @@ -171,7 +167,9 @@ private async void button2_Click(object sender, EventArgs e)
private void button3_Click(object sender, EventArgs e)
{
if (richTextBox1.Text.Length != 0)
{
Clipboard.SetText(richTextBox1.Text);
}
}

private void button4_Click(object sender, EventArgs e)
Expand Down Expand Up @@ -206,31 +204,71 @@ private void button4_Click(object sender, EventArgs e)
}
}

List<string> commandArgs = new List<string>() { };
if (richTextBox1.Text.Length == 0)
{
MessageBox.Show("You have to generate a config first.");
return;
}

commandArgs.Add("\"" + path_textBox.Text + "\"");
string exportFolder;

VistaFolderBrowserDialog chosenFolder = new VistaFolderBrowserDialog();
chosenFolder.Description = "Select the folder where to place the packed pbo...";
chosenFolder.Description = "Select the folder where to place the packed pbos...";

if (chosenFolder.ShowDialog().Value)
{
commandArgs.Add("\"" + chosenFolder.SelectedPath + "\"");
exportFolder = chosenFolder.SelectedPath;
}
else
{
MessageBox.Show("Packing canceled.");
return;
}

commandArgs.Add("-clear");
commandArgs.Add("-packonly");
string tempFolderPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), new DirectoryInfo(path_textBox.Text).Name) + "_config";

Directory.CreateDirectory(tempFolderPath);

File.WriteAllText(Path.Combine(tempFolderPath, "config.cpp"), richTextBox1.Text);

List<string> commandArgsConfig = new List<string>() { };

commandArgsConfig.Add("\"" + tempFolderPath + "\"");
commandArgsConfig.Add("\"" + exportFolder + "\"");
commandArgsConfig.Add("-clear");
commandArgsConfig.Add("-packonly");

Process builderProcessConfig = new Process();

builderProcessConfig.StartInfo.FileName = addonBuilderPath;
builderProcessConfig.StartInfo.Arguments = String.Join(" ", commandArgsConfig);
builderProcessConfig.Start();

Process myProcess = new Process();
List<string> commandArgsFiles = new List<string>() { };

myProcess.StartInfo.FileName = addonBuilderPath;
myProcess.StartInfo.Arguments = String.Join(" ", commandArgs);
myProcess.Start();
commandArgsFiles.Add("\"" + path_textBox.Text + "\"");
commandArgsFiles.Add("\"" + exportFolder + "\"");
commandArgsFiles.Add("-clear");
commandArgsFiles.Add("-packonly");

Process builderProcessFiles = new Process();

builderProcessFiles.StartInfo.FileName = addonBuilderPath;
builderProcessFiles.StartInfo.Arguments = String.Join(" ", commandArgsFiles);
builderProcessFiles.Start();
}

private async void button2_Click_1(object sender, EventArgs e)
{
if (!File.Exists(path_textBox.Text + "\\config.cpp"))
{
MessageBox.Show("There should be a config.cpp file in the root of the folder.");
return;
}

string finalConfig = await GenerateConfig();

richTextBox1.Text = finalConfig;
}
}
}

0 comments on commit 6b919be

Please sign in to comment.