Skip to content
4 changes: 4 additions & 0 deletions src/gui/gui2_togglebutton.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ bool GuiToggleButton::getValue() const
return value;
}

void GuiToggleButton::toggle() {
onClick(); // trigger the click event used to toggle probe view vie key.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

I don't like calling a handler from other code. Better to put the logic in the toggle function and call the toggle function from onClick.

}

GuiToggleButton* GuiToggleButton::setValue(bool value)
{
if (this->value == value)
Expand Down
1 change: 1 addition & 0 deletions src/gui/gui2_togglebutton.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class GuiToggleButton : public GuiButton

bool getValue() const;
GuiToggleButton* setValue(bool value);
void toggle();
private:
void onClick();
};
Expand Down
2 changes: 2 additions & 0 deletions src/gui/hotkeyConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@ Keys::Keys() :
// Science crew screen
science_scan_object("SCIENCE_SCAN_OBJECT", "S"),
science_scan_abort("SCIENCE_SCAN_ABORT", "D"),
science_toggle_probe_view("SCIENCE_TOGGLE_PROBE_VIEW"),
science_select_next_scannable("SCIENCE_SELECT_NEXT_SCANNABLE", "C"),
science_scan_param_increase{{
{"SCIENCE_SCAN_PARAM_INCREASE_1"},
Expand Down Expand Up @@ -459,6 +460,7 @@ void Keys::init()
// Science
science_scan_object.setLabel(tr("hotkey_menu", "Science"), tr("hotkey_Science", "Scan object"));
science_scan_abort.setLabel(tr("hotkey_menu", "Science"), tr("hotkey_Science", "Abort scan"));
science_toggle_probe_view.setLabel(tr("hotkey_menu", "Science"), tr("hotkey_Science", "Toggle probe view"));
science_select_next_scannable.setLabel(tr("hotkey_menu", "Science"), tr("hotkey_Science", "Select next scannable object"));
for (auto n = 0u; n < science_scan_param_increase.size(); n++)
{
Expand Down
1 change: 1 addition & 0 deletions src/gui/hotkeyConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ class Keys
sp::io::Keybinding science_scan_object;
sp::io::Keybinding science_scan_abort;
sp::io::Keybinding science_select_next_scannable;
sp::io::Keybinding science_toggle_probe_view;
std::array<sp::io::Keybinding, 4> science_scan_param_increase;
std::array<sp::io::Keybinding, 4> science_scan_param_decrease;
std::array<sp::io::Keybinding, 4> science_scan_param_set;
Expand Down
6 changes: 6 additions & 0 deletions src/screens/crew6/scienceScreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -549,6 +549,12 @@ void ScienceScreen::onUpdate()
{
if (my_spaceship)
{
// Toggle probe view from the Science hotkey.
auto rl = my_spaceship.getComponent<RadarLink>();
if (keys.science_toggle_probe_view.getDown() && rl && rl->linked_entity)
{
probe_view_button->toggle();
}
// Initiate a scan on scannable objects.
if (keys.science_scan_object.getDown() &&
my_spaceship.hasComponent<ScienceScanner>() &&
Expand Down
Loading