summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJared Adams <jaxad0127@gmail.com>2009-03-28 07:55:54 -0600
committerJared Adams <jaxad0127@gmail.com>2009-03-28 07:55:54 -0600
commitef2e1bafa7c5f19b0353e0bf01a7ad9d7f8cddf5 (patch)
treebe4372c79a990a4864fcc2567463199794221410 /src
parent91da5b104a0895578a0a2a7debbfb495e50ef4f4 (diff)
downloadmana-ef2e1bafa7c5f19b0353e0bf01a7ad9d7f8cddf5.tar.gz
mana-ef2e1bafa7c5f19b0353e0bf01a7ad9d7f8cddf5.tar.bz2
mana-ef2e1bafa7c5f19b0353e0bf01a7ad9d7f8cddf5.tar.xz
mana-ef2e1bafa7c5f19b0353e0bf01a7ad9d7f8cddf5.zip
Allow changing chat tabs with the keyboard
Defaults to: [ for previous tab ] for next tab
Diffstat (limited to 'src')
-rw-r--r--src/game.cpp11
-rw-r--r--src/gui/chat.cpp22
-rw-r--r--src/gui/chat.h10
-rw-r--r--src/keyboardconfig.cpp2
-rw-r--r--src/keyboardconfig.h2
5 files changed, 47 insertions, 0 deletions
diff --git a/src/game.cpp b/src/game.cpp
index ba756df3..2dc62b05 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -722,6 +722,17 @@ void Game::handleInput()
used = true;
}
+ if (keyboard.isKeyActive(keyboard.KEY_PREV_CHAT_TAB))
+ {
+ chatWindow->prevTab();
+ return;
+ }
+ else if (keyboard.isKeyActive(keyboard.KEY_NEXT_CHAT_TAB))
+ {
+ chatWindow->nextTab();
+ return;
+ }
+
const int tKey = keyboard.getKeyIndex(event.key.keysym.sym);
switch (tKey)
{
diff --git a/src/gui/chat.cpp b/src/gui/chat.cpp
index 987de11e..398b5792 100644
--- a/src/gui/chat.cpp
+++ b/src/gui/chat.cpp
@@ -159,6 +159,28 @@ void ChatWindow::clearTab()
clearTab(getFocused());
}
+void ChatWindow::prevTab()
+{
+ int tab = mChatTabs->getSelectedTabIndex();
+
+ if (tab == 0)
+ tab = mChatTabs->getNumberOfTabs();
+ tab--;
+
+ mChatTabs->setSelectedTab(tab);
+}
+
+void ChatWindow::nextTab()
+{
+ int tab = mChatTabs->getSelectedTabIndex();
+
+ tab++;
+ if (tab == mChatTabs->getNumberOfTabs())
+ tab = 0;
+
+ mChatTabs->setSelectedTab(tab);
+}
+
void ChatWindow::action(const gcn::ActionEvent &event)
{
if (event.getId() == "chatinput")
diff --git a/src/gui/chat.h b/src/gui/chat.h
index 54270055..3a2f7fdb 100644
--- a/src/gui/chat.h
+++ b/src/gui/chat.h
@@ -103,6 +103,16 @@ class ChatWindow : public Window,
void clearTab();
/**
+ * Switch to the previous tab in order
+ */
+ void prevTab();
+
+ /**
+ * Switch to the next tab in order
+ */
+ void nextTab();
+
+ /**
* Performs action.
*/
void action(const gcn::ActionEvent &event);
diff --git a/src/keyboardconfig.cpp b/src/keyboardconfig.cpp
index 06ce4ac7..e13af147 100644
--- a/src/keyboardconfig.cpp
+++ b/src/keyboardconfig.cpp
@@ -94,6 +94,8 @@ static KeyData const keyData[KeyboardConfig::KEY_TOTAL] = {
{"keyChat", SDLK_RETURN, _("Toggle Chat")},
{"keyChatScrollUp", SDLK_PAGEUP, _("Scroll Chat Up")},
{"keyChatScrollDown", SDLK_PAGEDOWN, _("Scroll Chat Down")},
+ {"keyChatPrevTab", SDLK_LEFTBRACKET, _("Previous Chat Tab")},
+ {"keyChatNextTab", SDLK_RIGHTBRACKET, _("Next Chat Tab")},
{"keyOK", SDLK_RETURN, _("Select OK")},
{"keyQuit", SDLK_ESCAPE, _("Quit")},
{"keyIgnoreInput1", SDLK_LSUPER, _("Ignore input 1")},
diff --git a/src/keyboardconfig.h b/src/keyboardconfig.h
index f7750b30..ecbe5de5 100644
--- a/src/keyboardconfig.h
+++ b/src/keyboardconfig.h
@@ -205,6 +205,8 @@ class KeyboardConfig
KEY_TOGGLE_CHAT,
KEY_SCROLL_CHAT_UP,
KEY_SCROLL_CHAT_DOWN,
+ KEY_PREV_CHAT_TAB,
+ KEY_NEXT_CHAT_TAB,
KEY_OK,
KEY_QUIT,
KEY_IGNORE_INPUT_1,