diff --git a/ClassicalSharp/2D/Widgets/BlockHotbarWidget.cs b/ClassicalSharp/2D/Widgets/BlockHotbarWidget.cs index 115437b4c..bbf9d731b 100644 --- a/ClassicalSharp/2D/Widgets/BlockHotbarWidget.cs +++ b/ClassicalSharp/2D/Widgets/BlockHotbarWidget.cs @@ -42,7 +42,7 @@ namespace ClassicalSharp { Height = blockSize; for( int i = 0; i < barTextures.Length; i++ ) { - barTextures[i] = MakeTexture( x, y, game.BlocksHotbar[i] ); + barTextures[i] = MakeTexture( x, y, game.Hotbar[i] ); x += blockSize; } } diff --git a/ClassicalSharp/Game/Game.InputHandling.cs b/ClassicalSharp/Game/Game.InputHandling.cs index ed261bf97..3a75db9b3 100644 --- a/ClassicalSharp/Game/Game.InputHandling.cs +++ b/ClassicalSharp/Game/Game.InputHandling.cs @@ -64,10 +64,10 @@ namespace ClassicalSharp { if( activeScreen == null || !activeScreen.HandlesMouseScroll( e.Delta ) ) { if( Camera.MouseZoom( e ) || !CanChangeHeldBlock ) return; - int diff = -e.Delta % BlocksHotbar.Length; + int diff = -e.Delta % Hotbar.Length; int newIndex = HeldBlockIndex + diff; - if( newIndex < 0 ) newIndex += BlocksHotbar.Length; - if( newIndex >= BlocksHotbar.Length ) newIndex -= BlocksHotbar.Length; + if( newIndex < 0 ) newIndex += Hotbar.Length; + if( newIndex >= Hotbar.Length ) newIndex -= Hotbar.Length; HeldBlockIndex = newIndex; } } diff --git a/ClassicalSharp/Game/Game.cs b/ClassicalSharp/Game/Game.cs index e40222b8c..bdd728eee 100644 --- a/ClassicalSharp/Game/Game.cs +++ b/ClassicalSharp/Game/Game.cs @@ -51,8 +51,7 @@ namespace ClassicalSharp { int hotbarIndex = 0; public bool CanChangeHeldBlock = true; - public Block[] BlocksHotbar = new Block[] { Block.Stone, Block.Cobblestone, - Block.Brick, Block.Dirt, Block.WoodenPlanks, Block.Wood, Block.Leaves, Block.Glass, Block.Slab }; + public Block[] Hotbar = new Block[9]; public int HeldBlockIndex { get { return hotbarIndex; } @@ -67,20 +66,20 @@ namespace ClassicalSharp { } public Block HeldBlock { - get { return BlocksHotbar[hotbarIndex]; } + get { return Hotbar[hotbarIndex]; } set { if( !CanChangeHeldBlock ) { AddChat( "&e/client: &cThe server has forbidden you from changing your held block." ); return; } - for( int i = 0; i < BlocksHotbar.Length; i++ ) { - if( BlocksHotbar[i] == value ) { + for( int i = 0; i < Hotbar.Length; i++ ) { + if( Hotbar[i] == value ) { hotbarIndex = i; RaiseHeldBlockChanged(); return; } } - BlocksHotbar[hotbarIndex] = value; + Hotbar[hotbarIndex] = value; RaiseHeldBlockChanged(); } } @@ -113,12 +112,14 @@ namespace ClassicalSharp { Raise( TerrainAtlasChanged ); } - void PrintGraphicsInfo() { - Console.ForegroundColor = ConsoleColor.Green; - Graphics.PrintApiSpecificInfo(); - Utils.Log( "Max 2D texture dimensions: " + Graphics.MaxTextureDimensions ); - Utils.Log( "== End of graphics info ==" ); - Console.ResetColor(); + public Game() : base() { + // We can't use enum array initaliser because this causes problems when building with mono + // and running on default .NET (https://bugzilla.xamarin.com/show_bug.cgi?id=572) + Hotbar[0] = Block.Stone; Hotbar[1] = Block.Cobblestone; + Hotbar[2] = Block.Brick; Hotbar[3] = Block.Dirt; + Hotbar[4] = Block.WoodenPlanks; Hotbar[5] = Block.Wood; + Hotbar[6] = Block.Leaves; Hotbar[7] = Block.Glass; + Hotbar[8] = Block.Slab; } protected override void OnLoad( EventArgs e ) { @@ -131,7 +132,7 @@ namespace ClassicalSharp { ModelCache = new ModelCache( this ); ModelCache.InitCache(); AsyncDownloader = new AsyncDownloader( skinServer ); - PrintGraphicsInfo(); + Graphics.PrintGraphicsInfo(); Bitmap terrainBmp = new Bitmap( "terrain.png" ); TerrainAtlas1D = new TerrainAtlas1D( Graphics ); TerrainAtlas = new TerrainAtlas2D( Graphics ); diff --git a/ClassicalSharp/GraphicsAPI/IGraphicsApi.cs b/ClassicalSharp/GraphicsAPI/IGraphicsApi.cs index 96df54149..263311b8f 100644 --- a/ClassicalSharp/GraphicsAPI/IGraphicsApi.cs +++ b/ClassicalSharp/GraphicsAPI/IGraphicsApi.cs @@ -157,6 +157,14 @@ namespace ClassicalSharp.GraphicsAPI { public abstract void PrintApiSpecificInfo(); + public void PrintGraphicsInfo() { + Console.ForegroundColor = ConsoleColor.Green; + PrintApiSpecificInfo(); + Utils.Log( "Max 2D texture dimensions: " + MaxTextureDimensions ); + Utils.Log( "== End of graphics info ==" ); + Console.ResetColor(); + } + public abstract void BeginFrame( Game game ); public abstract void EndFrame( Game game );