mirror of
https://git.do.srb2.org/STJr/UltimateZoneBuilder.git
synced 2025-01-19 06:51:09 +00:00
OBJ Exporter: unchecking the "Generate ZScript/DECORATE" and/or "Generate MODELDEF" checkboxes will now really not generate the respective files
This commit is contained in:
parent
e8c3a41a47
commit
7dd0a0a4af
3 changed files with 89 additions and 92 deletions
|
@ -42,6 +42,8 @@ namespace CodeImp.DoomBuilder.BuilderModes.IO
|
|||
public bool NormalizeLowestVertex;
|
||||
public bool CenterModel;
|
||||
public bool ZScript;
|
||||
public bool GenerateCode;
|
||||
public bool GenerateModeldef;
|
||||
|
||||
// Actor properties and flags
|
||||
public int Radius;
|
||||
|
@ -51,32 +53,6 @@ namespace CodeImp.DoomBuilder.BuilderModes.IO
|
|||
public bool SpawnOnCeiling;
|
||||
public bool Solid;
|
||||
|
||||
/*
|
||||
public WavefrontExportSettings(string name, string path, float scale, bool fixScale, bool exportTextures, string actorName, string basePath, string actorPath, string modelPath, List<string> skipTextures, bool ignoreControlSectors)
|
||||
{
|
||||
ObjName = name;
|
||||
ObjPath = path;
|
||||
Scale = scale;
|
||||
FixScale = fixScale;
|
||||
ExportTextures = exportTextures;
|
||||
|
||||
ActorName = actorName;
|
||||
BasePath = basePath;
|
||||
ActorPath = actorPath;
|
||||
ModelPath = modelPath;
|
||||
SkipTextures = skipTextures;
|
||||
IgnoreControlSectors = ignoreControlSectors;
|
||||
|
||||
Radius = 20;
|
||||
Height = 16;
|
||||
|
||||
Valid = false;
|
||||
Obj = string.Empty;
|
||||
Textures = null;
|
||||
Flats = null;
|
||||
}
|
||||
*/
|
||||
|
||||
public WavefrontExportSettings(WavefrontSettingsForm form)
|
||||
{
|
||||
ObjName = Path.GetFileNameWithoutExtension(form.FilePath);
|
||||
|
@ -94,6 +70,8 @@ namespace CodeImp.DoomBuilder.BuilderModes.IO
|
|||
NormalizeLowestVertex = form.NormalizeLowestVertex;
|
||||
CenterModel = form.CenterModel;
|
||||
ZScript = form.ZScript;
|
||||
GenerateCode = form.GenerateCode;
|
||||
GenerateModeldef = form.GenerateModeldef;
|
||||
|
||||
NoGravity = form.NoGravity;
|
||||
SpawnOnCeiling = form.SpawnOnCeiling;
|
||||
|
@ -284,79 +262,85 @@ namespace CodeImp.DoomBuilder.BuilderModes.IO
|
|||
else
|
||||
{
|
||||
// Create ZScript or DECORATE
|
||||
Stream stream;
|
||||
string path = Path.Combine(settings.ActorPath, settings.ActorName);
|
||||
|
||||
if (settings.ZScript)
|
||||
if (settings.GenerateCode)
|
||||
{
|
||||
stream = BuilderPlug.Me.GetResourceStream("ObjExportZScriptTemplate.txt");
|
||||
path += ".zs";
|
||||
}
|
||||
else
|
||||
{
|
||||
stream = BuilderPlug.Me.GetResourceStream("ObjExportDecorateTemplate.txt");
|
||||
path += ".txt";
|
||||
}
|
||||
Stream stream;
|
||||
string path = Path.Combine(settings.ActorPath, settings.ActorName);
|
||||
|
||||
using (StreamReader reader = new StreamReader(stream, Encoding.ASCII))
|
||||
{
|
||||
string template = reader.ReadToEnd();
|
||||
if (settings.ZScript)
|
||||
{
|
||||
stream = BuilderPlug.Me.GetResourceStream("ObjExportZScriptTemplate.txt");
|
||||
path += ".zs";
|
||||
}
|
||||
else
|
||||
{
|
||||
stream = BuilderPlug.Me.GetResourceStream("ObjExportDecorateTemplate.txt");
|
||||
path += ".txt";
|
||||
}
|
||||
|
||||
template = template.Replace("{ActorName}", settings.ActorName);
|
||||
template = template.Replace("{Sprite}", settings.Sprite);
|
||||
template = template.Replace("{FlagNoGravity}", settings.NoGravity ? "+NOGRAVITY" : "");
|
||||
template = template.Replace("{FlagSpawnOnCeiling}", settings.SpawnOnCeiling ? "+SPAWNCEILING" : "");
|
||||
template = template.Replace("{FlagSolid}", settings.Solid ? "+SOLID" : "");
|
||||
template = template.Replace("{FlagInvulnerable}", settings.Solid ? "+INVULNERABLE" : "");
|
||||
template = template.Replace("{FlagNoDamage}", settings.Solid ? "+NODAMAGE" : "");
|
||||
template = template.Replace("{FlagShootable}", settings.Solid ? "+SHOOTABLE" : "");
|
||||
template = template.Replace("{FlagNotAutoAimed}", settings.Solid ? "+NOTAUTOAIMED" : "");
|
||||
template = template.Replace("{FlagNeverTarget}", settings.Solid ? "+NEVERTARGET" : "");
|
||||
template = template.Replace("{FlagDontThrust}", settings.Solid ? "+DONTTHRUST" : "");
|
||||
template = template.Replace("{PropRadius}", settings.Radius.ToString());
|
||||
template = template.Replace("{PropHeight}", settings.Height.ToString());
|
||||
using (StreamReader reader = new StreamReader(stream, Encoding.ASCII))
|
||||
{
|
||||
string template = reader.ReadToEnd();
|
||||
|
||||
// Make sure the directory is there
|
||||
Directory.CreateDirectory(Path.GetDirectoryName(path));
|
||||
template = template.Replace("{ActorName}", settings.ActorName);
|
||||
template = template.Replace("{Sprite}", settings.Sprite);
|
||||
template = template.Replace("{FlagNoGravity}", settings.NoGravity ? "+NOGRAVITY" : "");
|
||||
template = template.Replace("{FlagSpawnOnCeiling}", settings.SpawnOnCeiling ? "+SPAWNCEILING" : "");
|
||||
template = template.Replace("{FlagSolid}", settings.Solid ? "+SOLID" : "");
|
||||
template = template.Replace("{FlagInvulnerable}", settings.Solid ? "+INVULNERABLE" : "");
|
||||
template = template.Replace("{FlagNoDamage}", settings.Solid ? "+NODAMAGE" : "");
|
||||
template = template.Replace("{FlagShootable}", settings.Solid ? "+SHOOTABLE" : "");
|
||||
template = template.Replace("{FlagNotAutoAimed}", settings.Solid ? "+NOTAUTOAIMED" : "");
|
||||
template = template.Replace("{FlagNeverTarget}", settings.Solid ? "+NEVERTARGET" : "");
|
||||
template = template.Replace("{FlagDontThrust}", settings.Solid ? "+DONTTHRUST" : "");
|
||||
template = template.Replace("{PropRadius}", settings.Radius.ToString());
|
||||
template = template.Replace("{PropHeight}", settings.Height.ToString());
|
||||
|
||||
using (StreamWriter sw = new StreamWriter(path, false))
|
||||
sw.Write(template);
|
||||
// Make sure the directory is there
|
||||
Directory.CreateDirectory(Path.GetDirectoryName(path));
|
||||
|
||||
using (StreamWriter sw = new StreamWriter(path, false))
|
||||
sw.Write(template);
|
||||
}
|
||||
}
|
||||
|
||||
// Create MODELDEF
|
||||
stream = BuilderPlug.Me.GetResourceStream("ObjExportModeldefTemplate.txt");
|
||||
|
||||
using (StreamReader reader = new StreamReader(stream, Encoding.ASCII))
|
||||
if (settings.GenerateModeldef)
|
||||
{
|
||||
path = Path.Combine(settings.BasePath, "modeldef." + settings.ActorName + ".txt");
|
||||
string template = reader.ReadToEnd();
|
||||
Stream stream = BuilderPlug.Me.GetResourceStream("ObjExportModeldefTemplate.txt");
|
||||
|
||||
// The path to the model is relative to the base path, so generate the base path
|
||||
string basepath = settings.BasePath.Trim();
|
||||
string modelpath = settings.ModelPath.Trim();
|
||||
using (StreamReader reader = new StreamReader(stream, Encoding.ASCII))
|
||||
{
|
||||
string path = Path.Combine(settings.BasePath, "modeldef." + settings.ActorName + ".txt");
|
||||
string template = reader.ReadToEnd();
|
||||
|
||||
// Make sue there's a directory separator at the end of the paths, otherwise it'll not work correctly
|
||||
if (!basepath.EndsWith(Path.DirectorySeparatorChar.ToString()))
|
||||
basepath += Path.DirectorySeparatorChar;
|
||||
// The path to the model is relative to the base path, so generate the base path
|
||||
string basepath = settings.BasePath.Trim();
|
||||
string modelpath = settings.ModelPath.Trim();
|
||||
|
||||
if (!modelpath.EndsWith(Path.DirectorySeparatorChar.ToString()))
|
||||
modelpath += Path.DirectorySeparatorChar;
|
||||
// Make sue there's a directory separator at the end of the paths, otherwise it'll not work correctly
|
||||
if (!basepath.EndsWith(Path.DirectorySeparatorChar.ToString()))
|
||||
basepath += Path.DirectorySeparatorChar;
|
||||
|
||||
Uri baseUri = new Uri(basepath);
|
||||
Uri modelUri = new Uri(modelpath);
|
||||
if (!modelpath.EndsWith(Path.DirectorySeparatorChar.ToString()))
|
||||
modelpath += Path.DirectorySeparatorChar;
|
||||
|
||||
Uri relativeUri = baseUri.MakeRelativeUri(modelUri);
|
||||
string relativepath = Uri.UnescapeDataString(relativeUri.OriginalString);
|
||||
Uri baseUri = new Uri(basepath);
|
||||
Uri modelUri = new Uri(modelpath);
|
||||
|
||||
template = template.Replace("{ActorName}", settings.ActorName);
|
||||
template = template.Replace("{ModelPath}", relativepath);
|
||||
template = template.Replace("{Sprite}", settings.Sprite);
|
||||
Uri relativeUri = baseUri.MakeRelativeUri(modelUri);
|
||||
string relativepath = Uri.UnescapeDataString(relativeUri.OriginalString);
|
||||
|
||||
// Make sure the directory is there
|
||||
Directory.CreateDirectory(Path.GetDirectoryName(path));
|
||||
template = template.Replace("{ActorName}", settings.ActorName);
|
||||
template = template.Replace("{ModelPath}", relativepath);
|
||||
template = template.Replace("{Sprite}", settings.Sprite);
|
||||
|
||||
using (StreamWriter sw = new StreamWriter(path, false))
|
||||
sw.Write(template);
|
||||
// Make sure the directory is there
|
||||
Directory.CreateDirectory(Path.GetDirectoryName(path));
|
||||
|
||||
using (StreamWriter sw = new StreamWriter(path, false))
|
||||
sw.Write(template);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -229,6 +229,7 @@
|
|||
this.cbGenerateModeldef.TabIndex = 25;
|
||||
this.cbGenerateModeldef.Text = "Generate MODELDEF";
|
||||
this.cbGenerateModeldef.UseVisualStyleBackColor = true;
|
||||
this.cbGenerateModeldef.CheckedChanged += new System.EventHandler(this.cbGenerateModeldef_CheckedChanged);
|
||||
//
|
||||
// actorNameError
|
||||
//
|
||||
|
|
|
@ -34,6 +34,8 @@ namespace CodeImp.DoomBuilder.BuilderModes.Interface
|
|||
public bool SpawnOnCeiling { get { return cbSpawnOnCeiling.Checked; } }
|
||||
public bool Solid { get { return cbSolid.Checked; } }
|
||||
public bool ZScript { get { return rbZScript.Checked; } }
|
||||
public bool GenerateCode { get { return cbGenerateCode.Checked; } }
|
||||
public bool GenerateModeldef { get { return cbGenerateModeldef.Checked; } }
|
||||
public string Sprite { get { return tbSprite.Text.Trim().ToUpperInvariant(); } }
|
||||
|
||||
#endregion
|
||||
|
@ -89,11 +91,6 @@ namespace CodeImp.DoomBuilder.BuilderModes.Interface
|
|||
cbGenerateCode.Checked = General.Settings.ReadPluginSetting("objgeneratecode", true);
|
||||
cbGenerateModeldef.Checked = General.Settings.ReadPluginSetting("objgeneratemodeldef", true);
|
||||
|
||||
if (cbExportForGZDoom.Checked)
|
||||
{
|
||||
gbActorFormat.Enabled = gbActorSettings.Enabled = cbGenerateCode.Checked;
|
||||
}
|
||||
|
||||
// Toggle enable/disable manually because cbFixScale is a child of the group box, so disabling
|
||||
// the group box would also disable cbFixScale
|
||||
//foreach (Control c in gbGZDoom.Controls)
|
||||
|
@ -102,6 +99,15 @@ namespace CodeImp.DoomBuilder.BuilderModes.Interface
|
|||
if (c != cbExportForGZDoom)
|
||||
c.Enabled = cbExportForGZDoom.Checked;
|
||||
}
|
||||
|
||||
if (cbExportForGZDoom.Checked)
|
||||
{
|
||||
// gbActorFormat.Enabled = gbActorSettings.Enabled = cbGenerateCode.Checked;
|
||||
gbActorFormat.Enabled = gbActorSettings.Enabled = tbActorPath.Enabled = bBrowseActorPath.Enabled = cbGenerateCode.Checked;
|
||||
tbModelPath.Enabled = bBrowseModelPath.Enabled = cbGenerateModeldef.Checked && cbExportForGZDoom.Checked;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
#region ================== Methods
|
||||
|
@ -153,13 +159,13 @@ namespace CodeImp.DoomBuilder.BuilderModes.Interface
|
|||
return;
|
||||
}
|
||||
|
||||
if (!PathIsValid(tbActorPath.Text.Trim()))
|
||||
if (cbGenerateCode.Enabled && !PathIsValid(tbActorPath.Text.Trim()))
|
||||
{
|
||||
MessageBox.Show("Actor path does not exist!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!PathIsValid(tbModelPath.Text.Trim()))
|
||||
if (cbGenerateModeldef.Enabled && !PathIsValid(tbModelPath.Text.Trim()))
|
||||
{
|
||||
MessageBox.Show("Model path does not exist!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
|
@ -225,10 +231,11 @@ namespace CodeImp.DoomBuilder.BuilderModes.Interface
|
|||
foreach(Control c in cbExportForGZDoom.Parent.Controls)
|
||||
{
|
||||
if (c != cbExportForGZDoom && c != gbActorSettings && c != gbActorFormat)
|
||||
c.Enabled = !c.Enabled;
|
||||
c.Enabled = cbExportForGZDoom.Checked;
|
||||
}
|
||||
|
||||
gbActorSettings.Enabled = gbActorFormat.Enabled = cbGenerateCode.Checked && cbExportForGZDoom.Checked;
|
||||
gbActorSettings.Enabled = gbActorFormat.Enabled = tbActorPath.Enabled = bBrowseActorPath.Enabled = cbGenerateCode.Checked && cbExportForGZDoom.Checked;
|
||||
tbModelPath.Enabled = bBrowseModelPath.Enabled = cbGenerateModeldef.Checked && cbExportForGZDoom.Checked;
|
||||
|
||||
tbExportPath.Enabled = browse.Enabled = cbExportTextures.Enabled = nudScale.Enabled = !cbExportForGZDoom.Checked;
|
||||
}
|
||||
|
@ -366,7 +373,12 @@ namespace CodeImp.DoomBuilder.BuilderModes.Interface
|
|||
|
||||
private void cbGenerateCode_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
gbActorFormat.Enabled = gbActorSettings.Enabled = cbGenerateCode.Checked;
|
||||
gbActorFormat.Enabled = gbActorSettings.Enabled = tbActorPath.Enabled = bBrowseActorPath.Enabled = cbGenerateCode.Checked && cbExportForGZDoom.Checked;
|
||||
}
|
||||
|
||||
private void cbGenerateModeldef_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
tbModelPath.Enabled = bBrowseModelPath.Enabled = cbGenerateModeldef.Checked && cbExportForGZDoom.Checked;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue