@@ -1233,13 +1233,104 @@ void LabUi::show_object_options() const
12331233 if (getLabManager ()->isSafeForShips ()) {
12341234 if (Button (" Destroy ship" )) {
12351235 if (Objects[getLabManager ()->CurrentObject ].type == OBJ_SHIP ) {
1236+ // If we have an undocker, delete it before destroying the current ship
1237+ getLabManager ()->deleteDockerObject ();
1238+
12361239 auto obj = &Objects[getLabManager ()->CurrentObject ];
12371240
12381241 obj->flags .remove (Object::Object_Flags::Player_ship);
12391242 ship_self_destruct (obj);
12401243 }
12411244 }
12421245
1246+ const ship* dockee_shipp = &Ships[Objects[getLabManager ()->CurrentObject ].instance ];
1247+ auto dockee_dock_map = get_docking_point_map (Ship_info[dockee_shipp->ship_info_index ].model_num );
1248+
1249+ if (!dockee_dock_map.empty ()) {
1250+
1251+ if (ImGui::BeginCombo (" Docker Ship Class" , Ship_info[getLabManager ()->DockerClass ].name )) {
1252+ for (size_t i = 0 ; i < Ship_info.size (); ++i) {
1253+ bool is_selected = (static_cast <int >(i) == getLabManager ()->DockerClass );
1254+ if (ImGui::Selectable (Ship_info[i].name , is_selected)) {
1255+ getLabManager ()->DockerClass = static_cast <int >(i);
1256+ // Load model if needed
1257+ auto & dsip = Ship_info[getLabManager ()->DockerClass ];
1258+ if (dsip.model_num < 0 ) {
1259+ dsip.model_num = model_load (dsip.pof_file , &dsip);
1260+ }
1261+ auto new_dock_map = get_docking_point_map (dsip.model_num );
1262+
1263+ // Auto-select first available dockpoint (or clear if none)
1264+ if (!new_dock_map.empty ()) {
1265+ getLabManager ()->DockerDockPoint = new_dock_map.begin ()->second ;
1266+ } else {
1267+ getLabManager ()->DockerDockPoint .clear ();
1268+ }
1269+ }
1270+ if (is_selected)
1271+ ImGui::SetItemDefaultFocus ();
1272+ }
1273+ ImGui::EndCombo ();
1274+ }
1275+
1276+ auto & dsip = Ship_info[getLabManager ()->DockerClass ];
1277+ if (dsip.model_num < 0 ) {
1278+ dsip.model_num = model_load (dsip.pof_file , &dsip);
1279+ }
1280+ auto dock_map = get_docking_point_map (dsip.model_num );
1281+
1282+ // Ensure DockerDockPoint is initialized once based on the current DockerClass
1283+ if (getLabManager ()->DockerDockPoint .empty ()) {
1284+ if (!dock_map.empty ()) {
1285+ getLabManager ()->DockerDockPoint = dock_map.begin ()->second ;
1286+ }
1287+ }
1288+
1289+ const char * docker_label = getLabManager ()->DockerDockPoint .c_str ();
1290+
1291+ if (ImGui::BeginCombo (" Docker Dockpoint" , docker_label)) {
1292+ if (!dock_map.empty ()) {
1293+ for (const auto & [index, name] : dock_map) {
1294+ bool is_selected = (name == getLabManager ()->DockerDockPoint );
1295+ if (ImGui::Selectable (name.c_str (), is_selected)) {
1296+ getLabManager ()->DockerDockPoint = name;
1297+ }
1298+ if (is_selected)
1299+ ImGui::SetItemDefaultFocus ();
1300+ }
1301+ }
1302+ ImGui::EndCombo ();
1303+ }
1304+
1305+ // Auto-select first dockpoint if none currently selected
1306+ if (getLabManager ()->DockeeDockPoint .empty ()) {
1307+ getLabManager ()->DockeeDockPoint = dockee_dock_map.begin ()->second ;
1308+ }
1309+
1310+ const char * dockee_label = getLabManager ()->DockeeDockPoint .c_str ();
1311+
1312+ if (ImGui::BeginCombo (" Dockee Dockpoint" , dockee_label)) {
1313+ for (const auto & [index, name] : dockee_dock_map) {
1314+ bool is_selected = (name == getLabManager ()->DockeeDockPoint );
1315+ if (ImGui::Selectable (name.c_str (), is_selected)) {
1316+ getLabManager ()->DockeeDockPoint = name;
1317+ }
1318+ if (is_selected)
1319+ ImGui::SetItemDefaultFocus ();
1320+ }
1321+ ImGui::EndCombo ();
1322+ }
1323+
1324+ if (Button (" Begin Docking Test" )) {
1325+ getLabManager ()->beginDockingTest ();
1326+ }
1327+
1328+ if (Button (" Begin Undocking Test" )) {
1329+ getLabManager ()->beginUndockingTest ();
1330+ }
1331+ }
1332+
1333+
12431334 build_animation_options (shipp, sip);
12441335 }
12451336 }
0 commit comments