Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/playerInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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<max_crew_positions; n++)
Expand Down Expand Up @@ -265,6 +267,7 @@ string getCrewPositionName(ECrewPosition position)
case altRelay: return tr("station","Strategic Map");
case commsOnly: return tr("station","Comms");
case shipLog: return tr("station","Ship's Log");
case captainsMap: return tr("station","Captains Map");
default: return "ErrUnk: " + string(position);
}
}
Expand All @@ -288,6 +291,7 @@ string getCrewPositionIcon(ECrewPosition position)
case altRelay: return "";
case commsOnly: return "";
case shipLog: return "";
case captainsMap: return "";
default: return "ErrUnk: " + string(position);
}
}
Expand Down Expand Up @@ -334,6 +338,8 @@ template<> void convert<ECrewPosition>::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());
}
1 change: 1 addition & 0 deletions src/playerInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ enum ECrewPosition
altRelay,
commsOnly,
shipLog,
captainsMap,
max_crew_positions
};

Expand Down
163 changes: 90 additions & 73 deletions src/screens/crew6/relayScreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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<SpaceObject> 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<SpaceObject> 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") + ":", "");
Expand All @@ -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);
Expand Down Expand Up @@ -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();
}
}
13 changes: 12 additions & 1 deletion src/screens/crew6/relayScreen.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@ class GuiHackingDialog;

class RelayScreen : public GuiOverlay
{
public:
enum class Variant
{
relay,
stategic_map,
captains_map
};

private:
enum EMode
{
Expand Down Expand Up @@ -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;
};
Expand Down
2 changes: 1 addition & 1 deletion src/tutorialGame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down