Skip to content

Commit

Permalink
shipSelectionScreen: fewer stations for fighters
Browse files Browse the repository at this point in the history
  • Loading branch information
Pithlit authored and Piglit committed Jul 26, 2023
1 parent 78e7b01 commit ce1e8f6
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions src/menus/shipSelectionScreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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();
Expand All @@ -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.
Expand Down Expand Up @@ -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<PlayerSpaceship> ship = new PlayerSpaceship();
Expand All @@ -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);
Expand Down Expand Up @@ -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<string> players;
foreach(PlayerInfo, i, player_info_list)
{
Expand Down

0 comments on commit ce1e8f6

Please sign in to comment.