mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-18 03:55:19 -04:00
Fix chat when resizing.
This commit is contained in:
parent
b38a61cea6
commit
6102ad8123
@ -17,12 +17,13 @@ namespace ClassicalSharp {
|
|||||||
TextGroupWidget status, bottomRight, normalChat;
|
TextGroupWidget status, bottomRight, normalChat;
|
||||||
bool suppressNextPress = true;
|
bool suppressNextPress = true;
|
||||||
int chatIndex;
|
int chatIndex;
|
||||||
|
int blockSize;
|
||||||
|
|
||||||
public override void Render( double delta ) {
|
public override void Render( double delta ) {
|
||||||
status.Render( delta );
|
status.Render( delta );
|
||||||
bottomRight.Render( delta );
|
bottomRight.Render( delta );
|
||||||
|
|
||||||
UpdateChatYOffset();
|
UpdateChatYOffset( false );
|
||||||
DateTime now = DateTime.UtcNow;
|
DateTime now = DateTime.UtcNow;
|
||||||
if( HandlesAllInput )
|
if( HandlesAllInput )
|
||||||
normalChat.Render( delta );
|
normalChat.Render( delta );
|
||||||
@ -64,11 +65,10 @@ namespace ClassicalSharp {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int inputOldHeight = -1;
|
int inputOldHeight = -1;
|
||||||
void UpdateChatYOffset() {
|
void UpdateChatYOffset( bool force ) {
|
||||||
int height = textInput.Height;
|
int height = textInput.Height;
|
||||||
if( height != inputOldHeight ) {
|
if( force || height != inputOldHeight ) {
|
||||||
const int blockSize = 40;
|
normalChat.YOffset = height + blockSize + 15;
|
||||||
normalChat.YOffset = height + blockSize * 2;
|
|
||||||
int y = game.Height - normalChat.Height - normalChat.YOffset;
|
int y = game.Height - normalChat.Height - normalChat.YOffset;
|
||||||
|
|
||||||
normalChat.MoveTo( normalChat.X, y );
|
normalChat.MoveTo( normalChat.X, y );
|
||||||
@ -81,10 +81,10 @@ namespace ClassicalSharp {
|
|||||||
chatFont = new Font( "Arial", game.Chat.FontSize );
|
chatFont = new Font( "Arial", game.Chat.FontSize );
|
||||||
chatInputFont = new Font( "Arial", game.Chat.FontSize, FontStyle.Bold );
|
chatInputFont = new Font( "Arial", game.Chat.FontSize, FontStyle.Bold );
|
||||||
announcementFont = new Font( "Arial", 14 );
|
announcementFont = new Font( "Arial", 14 );
|
||||||
int blockSize = (int)(40 * Utils.GuiScale( game.Width, game.Height ));
|
blockSize = (int)(40 * Utils.GuiScale( game.Width, game.Height ));
|
||||||
|
|
||||||
textInput = new TextInputWidget( game, chatFont, chatInputFont );
|
textInput = new TextInputWidget( game, chatFont, chatInputFont );
|
||||||
textInput.YOffset = 3 * blockSize / 2;
|
textInput.YOffset = blockSize + 5;
|
||||||
status = new TextGroupWidget( game, 3, chatFont );
|
status = new TextGroupWidget( game, 3, chatFont );
|
||||||
status.VerticalAnchor = Anchor.LeftOrTop;
|
status.VerticalAnchor = Anchor.LeftOrTop;
|
||||||
status.HorizontalAnchor = Anchor.BottomOrRight;
|
status.HorizontalAnchor = Anchor.BottomOrRight;
|
||||||
@ -92,11 +92,11 @@ namespace ClassicalSharp {
|
|||||||
bottomRight = new TextGroupWidget( game, 3, chatFont );
|
bottomRight = new TextGroupWidget( game, 3, chatFont );
|
||||||
bottomRight.VerticalAnchor = Anchor.BottomOrRight;
|
bottomRight.VerticalAnchor = Anchor.BottomOrRight;
|
||||||
bottomRight.HorizontalAnchor = Anchor.BottomOrRight;
|
bottomRight.HorizontalAnchor = Anchor.BottomOrRight;
|
||||||
bottomRight.YOffset = textInput.YOffset;
|
bottomRight.YOffset = blockSize * 3 / 2;
|
||||||
bottomRight.Init();
|
bottomRight.Init();
|
||||||
normalChat = new TextGroupWidget( game, chatLines, chatFont );
|
normalChat = new TextGroupWidget( game, chatLines, chatFont );
|
||||||
normalChat.XOffset = 10;
|
normalChat.XOffset = 10;
|
||||||
normalChat.YOffset = blockSize * 2;
|
normalChat.YOffset = blockSize * 2 + 15;
|
||||||
normalChat.HorizontalAnchor = Anchor.LeftOrTop;
|
normalChat.HorizontalAnchor = Anchor.LeftOrTop;
|
||||||
normalChat.VerticalAnchor = Anchor.BottomOrRight;
|
normalChat.VerticalAnchor = Anchor.BottomOrRight;
|
||||||
normalChat.Init();
|
normalChat.Init();
|
||||||
@ -171,15 +171,15 @@ namespace ClassicalSharp {
|
|||||||
public override void OnResize( int oldWidth, int oldHeight, int width, int height ) {
|
public override void OnResize( int oldWidth, int oldHeight, int width, int height ) {
|
||||||
announcementTex.X1 += (width - oldWidth) / 2;
|
announcementTex.X1 += (width - oldWidth) / 2;
|
||||||
announcementTex.Y1 += (height - oldHeight) / 2;
|
announcementTex.Y1 += (height - oldHeight) / 2;
|
||||||
int blockSize = (int)(40 * Utils.GuiScale( game.Width, game.Height ));
|
blockSize = (int)(40 * Utils.GuiScale( game.Width, game.Height ));
|
||||||
textInput.YOffset = 3 * blockSize / 2;
|
textInput.YOffset = blockSize + 5;
|
||||||
bottomRight.YOffset = textInput.YOffset;
|
bottomRight.YOffset = blockSize * 3 / 2;
|
||||||
normalChat.YOffset = blockSize;
|
|
||||||
|
|
||||||
textInput.OnResize( oldWidth, oldHeight, width, height );
|
int inputY = game.Height - textInput.Height - textInput.YOffset;
|
||||||
|
textInput.MoveTo( textInput.X, inputY );
|
||||||
status.OnResize( oldWidth, oldHeight, width, height );
|
status.OnResize( oldWidth, oldHeight, width, height );
|
||||||
bottomRight.OnResize( oldWidth, oldHeight, width, height );
|
bottomRight.OnResize( oldWidth, oldHeight, width, height );
|
||||||
normalChat.OnResize( oldWidth, oldHeight, width, height );
|
UpdateChatYOffset( true );
|
||||||
}
|
}
|
||||||
|
|
||||||
void UpdateAnnouncement( string text ) {
|
void UpdateAnnouncement( string text ) {
|
||||||
|
@ -19,11 +19,12 @@ namespace ClassicalSharp {
|
|||||||
chatInputText = new WrappableStringBuffer( len );
|
chatInputText = new WrappableStringBuffer( len );
|
||||||
DrawTextArgs args = new DrawTextArgs( "_", boldFont, false );
|
DrawTextArgs args = new DrawTextArgs( "_", boldFont, false );
|
||||||
defaultHeight = game.Drawer2D.MeasureChatSize( ref args ).Height;
|
defaultHeight = game.Drawer2D.MeasureChatSize( ref args ).Height;
|
||||||
|
Height = defaultHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
Texture chatInputTexture, caretTexture;
|
Texture chatInputTexture, caretTexture;
|
||||||
int caretPos = -1, typingLogPos = 0, defaultHeight;
|
int caretPos = -1, typingLogPos = 0;
|
||||||
public int YOffset;
|
public int YOffset, defaultHeight;
|
||||||
internal WrappableStringBuffer chatInputText;
|
internal WrappableStringBuffer chatInputText;
|
||||||
readonly Font font, boldFont;
|
readonly Font font, boldFont;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user