diff --git a/Source/Core/Editing/EditMode.cs b/Source/Core/Editing/EditMode.cs index 96354956ad796509292965ee5e05f2828d8d0d68..35d018cff5eac37c1361bb4d3bd0e973e6d092ca 100644 --- a/Source/Core/Editing/EditMode.cs +++ b/Source/Core/Editing/EditMode.cs @@ -150,6 +150,9 @@ namespace CodeImp.DoomBuilder.Editing //mxd. Show hints for this mode General.Hints.ShowHints(this.GetType(), HintsManager.GENERAL); + + //mxd. Display new mode name + General.Interface.HideInfo(); } // Mode disengages diff --git a/Source/Core/General/General.cs b/Source/Core/General/General.cs index e9cb7622acedabc1180d2736dcc6080121cb2f09..67ac90ef996ad1917d2a80b77cc5c787e2aebcea 100644 --- a/Source/Core/General/General.cs +++ b/Source/Core/General/General.cs @@ -541,8 +541,6 @@ namespace CodeImp.DoomBuilder [STAThread] internal static void Main(string[] args) { - Uri localpath; - // Determine states #if DEBUG debugbuild = true; @@ -571,7 +569,7 @@ namespace CodeImp.DoomBuilder thisasm = Assembly.GetExecutingAssembly(); // Find application path - localpath = new Uri(Path.GetDirectoryName(thisasm.GetName().CodeBase)); + Uri localpath = new Uri(Path.GetDirectoryName(thisasm.GetName().CodeBase)); apppath = Uri.UnescapeDataString(localpath.AbsolutePath); // Setup directories diff --git a/Source/Core/Windows/MainForm.cs b/Source/Core/Windows/MainForm.cs index 5ac64f1d19d9cb11aeaf46f46cfacb982a9fac22..f8f22b952c9fc475490c7364ebf6c6dff99c925d 100644 --- a/Source/Core/Windows/MainForm.cs +++ b/Source/Core/Windows/MainForm.cs @@ -2999,7 +2999,7 @@ namespace CodeImp.DoomBuilder.Windows //create path string date = DateTime.Now.ToString("yyyy.MM.dd HH-mm-ss.fff"); - string revision = "R" + General.ThisAssembly.GetName().Version.MinorRevision; + string revision = (General.DebugBuild ? "DEVBUILD" : "R" + General.ThisAssembly.GetName().Version.MinorRevision); string path = Path.Combine(folder, name + date + " [" + revision + "].jpg"); //save image diff --git a/Source/Plugins/BuilderEffects/BuilderEffects.csproj b/Source/Plugins/BuilderEffects/BuilderEffects.csproj index 0827ef13495977db4b5affbc368a808b5edc239a..c89044d5e520b3a8eae37f4192e574e5edf6da94 100644 --- a/Source/Plugins/BuilderEffects/BuilderEffects.csproj +++ b/Source/Plugins/BuilderEffects/BuilderEffects.csproj @@ -141,6 +141,9 @@ <Private>False</Private> </ProjectReference> </ItemGroup> + <ItemGroup> + <None Include="Resources\Folder.png" /> + </ItemGroup> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <!-- To modify your build process, add your task inside one of the targets below and uncomment it. Other similar extension points exist, see Microsoft.Common.targets. diff --git a/Source/Plugins/BuilderEffects/Interface/ObjImportSettingsForm.Designer.cs b/Source/Plugins/BuilderEffects/Interface/ObjImportSettingsForm.Designer.cs index 9e280e219a6b7ca01964308ca74ffe6bc6d03c18..a9cda3454f6d767c2f07f33ebb8568154ce9c075 100644 --- a/Source/Plugins/BuilderEffects/Interface/ObjImportSettingsForm.Designer.cs +++ b/Source/Plugins/BuilderEffects/Interface/ObjImportSettingsForm.Designer.cs @@ -30,7 +30,6 @@ this.cancel = new System.Windows.Forms.Button(); this.import = new System.Windows.Forms.Button(); this.label1 = new System.Windows.Forms.Label(); - this.browse = new System.Windows.Forms.Button(); this.tbImportPath = new System.Windows.Forms.TextBox(); this.label3 = new System.Windows.Forms.Label(); this.axisx = new System.Windows.Forms.RadioButton(); @@ -38,6 +37,8 @@ this.axisz = new System.Windows.Forms.RadioButton(); this.panel1 = new System.Windows.Forms.Panel(); this.openFileDialog = new System.Windows.Forms.OpenFileDialog(); + this.cbusevertexheight = new System.Windows.Forms.CheckBox(); + this.browse = new System.Windows.Forms.Button(); ((System.ComponentModel.ISupportInitialize)(this.nudScale)).BeginInit(); this.panel1.SuspendLayout(); this.SuspendLayout(); @@ -78,7 +79,7 @@ // this.cancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.cancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.cancel.Location = new System.Drawing.Point(279, 82); + this.cancel.Location = new System.Drawing.Point(226, 82); this.cancel.Name = "cancel"; this.cancel.Size = new System.Drawing.Size(75, 23); this.cancel.TabIndex = 14; @@ -89,7 +90,7 @@ // import // this.import.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.import.Location = new System.Drawing.Point(360, 82); + this.import.Location = new System.Drawing.Point(307, 82); this.import.Name = "import"; this.import.Size = new System.Drawing.Size(75, 23); this.import.TabIndex = 13; @@ -106,16 +107,6 @@ this.label1.TabIndex = 12; this.label1.Text = "Path:"; // - // browse - // - this.browse.Location = new System.Drawing.Point(360, 10); - this.browse.Name = "browse"; - this.browse.Size = new System.Drawing.Size(75, 23); - this.browse.TabIndex = 11; - this.browse.Text = "Browse..."; - this.browse.UseVisualStyleBackColor = true; - this.browse.Click += new System.EventHandler(this.browse_Click); - // // tbImportPath // this.tbImportPath.Location = new System.Drawing.Point(55, 12); @@ -182,13 +173,34 @@ this.openFileDialog.Filter = "Wavefront obj files|*.obj"; this.openFileDialog.Title = "Choose .obj file to import:"; // + // cbusevertexheight + // + this.cbusevertexheight.AutoSize = true; + this.cbusevertexheight.Location = new System.Drawing.Point(55, 64); + this.cbusevertexheight.Name = "cbusevertexheight"; + this.cbusevertexheight.Size = new System.Drawing.Size(95, 17); + this.cbusevertexheight.TabIndex = 22; + this.cbusevertexheight.Text = "Sloped Terrian"; + this.cbusevertexheight.UseVisualStyleBackColor = true; + // + // browse + // + this.browse.Image = global::CodeImp.DoomBuilder.BuilderEffects.Properties.Resources.Folder; + this.browse.Location = new System.Drawing.Point(360, 10); + this.browse.Name = "browse"; + this.browse.Size = new System.Drawing.Size(28, 23); + this.browse.TabIndex = 11; + this.browse.UseVisualStyleBackColor = true; + this.browse.Click += new System.EventHandler(this.browse_Click); + // // ObjImportSettingsForm // this.AcceptButton = this.import; this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi; this.CancelButton = this.cancel; - this.ClientSize = new System.Drawing.Size(447, 109); + this.ClientSize = new System.Drawing.Size(394, 109); + this.Controls.Add(this.cbusevertexheight); this.Controls.Add(this.panel1); this.Controls.Add(this.label3); this.Controls.Add(this.label2); @@ -202,6 +214,7 @@ this.MaximizeBox = false; this.MinimizeBox = false; this.Name = "ObjImportSettingsForm"; + this.Opacity = 1; this.ShowIcon = false; this.ShowInTaskbar = false; this.Text = "Import Wavefront .obj"; @@ -228,5 +241,6 @@ private System.Windows.Forms.RadioButton axisz; private System.Windows.Forms.Panel panel1; private System.Windows.Forms.OpenFileDialog openFileDialog; + private System.Windows.Forms.CheckBox cbusevertexheight; } } \ No newline at end of file diff --git a/Source/Plugins/BuilderEffects/Interface/ObjImportSettingsForm.cs b/Source/Plugins/BuilderEffects/Interface/ObjImportSettingsForm.cs index 94156cce8bba9251b7aa7859a8d68fee1d57e3c9..b780a1831b50e54829b375ea2017a55ff0dcb4cb 100644 --- a/Source/Plugins/BuilderEffects/Interface/ObjImportSettingsForm.cs +++ b/Source/Plugins/BuilderEffects/Interface/ObjImportSettingsForm.cs @@ -14,6 +14,7 @@ namespace CodeImp.DoomBuilder.BuilderEffects #region ================== Variables private ImportObjAsTerrainMode.UpAxis axis; + private bool slopessupported; #endregion @@ -22,6 +23,7 @@ namespace CodeImp.DoomBuilder.BuilderEffects internal string FilePath { get { return tbImportPath.Text.Trim(); } } internal ImportObjAsTerrainMode.UpAxis UpAxis { get { return axis; } } internal float ObjScale { get { return (float)nudScale.Value; } } + internal bool UseVertexHeights { get { return slopessupported && cbusevertexheight.Checked; } } //todo: floor/ceiling textures? height offsets? ceiling extra height? @@ -34,6 +36,11 @@ namespace CodeImp.DoomBuilder.BuilderEffects //restore settings axis = (ImportObjAsTerrainMode.UpAxis)General.Settings.ReadPluginSetting("objexportupaxis", 0); nudScale.Value = (decimal)General.Settings.ReadPluginSetting("objexportscale", 1.0f); + slopessupported = (General.Map.UDMF || General.Map.Data.GetThingInfoEx(ImportObjAsTerrainMode.VERTEX_HEIGHT_THING_TYPE) != null); + if(slopessupported) + cbusevertexheight.Checked = General.Settings.ReadPluginSetting("objusevertexheights", true); + else + cbusevertexheight.Enabled = false; switch(axis) { @@ -69,6 +76,7 @@ namespace CodeImp.DoomBuilder.BuilderEffects //save settings General.Settings.WritePluginSetting("objexportupaxis", (int)axis); General.Settings.WritePluginSetting("objexportscale", (float)nudScale.Value); + if(slopessupported) General.Settings.WritePluginSetting("objusevertexheights", cbusevertexheight.Checked); this.DialogResult = DialogResult.OK; this.Close(); diff --git a/Source/Plugins/BuilderEffects/Modes/ImportObjAsTerrainMode.cs b/Source/Plugins/BuilderEffects/Modes/ImportObjAsTerrainMode.cs index b432b5f4caa8174a88b29f11b6002e16a5d989bf..3612aaa8c5ad7b669e8ff21705c7c1b2793562e5 100644 --- a/Source/Plugins/BuilderEffects/Modes/ImportObjAsTerrainMode.cs +++ b/Source/Plugins/BuilderEffects/Modes/ImportObjAsTerrainMode.cs @@ -25,6 +25,7 @@ namespace CodeImp.DoomBuilder.BuilderEffects private readonly static char[] space = { ' ' }; private const string slash = "/"; + internal const int VERTEX_HEIGHT_THING_TYPE = 1504; #endregion @@ -72,12 +73,6 @@ namespace CodeImp.DoomBuilder.BuilderEffects public override void OnEngage() { - if(!General.Map.UDMF) - { - General.Interface.DisplayStatus(StatusType.Warning, "Terrain importer works only in UDMF map format!"); - OnCancel(); - } - base.OnEngage(); General.Map.Map.ClearAllSelected(); @@ -104,7 +99,7 @@ namespace CodeImp.DoomBuilder.BuilderEffects int maxZ = int.MinValue; // Read .obj, create and select sectors - if(!ReadGeometry(form.FilePath, form.ObjScale, form.UpAxis, verts, faces, ref minZ, ref maxZ) || !CreateGeometry(verts, faces, minZ, maxZ + (maxZ - minZ)/2)) + if(!ReadGeometry(form.FilePath, form.ObjScale, form.UpAxis, verts, faces, ref minZ, ref maxZ) || !CreateGeometry(verts, faces, maxZ + (maxZ - minZ)/2)) { // Fial! Cursor.Current = Cursors.Default; @@ -114,9 +109,14 @@ namespace CodeImp.DoomBuilder.BuilderEffects } // Update caches + General.Map.Map.SnapAllToAccuracy(); + General.Map.Map.UpdateConfiguration(); General.Map.Map.Update(); General.Map.IsChanged = true; + // Update things filter so that it includes added things + if(form.UseVertexHeights && !General.Map.UDMF) General.Map.ThingsFilter.Update(); + // Done Cursor.Current = Cursors.Default; @@ -137,29 +137,80 @@ namespace CodeImp.DoomBuilder.BuilderEffects #region ================== Geometry creation - private static bool CreateGeometry(List<Vector3D> verts, List<Face> faces, int minZ, int maxZ) + private bool CreateGeometry(List<Vector3D> verts, List<Face> faces, int maxZ) { + MapSet map = General.Map.Map; + + // Capacity checks + int totalverts = map.Vertices.Count + verts.Count; + int totalsides = map.Sidedefs.Count + faces.Count * 6; + int totallines = map.Linedefs.Count + faces.Count * 3; + int totalsectors = map.Sectors.Count + faces.Count; + int totalthings = 0; + if(form.UseVertexHeights && !General.Map.UDMF) + { + // We'll use vertex height things in non-udmf maps, if such things are defined in Game Configuration + totalthings = map.Things.Count + verts.Count; + } + + if(totalverts > General.Map.FormatInterface.MaxVertices) + { + MessageBox.Show("Cannot import the model: resulting vertex count (" + totalverts + + ") is larger than map format's maximum (" + General.Map.FormatInterface.MaxVertices + ")!", + "Terrain Importer", MessageBoxButtons.OK, MessageBoxIcon.Error); + return false; + } + if(totalsides > General.Map.FormatInterface.MaxSidedefs) + { + MessageBox.Show("Cannot import the model: resulting sidedefs count (" + totalsides + + ") is larger than map format's maximum (" + General.Map.FormatInterface.MaxSidedefs + ")!", + "Terrain Importer", MessageBoxButtons.OK, MessageBoxIcon.Error); + return false; + } + if(totallines > General.Map.FormatInterface.MaxLinedefs) + { + MessageBox.Show("Cannot import the model: resulting sidedefs count (" + totallines + + ") is larger than map format's maximum (" + General.Map.FormatInterface.MaxLinedefs + ")!", + "Terrain Importer", MessageBoxButtons.OK, MessageBoxIcon.Error); + return false; + } + if(totalsectors > General.Map.FormatInterface.MaxSectors) + { + MessageBox.Show("Cannot import the model: resulting sidedefs count (" + totalsectors + + ") is larger than map format's maximum (" + General.Map.FormatInterface.MaxSectors + ")!", + "Terrain Importer", MessageBoxButtons.OK, MessageBoxIcon.Error); + return false; + } + if(totalthings > General.Map.FormatInterface.MaxThings) + { + MessageBox.Show("Cannot import the model: resulting things count (" + totalthings + + ") is larger than map format's maximum (" + General.Map.FormatInterface.MaxThings + ")!", + "Terrain Importer", MessageBoxButtons.OK, MessageBoxIcon.Error); + return false; + } + //make undo General.Map.UndoRedo.CreateUndo("Import Terrain"); //prepare mapset List<Linedef> newlines = new List<Linedef>(); - MapSet map = General.Map.Map; map.BeginAddRemove(); - map.SetCapacity(map.Vertices.Count + verts.Count, map.Linedefs.Count + faces.Count * 3, map.Sidedefs.Count + faces.Count * 3, map.Sectors.Count + faces.Count, 0); + map.SetCapacity(totalverts, totallines, totalsides, totalsectors, totalthings); //terrain has many faces... let's create them Dictionary<Vector3D, Vertex> newverts = new Dictionary<Vector3D, Vertex>(); foreach(Face face in faces) { + // Create sector Sector s = map.CreateSector(); s.Selected = true; - s.FloorHeight = minZ; + s.FloorHeight = (int)Math.Round((face.V1.z + face.V2.z + face.V3.z) / 3); s.CeilHeight = maxZ; s.Brightness = General.Settings.DefaultBrightness; //todo: allow user to change this s.SetCeilTexture(General.Map.Config.SkyFlatName); s.SetFloorTexture(General.Map.Options.DefaultFloorTexture); //todo: allow user to change this + // And linedefs Linedef newline = GetLine(newverts, s, face.V1, face.V2); if(newline != null) newlines.Add(newline); @@ -172,6 +223,19 @@ namespace CodeImp.DoomBuilder.BuilderEffects s.UpdateCache(); } + // Add slope things + if(form.UseVertexHeights && !General.Map.UDMF) + { + foreach (Vector3D pos in newverts.Keys) + { + Thing t = map.CreateThing(); + General.Settings.ApplyDefaultThingSettings(t); + t.Type = VERTEX_HEIGHT_THING_TYPE; + t.Move(pos); + t.Selected = true; + } + } + //update new lines foreach(Linedef l in newlines) l.ApplySidedFlags(); @@ -179,7 +243,7 @@ namespace CodeImp.DoomBuilder.BuilderEffects return true; } - private static Linedef GetLine(Dictionary<Vector3D, Vertex> verts, Sector sector, Vector3D v1, Vector3D v2) + private Linedef GetLine(Dictionary<Vector3D, Vertex> verts, Sector sector, Vector3D v1, Vector3D v2) { Linedef line = null; @@ -198,31 +262,33 @@ namespace CodeImp.DoomBuilder.BuilderEffects } //create a new line? + Sidedef side; if(line == null) { line = General.Map.Map.CreateLinedef(start, end); //create front sidedef and attach sector to it - General.Map.Map.CreateSidedef(line, true, sector); + side = General.Map.Map.CreateSidedef(line, true, sector); } else { //create back sidedef and attach sector to it - General.Map.Map.CreateSidedef(line, false, sector); + side = General.Map.Map.CreateSidedef(line, false, sector); } + if(!form.UseVertexHeights) side.SetTextureLow(General.Map.Options.DefaultWallTexture); line.Selected = true; return line; } - private static Vertex GetVertex(Dictionary<Vector3D, Vertex> verts, Vector3D pos) + private Vertex GetVertex(Dictionary<Vector3D, Vertex> verts, Vector3D pos) { //already there? if(verts.ContainsKey(pos)) return verts[pos]; //make a new one Vertex v = General.Map.Map.CreateVertex(pos); - v.ZFloor = pos.z; + if(form.UseVertexHeights) v.ZFloor = pos.z; verts.Add(pos, v); return v; } diff --git a/Source/Plugins/BuilderEffects/Properties/Resources.Designer.cs b/Source/Plugins/BuilderEffects/Properties/Resources.Designer.cs index c987373e3bd72b58fd65765ff86c96e73c576271..77bc59c447990676ff1018b2567e8f0ba324944a 100644 --- a/Source/Plugins/BuilderEffects/Properties/Resources.Designer.cs +++ b/Source/Plugins/BuilderEffects/Properties/Resources.Designer.cs @@ -1,7 +1,7 @@ //------------------------------------------------------------------------------ // <auto-generated> // This code was generated by a tool. -// Runtime Version:2.0.50727.4927 +// Runtime Version:2.0.50727.5466 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. @@ -60,6 +60,13 @@ namespace CodeImp.DoomBuilder.BuilderEffects.Properties { } } + internal static System.Drawing.Bitmap Folder { + get { + object obj = ResourceManager.GetObject("Folder", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + internal static System.Drawing.Bitmap Jitter { get { object obj = ResourceManager.GetObject("Jitter", resourceCulture); diff --git a/Source/Plugins/BuilderEffects/Properties/Resources.resx b/Source/Plugins/BuilderEffects/Properties/Resources.resx index 54c9ead1f7457d50db2d4ac76f10b1bee7e3666a..7d1cece6365356a1dcd04d5c4ba3788b2b2dea41 100644 --- a/Source/Plugins/BuilderEffects/Properties/Resources.resx +++ b/Source/Plugins/BuilderEffects/Properties/Resources.resx @@ -118,13 +118,16 @@ <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> </resheader> <assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /> + <data name="Terrain" type="System.Resources.ResXFileRef, System.Windows.Forms"> + <value>..\Resources\Terrain.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value> + </data> <data name="Jitter" type="System.Resources.ResXFileRef, System.Windows.Forms"> <value>..\Resources\Jitter.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value> </data> <data name="Update" type="System.Resources.ResXFileRef, System.Windows.Forms"> <value>..\Resources\Update.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value> </data> - <data name="Terrain" type="System.Resources.ResXFileRef, System.Windows.Forms"> - <value>..\Resources\Terrain.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value> + <data name="Folder" type="System.Resources.ResXFileRef, System.Windows.Forms"> + <value>..\Resources\Folder.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value> </data> </root> \ No newline at end of file diff --git a/Source/Plugins/BuilderEffects/Resources/Folder.png b/Source/Plugins/BuilderEffects/Resources/Folder.png new file mode 100644 index 0000000000000000000000000000000000000000..1d415fd6ef824cb38223b86f63ffd149c99ac5a6 Binary files /dev/null and b/Source/Plugins/BuilderEffects/Resources/Folder.png differ diff --git a/Source/Plugins/BuilderModes/VisualModes/BaseVisualThing.cs b/Source/Plugins/BuilderModes/VisualModes/BaseVisualThing.cs index 73b53de1e63203d530d0963c408761008ef70a26..41f0c6d14253cc4e97e6dc5f1b82db0566f6b882 100644 --- a/Source/Plugins/BuilderModes/VisualModes/BaseVisualThing.cs +++ b/Source/Plugins/BuilderModes/VisualModes/BaseVisualThing.cs @@ -230,10 +230,11 @@ namespace CodeImp.DoomBuilder.BuilderModes if(Thing.Sector != null) { SectorData sd = mode.GetSectorData(Thing.Sector); - if(Thing.Position.z > 0) + pos.z = sd.Ceiling.plane.GetZ(Thing.Position) - info.Height; + /*if(Thing.Position.z > 0) pos.z = sd.Ceiling.plane.GetZ(Thing.Position) - info.Height; else - pos.z = Thing.Sector.CeilHeight - info.Height; //mxd. was [pos.z = Thing.Sector.CeilHeight;] + pos.z = Thing.Sector.CeilHeight - info.Height;*/ } pos.z -= Thing.Position.z; @@ -252,10 +253,11 @@ namespace CodeImp.DoomBuilder.BuilderModes if(Thing.Sector != null) { SectorData sd = mode.GetSectorData(Thing.Sector); - if(Thing.Position.z == 0) + pos.z = sd.Floor.plane.GetZ(Thing.Position); + /*if(Thing.Position.z == 0) pos.z = sd.Floor.plane.GetZ(Thing.Position); else - pos.z = Thing.Sector.FloorHeight; + pos.z = Thing.Sector.FloorHeight;*/ } pos.z += Thing.Position.z;