2014-01-30 14:52:08 +00:00
|
|
|
|
#region ================== Namespaces
|
|
|
|
|
|
|
|
|
|
using System;
|
2013-03-18 13:52:27 +00:00
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
using System.IO;
|
|
|
|
|
|
2014-01-30 14:52:08 +00:00
|
|
|
|
#endregion
|
|
|
|
|
|
2013-03-18 13:52:27 +00:00
|
|
|
|
namespace CodeImp.DoomBuilder.BuilderModes.Interface
|
|
|
|
|
{
|
|
|
|
|
public partial class WavefrontSettingsForm : Form
|
|
|
|
|
{
|
2014-01-30 14:52:08 +00:00
|
|
|
|
#region ================== Properties
|
|
|
|
|
|
|
|
|
|
public string FilePath { get { return tbExportPath.Text.Trim(); } }
|
|
|
|
|
public bool ExportTextures { get { return cbExportTextures.Checked; } }
|
|
|
|
|
public bool UseGZDoomScale { get { return cbFixScale.Checked; } }
|
|
|
|
|
public float ObjScale { get { return (float)nudScale.Value; } }
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
2013-03-18 13:52:27 +00:00
|
|
|
|
public WavefrontSettingsForm(int sectorsCount) {
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
|
2014-01-30 14:52:08 +00:00
|
|
|
|
string name = Path.GetFileNameWithoutExtension(General.Map.FileTitle) + "_" + General.Map.Options.LevelName + ".obj";
|
|
|
|
|
if(string.IsNullOrEmpty(General.Map.FilePathName)) {
|
|
|
|
|
saveFileDialog.FileName = name;
|
|
|
|
|
} else {
|
|
|
|
|
saveFileDialog.InitialDirectory = General.Map.FilePathName;
|
|
|
|
|
saveFileDialog.FileName = Path.GetDirectoryName(General.Map.FilePathName) + Path.DirectorySeparatorChar + name;
|
|
|
|
|
tbExportPath.Text = saveFileDialog.FileName;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//restore settings
|
|
|
|
|
cbExportTextures.Checked = General.Settings.ReadPluginSetting("objexporttextures", false);//BuilderPlug.Me.ObjExportTextures;
|
|
|
|
|
cbFixScale.Checked = General.Settings.ReadPluginSetting("objgzdoomscale", false);//BuilderPlug.Me.ObjGZDoomScale;
|
|
|
|
|
nudScale.Value = (decimal)General.Settings.ReadPluginSetting("objscale", 1.0f);//(decimal)BuilderPlug.Me.ObjScale;
|
2013-03-18 13:52:27 +00:00
|
|
|
|
|
|
|
|
|
this.Text = "Export " + (sectorsCount == -1 ? "whole map" : sectorsCount + (sectorsCount > 1 ? "sectors" : "sector")) + " to Wavefront .obj";
|
|
|
|
|
}
|
|
|
|
|
|
2014-01-30 14:52:08 +00:00
|
|
|
|
#region ================== Events
|
|
|
|
|
|
2013-03-18 13:52:27 +00:00
|
|
|
|
private void browse_Click(object sender, EventArgs e) {
|
|
|
|
|
if(saveFileDialog.ShowDialog() == DialogResult.OK) {
|
|
|
|
|
tbExportPath.Text = saveFileDialog.FileName;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void export_Click(object sender, EventArgs e) {
|
2014-01-30 14:52:08 +00:00
|
|
|
|
//BuilderPlug.Me.ObjExportTextures = cbExportTextures.Checked;
|
|
|
|
|
//BuilderPlug.Me.ObjGZDoomScale = cbFixScale.Checked;
|
|
|
|
|
//BuilderPlug.Me.ObjScale = (float)nudScale.Value;
|
2013-03-18 13:52:27 +00:00
|
|
|
|
|
2014-01-30 14:52:08 +00:00
|
|
|
|
if(nudScale.Value == 0) {
|
|
|
|
|
MessageBox.Show("Scale should not be zero!");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if(!Directory.Exists(Path.GetDirectoryName(tbExportPath.Text))) {
|
2013-03-18 13:52:27 +00:00
|
|
|
|
MessageBox.Show("Selected path does not exist!");
|
2014-01-30 14:52:08 +00:00
|
|
|
|
return;
|
2013-03-18 13:52:27 +00:00
|
|
|
|
}
|
2014-01-30 14:52:08 +00:00
|
|
|
|
|
|
|
|
|
//save settings
|
|
|
|
|
General.Settings.WritePluginSetting("objexporttextures", cbExportTextures.Checked);
|
|
|
|
|
General.Settings.WritePluginSetting("objgzdoomscale", cbFixScale.Checked);
|
|
|
|
|
General.Settings.WritePluginSetting("objscale", (float)nudScale.Value);
|
|
|
|
|
|
|
|
|
|
//filePath = tbExportPath.Text;
|
|
|
|
|
this.DialogResult = DialogResult.OK;
|
|
|
|
|
this.Close();
|
2013-03-18 13:52:27 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void cancel_Click(object sender, EventArgs e) {
|
|
|
|
|
this.Close();
|
|
|
|
|
}
|
2014-01-30 14:52:08 +00:00
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
2013-03-18 13:52:27 +00:00
|
|
|
|
}
|
|
|
|
|
}
|