Fix #8272: vehicle destination text colour when mousing over (#8543)

Co-authored-by: Jonathan G Rennison <j.g.rennison@gmail.com>
This commit is contained in:
Patric Stout 2021-01-09 23:43:06 +01:00 committed by GitHub
parent 928276a66e
commit 5f1154e076
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 1 deletions

View File

@ -2800,6 +2800,7 @@ public:
const Vehicle *v = Vehicle::Get(this->window_number);
StringID str;
TextColour text_colour = TC_FROMSTRING;
if (v->vehstatus & VS_CRASHED) {
str = STR_VEHICLE_STATUS_CRASHED;
} else if (v->type != VEH_AIRCRAFT && v->breakdown_ctr == 1) { // check for aircraft necessary?
@ -2824,6 +2825,13 @@ public:
} else if (v->type == VEH_AIRCRAFT && HasBit(Aircraft::From(v)->flags, VAF_DEST_TOO_FAR) && !v->current_order.IsType(OT_LOADING)) {
str = STR_VEHICLE_STATUS_AIRCRAFT_TOO_FAR;
} else { // vehicle is in a "normal" state, show current order
if (mouse_over_start_stop) {
if (v->vehstatus & VS_STOPPED) {
text_colour = TC_RED | TC_FORCED;
} else if (v->type == VEH_TRAIN && HasBit(Train::From(v)->flags, VRF_TRAIN_STUCK) && !v->current_order.IsType(OT_LOADING)) {
text_colour = TC_ORANGE | TC_FORCED;
}
}
switch (v->current_order.GetType()) {
case OT_GOTO_STATION: {
SetDParam(0, v->current_order.GetDestination());
@ -2890,7 +2898,7 @@ public:
int image = ((v->vehstatus & VS_STOPPED) != 0) ? SPR_FLAG_VEH_STOPPED : SPR_FLAG_VEH_RUNNING;
int lowered = this->IsWidgetLowered(WID_VV_START_STOP) ? 1 : 0;
DrawSprite(image, PAL_NONE, image_left + lowered, r.top + WD_IMGBTN_TOP + lowered);
DrawString(text_left + lowered, text_right + lowered, r.top + WD_FRAMERECT_TOP + lowered, str, TC_FROMSTRING, SA_HOR_CENTER);
DrawString(text_left + lowered, text_right + lowered, r.top + WD_FRAMERECT_TOP + lowered, str, text_colour, SA_HOR_CENTER);
}
void OnClick(Point pt, int widget, int click_count) override