From fd84f733236e6288d7b4b007eb976753c0ae19e2 Mon Sep 17 00:00:00 2001 From: Peter Nelson Date: Sat, 30 Dec 2023 00:19:27 +0000 Subject: [PATCH] Fix #11643: Empty area at top of survey preview. (#11647) Empty area at the top of some textfile windows due to calling SetDisplayedPlane() after calling FinishInitNested(), and/or changing the displayed plane and not calling ReInit() after. This was previously hidden by CheckForMissingGlyphs() reinitialising all windows anyway. --- src/help_gui.cpp | 2 +- src/textfile_gui.cpp | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/help_gui.cpp b/src/help_gui.cpp index ea318dbda7..2664d79458 100644 --- a/src/help_gui.cpp +++ b/src/help_gui.cpp @@ -85,7 +85,7 @@ struct GameManualTextfileWindow : public TextfileWindow { if (this->filename == CHANGELOG_FILENAME) { this->link_anchors.clear(); this->AfterLoadChangelog(); - this->GetWidget(WID_TF_SEL_JUMPLIST)->SetDisplayedPlane(this->jumplist.empty() ? SZSP_HORIZONTAL : 0); + if (this->GetWidget(WID_TF_SEL_JUMPLIST)->SetDisplayedPlane(this->jumplist.empty() ? SZSP_HORIZONTAL : 0)) this->ReInit(); } else { this->TextfileWindow::AfterLoadText(); } diff --git a/src/textfile_gui.cpp b/src/textfile_gui.cpp index 578ac7924a..cebfc38eac 100644 --- a/src/textfile_gui.cpp +++ b/src/textfile_gui.cpp @@ -86,9 +86,9 @@ TextfileWindow::TextfileWindow(TextfileType file_type) : Window(&_textfile_desc) this->CreateNestedTree(); this->vscroll = this->GetScrollbar(WID_TF_VSCROLLBAR); this->hscroll = this->GetScrollbar(WID_TF_HSCROLLBAR); - this->FinishInitNested(file_type); this->GetWidget(WID_TF_CAPTION)->SetDataTip(STR_TEXTFILE_README_CAPTION + file_type, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS); this->GetWidget(WID_TF_SEL_JUMPLIST)->SetDisplayedPlane(SZSP_HORIZONTAL); + this->FinishInitNested(file_type); this->DisableWidget(WID_TF_NAVBACK); this->DisableWidget(WID_TF_NAVFORWARD); @@ -493,7 +493,7 @@ void TextfileWindow::NavigateToFile(std::string newfile, size_t line) if (StrEndsWithIgnoreCase(this->filename, ".md")) this->AfterLoadMarkdown(); - this->GetWidget(WID_TF_SEL_JUMPLIST)->SetDisplayedPlane(this->jumplist.empty() ? SZSP_HORIZONTAL : 0); + if (this->GetWidget(WID_TF_SEL_JUMPLIST)->SetDisplayedPlane(this->jumplist.empty() ? SZSP_HORIZONTAL : 0)) this->ReInit(); } /** @@ -761,8 +761,7 @@ static void Xunzip(byte **bufp, size_t *sizep) this->lines.clear(); this->jumplist.clear(); - this->GetWidget(WID_TF_SEL_JUMPLIST)->SetDisplayedPlane(SZSP_HORIZONTAL); - this->ReInit(); + if (this->GetWidget(WID_TF_SEL_JUMPLIST)->SetDisplayedPlane(SZSP_HORIZONTAL)) this->ReInit(); if (textfile.empty()) return;