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

Function draw

src/OpenLoco/src/Ui/Windows/ObjectSelectionWindow.cpp:1027–1145  ·  view source on GitHub ↗

0x004733F5

Source from the content-addressed store, hash-verified

1025
1026 // 0x004733F5
1027 static void draw(Window& self, Gfx::DrawingContext& drawingCtx)
1028 {
1029 // Extend background frame with a solid colour
1030 // TODO: this should not be needed
1031 if (Config::get().windowFrameStyle == Config::WindowFrameStyle::background)
1032 {
1033 drawingCtx.fillRectInset(self.x, self.y + 20, self.x + self.width - 1, self.y + 20 + 60, self.getColour(WindowColour::primary), Gfx::RectInsetFlags::none);
1034 }
1035
1036 self.draw(drawingCtx);
1037
1038 drawTabs(self, drawingCtx);
1039 drawSecondaryTabs(self, drawingCtx);
1040 drawSearchBox(self, drawingCtx);
1041
1042 auto tr = Gfx::TextRenderer(drawingCtx);
1043
1044 bool doDefault = true;
1045 if (self.object != nullptr)
1046 {
1047 auto& objectHeader = ObjectManager::getObjectInIndex(self.rowHover)._header;
1048 if (objectHeader.getType() != ObjectType::townNames && objectHeader.getType() != ObjectType::climate)
1049 {
1050 doDefault = false;
1051 }
1052 }
1053
1054 if (doDefault)
1055 {
1056 auto widget = self.widgets[widx::objectImage];
1057 auto colour = Colours::getShade(self.getColour(WindowColour::secondary).c(), 5);
1058 drawingCtx.drawRect(self.x + widget.left, self.y + widget.top, widget.width(), widget.height(), colour, Gfx::RectFlags::none);
1059 }
1060 else
1061 {
1062 auto widget = self.widgets[widx::objectImage];
1063 auto colour = Colours::getShade(self.getColour(WindowColour::secondary).c(), 0);
1064 drawingCtx.drawRect(self.x + widget.left + 1, self.y + widget.top + 1, widget.width() - 2, widget.height() - 2, colour, Gfx::RectFlags::none);
1065 }
1066
1067 ObjectType type{};
1068 auto& currentTab = kMainTabInfo[self.currentTab];
1069 if (!currentTab.subTabs.empty())
1070 {
1071 type = currentTab.subTabs[self.currentSecondaryTab].objectType;
1072 }
1073 else
1074 {
1075 type = currentTab.objectType;
1076 }
1077 auto& selection = ObjectManager::getCurrentSelectionList();
1078 auto args = FormatArguments();
1079 args.push(selection.selectionMetaData.numSelectedObjects[enumValue(type)]);
1080 args.push(ObjectManager::getMaxObjects(type));
1081
1082 {
1083 auto point = Point(self.x + 3, self.y + self.height - 12);
1084 tr.drawStringLeft(point, Colour::black, StringIds::num_selected_num_max, args);

Callers

nothing calls this directly

Calls 15

drawSecondaryTabsFunction · 0.85
TextRendererClass · 0.85
getShadeFunction · 0.85
enumValueFunction · 0.85
getMaxObjectsFunction · 0.85
getTemporaryObjectFunction · 0.85
drawPreviewImageFunction · 0.85
getStringFunction · 0.85
drawDescriptionFunction · 0.85
drawDatDetailsFunction · 0.85
getColourMethod · 0.80
cMethod · 0.80

Tested by

no test coverage detected