diff --git a/src/menus/shipSelectionScreen.cpp b/src/menus/shipSelectionScreen.cpp index 0d0eca7b00..eebb92d02d 100644 --- a/src/menus/shipSelectionScreen.cpp +++ b/src/menus/shipSelectionScreen.cpp @@ -285,9 +285,7 @@ ShipSelectionScreen::ShipSelectionScreen() (new GuiPanel(left_container, "SHIP_SELECTION_BOX"))->setPosition(0, 50, sp::Alignment::TopCenter)->setSize(550, 560); fighter_toggle_selector = new GuiSelector(left_container, "FIGHTER_TOGGLE_SELECTOR", [this](int index, string value) - { - my_player_info->fighter_pilot = index; - }); + {}); fighter_toggle_selector->addEntry(tr("Select ship"), "ship"); fighter_toggle_selector->addEntry(tr("Select fighter"), "fighter"); fighter_toggle_selector->setSelectionIndex((int) my_player_info->fighter_pilot); @@ -317,6 +315,7 @@ ShipSelectionScreen::ShipSelectionScreen() return ship && ship->control_code == code; }, [this, ship](){ my_player_info->commandSetShipId(ship->getMultiplayerId()); + my_player_info->fighter_pilot = ship->isFighter(); crew_position_selection_overlay->show(); my_player_info->last_ship_password = ship->control_code; left_container->show(); @@ -330,6 +329,7 @@ ShipSelectionScreen::ShipSelectionScreen() else { my_player_info->commandSetShipId(ship->getMultiplayerId()); + my_player_info->fighter_pilot = ship->isFighter(); crew_position_selection_overlay->show(); } // If the selected item isn't a ship, reset the ship ID in player info. @@ -365,7 +365,7 @@ ShipSelectionScreen::ShipSelectionScreen() // Spawn a ship of the selected template near 0,0 and give it a random // heading. - (new GuiButton(left_container, "CREATE_SHIP_BUTTON", tr("Spawn player ship"), [ship_template_selector]() { + (new GuiButton(left_container, "CREATE_SHIP_BUTTON", tr("Spawn player ship"), [this, ship_template_selector]() { if (!gameGlobalInfo->allow_new_player_ships) return; P ship = new PlayerSpaceship(); @@ -377,6 +377,7 @@ ShipSelectionScreen::ShipSelectionScreen() ship->target_rotation = ship->getRotation(); ship->setPosition(glm::vec2(random(-100, 100), random(-100, 100))); ship->setTemplate(ship_template_selector->getSelectionValue()); + fighter_toggle_selector->setSelectionIndex(ship->isFighter()); my_player_info->commandSetShipId(ship->getMultiplayerId()); } }))->setPosition(0, 680, sp::Alignment::TopCenter)->setSize(490, 50); @@ -578,6 +579,17 @@ void CrewPositionSelection::onUpdate() string button_text = getCrewPositionName(ECrewPosition(n)); if (my_spaceship) { + if (n <= relayOfficer) + { + if (my_spaceship->isFighter()) + { + crew_position_button[n]->hide(); + crew_position_button[n]->setValue(false); + my_player_info->commandSetCrewPosition(window_index, ECrewPosition(n), false); + } else { + crew_position_button[n]->show(); + } + } std::vector players; foreach(PlayerInfo, i, player_info_list) {