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;
|
this.body = body;
|
||||||
}
|
}
|
||||||
internal Screen lastScreen;
|
internal Screen lastScreen;
|
||||||
internal bool lastCursorVisible;
|
internal bool wasCursorVisible;
|
||||||
string title;
|
string title;
|
||||||
string[] body;
|
string[] body;
|
||||||
|
|
||||||
@ -92,8 +92,10 @@ namespace ClassicalSharp {
|
|||||||
game.activeScreen = game.WarningScreens[0];
|
game.activeScreen = game.WarningScreens[0];
|
||||||
} else {
|
} else {
|
||||||
game.activeScreen = lastScreen;
|
game.activeScreen = lastScreen;
|
||||||
if( game.CursorVisible != lastCursorVisible )
|
if( game.CursorVisible != wasCursorVisible )
|
||||||
game.CursorVisible = lastCursorVisible;
|
game.CursorVisible = wasCursorVisible;
|
||||||
|
if( game.activeScreen == null && game.CursorVisible )
|
||||||
|
game.CursorVisible = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -197,6 +197,7 @@ namespace ClassicalSharp {
|
|||||||
Culling.CalcFrustumEquations( ref Projection, ref modelView );
|
Culling.CalcFrustumEquations( ref Projection, ref modelView );
|
||||||
|
|
||||||
bool visible = activeScreen == null || !activeScreen.BlocksWorld;
|
bool visible = activeScreen == null || !activeScreen.BlocksWorld;
|
||||||
|
if( Map.IsNotLoaded ) visible = false;
|
||||||
if( visible ) {
|
if( visible ) {
|
||||||
AxisLinesRenderer.Render( e.Time );
|
AxisLinesRenderer.Render( e.Time );
|
||||||
Players.RenderModels( Graphics, e.Time, t );
|
Players.RenderModels( Graphics, e.Time, t );
|
||||||
@ -352,10 +353,10 @@ namespace ClassicalSharp {
|
|||||||
screen.lastScreen = activeScreen;
|
screen.lastScreen = activeScreen;
|
||||||
activeScreen = screen;
|
activeScreen = screen;
|
||||||
|
|
||||||
screen.lastCursorVisible = CursorVisible;
|
screen.wasCursorVisible = CursorVisible;
|
||||||
if( !CursorVisible) CursorVisible = true;
|
if( !CursorVisible ) CursorVisible = true;
|
||||||
} else {
|
} else {
|
||||||
screen.lastCursorVisible = WarningScreens[0].lastCursorVisible;
|
screen.wasCursorVisible = WarningScreens[0].wasCursorVisible;
|
||||||
}
|
}
|
||||||
WarningScreens.Add( screen );
|
WarningScreens.Add( screen );
|
||||||
screen.Init();
|
screen.Init();
|
||||||
|
@ -147,7 +147,7 @@ namespace ClassicalSharp {
|
|||||||
void HandleLevelFinalise() {
|
void HandleLevelFinalise() {
|
||||||
game.SetNewScreen( null );
|
game.SetNewScreen( null );
|
||||||
game.activeScreen = prevScreen;
|
game.activeScreen = prevScreen;
|
||||||
if( prevScreen != null )
|
if( prevScreen != null && prevCursorVisible != game.CursorVisible )
|
||||||
game.CursorVisible = prevCursorVisible;
|
game.CursorVisible = prevCursorVisible;
|
||||||
prevScreen = null;
|
prevScreen = null;
|
||||||
|
|
||||||
|
@ -29,6 +29,7 @@ namespace ClassicalSharp {
|
|||||||
public void Render( double deltaTime ) {
|
public void Render( double deltaTime ) {
|
||||||
Weather weather = map.Weather;
|
Weather weather = map.Weather;
|
||||||
if( weather == Weather.Sunny ) return;
|
if( weather == Weather.Sunny ) return;
|
||||||
|
if( heightmap == null ) InitHeightmap();
|
||||||
|
|
||||||
graphics.Texturing = true;
|
graphics.Texturing = true;
|
||||||
graphics.BindTexture( weather == Weather.Rainy ? game.RainTexId : game.SnowTexId );
|
graphics.BindTexture( weather == Weather.Rainy ? game.RainTexId : game.SnowTexId );
|
||||||
@ -102,7 +103,9 @@ namespace ClassicalSharp {
|
|||||||
width = map.Width;
|
width = map.Width;
|
||||||
maxY = map.Height - 1;
|
maxY = map.Height - 1;
|
||||||
oneY = length * width;
|
oneY = length * width;
|
||||||
|
}
|
||||||
|
|
||||||
|
void InitHeightmap() {
|
||||||
heightmap = new short[map.Width * map.Length];
|
heightmap = new short[map.Width * map.Length];
|
||||||
for( int i = 0; i < heightmap.Length; i++ ) {
|
for( int i = 0; i < heightmap.Length; i++ ) {
|
||||||
heightmap[i] = short.MaxValue;
|
heightmap[i] = short.MaxValue;
|
||||||
@ -148,7 +151,7 @@ namespace ClassicalSharp {
|
|||||||
}
|
}
|
||||||
|
|
||||||
internal void UpdateHeight( int x, int y, int z, byte oldBlock, byte newBlock ) {
|
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 didBlock = BlocksRain( oldBlock );
|
||||||
bool nowBlocks = BlocksRain( newBlock );
|
bool nowBlocks = BlocksRain( newBlock );
|
||||||
if( didBlock == nowBlocks ) return;
|
if( didBlock == nowBlocks ) return;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user