diff options
-rw-r--r-- | ChangeLog | 2 | ||||
-rw-r--r-- | src/game.cpp | 16 | ||||
-rw-r--r-- | src/gui/chat.cpp | 27 | ||||
-rw-r--r-- | src/gui/chat.h | 19 |
4 files changed, 54 insertions, 10 deletions
@@ -2,6 +2,8 @@ * src/game.cpp: Make F8 toggle shortcut window as suggested by And1 and fate. + * src/game.cpp, src/gui/chat.h, src/gui/chat.cpp: Allow page up and + page down to scroll the chat window, based on patch by fate. 2008-05-06 Dennis Friis <peavey@placid.dk> diff --git a/src/game.cpp b/src/game.cpp index 8096ada4..b12b114f 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -532,6 +532,22 @@ void Game::handleInput() } switch (event.key.keysym.sym) { + case SDLK_PAGEUP: + if (chatWindow->isVisible()) + { + chatWindow->scroll(-DEFAULT_CHAT_WINDOW_SCROLL); + used = true; + } + break; + + case SDLK_PAGEDOWN: + if (chatWindow->isVisible()) + { + chatWindow->scroll(DEFAULT_CHAT_WINDOW_SCROLL); + used = true; + } + break; + case SDLK_F1: // In-game Help if (helpWindow->isVisible()) diff --git a/src/gui/chat.cpp b/src/gui/chat.cpp index 8b53ef98..5e3aaf60 100644 --- a/src/gui/chat.cpp +++ b/src/gui/chat.cpp @@ -411,6 +411,19 @@ ChatWindow::const_msg(CHATSKILL act) } void +ChatWindow::scroll(int amount) +{ + if (!isVisible()) + return; + + int range = mScrollArea->getHeight() / 8 * amount; + gcn::Rectangle scr; + scr.y = mScrollArea->getVerticalScrollAmount() + range; + scr.height = abs(range); + mTextOutput->showPart(scr); +} + +void ChatWindow::keyPressed(gcn::KeyEvent &event) { if (event.getKey().getValue() == gcn::Key::DOWN && @@ -446,11 +459,13 @@ ChatWindow::setInputText(std::string input_str) void ChatWindow::setVisible(bool isVisible) { - Window::setVisible(isVisible); + Window::setVisible(isVisible); - /* - * For whatever reason, if setVisible is called, the mTmpVisible effect - * should be disabled. - */ - mTmpVisible = false; + /* + * For whatever reason, if setVisible is called, the mTmpVisible effect + * should be disabled. + */ + + mTmpVisible = false; } + diff --git a/src/gui/chat.h b/src/gui/chat.h index f2e018a6..0bdc76f1 100644 --- a/src/gui/chat.h +++ b/src/gui/chat.h @@ -44,7 +44,7 @@ class ScrollArea; #define BY_SERVER 3 #define ACT_WHISPER 4 // getting whispered at -#define ACT_IS 5 // equivalent to "/me" in irc +#define ACT_IS 5 // equivalent to "/me" on IRC #define BY_LOGGER 6 @@ -99,7 +99,9 @@ class ScrollArea; #define RFAIL_GENERIC 0x0a /** should always be zero if failed */ -#define SKILL_FAILED 0x00 +#define SKILL_FAILED 0x00 + +#define DEFAULT_CHAT_WINDOW_SCROLL 7 // 1 means `1/8th of the window size'. struct CHATSKILL { @@ -157,7 +159,7 @@ class ChatWindow : public Window, public gcn::ActionListener, */ bool isInputFocused(); - /* + /** * Determines whether to send a command or an ordinary message, then * contructs packets & sends them. * @@ -196,6 +198,16 @@ class ChatWindow : public Window, public gcn::ActionListener, void setVisible(bool visible); + /** + * Scrolls the chat window + * + * @param amount direction and amount to scroll. Negative numbers scroll + * up, positive numbers scroll down. The absolute amount indicates the + * amount of 1/8ths of chat window real estate that should be scrolled. + */ + void + scroll(int amount); + private: Network *mNetwork; bool mTmpVisible; @@ -224,4 +236,3 @@ class ChatWindow : public Window, public gcn::ActionListener, extern ChatWindow *chatWindow; #endif - |