Skip to content
Merged
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
23 changes: 23 additions & 0 deletions src/gui/hotkeyConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,24 @@ Keys::Keys() :
debug_show_colliders("DEBUG_SHOW_COLLIDERS", "F12"),
#endif

trigger_custom_button{{
{"TRIGGER_CUSTOM_BUTTON1"},
{"TRIGGER_CUSTOM_BUTTON2"},
{"TRIGGER_CUSTOM_BUTTON3"},
{"TRIGGER_CUSTOM_BUTTON4"},
{"TRIGGER_CUSTOM_BUTTON5"},
{"TRIGGER_CUSTOM_BUTTON6"},
{"TRIGGER_CUSTOM_BUTTON7"},
{"TRIGGER_CUSTOM_BUTTON8"},
{"TRIGGER_CUSTOM_BUTTON9"},
{"TRIGGER_CUSTOM_BUTTON10"},
{"TRIGGER_CUSTOM_BUTTON11"},
{"TRIGGER_CUSTOM_BUTTON12"},
{"TRIGGER_CUSTOM_BUTTON13"},
{"TRIGGER_CUSTOM_BUTTON14"},
{"TRIGGER_CUSTOM_BUTTON15"}
}},

// Crew screen binds
next_station("STATION_NEXT", "Tab"),
prev_station("STATION_PREVIOUS"),
Expand Down Expand Up @@ -341,6 +359,11 @@ void Keys::init()
debug_show_colliders.setLabel(tr("hotkey_menu", "General"), tr("hotkey_General", "Show debug colliders"));
#endif

for (auto n = 0u; n < trigger_custom_button.size(); n++)
{
trigger_custom_button[n].setLabel(tr("hotkey_menu", "General"), tr("hotkey_General", "Custom button slot {number}").format({{"number", string(n + 1)}}));
}

// Crew screens
next_station.setLabel(tr("hotkey_menu", "Crew screens"), tr("hotkey_CrewScreen", "Switch to next crew screen"));
prev_station.setLabel(tr("hotkey_menu", "Crew screens"), tr("hotkey_CrewScreen", "Switch to previous crew screen"));
Expand Down
1 change: 1 addition & 0 deletions src/gui/hotkeyConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class Keys
#ifdef DEBUG
sp::io::Keybinding debug_show_colliders;
#endif
std::array<sp::io::Keybinding, 15> trigger_custom_button;

// Crew screen binds
sp::io::Keybinding next_station;
Expand Down
6 changes: 6 additions & 0 deletions src/screenComponents/customShipFunctions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ void GuiCustomShipFunctions::onUpdate()
void GuiCustomShipFunctions::checkEntries()
{
auto csf = my_spaceship.getComponent<CustomShipFunctions>();
int slot_count=0;
if (!csf) return;

if (csf->functions.size() != entries.size())
Expand All @@ -43,6 +44,10 @@ void GuiCustomShipFunctions::checkEntries()
}
else if (csf->functions[n].type == CustomShipFunctions::Function::Type::Button)
{
if (keys.trigger_custom_button[slot_count].getDown()) {
my_player_info->commandCustomFunction(entries[n].name);
}
slot_count++;
GuiButton* button = dynamic_cast<GuiButton*>(entries[n].element);
if (!button)
{
Expand All @@ -58,6 +63,7 @@ void GuiCustomShipFunctions::checkEntries()
else if (csf->functions[n].type == CustomShipFunctions::Function::Type::Info)
{
GuiLabel* label = dynamic_cast<GuiLabel*>(entries[n].element);
slot_count++;
if (!label)
{
// ship data says this is a label but we have something else, rebuild the entries
Expand Down
Loading