diff --git a/ClassicalSharp/known_bugs.txt b/ClassicalSharp/known_bugs.txt index 317b21da0..36e14c2b3 100644 --- a/ClassicalSharp/known_bugs.txt +++ b/ClassicalSharp/known_bugs.txt @@ -12,4 +12,5 @@ * 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 -* Two blank lines get shown in chat when you type /client cuboid \ No newline at end of file +* Two blank lines get shown in chat when you type /client cuboid +* Alt text is closed on window resize \ No newline at end of file diff --git a/src/Menus.c b/src/Menus.c index bca53f0e2..ddc3ed394 100644 --- a/src/Menus.c +++ b/src/Menus.c @@ -2377,8 +2377,8 @@ static void GuiOptionsScreen_SetChatScale(const String* v) { GuiOptionsScreen_Se static void GuiOptionsScreen_GetChatlines(String* v) { String_AppendInt(v, Gui_Chatlines); } static void GuiOptionsScreen_SetChatlines(const String* v) { Gui_Chatlines = Menu_Int(v); + HUDScreen_SetChatlines(Gui_Chatlines); Options_Set(OPT_CHATLINES, v); - Gui_RefreshHud(); } static void GuiOptionsScreen_GetUseFont(String* v) { Menu_GetBool(v, !Drawer2D_BitmappedText); } diff --git a/src/Screens.c b/src/Screens.c index 44991733c..bd97fec2e 100644 --- a/src/Screens.c +++ b/src/Screens.c @@ -740,9 +740,9 @@ 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->clientStatus.placeholderHeight[0] = false; - s->clientStatus.placeholderHeight[1] = false; + s->status.collapsible[0] = true; /* Texture pack download status */ + s->clientStatus.collapsible[0] = true; + s->clientStatus.collapsible[1] = true; s->chat.underlineUrls = !Game_ClassicMode; s->chatIndex = Chat_Log.count - Gui_Chatlines; @@ -1236,6 +1236,14 @@ void HUDScreen_AppendInput(const String* text) { InputWidget_AppendString(&s->input.base, text); } +void HUDScreen_SetChatlines(int lines) { + struct HUDScreen* s = &HUDScreen_Instance; + Elem_Free(&s->chat); + s->chatIndex += s->chat.lines - lines; + s->chat.lines = lines; + TextGroupWidget_RedrawAll(&s->chat); +} + struct Widget* HUDScreen_GetHotbar(void) { return (struct Widget*)&HUDScreen_Instance.hotbar; } diff --git a/src/Screens.h b/src/Screens.h index 1d42100cb..67e8ff816 100644 --- a/src/Screens.h +++ b/src/Screens.h @@ -34,5 +34,6 @@ extern struct Screen* LoadingScreen_UNSAFE_RawPointer; void HUDScreen_OpenInput(const String* text); /* Appends text to the chat input in the HUD. */ void HUDScreen_AppendInput(const String* text); +void HUDScreen_SetChatlines(int lines); struct Widget* HUDScreen_GetHotbar(void); #endif diff --git a/src/Widgets.c b/src/Widgets.c index f6236c2e6..f9d9fc868 100644 --- a/src/Widgets.c +++ b/src/Widgets.c @@ -2448,7 +2448,7 @@ void TextGroupWidget_Redraw(struct TextGroupWidget* w, int index) { } Drawer2D_ReducePadding_Tex(&tex, w->font->Size, 3); } else { - tex.Height = w->placeholderHeight[index] ? w->defaultHeight : 0; + tex.Height = w->collapsible[index] ? 0 : w->defaultHeight; } tex.X = Gui_CalcPos(w->horAnchor, w->xOffset, tex.Width, Window_Width); @@ -2482,7 +2482,7 @@ void TextGroupWidget_SetFont(struct TextGroupWidget* w, FontDesc* font) { w->defaultHeight = height; for (i = 0; i < w->lines; i++) { - w->textures[i].Height = w->placeholderHeight[i] ? height : 0; + w->textures[i].Height = w->collapsible[i] ? 0 : height; } w->font = font; Widget_Reposition(w); @@ -2515,11 +2515,8 @@ static const struct WidgetVTABLE TextGroupWidget_VTABLE = { TextGroupWidget_Reposition }; void TextGroupWidget_Create(struct TextGroupWidget* w, int lines, struct Texture* textures, TextGroupWidget_Get getLine) { - int i; Widget_Reset(w); - w->VTABLE = &TextGroupWidget_VTABLE; - for (i = 0; i < lines; i++) { w->placeholderHeight[i] = true; } - + w->VTABLE = &TextGroupWidget_VTABLE; w->lines = lines; w->textures = textures; w->GetLine = getLine; diff --git a/src/Widgets.h b/src/Widgets.h index 55ef53191..9feea614e 100644 --- a/src/Widgets.h +++ b/src/Widgets.h @@ -204,8 +204,8 @@ struct TextGroupWidget { Widget_Layout int lines, defaultHeight; FontDesc* font; - /* Whether a line has non-zero height when that line has no text in it. */ - bool placeholderHeight[TEXTGROUPWIDGET_MAX_LINES]; + /* Whether a line has zero height when that line has no text in it. */ + bool collapsible[TEXTGROUPWIDGET_MAX_LINES]; bool underlineUrls; struct Texture* textures; TextGroupWidget_Get GetLine;