- Textures now take precedence when on walls and flats take precedence when on floors/ceilings

- Removed an unused action
This commit is contained in:
codeimp 2009-04-18 09:38:13 +00:00
parent 1c2045e42e
commit 95d3d79d11
3 changed files with 59 additions and 49 deletions

View file

@ -573,16 +573,6 @@ togglelowerunpegged
allowscroll = true; 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 togglegravity
{ {
title = "Toggle Gravity"; title = "Toggle Gravity";

View file

@ -204,6 +204,8 @@ namespace CodeImp.DoomBuilder.Data
internal void Load(DataLocationList locations) internal void Load(DataLocationList locations)
{ {
int texcount, flatcount, spritecount, thingcount; int texcount, flatcount, spritecount, thingcount;
Dictionary<long, ImageData> texturesonly = new Dictionary<long, ImageData>();
Dictionary<long, ImageData> flatsonly = new Dictionary<long, ImageData>();
DataReader c; DataReader c;
// Create collections // Create collections
@ -282,11 +284,49 @@ namespace CodeImp.DoomBuilder.Data
// Load stuff // Load stuff
LoadPalette(); LoadPalette();
texcount = LoadTextures(); texcount = LoadTextures(texturesonly);
flatcount = LoadFlats(); flatcount = LoadFlats(flatsonly);
thingcount = LoadDecorateThings(); thingcount = LoadDecorateThings();
spritecount = LoadSprites(); spritecount = LoadSprites();
LoadInternalSprites(); 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 // Sort names
texturenames.Sort(); texturenames.Sort();
@ -586,17 +626,13 @@ namespace CodeImp.DoomBuilder.Data
if(i.Value.IsImageLoaded != i.Value.IsReferenced) ProcessImage(i.Value); if(i.Value.IsImageLoaded != i.Value.IsReferenced) ProcessImage(i.Value);
} }
// Flats are not already included with the textures? // Set used on all flats
if(!General.Map.Config.MixTexturesFlats) foreach(KeyValuePair<long, ImageData> i in flats)
{ {
// Set used on all flats i.Value.SetUsedInMap(usedimages.ContainsKey(i.Key));
foreach(KeyValuePair<long, ImageData> i in flats) 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 // Done
updatedusedtextures = false; updatedusedtextures = false;
} }
@ -630,7 +666,7 @@ namespace CodeImp.DoomBuilder.Data
#region ================== Textures #region ================== Textures
// This loads the textures // This loads the textures
private int LoadTextures() private int LoadTextures(Dictionary<long, ImageData> list)
{ {
ICollection<ImageData> images; ICollection<ImageData> images;
PatchNames pnames = new PatchNames(); PatchNames pnames = new PatchNames();
@ -656,20 +692,11 @@ namespace CodeImp.DoomBuilder.Data
foreach(ImageData img in images) foreach(ImageData img in images)
{ {
// Add or replace in textures list // Add or replace in textures list
if(!textures.ContainsKey(img.LongName)) texturenames.Add(img.Name); list.Remove(img.LongName);
textures.Remove(img.LongName); list.Add(img.LongName, img);
textures.Add(img.LongName, img);
if(firsttexture == 0) firsttexture = img.LongName; if(firsttexture == 0) firsttexture = img.LongName;
counter++; 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 // Add to preview manager
previews.AddImage(img); previews.AddImage(img);
} }
@ -678,8 +705,7 @@ namespace CodeImp.DoomBuilder.Data
// The first texture cannot be used, because in the game engine it // 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. // has index 0 which means "no texture", so remove it from the list.
textures.Remove(firsttexture); list.Remove(firsttexture);
if(General.Map.Config.MixTexturesFlats) flats.Remove(firsttexture);
// Output info // Output info
return counter; return counter;
@ -787,7 +813,7 @@ namespace CodeImp.DoomBuilder.Data
#region ================== Flats #region ================== Flats
// This loads the flats // This loads the flats
private int LoadFlats() private int LoadFlats(Dictionary<long, ImageData> list)
{ {
ICollection<ImageData> images; ICollection<ImageData> images;
int counter = 0; int counter = 0;
@ -803,19 +829,10 @@ namespace CodeImp.DoomBuilder.Data
foreach(ImageData img in images) foreach(ImageData img in images)
{ {
// Add or replace in flats list // Add or replace in flats list
if(!flats.ContainsKey(img.LongName)) flatnames.Add(img.Name); list.Remove(img.LongName);
flats.Remove(img.LongName); list.Add(img.LongName, img);
flats.Add(img.LongName, img);
counter++; 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 // Add to preview manager
previews.AddImage(img); previews.AddImage(img);
} }

View file

@ -26,6 +26,7 @@ using System.IO;
using System.Reflection; using System.Reflection;
using System.Drawing; using System.Drawing;
using System.ComponentModel; using System.ComponentModel;
using CodeImp.DoomBuilder.IO;
using CodeImp.DoomBuilder.Map; using CodeImp.DoomBuilder.Map;
using SlimDX.Direct3D9; using SlimDX.Direct3D9;
using SlimDX; using SlimDX;
@ -1127,6 +1128,9 @@ namespace CodeImp.DoomBuilder.Rendering
targetsurface = surfacetex.GetSurfaceLevel(0); targetsurface = surfacetex.GetSurfaceLevel(0);
if(graphics.StartRendering(true, General.Colors.Background.WithAlpha(0).ToColorValue(), targetsurface, null)) 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 // Set transformations
UpdateTransformations(); UpdateTransformations();
@ -1202,7 +1206,7 @@ namespace CodeImp.DoomBuilder.Rendering
private void RenderSectorSurface(Sector s, VertexBuffer buffer, long longimagename) private void RenderSectorSurface(Sector s, VertexBuffer buffer, long longimagename)
{ {
Texture t = null; Texture t = null;
if((buffer != null) && (s.FlatVertices != null) && (s.FlatVertices.Length > 0)) if((buffer != null) && (s.FlatVertices != null) && (s.FlatVertices.Length > 0))
{ {
if(longimagename == 0) if(longimagename == 0)
@ -1217,7 +1221,6 @@ namespace CodeImp.DoomBuilder.Rendering
// Texture unknown? // Texture unknown?
if(img is UnknownImage) if(img is UnknownImage)
{ {
General.Map.Data.UnknownTexture3D.CreateTexture();
t = General.Map.Data.UnknownTexture3D.Texture; t = General.Map.Data.UnknownTexture3D.Texture;
} }
// Is the texture loaded? // Is the texture loaded?