0x00473A13
| 1285 | |
| 1286 | // 0x00473A13 |
| 1287 | bool tryCloseWindow() |
| 1288 | { |
| 1289 | auto& selection = ObjectManager::getCurrentSelectionList(); |
| 1290 | const auto res = ObjectManager::validateObjectSelection(selection.objectFlags); |
| 1291 | if (!res.has_value()) |
| 1292 | { |
| 1293 | // All okay selection is good! |
| 1294 | auto* w = WindowManager::find(WindowType::objectSelection); |
| 1295 | if (w != nullptr) |
| 1296 | { |
| 1297 | WindowManager::close(w); |
| 1298 | } |
| 1299 | return true; |
| 1300 | } |
| 1301 | else |
| 1302 | { |
| 1303 | // Selection was bad so throw up an error message |
| 1304 | // and switch tabs to the bad type |
| 1305 | |
| 1306 | Windows::Error::open(StringIds::invalid_selection_of_objects, GameCommands::getErrorText()); |
| 1307 | |
| 1308 | auto* w = WindowManager::find(WindowType::objectSelection); |
| 1309 | if (w != nullptr) |
| 1310 | { |
| 1311 | // TODO: switch modes as needed? |
| 1312 | auto objectType = res.value(); |
| 1313 | switchTabByObjectType(*w, objectType); |
| 1314 | |
| 1315 | w->rowHover = -1; |
| 1316 | w->object = nullptr; |
| 1317 | w->scrollAreas[0].contentWidth = 0; |
| 1318 | ObjectManager::freeTemporaryObject(); |
| 1319 | w->invalidate(); |
| 1320 | |
| 1321 | auto objIndex = getFirstAvailableSelectedObject(selection); |
| 1322 | if (objIndex.index != ObjectManager::kNullObjectIndex) |
| 1323 | { |
| 1324 | w->rowHover = objIndex.index; |
| 1325 | w->object = reinterpret_cast<std::byte*>(&objIndex.object._header); |
| 1326 | |
| 1327 | ObjectManager::loadTemporaryObject(objIndex.object._header); |
| 1328 | } |
| 1329 | } |
| 1330 | return false; |
| 1331 | } |
| 1332 | } |
| 1333 | |
| 1334 | static void switchPrimaryTab(Window& self, uint8_t tabIndex) |
| 1335 | { |
no test coverage detected