Skip to content

Commit

Permalink
Fixed ChangeExportPath button in ExportAllTextures form
Browse files Browse the repository at this point in the history
  • Loading branch information
pavledev committed Jul 5, 2020
1 parent 4e8423c commit b52e23f
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 13 deletions.
18 changes: 6 additions & 12 deletions GlacierTEXEditor/ExportAllTextures.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ public partial class ExportAllTextures : Form
private bool checkSelectedDimensions = false;
private int previousIndex = 0;
private readonly List<string> extensions = new List<string>() { ".dds", ".tga", ".bmp", ".png", ".jpg" };
private Form1 form1;

public ExportAllTextures()
public ExportAllTextures(Form1 form1)
{
InitializeComponent();

Expand Down Expand Up @@ -51,6 +52,8 @@ public ExportAllTextures()
chkExportAsSingleFile.Visible = false;

ExportPath = Path.GetDirectoryName(Application.ExecutablePath) + @"\";

this.form1 = form1;
}

public List<Texture> Textures
Expand Down Expand Up @@ -426,18 +429,9 @@ private void BtnSelectAllExtensionTypes_Click(object sender, EventArgs e)

private void BtnChangeExportPath_Click(object sender, EventArgs e)
{
OpenFileDialog openFileDialog = new OpenFileDialog();

openFileDialog.ValidateNames = false;
openFileDialog.CheckFileExists = false;
openFileDialog.CheckPathExists = true;
openFileDialog.FileName = "Folder Selection.";
Invoke(new Action(() => ExportPath = form1.ShowOpenFileDialog()));

if (openFileDialog.ShowDialog() == DialogResult.OK)
{
ExportPath = Path.GetDirectoryName(openFileDialog.FileName);
txtExportPath.Text = ExportPath;
}
txtExportPath.Text = ExportPath;
}

private void CheckBox_CheckedChanged(object sender, EventArgs e)
Expand Down
23 changes: 22 additions & 1 deletion GlacierTEXEditor/Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,27 @@ private void Form1_Load(object sender, EventArgs e)
}
}

public string ShowOpenFileDialog()
{
OpenFileDialog openFileDialog = new OpenFileDialog();

openFileDialog.ValidateNames = false;
openFileDialog.CheckFileExists = false;
openFileDialog.CheckPathExists = true;
openFileDialog.FileName = "Folder Selection.";

DialogResult dialogResult = DialogResult.Cancel;

Invoke(new Action(() => dialogResult = openFileDialog.ShowDialog()));

if (dialogResult == DialogResult.OK)
{
return Path.GetDirectoryName(openFileDialog.FileName);
}

return null;
}

private void BtnChangeDirectory_Click(object sender, EventArgs e)
{
OpenFileDialog openFileDialog = new OpenFileDialog();
Expand Down Expand Up @@ -2560,7 +2581,7 @@ private void ExportAllFiles()
{
toolStripStatusLabel1.Text = "Exporting all textures...";

using (ExportAllTextures exportAllTextures = new ExportAllTextures())
using (ExportAllTextures exportAllTextures = new ExportAllTextures(this))
{
exportAllTextures.Textures = textures;
DialogResult dialogResult = exportAllTextures.ShowDialog();
Expand Down

0 comments on commit b52e23f

Please sign in to comment.