summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog17
-rw-r--r--NEWS2
-rw-r--r--src/gui/chat.cpp83
-rw-r--r--src/gui/chat.h7
-rw-r--r--src/net/network.cpp6
5 files changed, 84 insertions, 31 deletions
diff --git a/ChangeLog b/ChangeLog
index a68612f7..64339565 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,11 +1,18 @@
+2005-12-30 Bjørn Lindeijer <bjorn@lindeijer.nl>
+
+ * src/gui/chat.cpp, src/gui/chat.h: Applied patch by pclouds to have
+ the chat window temporarily become visible when chatting while it is
+ hidden.
+
2005-12-30 Eugenio Favalli <elvenprogrammer@gmail.com>
* The Mana World.dev, data/graphics/sprites/items.png,
data/items.xml, src/Makefile.am, src/gui/char_select.cpp,
- src/gui/char_server.cpp, src/gui/login.cpp, src/gui/login.h, src/main.cpp,
- src/main.h, src/net/network.cpp, src/net/network.h, src/gui/register.cpp,
- src/gui/register.h: Added a new item, improved smooth login sequence,
- added a registration window (a lot of duplicated code to be removed).
+ src/gui/char_server.cpp, src/gui/login.cpp, src/gui/login.h,
+ src/main.cpp, src/main.h, src/net/network.cpp, src/net/network.h,
+ src/gui/register.cpp, src/gui/register.h: Added a new item, improved
+ smooth login sequence, added a registration window (a lot of
+ duplicated code to be removed).
2005-12-29 Eugenio Favalli <elvenprogrammer@gmail.com>
@@ -37,7 +44,7 @@
2005-12-26 Duane Bailey <nayryeliab@gmail.com>
- * src/main.h: fixed define problems with The_Mana_World_private.h
+ * src/main.h: Fixed define problems with The_Mana_World_private.h.
2005-12-25 Bjørn Lindeijer <bjorn@lindeijer.nl>
diff --git a/NEWS b/NEWS
index a971879b..db214bec 100644
--- a/NEWS
+++ b/NEWS
@@ -1,4 +1,4 @@
-0.0.18.1 (25 December 2005)
+0.0.18.1 (30 December 2005)
- Fixed a drawing glitch with high tiles at the bottom of the screen
- Fixed glitches caused by fading out the damage display
diff --git a/src/gui/chat.cpp b/src/gui/chat.cpp
index 731cc0d0..664ba5cd 100644
--- a/src/gui/chat.cpp
+++ b/src/gui/chat.cpp
@@ -42,7 +42,8 @@ extern Graphics *graphics;
#include "../net/protocol.h"
ChatWindow::ChatWindow(const std::string &logfile):
- Window("")
+ Window(""),
+ mTmpVisible(false)
{
setWindowName("Chat");
chatlog_file.open(logfile.c_str(), std::ios::out | std::ios::app);
@@ -81,7 +82,8 @@ ChatWindow::~ChatWindow()
chatlog_file.close();
}
-void ChatWindow::logic()
+void
+ChatWindow::logic()
{
chatInput->setPosition(
chatInput->getBorderSize(),
@@ -98,7 +100,8 @@ void ChatWindow::logic()
scrollArea->logic();
}
-void ChatWindow::chat_log(std::string line, int own)
+void
+ChatWindow::chat_log(std::string line, int own)
{
// Delete overhead from the end of the list
while ((int)chatlog.size() > items_keep) {
@@ -114,13 +117,13 @@ void ChatWindow::chat_log(std::string line, int own)
{
own = BY_SERVER;
}
-
+
int pos = line.find(" : ");
if (pos > 0) {
tmp.nick = line.substr(0, pos);
line.erase(0, pos + 3);
}
-
+
std::string lineColor = "##0"; // Equiv. to BrowserBox::BLACK
switch (own) {
case BY_GM:
@@ -148,21 +151,21 @@ void ChatWindow::chat_log(std::string line, int own)
lineColor = "##5"; // Equiv. to BrowserBox::YELLOW
break;
}
-
+
// Get the current system time
time_t t;
time(&t);
// Format the time string properly
std::stringstream timeStr;
- timeStr << "[";
- timeStr << ((((t / 60) / 60) % 24 < 10) ? "0" : "");
- timeStr << (int)(((t / 60) / 60) % 24);
- timeStr << ":";
- timeStr << (((t / 60) % 60 < 10) ? "0" : "");
- timeStr << (int)((t / 60) % 60);
- timeStr << "] ";
-
+ timeStr << "["
+ << ((((t / 60) / 60) % 24 < 10) ? "0" : "")
+ << (int)(((t / 60) / 60) % 24)
+ << ":"
+ << (((t / 60) % 60 < 10) ? "0" : "")
+ << (int)((t / 60) % 60)
+ << "] ";
+
line = lineColor + timeStr.str() + tmp.nick + line;
// We look if the Vertical Scroll Bar is set at the max before
@@ -179,12 +182,14 @@ void ChatWindow::chat_log(std::string line, int own)
}
}
-void ChatWindow::chat_log(CHATSKILL act)
+void
+ChatWindow::chat_log(CHATSKILL act)
{
chat_log(const_msg(act), BY_SERVER);
}
-void ChatWindow::action(const std::string& eventId)
+void
+ChatWindow::action(const std::string& eventId)
{
if (eventId == "chatinput")
{
@@ -208,17 +213,38 @@ void ChatWindow::action(const std::string& eventId)
// Remove focus and hide input
mFocusHandler->focusNone();
+
+ // If the chatWindow is shown up because you want to send a message
+ // It should hide now
+ if (mTmpVisible) {
+ setVisible(false);
+ }
}
}
-void ChatWindow::requestChatFocus()
+void
+ChatWindow::requestChatFocus()
{
+ // Make sure chatWindow is visible
+ if (!isVisible())
+ {
+ setVisible(true);
+
+ /*
+ * This is used to hide chatWindow after sending the message. There is
+ * a trick here, because setVisible will set mTmpVisible to false, you
+ * have to put this sentence *after* setVisible, not before it
+ */
+ mTmpVisible = true;
+ }
+
// Give focus to the chat input
chatInput->setVisible(true);
chatInput->requestFocus();
}
-bool ChatWindow::isFocused()
+bool
+ChatWindow::isFocused()
{
return chatInput->hasFocus();
}
@@ -252,7 +278,8 @@ ChatWindow::chat_send(std::string nick, std::string msg)
outMsg.writeString(msg, msg.length());
}
-std::string ChatWindow::const_msg(CHATSKILL act)
+std::string
+ChatWindow::const_msg(CHATSKILL act)
{
std::string msg;
if (act.success == SKILL_FAILED && act.skill == SKILL_BASIC) {
@@ -329,7 +356,8 @@ std::string ChatWindow::const_msg(CHATSKILL act)
return msg;
}
-void ChatWindow::keyPress(const gcn::Key &key)
+void
+ChatWindow::keyPress(const gcn::Key &key)
{
if (key.getValue() == key.DOWN && curHist != history.end())
{
@@ -353,8 +381,21 @@ void ChatWindow::keyPress(const gcn::Key &key)
}
}
-void ChatWindow::setInputText(std::string input_str)
+void
+ChatWindow::setInputText(std::string input_str)
{
chatInput->setText(input_str + " ");
requestChatFocus();
}
+
+void
+ChatWindow::setVisible(bool isVisible)
+{
+ Widget::setVisible(isVisible);
+
+ /*
+ * 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 e648eda5..a4547d86 100644
--- a/src/gui/chat.h
+++ b/src/gui/chat.h
@@ -185,11 +185,16 @@ class ChatWindow : public Window, public gcn::ActionListener,
/** Called to set current text */
void setInputText(std::string input_str);
+ /** Override to reset mTmpVisible */
+ void setVisible(bool visible);
+
private:
std::ofstream chatlog_file;
+ bool mTmpVisible;
/** One item in the chat log */
- typedef struct CHATLOG {
+ typedef struct CHATLOG
+ {
std::string nick;
std::string text;
int own;
diff --git a/src/net/network.cpp b/src/net/network.cpp
index 4504a944..fbcf199b 100644
--- a/src/net/network.cpp
+++ b/src/net/network.cpp
@@ -143,7 +143,7 @@ int connectionThread(void *ptr)
memset(out, '\0', buffer_size);
in_size = 0;
out_size = 0;
-
+
SDL_mutexP(mMutex);
logger->log("Network::Started session with %s:%i",
iptostring(((IPaddress *)ptr)->host),
@@ -343,13 +343,13 @@ bool packetReady()
if (in_size >= 4)
{
length = readWord(2);
- if (in_size >= length)
+ if (in_size >= (unsigned int)length)
{
ret = true;
}
}
}
- else if (in_size >= length)
+ else if (in_size >= (unsigned int)length)
{
ret = true;
}