Skip to content

Commit

Permalink
Explain and clarify the keybinding menu (#2048)
Browse files Browse the repository at this point in the history
* Clarify that bindings are for joysticks as well

* Explain the input bindings

---------

Co-authored-by: aBlueShadow <falter@mxdreamer>
  • Loading branch information
aBlueShadow and aBlueShadow authored Mar 14, 2024
1 parent 84c05bd commit 3fd25c5
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 6 deletions.
3 changes: 2 additions & 1 deletion src/gui/hotkeyBinder.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include <i18n.h>
#include "engine.h"
#include "hotkeyConfig.h"
#include "hotkeyBinder.h"
Expand Down Expand Up @@ -32,6 +33,6 @@ void GuiHotkeyBinder::onDraw(sp::RenderTarget& renderer)
for(int n=1; key->getKeyType(n) != sp::io::Keybinding::Type::None; n++)
text += "," + key->getHumanReadableKeyName(n);
if (key->isUserRebinding())
text = "[Press new key]";
text = tr("[New input]");
renderer.drawText(sp::Rect(rect.position.x + 16, rect.position.y, rect.size.x, rect.size.y), text, sp::Alignment::CenterLeft, front.size, front.font, front.color);
}
8 changes: 5 additions & 3 deletions src/menus/hotkeyMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,23 @@ HotkeyMenu::HotkeyMenu()

// TODO: Figure out how to make this an AutoLayout.
container = new GuiElement(this, "HOTKEY_CONFIG_CONTAINER");
container->setSize(GuiElement::GuiSizeMax, GuiElement::GuiSizeMax)->setPosition(0, 0, sp::Alignment::TopLeft)->setMargins(FRAME_MARGIN);
container->setSize(GuiElement::GuiSizeMax, GuiElement::GuiSizeMax)->setPosition(0, 0, sp::Alignment::TopLeft)->setMargins(FRAME_MARGIN / 2);

top_row = new GuiElement(container, "TOP_ROW_CONTAINER");
top_row->setSize(GuiElement::GuiSizeMax, ROW_HEIGHT)->setPosition(0, 0, sp::Alignment::TopLeft);

rebinding_ui = new GuiPanel(container, "REBINDING_UI_CONTAINER");
rebinding_ui->setSize(GuiElement::GuiSizeMax, KEY_COLUMN_HEIGHT)->setPosition(0, KEY_COLUMN_TOP, sp::Alignment::TopLeft);

info_container = new GuiElement(container, "info_container_CONTAINER");
info_container->setSize(GuiElement::GuiSizeMax, ROW_HEIGHT)->setPosition(0, KEY_COLUMN_TOP+KEY_COLUMN_HEIGHT, sp::Alignment::TopLeft);
bottom_row = new GuiElement(container, "BOTTOM_ROW_CONTAINER");
bottom_row->setSize(GuiElement::GuiSizeMax, ROW_HEIGHT)->setPosition(0, 0, sp::Alignment::BottomLeft);

// Single-column layout
// Top: Title and category navigation

// Title label
(new GuiLabel(top_row, "CONFIGURE_KEYBOARD_LABEL", tr("Configure Keyboard"), 30))->addBackground()->setPosition(0, 0, sp::Alignment::TopLeft)->setSize(300, GuiElement::GuiSizeMax);
(new GuiLabel(top_row, "CONFIGURE_KEYBOARD_LABEL", tr("Configure Keyboard/Joystick"), 30))->addBackground()->setPosition(0, 0, sp::Alignment::TopLeft)->setSize(350, GuiElement::GuiSizeMax);

// Category selector
// Get a list of hotkey categories
Expand Down Expand Up @@ -66,6 +67,7 @@ HotkeyMenu::HotkeyMenu()

// Bottom: Menu navigation
// Back button to return to the Options menu
(new GuiScrollText(info_container, "INFO_LABEL", tr("Left Click: Assign input. Middle Click: Add input. Right Click: Delete inputs.\nPossible inputs: Keyboard keys, joystick buttons, joystick axes.")))->setPosition(10, 0, sp::Alignment::TopCenter)->setSize(GuiElement::GuiSizeMax, ROW_HEIGHT*3);
(new GuiButton(bottom_row, "BACK", tr("button", "Back"), [this]()
{
// Close this menu, stop the music, and return to the main menu.
Expand Down
5 changes: 4 additions & 1 deletion src/menus/hotkeyMenu.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "gui/gui2_entrylist.h"
#include "gui/gui2_canvas.h"
#include "gui/gui2_scrollbar.h"
#include "gui/gui2_scrolltext.h"
#include "gui/hotkeyBinder.h"
#include "Updatable.h"

Expand All @@ -25,18 +26,20 @@ class HotkeyMenu : public GuiCanvas, public Updatable
const int KEY_LABEL_WIDTH = 375;
const int KEY_FIELD_WIDTH = 150;
const int KEY_LABEL_MARGIN = 25;
const int KEY_COLUMN_TOP = ROW_HEIGHT * 2;
const int KEY_COLUMN_TOP = ROW_HEIGHT * 1.5;
const int KEY_ROW_COUNT = 10;
const int KEY_COLUMN_WIDTH = KEY_LABEL_WIDTH + KEY_LABEL_MARGIN + KEY_FIELD_WIDTH;
const int KEY_COLUMN_HEIGHT = ROW_HEIGHT * KEY_ROW_COUNT + FRAME_MARGIN * 2;
const int PAGER_BREAKPOINT = KEY_COLUMN_WIDTH * 2 + FRAME_MARGIN * 2;

GuiScrollText* help_text;
GuiElement* container;
GuiElement* top_row;
GuiPanel* rebinding_ui;
GuiElement* bottom_row;

GuiElement* rebinding_container;
GuiElement* info_container;
std::vector<GuiElement*> rebinding_columns;
std::vector<GuiElement*> rebinding_rows;
std::vector<GuiHotkeyBinder*> text_entries;
Expand Down
2 changes: 1 addition & 1 deletion src/menus/optionsMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ OptionsMenu::OptionsMenu()
(new GuiLabel(interface_page, "CONTROL_OPTIONS_LABEL", tr("Control Options"), 30))->addBackground()->setSize(GuiElement::GuiSizeMax, 50)->layout.margin.top = 20;

// Keyboard config (hotkeys/keybindings)
(new GuiButton(interface_page, "CONFIGURE_KEYBOARD", tr("Configure Keyboard"), [this]()
(new GuiButton(interface_page, "CONFIGURE_KEYBOARD", tr("Configure Keyboard/Joystick"), [this]()
{
new HotkeyMenu();
destroy();
Expand Down

1 comment on commit 3fd25c5

@daid-tinyci
Copy link

@daid-tinyci daid-tinyci bot commented on 3fd25c5 Mar 17, 2024

Choose a reason for hiding this comment

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

TinyCI build failure:

[ninja -j 2 package] returned [1]:


[2/173] Building CXX object CMakeFiles/EE_GuiLIB.dir/src/gui/hotkeyConfig.cpp.o

FAILED: CMakeFiles/EE_GuiLIB.dir/src/gui/hotkeyConfig.cpp.o 

/usr/bin/c++  -I/data/tinyci_build/daid/EmptyEpsilon/src -I/data/tinyci_build/daid/EmptyEpsilon/_build_native/include -I/data/tinyci_build/daid/SeriousProton/src -I/data/tinyci_build/daid/EmptyEpsilon/_build_native/SeriousProton/include -I/data/tinyci_build/daid/SeriousProton/libs/Box2D/.. -I/data/tinyci_build/daid/SeriousProton/libs/glad -I/data/tinyci_build/daid/SeriousProton/libs/lua/.. -I/home/tinyci/builds/daid/EmptyEpsilon/_build_native/_deps/glm-src/glm/.. -I/data/tinyci_build/daid/SeriousProton/libs/freetype2/include -I/home/tinyci/builds/daid/EmptyEpsilon/_build_native/_deps/basis-src -I/data/tinyci_build/daid/SeriousProton/libs/libopus/include -I/home/tinyci/builds/daid/EmptyEpsilon/_build_native/_deps/meshoptimizer-src/src -isystem /usr/include/SDL2 -O2 -g -DNDEBUG -fdiagnostics-color -g1 -O3 -flto -funsafe-math-optimizations -Wall -Wextra -Woverloaded-virtual -Wdouble-promotion -Wsuggest-override -Werror=return-type -Wno-unused-parameter -Wno-unused-but-set-parameter -MD -MT CMakeFiles/EE_GuiLIB.dir/src/gui/hotkeyConfig.cpp.o -MF CMakeFiles/EE_GuiLIB.dir/src/gui/hotkeyConfig.cpp.o.d -o CMakeFiles/EE_GuiLIB.dir/src/gui/hotkeyConfig.cpp.o -c /data/tinyci_build/daid/EmptyEpsilon/src/gui/hotkeyConfig.cpp

In file included from /data/tinyci_build/daid/EmptyEpsilon/src/shipTemplate.h:13,

                 from /data/tinyci_build/daid/EmptyEpsilon/src/gui/hotkeyConfig.cpp:4:

/data/tinyci_build/daid/EmptyEpsilon/src/missileWeaponData.h:25:41: error: expected constructor, destructor, or type conversion before ‘;’ token

   25 | REGISTER_MULTIPLAYER_ENUM(EMissileSizes);

      |                                         ^

/data/tinyci_build/daid/EmptyEpsilon/src/shipTemplate.h:209:35: error: expected constructor, destructor, or type conversion before ‘;’ token

  209 | REGISTER_MULTIPLAYER_ENUM(ESystem);

      |                                   ^

[3/173] Building CXX object CMakeFiles/EE_GuiLIB.dir/src/gui/scriptError.cpp.o

FAILED: CMakeFiles/EE_GuiLIB.dir/src/gui/scriptError.cpp.o 

/usr/bin/c++  -I/data/tinyci_build/daid/EmptyEpsilon/src -I/data/tinyci_build/daid/EmptyEpsilon/_build_native/include -I/data/tinyci_build/daid/SeriousProton/src -I/data/tinyci_build/daid/EmptyEpsilon/_build_native/SeriousProton/include -I/data/tinyci_build/daid/SeriousProton/libs/Box2D/.. -I/data/tinyci_build/daid/SeriousProton/libs/glad -I/data/tinyci_build/daid/SeriousProton/libs/lua/.. -I/home/tinyci/builds/daid/EmptyEpsilon/_build_native/_deps/glm-src/glm/.. -I/data/tinyci_build/daid/SeriousProton/libs/freetype2/include -I/home/tinyci/builds/daid/EmptyEpsilon/_build_native/_deps/basis-src -I/data/tinyci_build/daid/SeriousProton/libs/libopus/include -I/home/tinyci/builds/daid/EmptyEpsilon/_build_native/_deps/meshoptimizer-src/src -isystem /usr/include/SDL2 -O2 -g -DNDEBUG -fdiagnostics-color -g1 -O3 -flto -funsafe-math-optimizations -Wall -Wextra -Woverloaded-virtual -Wdouble-promotion -Wsuggest-override -Werror=return-type -Wno-unused-parameter -Wno-unused-but-set-parameter -MD -MT CMakeFiles/EE_GuiLIB.dir/src/gui/scriptError.cpp.o -MF CMakeFiles/EE_GuiLIB.dir/src/gui/scriptError.cpp.o.d -o CMakeFiles/EE_GuiLIB.dir/src/gui/scriptError.cpp.o -c /data/tinyci_build/daid/EmptyEpsilon/src/gui/scriptError.cpp

/data/tinyci_build/daid/EmptyEpsilon/src/gui/scriptError.cpp: In member function ‘virtual void ScriptErrorRenderer::render(sp::RenderTarget&)’:

/data/tinyci_build/daid/EmptyEpsilon/src/gui/scriptError.cpp:13:7: error: ‘ScriptObject’ was not declared in this scope; did you mean ‘scriptBindObject’?

   13 |     P<ScriptObject> script = engine->getObject("scenario");

      |       ^~~~~~~~~~~~

      |       scriptBindObject

/data/tinyci_build/daid/EmptyEpsilon/src/gui/scriptError.cpp:13:19: error: template argument 1 is invalid

   13 |     P<ScriptObject> script = engine->getObject("scenario");

      |                   ^

/data/tinyci_build/daid/EmptyEpsilon/src/gui/scriptError.cpp:13:47: error: cannot convert ‘P<PObject>’ to ‘int’ in initialization

   13 |     P<ScriptObject> script = engine->getObject("scenario");

      |                              ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~

      |                                               |

      |                                               P<PObject>

/data/tinyci_build/daid/EmptyEpsilon/src/gui/scriptError.cpp:20:26: error: base operand of ‘->’ is not a pointer

   20 |     string error = script->getError();

      |                          ^~

ninja: build stopped: subcommand failed.

Please sign in to comment.