mirror of
				https://github.com/ClassiCube/ClassiCube.git
				synced 2025-11-03 19:16:45 -05:00 
			
		
		
		
	More fixes for default.png, fix 'okay' widget not being properly closed when clicking on 'use font'.
This commit is contained in:
		
							parent
							
								
									7d1e716eb4
								
							
						
					
					
						commit
						ef34766b2b
					
				@ -16,7 +16,7 @@ namespace ClassicalSharp.Gui {
 | 
				
			|||||||
			this.title = title;
 | 
								this.title = title;
 | 
				
			||||||
			this.message = message;
 | 
								this.message = message;
 | 
				
			||||||
			titleFont = new Font( game.FontName, 16, FontStyle.Bold );
 | 
								titleFont = new Font( game.FontName, 16, FontStyle.Bold );
 | 
				
			||||||
			messageFont = new Font( game.FontName, 14, FontStyle.Regular );
 | 
								messageFont = new Font( game.FontName, 16, FontStyle.Regular );
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
		public override void Render( double delta ) {
 | 
							public override void Render( double delta ) {
 | 
				
			||||||
 | 
				
			|||||||
@ -22,7 +22,8 @@ namespace ClassicalSharp.Gui {
 | 
				
			|||||||
			textFont = new Font( game.FontName, 16, FontStyle.Bold );
 | 
								textFont = new Font( game.FontName, 16, FontStyle.Bold );
 | 
				
			||||||
			arrowFont = new Font( game.FontName, 18, FontStyle.Bold );
 | 
								arrowFont = new Font( game.FontName, 18, FontStyle.Bold );
 | 
				
			||||||
			titleFont = new Font( game.FontName, 16, FontStyle.Bold );
 | 
								titleFont = new Font( game.FontName, 16, FontStyle.Bold );
 | 
				
			||||||
			title = TextWidget.Create( game, 0, -130, titleText, Anchor.Centre, Anchor.Centre, titleFont );
 | 
								title = ChatTextWidget.Create( game, 0, -130, titleText, 
 | 
				
			||||||
 | 
								                          Anchor.Centre, Anchor.Centre, titleFont );
 | 
				
			||||||
			
 | 
								
 | 
				
			||||||
			buttons = new ButtonWidget[] {
 | 
								buttons = new ButtonWidget[] {
 | 
				
			||||||
				MakeText( 0, -80, Get( 0 ) ),
 | 
									MakeText( 0, -80, Get( 0 ) ),
 | 
				
			||||||
 | 
				
			|||||||
@ -77,7 +77,7 @@ namespace ClassicalSharp.Gui {
 | 
				
			|||||||
			base.Init();
 | 
								base.Init();
 | 
				
			||||||
			regularFont = new Font( game.FontName, 16, FontStyle.Regular );
 | 
								regularFont = new Font( game.FontName, 16, FontStyle.Regular );
 | 
				
			||||||
			arrowFont = new Font( game.FontName, 18, FontStyle.Bold );
 | 
								arrowFont = new Font( game.FontName, 18, FontStyle.Bold );
 | 
				
			||||||
			textFont = new Font( game.FontName, 14, FontStyle.Bold );
 | 
								textFont = new Font( game.FontName, 16, FontStyle.Bold );
 | 
				
			||||||
			
 | 
								
 | 
				
			||||||
			widgets = new [] {
 | 
								widgets = new [] {
 | 
				
			||||||
				MakeHotkey( 0, -180, 0 ),
 | 
									MakeHotkey( 0, -180, 0 ),
 | 
				
			||||||
 | 
				
			|||||||
@ -84,7 +84,7 @@ namespace ClassicalSharp.Gui {
 | 
				
			|||||||
		}
 | 
							}
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
		public override void Init() {
 | 
							public override void Init() {
 | 
				
			||||||
			playerFont = new Font( game.FontName, 14 );
 | 
								playerFont = new Font( game.FontName, 16 );
 | 
				
			||||||
			chat = new ChatScreen( game );
 | 
								chat = new ChatScreen( game );
 | 
				
			||||||
			chat.Init();
 | 
								chat.Init();
 | 
				
			||||||
			hotbar = new BlockHotbarWidget( game );
 | 
								hotbar = new BlockHotbarWidget( game );
 | 
				
			||||||
 | 
				
			|||||||
@ -9,7 +9,7 @@ namespace ClassicalSharp.Gui {
 | 
				
			|||||||
	public partial class InventoryScreen : Screen {
 | 
						public partial class InventoryScreen : Screen {
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
		public InventoryScreen( Game game ) : base( game ) {
 | 
							public InventoryScreen( Game game ) : base( game ) {
 | 
				
			||||||
			font = new Font( game.FontName, 13 );
 | 
								font = new Font( game.FontName, 16 );
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
		Block[] blocksTable;
 | 
							Block[] blocksTable;
 | 
				
			||||||
 | 
				
			|||||||
@ -16,7 +16,6 @@ namespace ClassicalSharp.Gui {
 | 
				
			|||||||
		TextWidget[] labels;
 | 
							TextWidget[] labels;
 | 
				
			||||||
		MenuInputWidget[] inputs;
 | 
							MenuInputWidget[] inputs;
 | 
				
			||||||
		MenuInputWidget selectedWidget;
 | 
							MenuInputWidget selectedWidget;
 | 
				
			||||||
		Font labelFont;
 | 
					 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
		public override void Render( double delta ) {
 | 
							public override void Render( double delta ) {
 | 
				
			||||||
			RenderMenuBounds();
 | 
								RenderMenuBounds();
 | 
				
			||||||
@ -56,20 +55,20 @@ namespace ClassicalSharp.Gui {
 | 
				
			|||||||
		public override void Init() {
 | 
							public override void Init() {
 | 
				
			||||||
			game.Keyboard.KeyRepeat = true;
 | 
								game.Keyboard.KeyRepeat = true;
 | 
				
			||||||
			base.Init();
 | 
								base.Init();
 | 
				
			||||||
			labelFont = new Font( game.FontName, 16, FontStyle.Regular );
 | 
					 | 
				
			||||||
			titleFont = new Font( game.FontName, 16, FontStyle.Bold );
 | 
								titleFont = new Font( game.FontName, 16, FontStyle.Bold );
 | 
				
			||||||
			regularFont = new Font( game.FontName, 16, FontStyle.Regular );
 | 
								regularFont = new Font( game.FontName, 16, FontStyle.Regular );
 | 
				
			||||||
			
 | 
								
 | 
				
			||||||
			inputs = new [] { 
 | 
								inputs = new [] {
 | 
				
			||||||
				MakeInput( -80, false, game.World.Width.ToString() ), 
 | 
									MakeInput( -80, false, game.World.Width.ToString() ),
 | 
				
			||||||
				MakeInput( -40, false, game.World.Height.ToString() ),
 | 
									MakeInput( -40, false, game.World.Height.ToString() ),
 | 
				
			||||||
				MakeInput( 0, false, game.World.Length.ToString() ),
 | 
									MakeInput( 0, false, game.World.Length.ToString() ),
 | 
				
			||||||
				MakeInput( 40, true, "" )
 | 
									MakeInput( 40, true, "" )
 | 
				
			||||||
			};
 | 
								};
 | 
				
			||||||
			labels = new [] { 
 | 
								labels = new [] {
 | 
				
			||||||
				MakeLabel( -150, -80, "Width:" ), MakeLabel( -150, -40, "Height:" ),
 | 
									MakeLabel( -150, -80, "Width:" ), MakeLabel( -150, -40, "Height:" ),
 | 
				
			||||||
				MakeLabel( -150, 0, "Length:" ), MakeLabel( -140, 40, "Seed:" ),
 | 
									MakeLabel( -150, 0, "Length:" ), MakeLabel( -140, 40, "Seed:" ),
 | 
				
			||||||
				TextWidget.Create( game, 0, -130, "Generate new level", Anchor.Centre, Anchor.Centre, titleFont ), 
 | 
									ChatTextWidget.Create( game, 0, -130, "Generate new level",
 | 
				
			||||||
 | 
									                      Anchor.Centre, Anchor.Centre, regularFont ),
 | 
				
			||||||
			};
 | 
								};
 | 
				
			||||||
			widgets = new [] {
 | 
								widgets = new [] {
 | 
				
			||||||
				ButtonWidget.Create( game, -120, 100, 201, 40, "Flatgrass", Anchor.Centre,
 | 
									ButtonWidget.Create( game, -120, 100, 201, 40, "Flatgrass", Anchor.Centre,
 | 
				
			||||||
@ -93,7 +92,7 @@ namespace ClassicalSharp.Gui {
 | 
				
			|||||||
		
 | 
							
 | 
				
			||||||
		TextWidget MakeLabel( int x, int y, string text ) {
 | 
							TextWidget MakeLabel( int x, int y, string text ) {
 | 
				
			||||||
			TextWidget widget = ChatTextWidget.Create( game, x, y, text,
 | 
								TextWidget widget = ChatTextWidget.Create( game, x, y, text,
 | 
				
			||||||
			                         Anchor.Centre, Anchor.Centre, labelFont );
 | 
								                                          Anchor.Centre, Anchor.Centre, regularFont );
 | 
				
			||||||
			int start = game.Width / 2 - 110;
 | 
								int start = game.Width / 2 - 110;
 | 
				
			||||||
			widget.MoveTo( start - widget.Width, widget.Y );
 | 
								widget.MoveTo( start - widget.Width, widget.Y );
 | 
				
			||||||
			widget.Colour = new FastColour( 224, 224, 224 );
 | 
								widget.Colour = new FastColour( 224, 224, 224 );
 | 
				
			||||||
@ -114,7 +113,6 @@ namespace ClassicalSharp.Gui {
 | 
				
			|||||||
				inputs[i].Dispose();
 | 
									inputs[i].Dispose();
 | 
				
			||||||
			for( int i = 0; i < labels.Length; i++ )
 | 
								for( int i = 0; i < labels.Length; i++ )
 | 
				
			||||||
				labels[i].Dispose();
 | 
									labels[i].Dispose();
 | 
				
			||||||
			labelFont.Dispose();
 | 
					 | 
				
			||||||
			base.Dispose();
 | 
								base.Dispose();
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
@ -128,7 +126,7 @@ namespace ClassicalSharp.Gui {
 | 
				
			|||||||
		}
 | 
							}
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
		void GenFlatgrassClick( Game game, Widget widget, MouseButton mouseBtn ) {
 | 
							void GenFlatgrassClick( Game game, Widget widget, MouseButton mouseBtn ) {
 | 
				
			||||||
			if( mouseBtn != MouseButton.Left ) return; 
 | 
								if( mouseBtn != MouseButton.Left ) return;
 | 
				
			||||||
			GenerateMap( new FlatGrassGenerator() );
 | 
								GenerateMap( new FlatGrassGenerator() );
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
 | 
				
			|||||||
@ -74,10 +74,13 @@ namespace ClassicalSharp.Gui {
 | 
				
			|||||||
		}
 | 
							}
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
		void HandleFontChange() {
 | 
							void HandleFontChange() {
 | 
				
			||||||
 | 
								int selIndex = Array.IndexOf<Widget>( widgets, selectedWidget );
 | 
				
			||||||
			game.Events.RaiseChatFontChanged();
 | 
								game.Events.RaiseChatFontChanged();
 | 
				
			||||||
			base.Dispose();
 | 
								base.Dispose();
 | 
				
			||||||
			base.Init();
 | 
								base.Init();
 | 
				
			||||||
			game.RefreshHud();
 | 
								game.RefreshHud();
 | 
				
			||||||
 | 
								if( selIndex >= 0 )
 | 
				
			||||||
 | 
									selectedWidget = (ButtonWidget)widgets[selIndex];
 | 
				
			||||||
			
 | 
								
 | 
				
			||||||
			for( int i = 0; i < widgets.Length; i++) {
 | 
								for( int i = 0; i < widgets.Length; i++) {
 | 
				
			||||||
				if( widgets[i] == null || !(widgets[i] is ButtonWidget)) {
 | 
									if( widgets[i] == null || !(widgets[i] is ButtonWidget)) {
 | 
				
			||||||
 | 
				
			|||||||
@ -28,7 +28,7 @@ namespace ClassicalSharp.Gui {
 | 
				
			|||||||
			base.Init();
 | 
								base.Init();
 | 
				
			||||||
			if( keyNames == null )
 | 
								if( keyNames == null )
 | 
				
			||||||
				keyNames = Enum.GetNames( typeof( Key ) );
 | 
									keyNames = Enum.GetNames( typeof( Key ) );
 | 
				
			||||||
			keyFont = new Font( game.FontName, 15, FontStyle.Bold );
 | 
								keyFont = new Font( game.FontName, 16, FontStyle.Bold );
 | 
				
			||||||
			regularFont = new Font( game.FontName, 16, FontStyle.Italic );
 | 
								regularFont = new Font( game.FontName, 16, FontStyle.Italic );
 | 
				
			||||||
			statusWidget = ChatTextWidget.Create( game, 0, 130, "", 
 | 
								statusWidget = ChatTextWidget.Create( game, 0, 130, "", 
 | 
				
			||||||
			                                     Anchor.Centre, Anchor.Centre, regularFont );
 | 
								                                     Anchor.Centre, Anchor.Centre, regularFont );
 | 
				
			||||||
 | 
				
			|||||||
@ -40,7 +40,7 @@ namespace ClassicalSharp.Gui {
 | 
				
			|||||||
		public override void Init() {
 | 
							public override void Init() {
 | 
				
			||||||
			base.Init();
 | 
								base.Init();
 | 
				
			||||||
			regularFont = new Font( game.FontName, 16, FontStyle.Regular );
 | 
								regularFont = new Font( game.FontName, 16, FontStyle.Regular );
 | 
				
			||||||
			extendedHelpFont = new Font( game.FontName, 13, FontStyle.Regular );
 | 
								extendedHelpFont = new Font( game.FontName, 16, FontStyle.Regular );
 | 
				
			||||||
			game.Keyboard.KeyRepeat = true;
 | 
								game.Keyboard.KeyRepeat = true;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
@ -78,11 +78,7 @@ namespace ClassicalSharp.Gui {
 | 
				
			|||||||
		}
 | 
							}
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
		public override void Dispose() {
 | 
							public override void Dispose() {
 | 
				
			||||||
			if( inputWidget != null ) {
 | 
								DisposeWidgets();		
 | 
				
			||||||
				inputWidget.Dispose();
 | 
					 | 
				
			||||||
				inputWidget = null;
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
			
 | 
					 | 
				
			||||||
			game.Keyboard.KeyRepeat = false;
 | 
								game.Keyboard.KeyRepeat = false;
 | 
				
			||||||
			extendedHelpFont.Dispose();
 | 
								extendedHelpFont.Dispose();
 | 
				
			||||||
			DisposeExtendedHelp();
 | 
								DisposeExtendedHelp();
 | 
				
			||||||
@ -260,18 +256,23 @@ namespace ClassicalSharp.Gui {
 | 
				
			|||||||
			string text = inputWidget.GetText();
 | 
								string text = inputWidget.GetText();
 | 
				
			||||||
			if( inputWidget.Validator.IsValidValue( text ) )
 | 
								if( inputWidget.Validator.IsValidValue( text ) )
 | 
				
			||||||
				targetWidget.SetValue( game, text );
 | 
									targetWidget.SetValue( game, text );
 | 
				
			||||||
 | 
								
 | 
				
			||||||
 | 
								DisposeWidgets();
 | 
				
			||||||
 | 
								UpdateDescription( targetWidget );
 | 
				
			||||||
 | 
								targetWidget = null;
 | 
				
			||||||
 | 
								InputClosed();
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							
 | 
				
			||||||
 | 
							void DisposeWidgets() {
 | 
				
			||||||
			if( inputWidget != null )
 | 
								if( inputWidget != null )
 | 
				
			||||||
				inputWidget.Dispose();
 | 
									inputWidget.Dispose();
 | 
				
			||||||
			widgets[widgets.Length - 2] = null;
 | 
								widgets[widgets.Length - 2] = null;
 | 
				
			||||||
			inputWidget = null;
 | 
								inputWidget = null;
 | 
				
			||||||
			UpdateDescription( targetWidget );
 | 
					 | 
				
			||||||
			targetWidget = null;
 | 
					 | 
				
			||||||
			
 | 
								
 | 
				
			||||||
			int okayIndex = widgets.Length - 1;
 | 
								int okayIndex = widgets.Length - 1;
 | 
				
			||||||
			if( widgets[okayIndex] != null )
 | 
								if( widgets[okayIndex] != null )
 | 
				
			||||||
				widgets[okayIndex].Dispose();
 | 
									widgets[okayIndex].Dispose();
 | 
				
			||||||
			widgets[okayIndex] = null;
 | 
								widgets[okayIndex] = null;
 | 
				
			||||||
			InputClosed();
 | 
					 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@ -10,7 +10,7 @@ namespace ClassicalSharp.Gui {
 | 
				
			|||||||
		
 | 
							
 | 
				
			||||||
		public ExtPlayerListWidget( Game game, Font font ) : base( game, font ) {
 | 
							public ExtPlayerListWidget( Game game, Font font ) : base( game, font ) {
 | 
				
			||||||
			textures = new Texture[512];
 | 
								textures = new Texture[512];
 | 
				
			||||||
			titleFont = new Font( game.FontName, 12, FontStyle.Underline );
 | 
								titleFont = new Font( game.FontName, 16, FontStyle.Underline );
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
		PlayerInfo[] info = new PlayerInfo[512];
 | 
							PlayerInfo[] info = new PlayerInfo[512];
 | 
				
			||||||
 | 
				
			|||||||
@ -44,7 +44,7 @@ namespace ClassicalSharp.Entities {
 | 
				
			|||||||
		}
 | 
							}
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
		protected void InitRenderingData() {
 | 
							protected void InitRenderingData() {
 | 
				
			||||||
			using( Font font = new Font( game.FontName, 20 ) ) {
 | 
								using( Font font = new Font( game.FontName, 24 ) ) {
 | 
				
			||||||
				DrawTextArgs args = new DrawTextArgs( DisplayName, font, true );
 | 
									DrawTextArgs args = new DrawTextArgs( DisplayName, font, true );
 | 
				
			||||||
				nameTex = game.Drawer2D.MakeBitmappedTextTexture( ref args, 0, 0 );
 | 
									nameTex = game.Drawer2D.MakeBitmappedTextTexture( ref args, 0, 0 );
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
 | 
				
			|||||||
@ -72,7 +72,7 @@ namespace ClassicalSharp.Model {
 | 
				
			|||||||
		
 | 
							
 | 
				
			||||||
		public override bool Bobbing { get { return true; } }
 | 
							public override bool Bobbing { get { return true; } }
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
		public override float NameYOffset { get { return 2.1375f; } }
 | 
							public override float NameYOffset { get { return 32/16f + 0.5f/16f; } }
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
		public override float GetEyeY( Entity entity ) { return 26/16f; }
 | 
							public override float GetEyeY( Entity entity ) { return 26/16f; }
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
 | 
				
			|||||||
@ -941,4 +941,3 @@ namespace OpenTK.Platform.MacOS.Carbon
 | 
				
			|||||||
	#endregion
 | 
						#endregion
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user