Codechange: Make DropDownListStringItem preformat and remove other implementations. (#11063)
Having to choose between DropDownListStringItem, DropDownListCharStringItem, and DropDownListParamStringItem depending on whether to draw a StringID, a raw string, or a StringID with extra parameters was needlessly complex. Instead, allow passing a StringID or raw string to DropDownListStringItem. This will preformat the StringID into a raw string, and can therefore accept parameters via the normal SetDParam mechanism. This also means that strings no longer need to be formatted on every draw.
This commit is contained in:
@@ -588,14 +588,9 @@ static const LiveryClass _livery_class[LS_END] = {
|
||||
LC_ROAD, LC_ROAD,
|
||||
};
|
||||
|
||||
class DropDownListColourItem : public DropDownListItem {
|
||||
class DropDownListColourItem : public DropDownListStringItem {
|
||||
public:
|
||||
DropDownListColourItem(int result, bool masked) : DropDownListItem(result, masked) {}
|
||||
|
||||
StringID String() const
|
||||
{
|
||||
return this->result >= COLOUR_END ? STR_COLOUR_DEFAULT : _colour_dropdown[this->result];
|
||||
}
|
||||
DropDownListColourItem(int result, bool masked) : DropDownListStringItem(result >= COLOUR_END ? STR_COLOUR_DEFAULT : _colour_dropdown[result], result, masked) {}
|
||||
|
||||
uint Width() const override
|
||||
{
|
||||
|
Reference in New Issue
Block a user