Skip to content

Commit

Permalink
Station selection rearrangement and added info (#2042)
Browse files Browse the repository at this point in the history
* rearrange station selection screen

* move crew info to info panel

* display number of people per station

* replace tabs with spaces

---------

Co-authored-by: aBlueShadow <falter@mxdreamer>
  • Loading branch information
aBlueShadow and aBlueShadow authored Feb 19, 2024
1 parent f7cac9e commit 9844824
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 36 deletions.
116 changes: 80 additions & 36 deletions src/menus/shipSelectionScreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");

Expand Down Expand Up @@ -334,8 +334,8 @@ ShipSelectionScreen::ShipSelectionScreen()
{
GuiSelector* ship_template_selector = new GuiSelector(left_container, "CREATE_SHIP_SELECTOR", [this](int index, string value)
{
P<ShipTemplate> ship_template = ShipTemplate::getTemplate(value);
playership_info->setText(ship_template->getDescription());
P<ShipTemplate> ship_template = ShipTemplate::getTemplate(value);
playership_info->setText(ship_template->getDescription());
});

// List only ships with templates designated for player use.
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
{
Expand All @@ -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);
Expand All @@ -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; n<int(max_crew_positions); n++)
for(int n=int(tacticalOfficer); n<=int(singlePilot); n++)
create_crew_position_button(layout, n);

// 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);
// 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, "");
Expand All @@ -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);
Expand All @@ -547,13 +562,39 @@ 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; n<int(max_crew_positions); n++)
create_crew_position_button(layout, n);
// Info text panel
auto info_panel = new GuiPanel(right_container,"");
station_info_text = tr("You can select multiple stations and switch between them during the game.\nIf mainscreen is selected alongside stations, it will be shown next to the current station (if the total screen size is wide enough).");
info_panel->setSize(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()
{
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));
Expand All @@ -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);
}
Expand Down
2 changes: 2 additions & 0 deletions src/menus/shipSelectionScreen.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

1 comment on commit 9844824

@daid-tinyci
Copy link

@daid-tinyci daid-tinyci bot commented on 9844824 Mar 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TinyCI build failure:

[ninja -j 2 package] returned [1]:


FAILED: CMakeFiles/EE_GuiLIB.dir/src/gui/scriptError.cpp.o 

/usr/bin/c++  -I/data/tinyci_build/daid/EmptyEpsilon/src -I/data/tinyci_build/daid/EmptyEpsilon/_build_native/include -I/data/tinyci_build/daid/SeriousProton/src -I/data/tinyci_build/daid/EmptyEpsilon/_build_native/SeriousProton/include -I/data/tinyci_build/daid/SeriousProton/libs/Box2D/.. -I/data/tinyci_build/daid/SeriousProton/libs/glad -I/data/tinyci_build/daid/SeriousProton/libs/lua/.. -I/home/tinyci/builds/daid/EmptyEpsilon/_build_native/_deps/glm-src/glm/.. -I/data/tinyci_build/daid/SeriousProton/libs/freetype2/include -I/home/tinyci/builds/daid/EmptyEpsilon/_build_native/_deps/basis-src -I/data/tinyci_build/daid/SeriousProton/libs/libopus/include -I/home/tinyci/builds/daid/EmptyEpsilon/_build_native/_deps/meshoptimizer-src/src -isystem /usr/include/SDL2 -O2 -g -DNDEBUG -fdiagnostics-color -g1 -O3 -flto -funsafe-math-optimizations -Wall -Wextra -Woverloaded-virtual -Wdouble-promotion -Wsuggest-override -Werror=return-type -Wno-unused-parameter -Wno-unused-but-set-parameter -MD -MT CMakeFiles/EE_GuiLIB.dir/src/gui/scriptError.cpp.o -MF CMakeFiles/EE_GuiLIB.dir/src/gui/scriptError.cpp.o.d -o CMakeFiles/EE_GuiLIB.dir/src/gui/scriptError.cpp.o -c /data/tinyci_build/daid/EmptyEpsilon/src/gui/scriptError.cpp

/data/tinyci_build/daid/EmptyEpsilon/src/gui/scriptError.cpp: In member function ‘virtual void ScriptErrorRenderer::render(sp::RenderTarget&)’:

/data/tinyci_build/daid/EmptyEpsilon/src/gui/scriptError.cpp:13:7: error: ‘ScriptObject’ was not declared in this scope; did you mean ‘scriptBindObject’?

   13 |     P<ScriptObject> script = engine->getObject("scenario");

      |       ^~~~~~~~~~~~

      |       scriptBindObject

/data/tinyci_build/daid/EmptyEpsilon/src/gui/scriptError.cpp:13:19: error: template argument 1 is invalid

   13 |     P<ScriptObject> script = engine->getObject("scenario");

      |                   ^

/data/tinyci_build/daid/EmptyEpsilon/src/gui/scriptError.cpp:13:47: error: cannot convert ‘P<PObject>’ to ‘int’ in initialization

   13 |     P<ScriptObject> script = engine->getObject("scenario");

      |                              ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~

      |                                               |

      |                                               P<PObject>

/data/tinyci_build/daid/EmptyEpsilon/src/gui/scriptError.cpp:20:26: error: base operand of ‘->’ is not a pointer

   20 |     string error = script->getError();

      |                          ^~

[2/172] Building CXX object CMakeFiles/EE_GuiLIB.dir/src/gui/hotkeyConfig.cpp.o

FAILED: CMakeFiles/EE_GuiLIB.dir/src/gui/hotkeyConfig.cpp.o 

/usr/bin/c++  -I/data/tinyci_build/daid/EmptyEpsilon/src -I/data/tinyci_build/daid/EmptyEpsilon/_build_native/include -I/data/tinyci_build/daid/SeriousProton/src -I/data/tinyci_build/daid/EmptyEpsilon/_build_native/SeriousProton/include -I/data/tinyci_build/daid/SeriousProton/libs/Box2D/.. -I/data/tinyci_build/daid/SeriousProton/libs/glad -I/data/tinyci_build/daid/SeriousProton/libs/lua/.. -I/home/tinyci/builds/daid/EmptyEpsilon/_build_native/_deps/glm-src/glm/.. -I/data/tinyci_build/daid/SeriousProton/libs/freetype2/include -I/home/tinyci/builds/daid/EmptyEpsilon/_build_native/_deps/basis-src -I/data/tinyci_build/daid/SeriousProton/libs/libopus/include -I/home/tinyci/builds/daid/EmptyEpsilon/_build_native/_deps/meshoptimizer-src/src -isystem /usr/include/SDL2 -O2 -g -DNDEBUG -fdiagnostics-color -g1 -O3 -flto -funsafe-math-optimizations -Wall -Wextra -Woverloaded-virtual -Wdouble-promotion -Wsuggest-override -Werror=return-type -Wno-unused-parameter -Wno-unused-but-set-parameter -MD -MT CMakeFiles/EE_GuiLIB.dir/src/gui/hotkeyConfig.cpp.o -MF CMakeFiles/EE_GuiLIB.dir/src/gui/hotkeyConfig.cpp.o.d -o CMakeFiles/EE_GuiLIB.dir/src/gui/hotkeyConfig.cpp.o -c /data/tinyci_build/daid/EmptyEpsilon/src/gui/hotkeyConfig.cpp

In file included from /data/tinyci_build/daid/EmptyEpsilon/src/shipTemplate.h:13,

                 from /data/tinyci_build/daid/EmptyEpsilon/src/gui/hotkeyConfig.cpp:4:

/data/tinyci_build/daid/EmptyEpsilon/src/missileWeaponData.h:25:41: error: expected constructor, destructor, or type conversion before ‘;’ token

   25 | REGISTER_MULTIPLAYER_ENUM(EMissileSizes);

      |                                         ^

/data/tinyci_build/daid/EmptyEpsilon/src/shipTemplate.h:209:35: error: expected constructor, destructor, or type conversion before ‘;’ token

  209 | REGISTER_MULTIPLAYER_ENUM(ESystem);

      |                                   ^

ninja: build stopped: subcommand failed.

Please sign in to comment.