Skip to content

Commit

Permalink
enable auto connect for ship window (#1989)
Browse files Browse the repository at this point in the history
Co-authored-by: aBlueShadow <falter@mxdreamer>
  • Loading branch information
aBlueShadow and aBlueShadow committed Jun 28, 2023
1 parent 68eedd2 commit c340880
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/menus/autoConnectScreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "playerInfo.h"
#include "multiplayer_client.h"
#include "multiplayer_server_scanner.h"
#include "screens/windowScreen.h"

#include "gui/gui2_label.h"

Expand All @@ -23,6 +24,8 @@ AutoConnectScreen::AutoConnectScreen(ECrewPosition crew_position, bool control_m
status_label->setPosition(0, 300, sp::Alignment::TopCenter)->setSize(0, 50);

string position_name = "Main screen";
if (crew_position_raw >=1000 && crew_position_raw<=1360)
position_name =tr("Ship window");
if (crew_position < max_crew_positions)
position_name = getCrewPositionName(crew_position);

Expand Down Expand Up @@ -117,7 +120,12 @@ void AutoConnectScreen::update(float delta)
if (my_spaceship->getMultiplayerId() == my_player_info->ship_id && (crew_position == max_crew_positions || my_player_info->crew_position[crew_position]))
{
destroy();
my_player_info->spawnUI(0, getRenderLayer());
if (crew_position_raw >=1000 && crew_position_raw<=1360){
uint8_t window_flags = PreferencesManager::get("ship_window_flags", "1").toInt();
new WindowScreen(getRenderLayer(), crew_position_raw-1000, window_flags);
} else{
my_player_info->spawnUI(0, getRenderLayer());
}
}
}
}else{
Expand Down
2 changes: 2 additions & 0 deletions src/menus/autoConnectScreen.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "gui/gui2_canvas.h"
#include "playerInfo.h"
#include "io/network/address.h"
#include "preferenceManager.h"

class GuiLabel;
class ServerScanner;
Expand All @@ -17,6 +18,7 @@ class AutoConnectScreen : public GuiCanvas, public Updatable
std::map<string, string> ship_filters;

GuiLabel* status_label;
int crew_position_raw = (PreferencesManager::get("autoconnect").toInt());
public:
AutoConnectScreen(ECrewPosition crew_position, bool control_main_screen, string ship_filter);
virtual ~AutoConnectScreen();
Expand Down

0 comments on commit c340880

Please sign in to comment.