1- using Rampastring . XNAUI . XNAControls ;
2- using Rampastring . XNAUI ;
3- using Microsoft . Xna . Framework ;
4- using DTAClient . Domain . Multiplayer ;
1+ using System ;
2+ using System . Diagnostics ;
3+
4+ using ClientCore ;
55using ClientCore . Extensions ;
6+
7+ using DTAClient . Domain . Multiplayer ;
8+
9+ using Microsoft . Xna . Framework ;
610using Microsoft . Xna . Framework . Graphics ;
7- using Rampastring . Tools ;
8- using System . Net . NetworkInformation ;
9- using System ;
10- using ClientCore ;
11+
12+ using Rampastring . XNAUI ;
13+ using Rampastring . XNAUI . XNAControls ;
1114
1215namespace DTAClient . DXGUI . Multiplayer
1316{
@@ -39,7 +42,9 @@ public GameInformationPanel(WindowManager windowManager, MapLoader mapLoader)
3942 private XNALabel [ ] lblPlayerNames ;
4043
4144 private GenericHostedGame game = null ;
42- private Texture2D mapTexture ;
45+
46+ private bool disposeTextures = false ;
47+ private Texture2D mapTexture = null ;
4348 private Texture2D noMapPreviewTexture = null ;
4449
4550 private const int leftColumnPositionX = 10 ;
@@ -65,7 +70,7 @@ public override void Initialize()
6570 lblGameInformation . FontIndex = 1 ;
6671 lblGameInformation . Text = "GAME INFORMATION" . L10N ( "Client:Main:GameInfo" ) ;
6772
68- if ( AssetLoader . AssetExists ( "noMapPreview.png" ) )
73+ if ( AssetLoader . AssetExists ( "noMapPreview.png" ) )
6974 noMapPreviewTexture = AssetLoader . LoadTexture ( "noMapPreview.png" ) ;
7075
7176 rightColumnPositionX = Width / 2 - columnMargin ;
@@ -189,9 +194,17 @@ public void SetInfo(GenericHostedGame game)
189194
190195 if ( mapLoader != null )
191196 {
192- mapTexture = mapLoader . GameModeMaps . Find ( m => m . Map . Name == game . Map ) ? . Map . LoadPreviewTexture ( ) ;
197+ mapTexture = mapLoader . GameModeMaps . Find ( m => m . Map . Name == game . Map && m . Map . IsPreviewTextureCached ( ) ) ? . Map ? . LoadPreviewTexture ( ) ;
193198 if ( mapTexture == null && noMapPreviewTexture != null )
199+ {
200+ Debug . Assert ( ! noMapPreviewTexture . IsDisposed , "noMapPreviewTexture should not be disposed." ) ;
194201 mapTexture = noMapPreviewTexture ;
202+ disposeTextures = false ;
203+ }
204+ else
205+ {
206+ disposeTextures = true ;
207+ }
195208 }
196209 }
197210
@@ -208,8 +221,12 @@ public void ClearInfo()
208221 foreach ( XNALabel label in lblPlayerNames )
209222 label . Visible = false ;
210223
211- mapTexture ? . Dispose ( ) ;
212- mapTexture = null ;
224+ if ( mapTexture != null && disposeTextures )
225+ {
226+ Debug . Assert ( ! mapTexture . IsDisposed , "mapTexture should not be disposed." ) ;
227+ mapTexture . Dispose ( ) ;
228+ mapTexture = null ;
229+ }
213230 }
214231
215232 public override void Draw ( GameTime gameTime )
0 commit comments