mirror of https://github.com/OpenTTD/OpenTTD
Cleanup: Don't mix switches and early returns in widget selection
parent
066ae6f3fb
commit
0bf6f82305
|
@ -406,10 +406,12 @@ struct NewGRFInspectWindow : Window {
|
|||
::DrawString(r.Shrink(WidgetDimensions::scaled.frametext).Shrink(0, offset * this->resize.step_height, 0, 0), buf, TC_BLACK);
|
||||
}
|
||||
|
||||
void DrawWidget(const Rect &r, int widget) const override
|
||||
/**
|
||||
* Helper function to draw the vehicle chain widget.
|
||||
* @param r The rectangle to draw within.
|
||||
*/
|
||||
void DrawVehicleChainWidget(const Rect& r) const
|
||||
{
|
||||
switch (widget) {
|
||||
case WID_NGRFI_VEH_CHAIN: {
|
||||
const Vehicle *v = Vehicle::Get(this->GetFeatureIndex());
|
||||
int total_width = 0;
|
||||
int sel_start = 0;
|
||||
|
@ -443,12 +445,14 @@ struct NewGRFInspectWindow : Window {
|
|||
} else {
|
||||
DrawFrameRect(r.left + sel_start - skip, y, r.left + sel_end - skip, y + h, COLOUR_WHITE, FR_BORDERONLY);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (widget != WID_NGRFI_MAINPANEL) return;
|
||||
|
||||
/**
|
||||
* Helper function to draw the main panel widget.
|
||||
* @param r The rectangle to draw within.
|
||||
*/
|
||||
void DrawMainPanelWidget(const Rect& r) const
|
||||
{
|
||||
uint index = this->GetFeatureIndex();
|
||||
const NIFeature *nif = GetFeature(this->window_number);
|
||||
const NIHelper *nih = nif->helper;
|
||||
|
@ -547,6 +551,19 @@ struct NewGRFInspectWindow : Window {
|
|||
const_cast<NewGRFInspectWindow*>(this)->vscroll->SetCount(i);
|
||||
}
|
||||
|
||||
void DrawWidget(const Rect &r, int widget) const override
|
||||
{
|
||||
switch (widget) {
|
||||
case WID_NGRFI_VEH_CHAIN:
|
||||
this->DrawVehicleChainWidget(r);
|
||||
break;
|
||||
|
||||
case WID_NGRFI_MAINPANEL:
|
||||
this->DrawMainPanelWidget(r);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void OnClick(Point pt, int widget, int click_count) override
|
||||
{
|
||||
switch (widget) {
|
||||
|
|
Loading…
Reference in New Issue