mirror of https://github.com/OpenTTD/OpenTTD
Change: Add alternate_colour widget data for boolean button.
Allows boolean button to have different background and button colours.pull/14086/head
parent
7953a97cbb
commit
17e7dafa2a
|
@ -3002,7 +3002,9 @@ void NWidgetLeaf::Draw(const Window *w)
|
|||
|
||||
case WWT_BOOLBTN: {
|
||||
Point pt = GetAlignedPosition(r, Dimension(SETTING_BUTTON_WIDTH, SETTING_BUTTON_HEIGHT), this->align);
|
||||
DrawBoolButton(pt.x, pt.y, this->colour, this->colour, clicked, !this->IsDisabled());
|
||||
Colours button_colour = this->widget_data.alternate_colour;
|
||||
if (button_colour == INVALID_COLOUR) button_colour = this->colour;
|
||||
DrawBoolButton(pt.x, pt.y, button_colour, this->colour, clicked, !this->IsDisabled());
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -353,6 +353,7 @@ struct WidgetData {
|
|||
SpriteID sprite{};
|
||||
ArrowWidgetValues arrow_widget_type{};
|
||||
ResizeWidgetValues resize_widget_type{};
|
||||
Colours alternate_colour = INVALID_COLOUR;
|
||||
Dimension matrix{};
|
||||
};
|
||||
|
||||
|
@ -1242,6 +1243,17 @@ constexpr NWidgetPart SetResizeWidgetTypeTip(ResizeWidgetValues widget_type, Str
|
|||
return NWidgetPart{WPT_DATATIP, NWidgetPartDataTip{{.resize_widget_type = widget_type}, tip}};
|
||||
}
|
||||
|
||||
/**
|
||||
* Widget part function for setting the alternate colour and tooltip.
|
||||
* @param colour Alternate colour of the widget.
|
||||
* @param tip Tooltip of the widget.
|
||||
* @ingroup NestedWidgetParts
|
||||
*/
|
||||
constexpr NWidgetPart SetAlternateColourTip(Colours colour, StringID tip)
|
||||
{
|
||||
return NWidgetPart{WPT_DATATIP, NWidgetPartDataTip{{.alternate_colour = colour}, tip}};
|
||||
}
|
||||
|
||||
/**
|
||||
* Widget part function for setting the data and tooltip of WWT_MATRIX widgets
|
||||
* @param cols Number of columns. \c 0 means to use draw columns with width according to the resize step size.
|
||||
|
|
Loading…
Reference in New Issue