- some bug fixes in the view modes

- fixed some bugs in resources loading
This commit is contained in:
codeimp 2008-10-15 17:26:59 +00:00
parent b120c567bc
commit 279b974683
5 changed files with 652 additions and 630 deletions

View file

@ -134,7 +134,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
// When ceiling surface geometry is created for classic modes
public override void OnSectorCeilingSurfaceUpdate(Sector s, ref FlatVertex[] vertices)
{
ImageData img = General.Map.Data.GetFlatImage(s.LongFloorTexture);
ImageData img = General.Map.Data.GetFlatImage(s.LongCeilTexture);
if(img != null)
{
// Make scalars

View file

@ -70,6 +70,9 @@ namespace CodeImp.DoomBuilder.Data
private ImageData missingtexture3d;
private ImageData hourglass3d;
// Used images
private Dictionary<long, long> usedimages;
// Disposing
private bool isdisposed = false;
@ -172,6 +175,7 @@ namespace CodeImp.DoomBuilder.Data
imageque = new Queue<ImageData>();
previews = new PreviewManager();
texturesets = new List<MatchingTextureSet>();
usedimages = new Dictionary<long, long>();
// Load texture sets
foreach(DefinedTextureSet ts in General.Map.ConfigSettings.TextureSets)
@ -413,11 +417,7 @@ namespace CodeImp.DoomBuilder.Data
do
{
// Do we have to update the used-in-map status?
if(updatedusedtextures)
{
BackgroundUpdateUsedTextures();
updatedusedtextures = false;
}
if(updatedusedtextures) BackgroundUpdateUsedTextures();
// Get next item
ImageData image = null;
@ -502,40 +502,28 @@ namespace CodeImp.DoomBuilder.Data
// This updates the used-in-map status on all textures and flats
private void BackgroundUpdateUsedTextures()
{
Dictionary<long, long> useditems = new Dictionary<long, long>();
// TODO: Move the map scanning part to the application thread (into the
// UpdateUsedTextures function)
// We shouldn't do this in the background, because we're not supposed
// to access the map from this thread! The map could change!
// Go through the map to find the used textures
foreach(Sidedef sd in General.Map.Map.Sidedefs)
lock(usedimages)
{
// Add used textures to dictionary
if(sd.HighTexture.Length > 0) useditems[sd.LongHighTexture] = 0;
if(sd.LowTexture.Length > 0) useditems[sd.LongMiddleTexture] = 0;
if(sd.MiddleTexture.Length > 0) useditems[sd.LongLowTexture] = 0;
}
// Set used on all textures
foreach(KeyValuePair<long, ImageData> i in textures)
{
i.Value.SetUsedInMap(usedimages.ContainsKey(i.Key));
if(i.Value.IsImageLoaded != i.Value.IsReferenced) ProcessImage(i.Value);
}
// Go through the map to find the used flats
foreach(Sector s in General.Map.Map.Sectors)
{
// Add used flats to dictionary
useditems[s.LongFloorTexture] = 0;
useditems[s.LongCeilTexture] = 0;
}
// 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)
{
i.Value.SetUsedInMap(usedimages.ContainsKey(i.Key));
if(i.Value.IsImageLoaded != i.Value.IsReferenced) ProcessImage(i.Value);
}
}
// Set used on all textures
foreach(KeyValuePair<long, ImageData> i in textures)
i.Value.SetUsedInMap(useditems.ContainsKey(i.Key));
// 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)
i.Value.SetUsedInMap(useditems.ContainsKey(i.Key));
// Done
updatedusedtextures = false;
}
}
@ -966,7 +954,30 @@ namespace CodeImp.DoomBuilder.Data
// used-in-map status on all textures and flats
public void UpdateUsedTextures()
{
updatedusedtextures = true;
lock(usedimages)
{
usedimages.Clear();
// Go through the map to find the used textures
foreach(Sidedef sd in General.Map.Map.Sidedefs)
{
// Add used textures to dictionary
if(sd.HighTexture.Length > 0) usedimages[sd.LongHighTexture] = 0;
if(sd.LowTexture.Length > 0) usedimages[sd.LongMiddleTexture] = 0;
if(sd.MiddleTexture.Length > 0) usedimages[sd.LongLowTexture] = 0;
}
// Go through the map to find the used flats
foreach(Sector s in General.Map.Map.Sectors)
{
// Add used flats to dictionary
usedimages[s.LongFloorTexture] = 0;
usedimages[s.LongCeilTexture] = 0;
}
// Notify the background thread that it needs to update the images
updatedusedtextures = true;
}
}
#endregion

File diff suppressed because it is too large Load diff

View file

@ -1252,10 +1252,21 @@ namespace CodeImp.DoomBuilder.Windows
buttontestmonsters.Enabled = (General.Map != null);
buttontestmonsters.Checked = General.Settings.TestMonsters;
// Only disable view mode buttons
if(General.Map == null)
// View mode buttons
for(int i = 0; i < Renderer2D.NUM_VIEW_MODES; i++)
{
for(int i = 0; i < Renderer2D.NUM_VIEW_MODES; i++) viewmodes[i].Enabled = false;
// NOTE: We only disable them when no map is loaded, because they may
// need to be disabled for non-classic modes
if(General.Map == null)
{
viewmodes[i].Enabled = false;
viewmodes[i].Checked = false;
}
else
{
// Check the correct button
viewmodes[i].Checked = (i == (int)General.Map.CRenderer2D.ViewMode);
}
}
}

View file

@ -156,6 +156,12 @@
<metadata name="toolStripSeparator12.GenerateMember" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value>
</metadata>
<metadata name="toolStripMenuItem4.GenerateMember" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value>
</metadata>
<metadata name="toolStripSeparator2.GenerateMember" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value>
</metadata>
<metadata name="menumain.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
@ -174,12 +180,6 @@
<metadata name="statusbar.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>207, 17</value>
</metadata>
<metadata name="toolStripMenuItem4.GenerateMember" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value>
</metadata>
<metadata name="toolStripSeparator2.GenerateMember" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value>
</metadata>
<metadata name="panelinfo.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>