From d174544cd6bbedf625cde96bcab980722bde046d Mon Sep 17 00:00:00 2001 From: codeimp Date: Sat, 3 Jan 2009 22:18:59 +0000 Subject: [PATCH] several fixes --- Documents/todo.txt | 4 +-- .../ClassicModes/DrawGeometryMode.cs | 3 ++ .../BuilderModes/ClassicModes/ThingsMode.cs | 1 + Source/Data/ImageData.cs | 4 +-- Source/Editing/EditingManager.cs | 6 ++++ Source/General/MapManager.cs | 15 ++++++++-- Source/Map/Linedef.cs | 7 +++++ Source/Map/Sector.cs | 4 +++ Source/Map/Sidedef.cs | 10 +++++++ Source/Map/Thing.cs | 4 +++ Source/Map/Vertex.cs | 29 ++++++++++++------- Source/Windows/MainForm.cs | 2 +- 12 files changed, 71 insertions(+), 18 deletions(-) diff --git a/Documents/todo.txt b/Documents/todo.txt index fb2c10e2..bde8cf30 100644 --- a/Documents/todo.txt +++ b/Documents/todo.txt @@ -3,9 +3,9 @@ quality over quantity. It is done when it's done. The order and included items may also change any time. ========================================================= -- Make Directory Resources support +- Create menus for different modes -- Make PK3 Resources support +- Create gradient ceiling/floor heights feature ========================================================= BETA TESTING STARTS HERE diff --git a/Source/BuilderModes/ClassicModes/DrawGeometryMode.cs b/Source/BuilderModes/ClassicModes/DrawGeometryMode.cs index 1e3c4fbd..54d5da23 100644 --- a/Source/BuilderModes/ClassicModes/DrawGeometryMode.cs +++ b/Source/BuilderModes/ClassicModes/DrawGeometryMode.cs @@ -394,6 +394,9 @@ namespace CodeImp.DoomBuilder.BuilderModes // Update cached values General.Map.Map.Update(); + // Update the used textures + General.Map.Data.UpdateUsedTextures(); + // Map is changed General.Map.IsChanged = true; } diff --git a/Source/BuilderModes/ClassicModes/ThingsMode.cs b/Source/BuilderModes/ClassicModes/ThingsMode.cs index 327215f5..394369cb 100644 --- a/Source/BuilderModes/ClassicModes/ThingsMode.cs +++ b/Source/BuilderModes/ClassicModes/ThingsMode.cs @@ -333,6 +333,7 @@ namespace CodeImp.DoomBuilder.BuilderModes editpressed = true; // Insert a new item and select it for dragging + General.Map.UndoRedo.CreateUndo("Insert thing"); Thing t = InsertThing(mousemappos); General.Map.Map.ClearSelectedThings(); t.Selected = true; diff --git a/Source/Data/ImageData.cs b/Source/Data/ImageData.cs index dba20108..1af0eb31 100644 --- a/Source/Data/ImageData.cs +++ b/Source/Data/ImageData.cs @@ -197,8 +197,8 @@ namespace CodeImp.DoomBuilder.Data LocalLoadImage(); // Anything changed? - if((oldwidth != width) || (oldheight != height) || - (oldscaledwidth != scaledwidth) || (oldscaledheight != scaledheight)) + //if((oldwidth != width) || (oldheight != height) || + // (oldscaledwidth != scaledwidth) || (oldscaledheight != scaledheight)) { // Notify the main thread about the change so that sectors can update their buffers IntPtr strptr = Marshal.StringToCoTaskMemAuto(this.name); diff --git a/Source/Editing/EditingManager.cs b/Source/Editing/EditingManager.cs index 20f64b8b..6e8e31c8 100644 --- a/Source/Editing/EditingManager.cs +++ b/Source/Editing/EditingManager.cs @@ -85,6 +85,9 @@ namespace CodeImp.DoomBuilder.Editing allmodes = new List(); usedmodes = new List(); + // Bind any methods + General.Actions.BindMethods(this); + // Make list of all editing modes we can find foreach(Plugin p in General.Plugins.Plugins) { @@ -118,6 +121,9 @@ namespace CodeImp.DoomBuilder.Editing // Not already disposed? if(!isdisposed) { + // Unbind any methods + General.Actions.UnbindMethods(this); + // Clean up // Done diff --git a/Source/General/MapManager.cs b/Source/General/MapManager.cs index cc4c3922..dcde7b1d 100644 --- a/Source/General/MapManager.cs +++ b/Source/General/MapManager.cs @@ -275,6 +275,7 @@ namespace CodeImp.DoomBuilder renderer2d.SetViewMode((ViewMode)General.Settings.DefaultViewMode); // Success + this.changed = false; General.WriteLogLine("Map creation done"); return true; } @@ -349,6 +350,7 @@ namespace CodeImp.DoomBuilder data.Load(configinfo.Resources, options.Resources, maplocation); // Update structures + map.SnapAllToAccuracy(); map.Update(); thingsfilter.Update(); @@ -363,6 +365,7 @@ namespace CodeImp.DoomBuilder if(General.Editing.Mode is ClassicMode) (General.Editing.Mode as ClassicMode).CenterInScreen(); // Success + this.changed = false; General.WriteLogLine("Map loading done"); return true; } @@ -1252,6 +1255,7 @@ namespace CodeImp.DoomBuilder map.Dispose(); map = newmap; map.UpdateConfiguration(); + map.SnapAllToAccuracy(); map.Update(); thingsfilter.Update(); @@ -1293,8 +1297,15 @@ namespace CodeImp.DoomBuilder // Reload data resources General.WriteLogLine("Reloading data resources..."); data = new DataManager(); - maplocation = new DataLocation(DataLocation.RESOURCE_WAD, filepathname, false, false); - data.Load(configinfo.Resources, options.Resources, maplocation); + if(!string.IsNullOrEmpty(filepathname)) + { + maplocation = new DataLocation(DataLocation.RESOURCE_WAD, filepathname, false, false); + data.Load(configinfo.Resources, options.Resources, maplocation); + } + else + { + data.Load(configinfo.Resources, options.Resources); + } // Apply new settings to map elements map.UpdateConfiguration(); diff --git a/Source/Map/Linedef.cs b/Source/Map/Linedef.cs index 9d8663d1..19fd673a 100644 --- a/Source/Map/Linedef.cs +++ b/Source/Map/Linedef.cs @@ -468,6 +468,7 @@ namespace CodeImp.DoomBuilder.Map // Update required (angle changed) NeedUpdate(); + General.Map.IsChanged = true; } // This flips the sidedefs @@ -477,6 +478,8 @@ namespace CodeImp.DoomBuilder.Map Sidedef sd = front; front = back; back = sd; + + General.Map.IsChanged = true; } // This returns a point for testing on one side @@ -521,6 +524,8 @@ namespace CodeImp.DoomBuilder.Map flags[General.Map.Config.SingleSidedFlag] = true; flags[General.Map.Config.DoubleSidedFlag] = false; } + + General.Map.IsChanged = true; } // This returns all points at which the line intersects with the grid @@ -697,6 +702,7 @@ namespace CodeImp.DoomBuilder.Map } // Return result + General.Map.IsChanged = true; return nl; } @@ -867,6 +873,7 @@ namespace CodeImp.DoomBuilder.Map // I got killed by the other. this.Dispose(); + General.Map.IsChanged = true; } // This changes sidedefs (used for joining lines) diff --git a/Source/Map/Sector.cs b/Source/Map/Sector.cs index 7c98a3e2..67de5792 100644 --- a/Source/Map/Sector.cs +++ b/Source/Map/Sector.cs @@ -474,6 +474,8 @@ namespace CodeImp.DoomBuilder.Map // Dispose manually this.Dispose(); } + + General.Map.IsChanged = true; } #endregion @@ -500,6 +502,7 @@ namespace CodeImp.DoomBuilder.Map floortexname = name; longfloortexname = Lump.MakeLongName(name); updateneeded = true; + General.Map.IsChanged = true; } // This sets texture @@ -508,6 +511,7 @@ namespace CodeImp.DoomBuilder.Map ceiltexname = name; longceiltexname = Lump.MakeLongName(name); updateneeded = true; + General.Map.IsChanged = true; } #endregion diff --git a/Source/Map/Sidedef.cs b/Source/Map/Sidedef.cs index 2623093e..032d1078 100644 --- a/Source/Map/Sidedef.cs +++ b/Source/Map/Sidedef.cs @@ -241,6 +241,8 @@ namespace CodeImp.DoomBuilder.Map s.offsetx = offsetx; s.offsety = offsety; } + + General.Map.IsChanged = true; } #endregion @@ -254,18 +256,21 @@ namespace CodeImp.DoomBuilder.Map { this.texnamehigh = "-"; this.longtexnamehigh = MapSet.EmptyLongName; + General.Map.IsChanged = true; } if(!MiddleRequired() && removemiddle) { this.texnamemid = "-"; this.longtexnamemid = MapSet.EmptyLongName; + General.Map.IsChanged = true; } if(!LowRequired()) { this.texnamelow = "-"; this.longtexnamelow = MapSet.EmptyLongName; + General.Map.IsChanged = true; } } @@ -326,6 +331,7 @@ namespace CodeImp.DoomBuilder.Map { texnamehigh = name; longtexnamehigh = Lump.MakeLongName(name); + General.Map.IsChanged = true; } // This sets texture @@ -333,6 +339,7 @@ namespace CodeImp.DoomBuilder.Map { texnamemid = name; longtexnamemid = Lump.MakeLongName(name); + General.Map.IsChanged = true; } // This sets texture @@ -340,6 +347,7 @@ namespace CodeImp.DoomBuilder.Map { texnamelow = name; longtexnamelow = Lump.MakeLongName(name); + General.Map.IsChanged = true; } // This changes sector @@ -353,6 +361,8 @@ namespace CodeImp.DoomBuilder.Map // Attach to sector sectorlistitem = sector.AttachSidedef(this); + + General.Map.IsChanged = true; } #endregion diff --git a/Source/Map/Thing.cs b/Source/Map/Thing.cs index aa157ee5..8532360a 100644 --- a/Source/Map/Thing.cs +++ b/Source/Map/Thing.cs @@ -315,6 +315,7 @@ namespace CodeImp.DoomBuilder.Map { // Change position this.pos = newpos; + General.Map.IsChanged = true; } // This moves the thing @@ -323,6 +324,7 @@ namespace CodeImp.DoomBuilder.Map { // Change position this.pos = new Vector3D(newpos.x, newpos.y, pos.z); + General.Map.IsChanged = true; } // This moves the thing @@ -331,6 +333,7 @@ namespace CodeImp.DoomBuilder.Map { // Change position this.pos = new Vector3D(x, y, zoffset); + General.Map.IsChanged = true; } // This rotates the thing @@ -338,6 +341,7 @@ namespace CodeImp.DoomBuilder.Map { // Change angle this.angle = newangle; + General.Map.IsChanged = true; } // This updates all properties diff --git a/Source/Map/Vertex.cs b/Source/Map/Vertex.cs index 45c63e27..1e4262ea 100644 --- a/Source/Map/Vertex.cs +++ b/Source/Map/Vertex.cs @@ -188,19 +188,24 @@ namespace CodeImp.DoomBuilder.Map // This moves the vertex public void Move(Vector2D newpos) { - // Change position - pos = newpos; - - #if DEBUG - if(float.IsNaN(pos.x) || float.IsNaN(pos.y) || - float.IsInfinity(pos.x) || float.IsInfinity(pos.y)) + // Do we actually move? + if(newpos != pos) { - General.Fail("Invalid vertex position! The given vertex coordinates cannot be NaN or Infinite."); + // Change position + pos = newpos; + + #if DEBUG + if(float.IsNaN(pos.x) || float.IsNaN(pos.y) || + float.IsInfinity(pos.x) || float.IsInfinity(pos.y)) + { + General.Fail("Invalid vertex position! The given vertex coordinates cannot be NaN or Infinite."); + } + #endif + + // Let all lines know they need an update + foreach(Linedef l in linedefs) l.NeedUpdate(); + General.Map.IsChanged = true; } - #endif - - // Let all lines know they need an update - foreach(Linedef l in linedefs) l.NeedUpdate(); } // This snaps the vertex to the map format accuracy @@ -247,6 +252,8 @@ namespace CodeImp.DoomBuilder.Map // Dispose manually this.Dispose(); } + + General.Map.IsChanged = true; } #endregion diff --git a/Source/Windows/MainForm.cs b/Source/Windows/MainForm.cs index b7a828a1..72f42377 100644 --- a/Source/Windows/MainForm.cs +++ b/Source/Windows/MainForm.cs @@ -2029,7 +2029,7 @@ namespace CodeImp.DoomBuilder.Windows case (int)ThreadMessages.ImageDataLoaded: string imagename = Marshal.PtrToStringAuto(m.WParam); Marshal.FreeCoTaskMem(m.WParam); - if(General.Map != null) + if((General.Map != null) && (General.Map.Data != null)) { ImageData img = General.Map.Data.GetFlatImage(imagename); if(img != null) ImageDataLoaded(img);