diff options
author | Joan Josep <juanjo.ng.83@gmail.com> | 2021-10-22 19:39:47 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-22 19:39:47 +0200 |
commit | b2e83b4da6742b1c463d336bf660d52eb9f8e4b9 (patch) | |
tree | 97617e6a9b9f385147c762e642859d22da8f8ab9 /src/vehicle_gui.cpp | |
parent | 08c048e0a1bd16a41a97faa7dc32d41492098365 (diff) | |
download | openttd-b2e83b4da6742b1c463d336bf660d52eb9f8e4b9.tar.xz |
Fix: Draw rotor in cursor when dragging helicopters. (#9612)
Diffstat (limited to 'src/vehicle_gui.cpp')
-rw-r--r-- | src/vehicle_gui.cpp | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/src/vehicle_gui.cpp b/src/vehicle_gui.cpp index c43347ca8..10e925b8b 100644 --- a/src/vehicle_gui.cpp +++ b/src/vehicle_gui.cpp @@ -3181,12 +3181,22 @@ void SetMouseCursorVehicle(const Vehicle *v, EngineImageType image_type) _cursor.sprite_count = 0; int total_width = 0; - for (; v != nullptr; v = v->HasArticulatedPart() ? v->GetNextArticulatedPart() : nullptr) { + int y_offset = 0; + bool rotor_seq = false; // Whether to draw the rotor of the vehicle in this step. + + while (v != nullptr) { if (total_width >= ScaleGUITrad(2 * (int)VEHICLEINFO_FULL_VEHICLE_WIDTH)) break; PaletteID pal = (v->vehstatus & VS_CRASHED) ? PALETTE_CRASH : GetVehiclePalette(v); VehicleSpriteSeq seq; - v->GetImage(rtl ? DIR_E : DIR_W, image_type, &seq); + + if (rotor_seq) { + GetCustomRotorSprite(Aircraft::From(v), true, image_type, &seq); + if (!seq.IsValid()) seq.Set(SPR_ROTOR_STOPPED); + y_offset = - ScaleGUITrad(5); + } else { + v->GetImage(rtl ? DIR_E : DIR_W, image_type, &seq); + } if (_cursor.sprite_count + seq.count > lengthof(_cursor.sprite_seq)) break; @@ -3195,11 +3205,17 @@ void SetMouseCursorVehicle(const Vehicle *v, EngineImageType image_type) _cursor.sprite_seq[_cursor.sprite_count].sprite = seq.seq[i].sprite; _cursor.sprite_seq[_cursor.sprite_count].pal = pal2; _cursor.sprite_pos[_cursor.sprite_count].x = rtl ? -total_width : total_width; - _cursor.sprite_pos[_cursor.sprite_count].y = 0; + _cursor.sprite_pos[_cursor.sprite_count].y = y_offset; _cursor.sprite_count++; } - total_width += GetSingleVehicleWidth(v, image_type); + if (v->type == VEH_AIRCRAFT && v->subtype == AIR_HELICOPTER && !rotor_seq) { + /* Draw rotor part in the next step. */ + rotor_seq = true; + } else { + total_width += GetSingleVehicleWidth(v, image_type); + v = v->HasArticulatedPart() ? v->GetNextArticulatedPart() : nullptr; + } } int offs = (ScaleGUITrad(VEHICLEINFO_FULL_VEHICLE_WIDTH) - total_width) / 2; |