MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / OnResize

Method OnResize

src/settings_gui.cpp:795–832  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

793 }
794
795 void OnResize() override
796 {
797 this->vscroll->SetCapacityFromWidget(this, WID_GO_OPTIONSPANEL, WidgetDimensions::scaled.framerect.Vertical());
798 UpdateHelpTextSize();
799
800 bool changed = false;
801
802 NWidgetResizeBase *wid = this->GetWidget<NWidgetResizeBase>(WID_GO_BASE_GRF_DESCRIPTION);
803 int y = 0;
804 for (int i = 0; i < BaseGraphics::GetNumSets(); i++) {
805 std::string str = GetString(STR_JUST_RAW_STRING, BaseGraphics::GetSet(i)->GetDescription(GetCurrentLanguageIsoCode()));
806 y = std::max(y, GetStringHeight(str, wid->current_x));
807 }
808 changed |= wid->UpdateVerticalSize(y);
809
810 wid = this->GetWidget<NWidgetResizeBase>(WID_GO_BASE_SFX_DESCRIPTION);
811 y = 0;
812 for (int i = 0; i < BaseSounds::GetNumSets(); i++) {
813 std::string str = GetString(STR_JUST_RAW_STRING, BaseSounds::GetSet(i)->GetDescription(GetCurrentLanguageIsoCode()));
814 y = std::max(y, GetStringHeight(str, wid->current_x));
815 }
816 changed |= wid->UpdateVerticalSize(y);
817
818 wid = this->GetWidget<NWidgetResizeBase>(WID_GO_BASE_MUSIC_DESCRIPTION);
819 y = 0;
820 for (int i = 0; i < BaseMusic::GetNumSets(); i++) {
821 std::string str = GetString(STR_JUST_RAW_STRING, BaseMusic::GetSet(i)->GetDescription(GetCurrentLanguageIsoCode()));
822 y = std::max(y, GetStringHeight(str, wid->current_x));
823 }
824 changed |= wid->UpdateVerticalSize(y);
825
826 wid = this->GetWidget<NWidgetResizeBase>(WID_GO_VIDEO_DRIVER_INFO);
827 std::string str = GetString(STR_GAME_OPTIONS_VIDEO_DRIVER_INFO, std::string{VideoDriver::GetInstance()->GetInfoString()});
828 y = GetStringHeight(str, wid->current_x);
829 changed |= wid->UpdateVerticalSize(y);
830
831 if (changed) this->ReInit(0, 0, this->flags.Test(WindowFlag::Centred));
832 }
833
834 void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
835 {

Callers

nothing calls this directly

Calls 10

GetStringHeightFunction · 0.85
SetCapacityFromWidgetMethod · 0.80
VerticalMethod · 0.80
UpdateVerticalSizeMethod · 0.80
ReInitMethod · 0.80
TestMethod · 0.80
GetStringFunction · 0.70
GetDescriptionMethod · 0.45
GetInfoStringMethod · 0.45

Tested by

no test coverage detected