| 142 | } |
| 143 | |
| 144 | static void paintSignalSide(PaintSession& session, const World::SignalElement::Side& side, const bool isRight, const bool isGhost, const uint8_t trackId, const uint8_t rotation, const coord_t height) |
| 145 | { |
| 146 | if (side.hasSignal()) |
| 147 | { |
| 148 | session.setItemType(InteractionItem::signal); |
| 149 | session.setTrackModId(isRight ? 1 : 0); |
| 150 | auto* signalObj = ObjectManager::get<TrainSignalObject>(side.signalObjectId()); |
| 151 | const auto trackRotation = getTrackRotation(isRight, trackId, rotation); |
| 152 | const auto& offsetAndBBoffsetArr = signalObj->hasFlags(TrainSignalObjectFlags::isLeft) ? _4FE870 : _4FE830; |
| 153 | const auto& offsetAndBBoffset = offsetAndBBoffsetArr[trackRotation]; |
| 154 | const auto imageRotationOffset = ((trackRotation & 0x3) << 1) | (trackRotation >= 12 ? 1 : 0); |
| 155 | const auto imageOffset = imageRotationOffset + signalObj->image + (side.frame() << 3); |
| 156 | |
| 157 | ImageId imageId{ imageOffset }; |
| 158 | if (isGhost) |
| 159 | { |
| 160 | session.setItemType(InteractionItem::noInteraction); |
| 161 | imageId = Gfx::applyGhostToImage(imageOffset); |
| 162 | // TODO: apply company colour if playerCompanyID != elTrack.owner()? |
| 163 | } |
| 164 | World::Pos3 offset(offsetAndBBoffset.offset.x, offsetAndBBoffset.offset.y, getSignalHeightOffset(isRight, trackId) + height); |
| 165 | World::Pos3 bbOffset(offsetAndBBoffset.boundingOffset.x, offsetAndBBoffset.boundingOffset.y, offset.z + 4); |
| 166 | World::Pos3 bbSize(1, 1, 14); |
| 167 | session.addToPlotListAsParent(imageId, offset, bbOffset, bbSize); |
| 168 | |
| 169 | if (signalObj->hasFlags(TrainSignalObjectFlags::hasLights)) |
| 170 | { |
| 171 | if (side.hasRedLight()) |
| 172 | { |
| 173 | const auto lightOffset = side.hasRedLight2() ? TrainSignal::ImageIds::redLights2 : TrainSignal::ImageIds::redLights; |
| 174 | const auto lightImageOffset = imageRotationOffset + signalObj->image + lightOffset; |
| 175 | imageId = ImageId{ lightImageOffset }; |
| 176 | if (isGhost) |
| 177 | { |
| 178 | session.setItemType(InteractionItem::noInteraction); |
| 179 | imageId = Gfx::applyGhostToImage(imageOffset); |
| 180 | } |
| 181 | session.addToPlotListAsChild(imageId, offset, bbOffset, bbSize); |
| 182 | } |
| 183 | if (side.hasGreenLight()) |
| 184 | { |
| 185 | const auto lightOffset = side.hasGreenLight2() ? TrainSignal::ImageIds::greenLights2 : TrainSignal::ImageIds::greenLights; |
| 186 | const auto lightImageOffset = imageRotationOffset + signalObj->image + lightOffset; |
| 187 | imageId = ImageId{ lightImageOffset }; |
| 188 | if (isGhost) |
| 189 | { |
| 190 | session.setItemType(InteractionItem::noInteraction); |
| 191 | imageId = Gfx::applyGhostToImage(imageOffset); |
| 192 | } |
| 193 | session.addToPlotListAsChild(imageId, offset, bbOffset, bbSize); |
| 194 | } |
| 195 | } |
| 196 | } |
| 197 | else |
| 198 | { |
| 199 | if (((session.getViewFlags() & Ui::ViewportFlags::one_way_direction_arrows) != Ui::ViewportFlags::none) |
| 200 | && (session.getRenderTarget()->zoomLevel == 0)) |
| 201 | { |
no test coverage detected