diff --git a/Source/BuilderModes/Resources/Actions.cfg b/Source/BuilderModes/Resources/Actions.cfg index 8ce26f12..98a33366 100644 --- a/Source/BuilderModes/Resources/Actions.cfg +++ b/Source/BuilderModes/Resources/Actions.cfg @@ -573,16 +573,6 @@ togglelowerunpegged allowscroll = true; } -togglemiddletexture -{ - title = "Toggle Middle Texture"; - category = "visual"; - description = "Toggles the middle texture on the selected or targeted double-sided linedef."; - allowkeys = true; - allowmouse = true; - allowscroll = true; -} - togglegravity { title = "Toggle Gravity"; diff --git a/Source/Data/DataManager.cs b/Source/Data/DataManager.cs index 4d6fa5f3..367ab6b3 100644 --- a/Source/Data/DataManager.cs +++ b/Source/Data/DataManager.cs @@ -204,6 +204,8 @@ namespace CodeImp.DoomBuilder.Data internal void Load(DataLocationList locations) { int texcount, flatcount, spritecount, thingcount; + Dictionary<long, ImageData> texturesonly = new Dictionary<long, ImageData>(); + Dictionary<long, ImageData> flatsonly = new Dictionary<long, ImageData>(); DataReader c; // Create collections @@ -282,11 +284,49 @@ namespace CodeImp.DoomBuilder.Data // Load stuff LoadPalette(); - texcount = LoadTextures(); - flatcount = LoadFlats(); + texcount = LoadTextures(texturesonly); + flatcount = LoadFlats(flatsonly); thingcount = LoadDecorateThings(); spritecount = LoadSprites(); LoadInternalSprites(); + + // Process textures + foreach(KeyValuePair<long, ImageData> t in texturesonly) + { + textures.Add(t.Key, t.Value); + texturenames.Add(t.Value.Name); + } + + // Process flats + foreach(KeyValuePair<long, ImageData> f in flatsonly) + { + flats.Add(f.Key, f.Value); + flatnames.Add(f.Value.Name); + } + + // Mixed textures and flats? + if(General.Map.Config.MixTexturesFlats) + { + // Add textures to flats + foreach(KeyValuePair<long, ImageData> t in texturesonly) + { + if(!flats.ContainsKey(t.Key)) + { + flats.Add(t.Key, t.Value); + flatnames.Add(t.Value.Name); + } + } + + // Add flats to textures + foreach(KeyValuePair<long, ImageData> f in flatsonly) + { + if(!textures.ContainsKey(f.Key)) + { + textures.Add(f.Key, f.Value); + texturenames.Add(f.Value.Name); + } + } + } // Sort names texturenames.Sort(); @@ -586,17 +626,13 @@ namespace CodeImp.DoomBuilder.Data if(i.Value.IsImageLoaded != i.Value.IsReferenced) ProcessImage(i.Value); } - // Flats are not already included with the textures? - if(!General.Map.Config.MixTexturesFlats) + // Set used on all flats + foreach(KeyValuePair<long, ImageData> i in flats) { - // Set used on all flats - foreach(KeyValuePair<long, ImageData> i in flats) - { - i.Value.SetUsedInMap(usedimages.ContainsKey(i.Key)); - if(i.Value.IsImageLoaded != i.Value.IsReferenced) ProcessImage(i.Value); - } + i.Value.SetUsedInMap(usedimages.ContainsKey(i.Key)); + if(i.Value.IsImageLoaded != i.Value.IsReferenced) ProcessImage(i.Value); } - + // Done updatedusedtextures = false; } @@ -630,7 +666,7 @@ namespace CodeImp.DoomBuilder.Data #region ================== Textures // This loads the textures - private int LoadTextures() + private int LoadTextures(Dictionary<long, ImageData> list) { ICollection<ImageData> images; PatchNames pnames = new PatchNames(); @@ -656,20 +692,11 @@ namespace CodeImp.DoomBuilder.Data foreach(ImageData img in images) { // Add or replace in textures list - if(!textures.ContainsKey(img.LongName)) texturenames.Add(img.Name); - textures.Remove(img.LongName); - textures.Add(img.LongName, img); + list.Remove(img.LongName); + list.Add(img.LongName, img); if(firsttexture == 0) firsttexture = img.LongName; counter++; - // Also add as flat when using mixed resources - if(General.Map.Config.MixTexturesFlats) - { - if(!flats.ContainsKey(img.LongName)) flatnames.Add(img.Name); - flats.Remove(img.LongName); - flats.Add(img.LongName, img); - } - // Add to preview manager previews.AddImage(img); } @@ -678,8 +705,7 @@ namespace CodeImp.DoomBuilder.Data // The first texture cannot be used, because in the game engine it // has index 0 which means "no texture", so remove it from the list. - textures.Remove(firsttexture); - if(General.Map.Config.MixTexturesFlats) flats.Remove(firsttexture); + list.Remove(firsttexture); // Output info return counter; @@ -787,7 +813,7 @@ namespace CodeImp.DoomBuilder.Data #region ================== Flats // This loads the flats - private int LoadFlats() + private int LoadFlats(Dictionary<long, ImageData> list) { ICollection<ImageData> images; int counter = 0; @@ -803,19 +829,10 @@ namespace CodeImp.DoomBuilder.Data foreach(ImageData img in images) { // Add or replace in flats list - if(!flats.ContainsKey(img.LongName)) flatnames.Add(img.Name); - flats.Remove(img.LongName); - flats.Add(img.LongName, img); + list.Remove(img.LongName); + list.Add(img.LongName, img); counter++; - // Also add as texture when using mixed resources - if(General.Map.Config.MixTexturesFlats) - { - if(!textures.ContainsKey(img.LongName)) texturenames.Add(img.Name); - textures.Remove(img.LongName); - textures.Add(img.LongName, img); - } - // Add to preview manager previews.AddImage(img); } diff --git a/Source/Rendering/Renderer2D.cs b/Source/Rendering/Renderer2D.cs index 807bb2e5..694d7c64 100644 --- a/Source/Rendering/Renderer2D.cs +++ b/Source/Rendering/Renderer2D.cs @@ -26,6 +26,7 @@ using System.IO; using System.Reflection; using System.Drawing; using System.ComponentModel; +using CodeImp.DoomBuilder.IO; using CodeImp.DoomBuilder.Map; using SlimDX.Direct3D9; using SlimDX; @@ -1127,6 +1128,9 @@ namespace CodeImp.DoomBuilder.Rendering targetsurface = surfacetex.GetSurfaceLevel(0); if(graphics.StartRendering(true, General.Colors.Background.WithAlpha(0).ToColorValue(), targetsurface, null)) { + // Make sure anything we need is loaded + General.Map.Data.UnknownTexture3D.CreateTexture(); + // Set transformations UpdateTransformations(); @@ -1202,7 +1206,7 @@ namespace CodeImp.DoomBuilder.Rendering private void RenderSectorSurface(Sector s, VertexBuffer buffer, long longimagename) { Texture t = null; - + if((buffer != null) && (s.FlatVertices != null) && (s.FlatVertices.Length > 0)) { if(longimagename == 0) @@ -1217,7 +1221,6 @@ namespace CodeImp.DoomBuilder.Rendering // Texture unknown? if(img is UnknownImage) { - General.Map.Data.UnknownTexture3D.CreateTexture(); t = General.Map.Data.UnknownTexture3D.Texture; } // Is the texture loaded?