mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-15 10:35:11 -04:00
Lazily allocate weather heightmap, also fix double texture warning screne not restoring the cursor (Thanks Zingan).
This commit is contained in:
parent
5e29f5cd23
commit
6dbce98a67
@ -17,7 +17,7 @@ namespace ClassicalSharp {
|
||||
this.body = body;
|
||||
}
|
||||
internal Screen lastScreen;
|
||||
internal bool lastCursorVisible;
|
||||
internal bool wasCursorVisible;
|
||||
string title;
|
||||
string[] body;
|
||||
|
||||
@ -92,8 +92,10 @@ namespace ClassicalSharp {
|
||||
game.activeScreen = game.WarningScreens[0];
|
||||
} else {
|
||||
game.activeScreen = lastScreen;
|
||||
if( game.CursorVisible != lastCursorVisible )
|
||||
game.CursorVisible = lastCursorVisible;
|
||||
if( game.CursorVisible != wasCursorVisible )
|
||||
game.CursorVisible = wasCursorVisible;
|
||||
if( game.activeScreen == null && game.CursorVisible )
|
||||
game.CursorVisible = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -197,6 +197,7 @@ namespace ClassicalSharp {
|
||||
Culling.CalcFrustumEquations( ref Projection, ref modelView );
|
||||
|
||||
bool visible = activeScreen == null || !activeScreen.BlocksWorld;
|
||||
if( Map.IsNotLoaded ) visible = false;
|
||||
if( visible ) {
|
||||
AxisLinesRenderer.Render( e.Time );
|
||||
Players.RenderModels( Graphics, e.Time, t );
|
||||
@ -352,10 +353,10 @@ namespace ClassicalSharp {
|
||||
screen.lastScreen = activeScreen;
|
||||
activeScreen = screen;
|
||||
|
||||
screen.lastCursorVisible = CursorVisible;
|
||||
if( !CursorVisible) CursorVisible = true;
|
||||
screen.wasCursorVisible = CursorVisible;
|
||||
if( !CursorVisible ) CursorVisible = true;
|
||||
} else {
|
||||
screen.lastCursorVisible = WarningScreens[0].lastCursorVisible;
|
||||
screen.wasCursorVisible = WarningScreens[0].wasCursorVisible;
|
||||
}
|
||||
WarningScreens.Add( screen );
|
||||
screen.Init();
|
||||
|
@ -147,7 +147,7 @@ namespace ClassicalSharp {
|
||||
void HandleLevelFinalise() {
|
||||
game.SetNewScreen( null );
|
||||
game.activeScreen = prevScreen;
|
||||
if( prevScreen != null )
|
||||
if( prevScreen != null && prevCursorVisible != game.CursorVisible )
|
||||
game.CursorVisible = prevCursorVisible;
|
||||
prevScreen = null;
|
||||
|
||||
|
@ -29,6 +29,7 @@ namespace ClassicalSharp {
|
||||
public void Render( double deltaTime ) {
|
||||
Weather weather = map.Weather;
|
||||
if( weather == Weather.Sunny ) return;
|
||||
if( heightmap == null ) InitHeightmap();
|
||||
|
||||
graphics.Texturing = true;
|
||||
graphics.BindTexture( weather == Weather.Rainy ? game.RainTexId : game.SnowTexId );
|
||||
@ -102,7 +103,9 @@ namespace ClassicalSharp {
|
||||
width = map.Width;
|
||||
maxY = map.Height - 1;
|
||||
oneY = length * width;
|
||||
|
||||
}
|
||||
|
||||
void InitHeightmap() {
|
||||
heightmap = new short[map.Width * map.Length];
|
||||
for( int i = 0; i < heightmap.Length; i++ ) {
|
||||
heightmap[i] = short.MaxValue;
|
||||
@ -148,7 +151,7 @@ namespace ClassicalSharp {
|
||||
}
|
||||
|
||||
internal void UpdateHeight( int x, int y, int z, byte oldBlock, byte newBlock ) {
|
||||
if( game.Map.IsNotLoaded ) return;
|
||||
if( game.Map.IsNotLoaded || heightmap == null ) return;
|
||||
bool didBlock = BlocksRain( oldBlock );
|
||||
bool nowBlocks = BlocksRain( newBlock );
|
||||
if( didBlock == nowBlocks ) return;
|
||||
|
Loading…
x
Reference in New Issue
Block a user