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

Function drawGraphLegend

src/OpenLoco/src/Ui/Windows/CompanyList.cpp:1050–1086  ·  view source on GitHub ↗

0x00437949

Source from the content-addressed store, hash-verified

1048
1049 // 0x00437949
1050 static void drawGraphLegend(Window* self, Gfx::DrawingContext& drawingCtx, int16_t x, int16_t y)
1051 {
1052 auto tr = Gfx::TextRenderer(drawingCtx);
1053
1054 auto cargoCount = 0;
1055 for (uint8_t i = 0; i < ObjectManager::getMaxObjects(ObjectType::cargo); i++)
1056 {
1057 auto cargo = ObjectManager::get<CargoObject>(i);
1058 if (cargo == nullptr)
1059 {
1060 continue;
1061 }
1062
1063 auto colour = _cargoLineColour[i];
1064 auto palette = Colours::getShade(colour, 6);
1065 auto stringId = StringIds::small_black_string;
1066
1067 if (self->var_854 & (1 << cargoCount))
1068 {
1069 stringId = StringIds::small_white_string;
1070 }
1071
1072 if (!(self->var_854 & (1 << cargoCount)) || !(_hoverItemTicks & (1 << 2)))
1073 {
1074 drawingCtx.fillRect(x, y + 3, x + 4, y + 7, palette, Gfx::RectFlags::none);
1075 }
1076
1077 auto args = FormatArguments();
1078 args.push(cargo->name);
1079
1080 auto point = Point(x + 6, y);
1081 tr.drawStringLeftClipped(point, 94, Colour::black, stringId, args);
1082
1083 y += 10;
1084 cargoCount++;
1085 }
1086 }
1087
1088 // 0x00437120
1089 static void draw(Window& self, Gfx::DrawingContext& drawingCtx)

Callers 2

drawFunction · 0.85
drawGraphAndLegendFunction · 0.85

Calls 10

TextRendererClass · 0.85
getMaxObjectsFunction · 0.85
getShadeFunction · 0.85
companiesFunction · 0.85
getCompanyColourFunction · 0.85
drawStringLeftClippedMethod · 0.80
FormatArgumentsClass · 0.50
fillRectMethod · 0.45
pushMethod · 0.45
idMethod · 0.45

Tested by

no test coverage detected