summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Athay <ko2fan@gmail.com>2008-07-04 17:02:03 +0000
committerDavid Athay <ko2fan@gmail.com>2008-07-04 17:02:03 +0000
commit6423c8eda76babaa50c13525b0deb7df5f2d24bd (patch)
tree6a44f0fde271ad739a5d2f1521b86445bd99d0e8
parentd22c6843a9b9f06a0f9e05bed268bfab90b75031 (diff)
downloadmana-client-6423c8eda76babaa50c13525b0deb7df5f2d24bd.tar.gz
mana-client-6423c8eda76babaa50c13525b0deb7df5f2d24bd.tar.bz2
mana-client-6423c8eda76babaa50c13525b0deb7df5f2d24bd.tar.xz
mana-client-6423c8eda76babaa50c13525b0deb7df5f2d24bd.zip
Ugly hack for chat scrolling.
-rw-r--r--ChangeLog4
-rw-r--r--src/gui/chat.cpp27
-rw-r--r--src/gui/chat.h12
3 files changed, 34 insertions, 9 deletions
diff --git a/ChangeLog b/ChangeLog
index 46e5f4f5..c7722355 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2008-07-04 David Athay <ko2fan@gmail.com>
+
+ * src/gui/chat.cpp, src/gui/chat.h: Ugly hack for chat scrolling.
+
2008-07-03 David Athay <ko2fan@gmail.com>
* src/game.cpp, src/gui/window.cpp: Fix guild window focus and fix crash
diff --git a/src/gui/chat.cpp b/src/gui/chat.cpp
index ba9ef8ee..ad5e0c9b 100644
--- a/src/gui/chat.cpp
+++ b/src/gui/chat.cpp
@@ -71,6 +71,7 @@ ChatWindow::ChatWindow():
scrollArea->getFrameSize(), scrollArea->getFrameSize());
scrollArea->setScrollPolicy(
gcn::ScrollArea::SHOW_NEVER, gcn::ScrollArea::SHOW_ALWAYS);
+ scrollArea->setScrollAmount(0, 1);
scrollArea->setOpaque(false);
mChatTabs = new TabbedArea();
@@ -123,7 +124,24 @@ void ChatWindow::widgetResized(const gcn::Event &event)
mChatTabs->setWidth(area.width - 2 * mChatTabs->getFrameSize());
mChatTabs->setHeight(area.height - 2 * mChatTabs->getFrameSize());
- const std::string &channelName = mChatTabs->getSelectedTab()->getCaption();
+ const std::string &channelName = getFocused();
+ ChannelMap::const_iterator chan = mChannels.find(channelName);
+ if (chan != mChannels.end()) {
+ ScrollArea *scroll = chan->second.scroll;
+ scroll->setWidth(area.width - 2 * scroll->getFrameSize());
+ scroll->setHeight(area.height - 2 * scroll->getFrameSize() -
+ mChatInput->getHeight() - 5);
+ scroll->logic();
+ }
+}
+
+void ChatWindow::logic()
+{
+ Window::logic();
+
+ const gcn::Rectangle area = getChildrenArea();
+
+ const std::string &channelName = getFocused();
ChannelMap::const_iterator chan = mChannels.find(channelName);
if (chan != mChannels.end()) {
ScrollArea *scroll = chan->second.scroll;
@@ -139,7 +157,7 @@ ChatWindow::chatLog(std::string line, int own, std::string channelName)
{
if(channelName == "getFocused\"")
channelName = getFocused();
-
+
ChannelMap::const_iterator chan = mChannels.find(channelName);
if (chan == mChannels.end())
return;
@@ -210,7 +228,7 @@ ChatWindow::chatLog(std::string line, int own, std::string channelName)
// We look if the Vertical Scroll Bar is set at the max before
// adding a row, otherwise the max will always be a row higher
// at comparison.
- if (scroll->getVerticalScrollAmount() == scroll->getVerticalMaxScroll())
+ if (scroll->getVerticalScrollAmount() >= scroll->getVerticalMaxScroll())
{
output->addRow(line);
scroll->setVerticalScrollAmount(scroll->getVerticalMaxScroll());
@@ -289,7 +307,7 @@ void ChatWindow::chatSend(std::string const &msg)
if (msg.empty()) return;
// Prepare ordinary message
- if (msg[0] != '/')
+ if (msg[0] != '/')
{
if (getFocused() == "General")
{
@@ -330,6 +348,7 @@ ChatWindow::removeChannel(Channel *channel)
Tab *tab = mChatTabs->getTab(channel->getName());
if (!tab)
return;
+ clearTab(channel->getName());
mChatTabs->removeTab(tab);
mChannels.erase(channel->getName());
channelManager->removeChannel(channel);
diff --git a/src/gui/chat.h b/src/gui/chat.h
index a999f8fc..e0e61ce5 100644
--- a/src/gui/chat.h
+++ b/src/gui/chat.h
@@ -75,12 +75,12 @@ class ChatWindow : public Window,
* the tabbed area.
*/
void widgetResized(const gcn::Event &event);
-
+
/**
* Gets the focused tab's name
*/
const std::string& getFocused() const;
-
+
/**
* Clear the tab with the given name
*/
@@ -93,8 +93,8 @@ class ChatWindow : public Window,
* @param own Type of message (usually the owner-type).
* @param channelName which channel to send the message to.
*/
- void chatLog(std::string line,
- int own = BY_SERVER,
+ void chatLog(std::string line,
+ int own = BY_SERVER,
std::string channelName = "getFocused\"");
/**
@@ -116,7 +116,7 @@ class ChatWindow : public Window,
* Determines whether the message is a command or message, then
* sends the given message to the game server to be said, or to the
* command handler
- *
+ *
* @param msg The message text which is to be sent.
*
*/
@@ -156,6 +156,8 @@ class ChatWindow : public Window,
bool
tabExists(const std::string &tabName);
+ void logic();
+
private:
bool mTmpVisible;