Skip to content

Commit

Permalink
[GameKey] 'BlockInfoToggle' key added.
Browse files Browse the repository at this point in the history
  • Loading branch information
Unarelith committed Jul 18, 2020
1 parent ea00d12 commit a2f79aa
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 18 deletions.
1 change: 1 addition & 0 deletions misc/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ cp /usr/lib/ld-linux-x86-64.so.2 \
/usr/lib/libXdmcp.so.6 \
/usr/lib/libzstd.so.1 \
deploy/linux64/bin/openminer/lib && \
strip deploy/linux64/bin/openminer/lib/*.so.* && \
echo -e "#!/bin/bash\n./lib/ld-linux-x86-64.so.2 --library-path lib ./bin/openminer \$*" > deploy/linux64/bin/openminer/openminer && \
echo -e "#!/bin/bash\n./lib/ld-linux-x86-64.so.2 --library-path lib ./bin/openminer_server \$*" > deploy/linux64/bin/openminer/openminer_server && \
chmod +x deploy/linux64/bin/openminer/openminer deploy/linux64/bin/openminer/openminer_server && \
Expand Down
24 changes: 13 additions & 11 deletions source/client/core/KeyboardHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,20 +35,22 @@
#include "KeyboardHandler.hpp"

KeyboardHandler::KeyboardHandler() {
addKey(GameKey::Left, "Left", SDLK_a);
addKey(GameKey::Right, "Right", SDLK_d);
addKey(GameKey::Forward, "Forward", SDLK_w);
addKey(GameKey::Back, "Back", SDLK_s);
addKey(GameKey::Left, "Left", SDLK_a);
addKey(GameKey::Right, "Right", SDLK_d);
addKey(GameKey::Forward, "Forward", SDLK_w);
addKey(GameKey::Back, "Back", SDLK_s);

addKey(GameKey::Jump, "Jump", SDLK_SPACE);
addKey(GameKey::Fly, "Fly", SDLK_x);
addKey(GameKey::Sneak, "Sneak", SDLK_LSHIFT);
addKey(GameKey::Sprint, "Sprint", SDLK_LCTRL);
addKey(GameKey::Jump, "Jump", SDLK_SPACE);
addKey(GameKey::Fly, "Fly", SDLK_x);
addKey(GameKey::Sneak, "Sneak", SDLK_LSHIFT);
addKey(GameKey::Sprint, "Sprint", SDLK_LCTRL);

addKey(GameKey::Chat, "Chat", SDLK_t);
addKey(GameKey::Command, "Command", SDLK_KP_DIVIDE);
addKey(GameKey::Chat, "Chat", SDLK_t);
addKey(GameKey::Command, "Command", SDLK_KP_DIVIDE);

addKey(GameKey::Shift, "Shift", SDLK_LSHIFT);
addKey(GameKey::Shift, "Shift", SDLK_LSHIFT);

addKey(GameKey::BlockInfoToggle, "Block info toggle", SDLK_p);
}

void KeyboardHandler::loadKeysFromFile(const std::string &filename) {
Expand Down
15 changes: 8 additions & 7 deletions source/client/states/GameState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,6 @@ void GameState::onEvent(const SDL_Event &event) {
else if (event.type == SDL_KEYDOWN && event.key.keysym.sym == SDLK_ESCAPE) {
m_stateStack->push<PauseMenuState>(m_client, this);
}
else if (event.type == SDL_KEYDOWN
&& (event.key.keysym.sym == keyboardHandler->getKeycode(GameKey::Chat)
|| event.key.keysym.sym == keyboardHandler->getKeycode(GameKey::Command)))
{
m_stateStack->push<ChatState>(m_clientCommandHandler, m_hud.chat(), event.key.keysym.sym == keyboardHandler->getKeycode(GameKey::Command), this);
}
else if (event.type == SDL_WINDOWEVENT) {
if (event.window.event == SDL_WINDOWEVENT_FOCUS_LOST) {
m_stateStack->push<PauseMenuState>(m_client, this);
Expand All @@ -121,7 +115,14 @@ void GameState::onEvent(const SDL_Event &event) {
}
}
else if (event.type == SDL_KEYDOWN) {
if (event.key.keysym.sym == SDLK_F2) {
if (event.key.keysym.sym == keyboardHandler->getKeycode(GameKey::Chat)
|| event.key.keysym.sym == keyboardHandler->getKeycode(GameKey::Command)) {
m_stateStack->push<ChatState>(m_clientCommandHandler, m_hud.chat(), event.key.keysym.sym == keyboardHandler->getKeycode(GameKey::Command), this);
}
else if (event.key.keysym.sym == keyboardHandler->getKeycode(GameKey::BlockInfoToggle)) {
Config::isBlockInfoWidgetEnabled = !Config::isBlockInfoWidgetEnabled;
}
else if (event.key.keysym.sym == SDLK_F2) {
std::time_t now = std::chrono::system_clock::to_time_t(std::chrono::system_clock::now());

char filename[100];
Expand Down
2 changes: 2 additions & 0 deletions source/common/core/input/GameKey.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ namespace GameKey {

Shift,

BlockInfoToggle,

KeyCount
};
}
Expand Down

0 comments on commit a2f79aa

Please sign in to comment.