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

Method UpdateWidgetSize

src/error_gui.cpp:117–136  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

115 }
116
117 void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
118 {
119 switch (widget) {
120 case WID_EM_MESSAGE: {
121 this->height_summary = GetStringHeight(this->summary_msg.GetDecodedString(), size.width);
122 this->height_detailed = (this->detailed_msg.empty()) ? 0 : GetStringHeight(this->detailed_msg.GetDecodedString(), size.width);
123 this->height_extra = (this->extra_msg.empty()) ? 0 : GetStringHeight(this->extra_msg.GetDecodedString(), size.width);
124
125 uint panel_height = this->height_summary;
126 if (!this->detailed_msg.empty()) panel_height += this->height_detailed + WidgetDimensions::scaled.vsep_wide;
127 if (!this->extra_msg.empty()) panel_height += this->height_extra + WidgetDimensions::scaled.vsep_wide;
128
129 size.height = std::max(size.height, panel_height);
130 break;
131 }
132 case WID_EM_FACE:
133 size = maxdim(size, GetScaledSpriteSize(SPR_GRADIENT));
134 break;
135 }
136 }
137
138 Point OnInitialPosition([[maybe_unused]] int16_t sm_width, [[maybe_unused]] int16_t sm_height, [[maybe_unused]] int window_number) override
139 {

Callers

nothing calls this directly

Calls 5

GetStringHeightFunction · 0.85
maxdimFunction · 0.85
GetScaledSpriteSizeFunction · 0.85
GetDecodedStringMethod · 0.80
emptyMethod · 0.45

Tested by

no test coverage detected