diff --git a/src/playerInfo.cpp b/src/playerInfo.cpp index c9b67c71ea..5a58e063e6 100644 --- a/src/playerInfo.cpp +++ b/src/playerInfo.cpp @@ -192,7 +192,7 @@ void PlayerInfo::spawnUI(int monitor_index, RenderLayer* render_layer) if (crew_position[scienceOfficer] & (1 << monitor_index)) screen->addStationTab(new ScienceScreen(container), scienceOfficer, getCrewPositionName(scienceOfficer), getCrewPositionIcon(scienceOfficer)); if (crew_position[relayOfficer] & (1 << monitor_index)) - screen->addStationTab(new RelayScreen(container, true), relayOfficer, getCrewPositionName(relayOfficer), getCrewPositionIcon(relayOfficer)); + screen->addStationTab(new RelayScreen(container, RelayScreen::Variant::relay), relayOfficer, getCrewPositionName(relayOfficer), getCrewPositionIcon(relayOfficer)); //Crew 4/3 if (crew_position[tacticalOfficer] & (1 << monitor_index)) @@ -214,11 +214,13 @@ void PlayerInfo::spawnUI(int monitor_index, RenderLayer* render_layer) if (crew_position[databaseView] & (1 << monitor_index)) screen->addStationTab(new DatabaseScreen(container), databaseView, getCrewPositionName(databaseView), getCrewPositionIcon(databaseView)); if (crew_position[altRelay] & (1 << monitor_index)) - screen->addStationTab(new RelayScreen(container, false), altRelay, getCrewPositionName(altRelay), getCrewPositionIcon(altRelay)); + screen->addStationTab(new RelayScreen(container, RelayScreen::Variant::stategic_map), altRelay, getCrewPositionName(altRelay), getCrewPositionIcon(altRelay)); if (crew_position[commsOnly] & (1 << monitor_index)) screen->addStationTab(new CommsScreen(container), commsOnly, getCrewPositionName(commsOnly), getCrewPositionIcon(commsOnly)); if (crew_position[shipLog] & (1 << monitor_index)) screen->addStationTab(new ShipLogScreen(container), shipLog, getCrewPositionName(shipLog), getCrewPositionIcon(shipLog)); + if (crew_position[captainsMap] & (1 << monitor_index)) + screen->addStationTab(new RelayScreen(container, RelayScreen::Variant::captains_map), captainsMap, getCrewPositionName(captainsMap), getCrewPositionIcon(captainsMap)); GuiSelfDestructEntry* sde = new GuiSelfDestructEntry(container, "SELF_DESTRUCT_ENTRY"); for(int n=0; n void convert::param(lua_State* L, int& idx, ECrewPosit cp = commsOnly; else if (str == "shiplog") cp = shipLog; + else if (str == "captainsmap") + cp = captainsMap; else luaL_error(L, "Unknown value for crew position: %s", str.c_str()); } diff --git a/src/playerInfo.h b/src/playerInfo.h index 8e58f278b3..4162193577 100644 --- a/src/playerInfo.h +++ b/src/playerInfo.h @@ -25,6 +25,7 @@ enum ECrewPosition altRelay, commsOnly, shipLog, + captainsMap, max_crew_positions }; diff --git a/src/screens/crew6/relayScreen.cpp b/src/screens/crew6/relayScreen.cpp index 30d672564d..1a5bfed876 100644 --- a/src/screens/crew6/relayScreen.cpp +++ b/src/screens/crew6/relayScreen.cpp @@ -20,8 +20,8 @@ #include "gui/gui2_togglebutton.h" -RelayScreen::RelayScreen(GuiContainer* owner, bool allow_comms) -: GuiOverlay(owner, "RELAY_SCREEN", colorConfig.background), mode(TargetSelection) +RelayScreen::RelayScreen(GuiContainer* owner, Variant variant) +: GuiOverlay(owner, "RELAY_SCREEN", colorConfig.background), mode(TargetSelection), variant(variant) { targets.setAllowWaypointSelection(); radar = new GuiRadarView(this, "RELAY_RADAR", 50000.0f, &targets); @@ -96,56 +96,58 @@ RelayScreen::RelayScreen(GuiContainer* owner, bool allow_comms) option_buttons = new GuiElement(this, "BUTTONS"); option_buttons->setPosition(20, 50, sp::Alignment::TopLeft)->setSize(250, GuiElement::GuiSizeMax)->setAttribute("layout", "vertical"); - // Open comms button. - if (allow_comms == true) - (new GuiOpenCommsButton(option_buttons, "OPEN_COMMS_BUTTON", tr("Open Comms"), &targets))->setSize(GuiElement::GuiSizeMax, 50); - else - (new GuiOpenCommsButton(option_buttons, "OPEN_COMMS_BUTTON", tr("Link to Comms"), &targets))->setSize(GuiElement::GuiSizeMax, 50); - + if (variant != Variant::captains_map) { + // Open comms button. + if (variant == Variant::relay) + (new GuiOpenCommsButton(option_buttons, "OPEN_COMMS_BUTTON", tr("Open Comms"), &targets))->setSize(GuiElement::GuiSizeMax, 50); + else + (new GuiOpenCommsButton(option_buttons, "OPEN_COMMS_BUTTON", tr("Link to Comms"), &targets))->setSize(GuiElement::GuiSizeMax, 50); - // Hack target - hack_target_button = new GuiButton(option_buttons, "HACK_TARGET", tr("Start hacking"), [this](){ - P target = targets.get(); - if (my_spaceship && target && target->canBeHackedBy(my_spaceship)) - { - hacking_dialog->open(target); - } - }); - hack_target_button->setSize(GuiElement::GuiSizeMax, 50); - // Link probe to science button. - link_to_science_button = new GuiToggleButton(option_buttons, "LINK_TO_SCIENCE", tr("Link to Science"), [this](bool value){ - if (value) - { - my_spaceship->commandSetScienceLink(targets.get()); - } - else - { - my_spaceship->commandClearScienceLink(); - } - }); - link_to_science_button->setSize(GuiElement::GuiSizeMax, 50)->setVisible(my_spaceship && my_spaceship->getCanLaunchProbe()); + // Hack target + hack_target_button = new GuiButton(option_buttons, "HACK_TARGET", tr("Start hacking"), [this](){ + P target = targets.get(); + if (my_spaceship && target && target->canBeHackedBy(my_spaceship)) + { + hacking_dialog->open(target); + } + }); + hack_target_button->setSize(GuiElement::GuiSizeMax, 50); - // Manage waypoints. - (new GuiButton(option_buttons, "WAYPOINT_PLACE_BUTTON", tr("Place Waypoint"), [this]() { - mode = WaypointPlacement; - option_buttons->hide(); - }))->setSize(GuiElement::GuiSizeMax, 50); + // Link probe to science button. + link_to_science_button = new GuiToggleButton(option_buttons, "LINK_TO_SCIENCE", tr("Link to Science"), [this](bool value){ + if (value) + { + my_spaceship->commandSetScienceLink(targets.get()); + } + else + { + my_spaceship->commandClearScienceLink(); + } + }); + link_to_science_button->setSize(GuiElement::GuiSizeMax, 50)->setVisible(my_spaceship && my_spaceship->getCanLaunchProbe()); - delete_waypoint_button = new GuiButton(option_buttons, "WAYPOINT_DELETE_BUTTON", tr("Delete Waypoint"), [this]() { - if (my_spaceship && targets.getWaypointIndex() >= 0) - { - my_spaceship->commandRemoveWaypoint(targets.getWaypointIndex()); - } - }); - delete_waypoint_button->setSize(GuiElement::GuiSizeMax, 50); + // Manage waypoints. + (new GuiButton(option_buttons, "WAYPOINT_PLACE_BUTTON", tr("Place Waypoint"), [this]() { + mode = WaypointPlacement; + option_buttons->hide(); + }))->setSize(GuiElement::GuiSizeMax, 50); - // Launch probe button. - launch_probe_button = new GuiButton(option_buttons, "LAUNCH_PROBE_BUTTON", tr("Launch Probe"), [this]() { - mode = LaunchProbe; - option_buttons->hide(); - }); - launch_probe_button->setSize(GuiElement::GuiSizeMax, 50)->setVisible(my_spaceship && my_spaceship->getCanLaunchProbe()); + delete_waypoint_button = new GuiButton(option_buttons, "WAYPOINT_DELETE_BUTTON", tr("Delete Waypoint"), [this]() { + if (my_spaceship && targets.getWaypointIndex() >= 0) + { + my_spaceship->commandRemoveWaypoint(targets.getWaypointIndex()); + } + }); + delete_waypoint_button->setSize(GuiElement::GuiSizeMax, 50); + + // Launch probe button. + launch_probe_button = new GuiButton(option_buttons, "LAUNCH_PROBE_BUTTON", tr("Launch Probe"), [this]() { + mode = LaunchProbe; + option_buttons->hide(); + }); + launch_probe_button->setSize(GuiElement::GuiSizeMax, 50)->setVisible(my_spaceship && my_spaceship->getCanLaunchProbe()); + } // Reputation display. info_reputation = new GuiKeyValueDisplay(option_buttons, "INFO_REPUTATION", 0.4f, tr("Reputation") + ":", ""); @@ -161,7 +163,7 @@ RelayScreen::RelayScreen(GuiContainer* owner, bool allow_comms) hacking_dialog = new GuiHackingDialog(this, ""); - if (allow_comms) + if (variant == Variant::relay) { new ShipsLog(this); (new GuiCommsOverlay(this))->setSize(GuiElement::GuiSizeMax, GuiElement::GuiSizeMax); @@ -263,46 +265,61 @@ void RelayScreen::onDraw(sp::RenderTarget& renderer) } } - if (probe && my_spaceship && probe->owner_id == my_spaceship->getMultiplayerId() && probe->canBeTargetedBy(my_spaceship)) - { - link_to_science_button->setValue(my_spaceship->linked_science_probe_id == probe->getMultiplayerId()); - link_to_science_button->enable(); - } - else + if (variant != Variant::captains_map) { - link_to_science_button->setValue(false); - link_to_science_button->disable(); + if (probe && my_spaceship && probe->owner_id == my_spaceship->getMultiplayerId() && probe->canBeTargetedBy(my_spaceship)) + { + link_to_science_button->setValue(my_spaceship->linked_science_probe_id == probe->getMultiplayerId()); + link_to_science_button->enable(); + } + else + { + link_to_science_button->setValue(false); + link_to_science_button->disable(); + } + if (my_spaceship && obj->canBeHackedBy(my_spaceship)) + { + hack_target_button->enable(); + }else{ + hack_target_button->disable(); + } } - if (my_spaceship && obj->canBeHackedBy(my_spaceship)) + }else{ + if (variant != Variant::captains_map) { - hack_target_button->enable(); - }else{ hack_target_button->disable(); + link_to_science_button->disable(); + link_to_science_button->setValue(false); } - }else{ - hack_target_button->disable(); - link_to_science_button->disable(); - link_to_science_button->setValue(false); info_callsign->setValue("-"); } if (my_spaceship) { - // Toggle ship capabilities. - launch_probe_button->setVisible(my_spaceship->getCanLaunchProbe()); - launch_probe_button->setEnable(my_spaceship->scan_probe_stock > 0); - link_to_science_button->setVisible(my_spaceship->getCanLaunchProbe()); - hack_target_button->setVisible(my_spaceship->getCanHack()); + if (variant != Variant::captains_map) + { + // Toggle ship capabilities. + launch_probe_button->setVisible(my_spaceship->getCanLaunchProbe()); + launch_probe_button->setEnable(my_spaceship->scan_probe_stock > 0); + link_to_science_button->setVisible(my_spaceship->getCanLaunchProbe()); + hack_target_button->setVisible(my_spaceship->getCanHack()); + } info_reputation->setValue(string(my_spaceship->getReputationPoints(), 0)); // Update mission clock info_clock->setValue(gameGlobalInfo->getMissionTime()); - launch_probe_button->setText(tr("Launch Probe") + " (" + string(my_spaceship->scan_probe_stock) + ")"); + if (variant != Variant::captains_map) + { + launch_probe_button->setText(tr("Launch Probe") + " (" + string(my_spaceship->scan_probe_stock) + ")"); + } } - if (targets.getWaypointIndex() >= 0) - delete_waypoint_button->enable(); - else - delete_waypoint_button->disable(); + if (variant != Variant::captains_map) + { + if (targets.getWaypointIndex() >= 0) + delete_waypoint_button->enable(); + else + delete_waypoint_button->disable(); + } } diff --git a/src/screens/crew6/relayScreen.h b/src/screens/crew6/relayScreen.h index ce78ad89ee..9aff8b0915 100644 --- a/src/screens/crew6/relayScreen.h +++ b/src/screens/crew6/relayScreen.h @@ -14,6 +14,14 @@ class GuiHackingDialog; class RelayScreen : public GuiOverlay { +public: + enum class Variant + { + relay, + stategic_map, + captains_map + }; + private: enum EMode { @@ -45,8 +53,11 @@ class RelayScreen : public GuiOverlay GuiHackingDialog* hacking_dialog; glm::vec2 mouse_down_position{}; + + Variant variant; + public: - RelayScreen(GuiContainer* owner, bool allow_comms); + RelayScreen(GuiContainer* owner, Variant variant); virtual void onDraw(sp::RenderTarget& target) override; }; diff --git a/src/tutorialGame.cpp b/src/tutorialGame.cpp index d30468acc0..c0a649eebf 100644 --- a/src/tutorialGame.cpp +++ b/src/tutorialGame.cpp @@ -84,7 +84,7 @@ void TutorialGame::createScreens() station_screen[1] = new WeaponsScreen(this); station_screen[2] = new EngineeringScreen(this); station_screen[3] = new ScienceScreen(this); - station_screen[4] = new RelayScreen(this, true); + station_screen[4] = new RelayScreen(this, RelayScreen::Variant::relay); station_screen[5] = new TacticalScreen(this); station_screen[6] = new EngineeringAdvancedScreen(this); station_screen[7] = new OperationScreen(this);