MCPcopy Create free account
hub / github.com/OpenLoco/OpenLoco / drawScroll

Function drawScroll

src/OpenLoco/src/Ui/Windows/Vehicle.cpp:1924–1979  ·  view source on GitHub ↗

0x004B36A3

Source from the content-addressed store, hash-verified

1922
1923 // 0x004B36A3
1924 static void drawScroll(Window& self, Gfx::DrawingContext& drawingCtx, [[maybe_unused]] const uint32_t i)
1925 {
1926 auto tr = Gfx::TextRenderer(drawingCtx);
1927
1928 drawingCtx.clearSingle(Colours::getShade(self.getColour(WindowColour::secondary).c(), 4));
1929 auto head = Common::getVehicle(self);
1930 if (head == nullptr)
1931 {
1932 return;
1933 }
1934 OpenLoco::Vehicles::Vehicle train{ *head };
1935 Ui::Point pos{ 0, 0 };
1936 for (auto& car : train.cars)
1937 {
1938 StringId carStr = StringIds::black_stringid;
1939 if (EntityId(self.rowHover) == car.front->id)
1940 {
1941 carStr = StringIds::wcolour2_stringid;
1942
1943 int16_t top = pos.y;
1944 int16_t bottom = pos.y + self.rowHeight - 1;
1945 if (DragVehiclePart::getDragCarComponent() != nullptr)
1946 {
1947 bottom = pos.y;
1948 top = pos.y - 1;
1949 carStr = StringIds::black_stringid;
1950 }
1951 drawingCtx.fillRect(0, top, self.width, bottom, enumValue(ExtColour::unk30), Gfx::RectFlags::transparent);
1952 }
1953
1954 int16_t y = pos.y + (self.rowHeight - 22) / 2;
1955 const auto disableColour = car.front == DragVehiclePart::getDragCarComponent()
1956 ? std::make_optional(self.getColour(WindowColour::secondary).c())
1957 : std::nullopt;
1958 drawVehicleInline(drawingCtx, car, { 0, y }, VehicleInlineMode::basic, VehiclePartsToDraw::bogies, disableColour);
1959 auto x = drawVehicleInline(drawingCtx, car, { 0, y }, VehicleInlineMode::basic, VehiclePartsToDraw::bodies, disableColour);
1960
1961 auto vehicleObj = ObjectManager::get<VehicleObject>(car.front->objectId);
1962 FormatArguments args{};
1963 args.push(vehicleObj->name);
1964 x += 2;
1965 y = pos.y + (self.rowHeight / 2) - 6;
1966
1967 {
1968 auto point = Point(x, y);
1969 tr.drawStringLeft(point, Colour::black, carStr, args);
1970 }
1971
1972 pos.y += self.rowHeight;
1973 }
1974
1975 if (EntityId(self.rowHover) == train.tail->id && DragVehiclePart::getDragCarComponent() != nullptr)
1976 {
1977 drawingCtx.fillRect(0, pos.y - 1, self.width, pos.y, enumValue(ExtColour::unk30), Gfx::RectFlags::transparent);
1978 }
1979 }
1980
1981 static constexpr WindowEventList kEvents = {

Callers

nothing calls this directly

Calls 15

TextRendererClass · 0.85
getShadeFunction · 0.85
getVehicleFunction · 0.85
EntityIdEnum · 0.85
getDragCarComponentFunction · 0.85
enumValueFunction · 0.85
drawVehicleInlineFunction · 0.85
getWidthVehicleInlineFunction · 0.85
drawCargoTextFunction · 0.85
getOrderTableFunction · 0.85
drawOrderLabelFunction · 0.85
commonFunction · 0.85

Tested by

no test coverage detected