diff --git a/src/menus/shipSelectionScreen.cpp b/src/menus/shipSelectionScreen.cpp index 5c4b8d0463..5be8fd0dcb 100644 --- a/src/menus/shipSelectionScreen.cpp +++ b/src/menus/shipSelectionScreen.cpp @@ -146,11 +146,11 @@ ShipSelectionScreen::ShipSelectionScreen() auto right_panel = new GuiPanel(right_container, "DIRECT_OPTIONS_PANEL"); if (game_server) { right_panel->setPosition(0, 50, sp::Alignment::TopCenter)->setSize(550, 325); - } - else - { - right_panel->setPosition(0, 50, sp::Alignment::TopCenter)->setSize(550, 560); - } + } + else + { + right_panel->setPosition(0, 50, sp::Alignment::TopCenter)->setSize(550, 560); + } auto right_content = new GuiElement(right_panel, ""); right_content->setMargins(50)->setPosition(0, 0)->setSize(GuiElement::GuiSizeMax, GuiElement::GuiSizeMax)->setAttribute("layout", "vertical"); @@ -334,8 +334,8 @@ ShipSelectionScreen::ShipSelectionScreen() { GuiSelector* ship_template_selector = new GuiSelector(left_container, "CREATE_SHIP_SELECTOR", [this](int index, string value) { - P ship_template = ShipTemplate::getTemplate(value); - playership_info->setText(ship_template->getDescription()); + P ship_template = ShipTemplate::getTemplate(value); + playership_info->setText(ship_template->getDescription()); }); // List only ships with templates designated for player use. @@ -406,6 +406,7 @@ ShipSelectionScreen::ShipSelectionScreen() void ShipSelectionScreen::update(float delta) { + // If this is a client and is disconnected from the server, destroy the // screen and return to the main menu. if (game_client && game_client->getStatus() == GameClient::Disconnected) @@ -448,7 +449,6 @@ void ShipSelectionScreen::update(float delta) } - // If there aren't any player ships, show a label stating so. if (player_ship_list->entryCount() > 0) { @@ -472,17 +472,25 @@ CrewPositionSelection::CrewPositionSelection(GuiContainer* owner, string id, int auto container = new GuiElement(this, ""); container->setSize(GuiElement::GuiSizeMax, GuiElement::GuiSizeMax)->setAttribute("layout", "horizontal"); - auto one = new GuiPanel(container, ""); - one->setMargins(50, 50, 25, 100)->setSize(GuiElement::GuiSizeMax, GuiElement::GuiSizeMax); - (new GuiLabel(one, "CREW_POSITION_SELECT_LABEL", tr("6/5 player crew"), 30))->addBackground()->setSize(GuiElement::GuiSizeMax, 50)->setMargins(15, 0); - auto layout = new GuiElement(one, ""); - layout->setMargins(25, 50)->setSize(GuiElement::GuiSizeMax, GuiElement::GuiSizeMax)->setAttribute("layout", "vertical"); - main_screen_button = new GuiToggleButton(layout, "", tr("Main screen"), [this](bool value) { - my_player_info->commandSetMainScreen(window_index, value); - unselectSingleOptions(); - }); - main_screen_button->setValue(my_player_info->main_screen & (1 << window_index)); - main_screen_button->setSize(GuiElement::GuiSizeMax, 50); + auto left_container = new GuiElement(container, ""); + left_container->setSize(GuiElement::GuiSizeMax, GuiElement::GuiSizeMax)->setAttribute("layout", "vertical"); + left_container->setMargins(50, 50, 25, 100); + + auto center_container = new GuiElement(container, ""); + center_container->setSize(GuiElement::GuiSizeMax, GuiElement::GuiSizeMax)->setAttribute("layout", "vertical"); + center_container->setMargins(25, 50, 25, 100); + + auto right_container = new GuiElement(container, ""); + right_container->setSize(GuiElement::GuiSizeMax, GuiElement::GuiSizeMax)->setAttribute("layout", "vertical"); + right_container->setMargins(25, 50, 25, 100); + + // 5-6-crew panel + auto standard_crew_panel = new GuiPanel(left_container, ""); + standard_crew_panel->setSize(GuiElement::GuiSizeMax, 335)->setPosition(0, 0, sp::Alignment::BottomCenter)->setMargins(0, 0, 0, 25); + (new GuiLabel(standard_crew_panel, "CREW_POSITION_SELECT_LABEL", tr("6/5 player crew"), 30))->addBackground()->setSize(GuiElement::GuiSizeMax, 50)->setMargins(15, 0); + auto layout = new GuiElement(standard_crew_panel, ""); + layout->setMargins(25, 50, 25, 0)->setSize(GuiElement::GuiSizeMax, GuiElement::GuiSizeMax)->setAttribute("layout", "vertical"); + auto create_crew_position_button = [this](GuiElement* layout, int n) { auto button = new GuiToggleButton(layout, "", getCrewPositionName(ECrewPosition(n)), [this, n](bool value){ my_player_info->commandSetCrewPosition(window_index, ECrewPosition(n), value); @@ -497,27 +505,28 @@ CrewPositionSelection::CrewPositionSelection(GuiContainer* owner, string id, int for(int n=0; n<=int(relayOfficer); n++) create_crew_position_button(layout, n); - auto two = new GuiPanel(container, ""); - two->setMargins(25, 50, 25, 100)->setSize(GuiElement::GuiSizeMax, GuiElement::GuiSizeMax);; - (new GuiLabel(two, "CREW_POSITION_SELECT_LABEL", tr("4/3/1 player crew"), 30))->addBackground()->setSize(GuiElement::GuiSizeMax, 50)->setMargins(15, 0); - layout = new GuiElement(two, ""); - layout->setMargins(25, 50)->setSize(GuiElement::GuiSizeMax, GuiElement::GuiSizeMax)->setAttribute("layout", "vertical"); - for(int n=int(tacticalOfficer); n<=int(singlePilot); n++) - create_crew_position_button(layout, n); - auto three = new GuiPanel(container, ""); - three->setMargins(25, 50, 50, 100)->setSize(GuiElement::GuiSizeMax, GuiElement::GuiSizeMax);; - (new GuiLabel(three, "CREW_POSITION_SELECT_LABEL", tr("Alternative options"), 30))->addBackground()->setSize(GuiElement::GuiSizeMax, 50)->setMargins(15, 0); - layout = new GuiElement(three, ""); + // 3-4-crew panel + auto limited_crew_panel = new GuiPanel(left_container, ""); + limited_crew_panel->setSize(GuiElement::GuiSizeMax, GuiElement::GuiSizeMax);; + (new GuiLabel(limited_crew_panel, "CREW_POSITION_SELECT_LABEL", tr("4/3/1 player crew"), 30))->addBackground()->setSize(GuiElement::GuiSizeMax, 50)->setMargins(15, 0); + layout = new GuiElement(limited_crew_panel, ""); layout->setMargins(25, 50)->setSize(GuiElement::GuiSizeMax, GuiElement::GuiSizeMax)->setAttribute("layout", "vertical"); - for(int n=int(singlePilot) + 1; ncommandSetMainScreenControl(window_index, value); + // 3d views panel + auto space_screens_panel= new GuiPanel(center_container,""); + space_screens_panel->setSize(GuiElement::GuiSizeMax, 215)->setMargins(0, 0, 0, 25); + (new GuiLabel(space_screens_panel, "CREW_POSITION_SELECT_LABEL", tr("3D screens"), 30))->addBackground()->setSize(GuiElement::GuiSizeMax, 50)->setMargins(15, 0); + layout = new GuiElement(space_screens_panel, ""); + layout->setMargins(25, 50, 25, 0)->setSize(GuiElement::GuiSizeMax, GuiElement::GuiSizeMax)->setAttribute("layout", "vertical"); + main_screen_button = new GuiToggleButton(layout, "", tr("Main screen"), [this](bool value) { + my_player_info->commandSetMainScreen(window_index, value); + unselectSingleOptions(); }); - main_screen_controls_button->setValue(my_player_info->main_screen_control)->setSize(GuiElement::GuiSizeMax, 50); + main_screen_button->setValue(my_player_info->main_screen & (1 << window_index)); + main_screen_button->setSize(GuiElement::GuiSizeMax, 50); // Window auto window_button_row = new GuiElement(layout, ""); @@ -530,6 +539,12 @@ CrewPositionSelection::CrewPositionSelection(GuiContainer* owner, string id, int window_angle = new GuiTextEntry(window_button_row, "WINDOW_ANGLE","0"); window_angle->setSize(75, 50); window_angle->setSelectOnFocus(); + window_angle->callback([this](string text) { // Check validity: Only allow numbers and no more than 3 digits. Angles above 360 are fine though. + if (text !="" && text !="-") window_angle->setText(text.toInt()); + if (text.length() >3 && text.toInt()>=0 ) window_angle->setText(text.substr(0,3)); + if (text.length() >4 && text.toInt()<0 ) window_angle->setText(text.substr(0,4)); + }); + window_angle_label = new GuiLabel(window_button_row, "WINDOW_ANGLE_LABEL", "°", 30); window_angle_label->setSize(12, GuiElement::GuiSizeMax); @@ -547,6 +562,31 @@ CrewPositionSelection::CrewPositionSelection(GuiContainer* owner, string id, int ready_button = new GuiButton(this, "READY", tr("button", "Ready"), on_ready); ready_button->setSize(300, 50)->setPosition(-100, -25, sp::Alignment::BottomRight); + + + // Alternative options panel + auto alternative_options_panel = new GuiPanel(center_container, ""); + alternative_options_panel->setSize(GuiElement::GuiSizeMax, GuiElement::GuiSizeMax);; + (new GuiLabel(alternative_options_panel, "CREW_POSITION_SELECT_LABEL", tr("Alternative options"), 30))->addBackground()->setSize(GuiElement::GuiSizeMax, 50)->setMargins(15, 0); + layout = new GuiElement(alternative_options_panel, ""); + + // Main screen controls button + main_screen_controls_button = new GuiToggleButton(layout, "MAIN_SCREEN_CONTROLS_ENABLE", tr("Main screen controls"), [this](bool value) { + my_player_info->commandSetMainScreenControl(window_index, value); + }); + main_screen_controls_button->setValue(my_player_info->main_screen_control)->setSize(GuiElement::GuiSizeMax, 50); + + layout->setMargins(25, 50, 25, 0)->setSize(GuiElement::GuiSizeMax, GuiElement::GuiSizeMax)->setAttribute("layout", "vertical"); + for(int n=int(singlePilot) + 1; nsetSize(GuiElement::GuiSizeMax, GuiElement::GuiSizeMax); + + station_info = new GuiScrollText(info_panel, "STATION_INFO", station_info_text); + station_info->setPosition(0, 10, sp::Alignment::TopCenter)->setSize(GuiElement::GuiSizeMax, GuiElement::GuiSizeMax)->setMargins(15, 0, 15, 10); + } void CrewPositionSelection::onUpdate() @@ -554,6 +594,7 @@ void CrewPositionSelection::onUpdate() bool any_selected = main_screen_button->getValue() || window_button->getValue() || topdown_button->getValue(); // If a position already has a player on the currently selected player ship, // indicate that on the button. + string crew_text = ""; for(int n = 0; n < max_crew_positions; n++) { string button_text = getCrewPositionName(ECrewPosition(n)); @@ -572,13 +613,16 @@ void CrewPositionSelection::onUpdate() if (players.size() > 0) { - crew_position_button[n]->setText(button_text + " (" + string(", ").join(players) + ")"); + crew_position_button[n]->setText(button_text + " ["+ std::to_string(players.size()) +"]"); + crew_text += "\n" + button_text + ": " + string(", ").join(players) + ""; } else { crew_position_button[n]->setText(button_text); } any_selected = any_selected || crew_position_button[n]->getValue(); } } + if (crew_text != "") crew_text = "\n\n" + tr("--- Crew ---") + crew_text; + station_info->setText(station_info_text + crew_text); ready_button->setEnable(any_selected); } diff --git a/src/menus/shipSelectionScreen.h b/src/menus/shipSelectionScreen.h index df485c0688..b2e9cc0a4e 100644 --- a/src/menus/shipSelectionScreen.h +++ b/src/menus/shipSelectionScreen.h @@ -59,6 +59,8 @@ class CrewPositionSelection : public GuiPanel GuiTextEntry* window_angle; GuiLabel* window_angle_label; GuiToggleButton* topdown_button; + GuiScrollText* station_info; + string station_info_text; }; class SecondMonitorScreen : public GuiCanvas, public Updatable