Add configurable key bindings for hotbar scrolling, and for changing volume.
This commit is contained in:
parent
45ab62d6a3
commit
07c17db114
|
@ -186,6 +186,26 @@ keymap_fastmove (Fast key) key KEY_KEY_J
|
|||
# See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3
|
||||
keymap_noclip (Noclip key) key KEY_KEY_H
|
||||
|
||||
# Key for selecting the next item in the hotbar.
|
||||
# See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3
|
||||
keymap_hotbar_next (Hotbar next key) key KEY_KEY_N
|
||||
|
||||
# Key for selecting the previous item in the hotbar.
|
||||
# See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3
|
||||
keymap_hotbar_previous (Hotbar previous key) key KEY_KEY_B
|
||||
|
||||
# Key for muting the game.
|
||||
# See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3
|
||||
keymap_mute (Mute key) key KEY_KEY_M
|
||||
|
||||
# Key for increasing the volume.
|
||||
# See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3
|
||||
keymap_increase_volume (Inc. volume key) key
|
||||
|
||||
# Key for decreasing the volume.
|
||||
# See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3
|
||||
keymap_decrease_volume (Dec. volume key) key
|
||||
|
||||
# Key for toggling autorun.
|
||||
# See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3
|
||||
keymap_autorun (Autorun key) key
|
||||
|
|
|
@ -186,6 +186,31 @@
|
|||
# type: key
|
||||
# keymap_noclip = KEY_KEY_H
|
||||
|
||||
# Key for selecting the next item in the hotbar.
|
||||
# See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3
|
||||
# type: key
|
||||
# keymap_hotbar_next = KEY_KEY_N
|
||||
|
||||
# Key for selecting the previous item in the hotbar.
|
||||
# See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3
|
||||
# type: key
|
||||
# keymap_hotbar_previous = KEY_KEY_B
|
||||
|
||||
# Key for muting the game.
|
||||
# See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3
|
||||
# type: key
|
||||
# keymap_mute = KEY_KEY_M
|
||||
|
||||
# Key for increasing the volume.
|
||||
# See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3
|
||||
# type: key
|
||||
# keymap_increase_volume =
|
||||
|
||||
# Key for decreasing the volume.
|
||||
# See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3
|
||||
# type: key
|
||||
# keymap_decrease_volume =
|
||||
|
||||
# Key for toggling autorun.
|
||||
# See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3
|
||||
# type: key
|
||||
|
|
|
@ -50,6 +50,11 @@ public:
|
|||
FREEMOVE,
|
||||
FASTMOVE,
|
||||
NOCLIP,
|
||||
HOTBAR_PREV,
|
||||
HOTBAR_NEXT,
|
||||
MUTE,
|
||||
INC_VOLUME,
|
||||
DEC_VOLUME,
|
||||
CINEMATIC,
|
||||
SCREENSHOT,
|
||||
TOGGLE_HUD,
|
||||
|
|
|
@ -80,6 +80,11 @@ void set_default_settings(Settings *settings)
|
|||
settings->setDefault("keymap_freemove", "KEY_KEY_K");
|
||||
settings->setDefault("keymap_fastmove", "KEY_KEY_J");
|
||||
settings->setDefault("keymap_noclip", "KEY_KEY_H");
|
||||
settings->setDefault("keymap_hotbar_next", "KEY_KEY_N");
|
||||
settings->setDefault("keymap_hotbar_previous", "KEY_KEY_B");
|
||||
settings->setDefault("keymap_mute", "KEY_KEY_M");
|
||||
settings->setDefault("keymap_increase_volume", "");
|
||||
settings->setDefault("keymap_decrease_volume", "");
|
||||
settings->setDefault("keymap_cinematic", "");
|
||||
settings->setDefault("keymap_toggle_hud", "KEY_F1");
|
||||
settings->setDefault("keymap_toggle_chat", "KEY_F2");
|
||||
|
|
35
src/game.cpp
35
src/game.cpp
|
@ -1049,6 +1049,11 @@ void KeyCache::populate()
|
|||
key[KeyType::FREEMOVE] = getKeySetting("keymap_freemove");
|
||||
key[KeyType::FASTMOVE] = getKeySetting("keymap_fastmove");
|
||||
key[KeyType::NOCLIP] = getKeySetting("keymap_noclip");
|
||||
key[KeyType::HOTBAR_PREV] = getKeySetting("keymap_hotbar_previous");
|
||||
key[KeyType::HOTBAR_NEXT] = getKeySetting("keymap_hotbar_next");
|
||||
key[KeyType::MUTE] = getKeySetting("keymap_mute");
|
||||
key[KeyType::INC_VOLUME] = getKeySetting("keymap_increase_volume");
|
||||
key[KeyType::DEC_VOLUME] = getKeySetting("keymap_decrease_volume");
|
||||
key[KeyType::CINEMATIC] = getKeySetting("keymap_cinematic");
|
||||
key[KeyType::SCREENSHOT] = getKeySetting("keymap_screenshot");
|
||||
key[KeyType::TOGGLE_HUD] = getKeySetting("keymap_toggle_hud");
|
||||
|
@ -2493,6 +2498,30 @@ void Game::processKeyInput()
|
|||
toggleFast();
|
||||
} else if (wasKeyDown(KeyType::NOCLIP)) {
|
||||
toggleNoClip();
|
||||
} else if (wasKeyDown(KeyType::MUTE)) {
|
||||
float volume = g_settings->getFloat("sound_volume");
|
||||
if (volume < 0.001f) {
|
||||
g_settings->setFloat("sound_volume", 1.0f);
|
||||
m_statustext = narrow_to_wide(gettext("Volume changed to 100%"));
|
||||
} else {
|
||||
g_settings->setFloat("sound_volume", 0.0f);
|
||||
m_statustext = narrow_to_wide(gettext("Volume changed to 0%"));
|
||||
}
|
||||
runData.statustext_time = 0;
|
||||
} else if (wasKeyDown(KeyType::INC_VOLUME)) {
|
||||
float new_volume = rangelim(g_settings->getFloat("sound_volume") + 0.1f, 0.0f, 1.0f);
|
||||
char buf[100];
|
||||
g_settings->setFloat("sound_volume", new_volume);
|
||||
snprintf(buf, sizeof(buf), gettext("Volume changed to %d%%"), myround(new_volume * 100));
|
||||
m_statustext = narrow_to_wide(buf);
|
||||
runData.statustext_time = 0;
|
||||
} else if (wasKeyDown(KeyType::DEC_VOLUME)) {
|
||||
float new_volume = rangelim(g_settings->getFloat("sound_volume") - 0.1f, 0.0f, 1.0f);
|
||||
char buf[100];
|
||||
g_settings->setFloat("sound_volume", new_volume);
|
||||
snprintf(buf, sizeof(buf), gettext("Volume changed to %d%%"), myround(new_volume * 100));
|
||||
m_statustext = narrow_to_wide(buf);
|
||||
runData.statustext_time = 0;
|
||||
} else if (wasKeyDown(KeyType::CINEMATIC)) {
|
||||
toggleCinematic();
|
||||
} else if (wasKeyDown(KeyType::SCREENSHOT)) {
|
||||
|
@ -2560,11 +2589,13 @@ void Game::processItemSelection(u16 *new_playeritem)
|
|||
|
||||
s32 dir = wheel;
|
||||
|
||||
if (input->joystick.wasKeyDown(KeyType::SCROLL_DOWN)) {
|
||||
if (input->joystick.wasKeyDown(KeyType::SCROLL_DOWN) ||
|
||||
wasKeyDown(KeyType::HOTBAR_NEXT)) {
|
||||
dir = -1;
|
||||
}
|
||||
|
||||
if (input->joystick.wasKeyDown(KeyType::SCROLL_UP)) {
|
||||
if (input->joystick.wasKeyDown(KeyType::SCROLL_UP) ||
|
||||
wasKeyDown(KeyType::HOTBAR_PREV)) {
|
||||
dir = 1;
|
||||
}
|
||||
|
||||
|
|
|
@ -58,6 +58,11 @@ enum
|
|||
GUI_ID_KEY_SNEAK_BUTTON,
|
||||
GUI_ID_KEY_DROP_BUTTON,
|
||||
GUI_ID_KEY_INVENTORY_BUTTON,
|
||||
GUI_ID_KEY_HOTBAR_PREV_BUTTON,
|
||||
GUI_ID_KEY_HOTBAR_NEXT_BUTTON,
|
||||
GUI_ID_KEY_MUTE_BUTTON,
|
||||
GUI_ID_KEY_DEC_VOLUME_BUTTON,
|
||||
GUI_ID_KEY_INC_VOLUME_BUTTON,
|
||||
GUI_ID_KEY_DUMP_BUTTON,
|
||||
GUI_ID_KEY_RANGE_BUTTON,
|
||||
GUI_ID_KEY_ZOOM_BUTTON,
|
||||
|
@ -109,7 +114,7 @@ void GUIKeyChangeMenu::removeChildren()
|
|||
void GUIKeyChangeMenu::regenerateGui(v2u32 screensize)
|
||||
{
|
||||
removeChildren();
|
||||
v2s32 size(620, 430);
|
||||
v2s32 size(745, 430);
|
||||
|
||||
core::rect < s32 > rect(screensize.X / 2 - size.X / 2,
|
||||
screensize.Y / 2 - size.Y / 2, screensize.X / 2 + size.X / 2,
|
||||
|
@ -146,16 +151,18 @@ void GUIKeyChangeMenu::regenerateGui(v2u32 screensize)
|
|||
|
||||
{
|
||||
core::rect < s32 > rect(0, 0, 100, 30);
|
||||
rect += topleft + v2s32(offset.X + 115, offset.Y - 5);
|
||||
rect += topleft + v2s32(offset.X + 120, offset.Y - 5);
|
||||
const wchar_t *text = wgettext(k->key.name());
|
||||
k->button = Environment->addButton(rect, this, k->id, text);
|
||||
delete[] text;
|
||||
}
|
||||
if(i + 1 == KMaxButtonPerColumns)
|
||||
offset = v2s32(260, 60);
|
||||
else
|
||||
if ((i + 1) % KMaxButtonPerColumns == 0) {
|
||||
offset.X += 230;
|
||||
offset.Y = 60;
|
||||
} else {
|
||||
offset += v2s32(0, 25);
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
s32 option_x = offset.X;
|
||||
|
@ -215,7 +222,7 @@ void GUIKeyChangeMenu::drawMenu()
|
|||
video::SColor bgcolor(140, 0, 0, 0);
|
||||
|
||||
{
|
||||
core::rect < s32 > rect(0, 0, 620, 620);
|
||||
core::rect < s32 > rect(0, 0, 745, 620);
|
||||
rect += AbsoluteRect.UpperLeftCorner;
|
||||
driver->draw2DRectangle(bgcolor, rect, &AbsoluteClippingRect);
|
||||
}
|
||||
|
@ -407,6 +414,11 @@ void GUIKeyChangeMenu::init_keys()
|
|||
this->add_key(GUI_ID_KEY_SNEAK_BUTTON, wgettext("Sneak"), "keymap_sneak");
|
||||
this->add_key(GUI_ID_KEY_DROP_BUTTON, wgettext("Drop"), "keymap_drop");
|
||||
this->add_key(GUI_ID_KEY_INVENTORY_BUTTON, wgettext("Inventory"), "keymap_inventory");
|
||||
this->add_key(GUI_ID_KEY_HOTBAR_PREV_BUTTON,wgettext("Prev. item"), "keymap_hotbar_previous");
|
||||
this->add_key(GUI_ID_KEY_HOTBAR_NEXT_BUTTON,wgettext("Next item"), "keymap_hotbar_next");
|
||||
this->add_key(GUI_ID_KEY_MUTE_BUTTON, wgettext("Mute"), "keymap_mute");
|
||||
this->add_key(GUI_ID_KEY_DEC_VOLUME_BUTTON,wgettext("Dec. volume"), "keymap_decrease_volume");
|
||||
this->add_key(GUI_ID_KEY_INC_VOLUME_BUTTON,wgettext("Inc. volume"), "keymap_increase_volume");
|
||||
this->add_key(GUI_ID_KEY_CHAT_BUTTON, wgettext("Chat"), "keymap_chat");
|
||||
this->add_key(GUI_ID_KEY_CMD_BUTTON, wgettext("Command"), "keymap_cmd");
|
||||
this->add_key(GUI_ID_KEY_CMD_LOCAL_BUTTON, wgettext("Local command"), "keymap_cmd_local");
|
||||
|
|
|
@ -77,6 +77,16 @@ fake_function() {
|
|||
gettext("Key for toggling fast mode.\nSee http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3");
|
||||
gettext("Noclip key");
|
||||
gettext("Key for toggling noclip mode.\nSee http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3");
|
||||
gettext("Hotbar next key");
|
||||
gettext("Key for selecting the next item in the hotbar.\nSee http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3");
|
||||
gettext("Hotbar previous key");
|
||||
gettext("Key for selecting the previous item in the hotbar.\nSee http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3");
|
||||
gettext("Mute key");
|
||||
gettext("Key for muting the game.\nSee http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3");
|
||||
gettext("Inc. volume key");
|
||||
gettext("Key for increasing the volume.\nSee http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3");
|
||||
gettext("Dec. volume key");
|
||||
gettext("Key for decreasing the volume.\nSee http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3");
|
||||
gettext("Autorun key");
|
||||
gettext("Key for toggling autorun.\nSee http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3");
|
||||
gettext("Cinematic mode key");
|
||||
|
|
Loading…
Reference in New Issue