From 9c8037b95dc4ec71f5117743f641a2b51fdbd1f3 Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Fri, 23 Aug 2019 08:01:56 +1000 Subject: [PATCH] Fix blank line appearing when you type /client cuboid --- ClassicalSharp/known_bugs.txt | 3 ++- src/Screens.c | 28 ++++++++++++---------------- src/Widgets.c | 2 +- 3 files changed, 15 insertions(+), 18 deletions(-) diff --git a/ClassicalSharp/known_bugs.txt b/ClassicalSharp/known_bugs.txt index b7986e318..317b21da0 100644 --- a/ClassicalSharp/known_bugs.txt +++ b/ClassicalSharp/known_bugs.txt @@ -11,4 +11,5 @@ * Alt text doesn't update its Y position if you click on chat * Menu inputs (save, edit hotkey, water level, etc) are reset on window resize * Chat input caret is reset on window resize -* Position in chat (if you scrolled up into history) is reset on window resize \ No newline at end of file +* Position in chat (if you scrolled up into history) is reset on window resize +* Two blank lines get shown in chat when you type /client cuboid \ No newline at end of file diff --git a/src/Screens.c b/src/Screens.c index 3dde25735..44991733c 100644 --- a/src/Screens.c +++ b/src/Screens.c @@ -720,9 +720,9 @@ static void HUDScreen_ChatUpdateLayout(struct HUDScreen* s) { Widget_SetLocation(&s->altText, ANCHOR_MIN, ANCHOR_MAX, 5, 5); HUDScreen_UpdateAltTextY(s); - Widget_SetLocation(&s->status, ANCHOR_MAX, ANCHOR_MIN, 0, 0); - Widget_SetLocation(&s->bottomRight, ANCHOR_MAX, ANCHOR_MAX, 0, yOffset); - Widget_SetLocation(&s->chat, ANCHOR_MIN, ANCHOR_MAX, 10, yOffset); + Widget_SetLocation(&s->status, ANCHOR_MAX, ANCHOR_MIN, 0, 0); + Widget_SetLocation(&s->bottomRight, ANCHOR_MAX, ANCHOR_MAX, 0, yOffset); + Widget_SetLocation(&s->chat, ANCHOR_MIN, ANCHOR_MAX, 10, yOffset); Widget_SetLocation(&s->clientStatus, ANCHOR_MIN, ANCHOR_MAX, 10, yOffset); } @@ -740,7 +740,10 @@ static void HUDScreen_ChatInit(struct HUDScreen* s) { s->clientStatusTextures, HUDScreen_GetClientStatus); TextWidget_Make(&s->announcement, ANCHOR_CENTRE, ANCHOR_CENTRE, 0, -Window_Height / 4); - s->status.placeholderHeight[0] = false; /* Texture pack download status */ + s->status.placeholderHeight[0] = false; /* Texture pack download status */ + s->clientStatus.placeholderHeight[0] = false; + s->clientStatus.placeholderHeight[1] = false; + s->chat.underlineUrls = !Game_ClassicMode; s->chatIndex = Chat_Log.count - Gui_Chatlines; } @@ -762,8 +765,8 @@ static void HUDScreen_UpdateChatYOffset(struct HUDScreen* s, bool force) { int bottomOffset = HUDScreen_BottomOffset() + 15; s->clientStatus.yOffset = max(bottomOffset, height); Widget_Reposition(&s->clientStatus); - - s->chat.yOffset = s->clientStatus.yOffset + TextGroupWidget_UsedHeight(&s->clientStatus); + + s->chat.yOffset = s->clientStatus.yOffset + s->clientStatus.height; Widget_Reposition(&s->chat); s->inputOldHeight = height; } @@ -908,7 +911,7 @@ static void HUDScreen_DrawChatBackground(struct HUDScreen* s) { int y = s->chat.y + s->chat.height - usedHeight; int width = max(s->clientStatus.width, s->chat.width); - int height = usedHeight + TextGroupWidget_UsedHeight(&s->clientStatus); + int height = usedHeight + s->clientStatus.height; if (height > 0) { PackedCol backCol = PACKEDCOL_CONST(0, 0, 0, 127); @@ -919,21 +922,14 @@ static void HUDScreen_DrawChatBackground(struct HUDScreen* s) { static void HUDScreen_DrawChat(struct HUDScreen* s, double delta) { struct Texture tex; TimeMS now; - int i, y, logIdx; + int i, logIdx; HUDScreen_UpdateTexpackStatus(s); if (!Game_PureClassic) { Elem_Render(&s->status, delta); } Elem_Render(&s->bottomRight, delta); HUDScreen_UpdateChatYOffset(s, false); - y = s->clientStatus.y + s->clientStatus.height; - for (i = 0; i < s->clientStatus.lines; i++) { - tex = s->clientStatus.textures[i]; - if (!tex.ID) continue; - - y -= tex.Height; tex.Y = y; - Texture_Render(&tex); - } + Elem_Render(&s->clientStatus, delta); now = DateTime_CurrentUTC_MS(); if (s->grabsInput) { diff --git a/src/Widgets.c b/src/Widgets.c index 44804dabc..f6236c2e6 100644 --- a/src/Widgets.c +++ b/src/Widgets.c @@ -1208,7 +1208,7 @@ static bool InputWidget_MouseDown(void* widget, int x, int y, MouseButton button x -= w->inputTex.X; y -= w->inputTex.Y; DrawTextArgs_MakeEmpty(&args, w->font, true); - charHeight = w->caretTex.Height; + charHeight = w->lineHeight; String_InitArray(line, lineBuffer); for (cy = 0; cy < w->GetMaxLines(); cy++) {