summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2008-02-12 10:59:11 +0000
committerBjørn Lindeijer <bjorn@lindeijer.nl>2008-02-12 10:59:11 +0000
commit915c9b4e7daf2f49c25e254b66ef6e53a9207b29 (patch)
treea5986e1c31ad77366b26a82c4568d9ef1d65ef19
parent078a31f906b618c1526b98ba63043a2267a858c6 (diff)
downloadmana-client-915c9b4e7daf2f49c25e254b66ef6e53a9207b29.tar.gz
mana-client-915c9b4e7daf2f49c25e254b66ef6e53a9207b29.tar.bz2
mana-client-915c9b4e7daf2f49c25e254b66ef6e53a9207b29.tar.xz
mana-client-915c9b4e7daf2f49c25e254b66ef6e53a9207b29.zip
Merged revisions 3687-3688,3690 via svnmerge from
https://themanaworld.svn.sourceforge.net/svnroot/themanaworld/tmw/branches/0.0 ........ r3687 | crush_tmw | 2007-10-26 02:22:12 +0200 (Fri, 26 Oct 2007) | 1 line Added possibility of length limitation to browserbox and used it for the chatlog (length set by the config option "ChatLogLength"). ........ r3688 | crush_tmw | 2007-10-26 02:38:00 +0200 (Fri, 26 Oct 2007) | 1 line Removed some completely useless code from the chat class. ........ r3690 | crush_tmw | 2007-10-26 14:50:49 +0200 (Fri, 26 Oct 2007) | 1 line Implemented monster hurt sounds and added new sound effects by Cosmostrator. ........
-rw-r--r--ChangeLog10
-rw-r--r--src/gui/browserbox.cpp24
-rw-r--r--src/gui/browserbox.h8
-rw-r--r--src/gui/chat.cpp10
-rw-r--r--src/gui/chat.h5
-rw-r--r--src/main.cpp1
-rw-r--r--src/monster.cpp7
-rw-r--r--src/monster.h7
8 files changed, 51 insertions, 21 deletions
diff --git a/ChangeLog b/ChangeLog
index 71a248b3..73c1ee73 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,16 @@
2008-02-12 Philipp Sehmisch <tmw@crushnet.org>
* data/monsters.xml: Added size and speed to the first four monsters.
+ * src/browserbox.cpp, src/browserbox.h, src/chat.h, src/main.cpp:
+ Added possibility of length limitation to browserbox and used it
+ for the chatlog (length set by the config option "ChatLogLength").
+ * src/chat.cpp, src/chat.h: Removed some completely useless code
+ from the chat class.
+ * src/monster.cpp, src/monster.h, data/sfx/logmonster-hurt1.ogg,
+ data/sfx/logmonster-hurt2.ogg, data/sfx/logmonster-hurt3.ogg,
+ data/sfx/logmonster-hurt4.ogg, data/sfx/logmonster-hurt5.ogg:
+ Implemented monster hurt sounds and added new sound effects by
+ Cosmostrator.
2008-02-10 Philipp Sehmisch <tmw@crushnet.org>
diff --git a/src/gui/browserbox.cpp b/src/gui/browserbox.cpp
index 584f2911..61bc571b 100644
--- a/src/gui/browserbox.cpp
+++ b/src/gui/browserbox.cpp
@@ -32,7 +32,9 @@ BrowserBox::BrowserBox(unsigned int mode):
gcn::Widget(),
mMode(mode), mHighMode(UNDERLINE | BACKGROUND),
mOpaque(true),
- mUseLinksAndUserColors(true), mSelectedLink(-1)
+ mUseLinksAndUserColors(true),
+ mSelectedLink(-1),
+ mMaxRows(0)
{
setFocusable(true);
addMouseListener(this);
@@ -119,6 +121,12 @@ void BrowserBox::addRow(const std::string &row)
mTextRows.push_back(newRow);
+ //discard older rows when a row limit has been set
+ if (mMaxRows > 0)
+ {
+ while (mTextRows.size() > mMaxRows) mTextRows.pop_front();
+ }
+
// Auto size mode
if (mMode == AUTO_SIZE)
{
@@ -134,15 +142,16 @@ void BrowserBox::addRow(const std::string &row)
if (mMode == AUTO_WRAP)
{
- unsigned int i, j, y = 0;
+ unsigned int y = 0;
unsigned int nextChar;
char const *hyphen = "~";
int hyphenWidth = font->getWidth(hyphen);
int x = 0;
- for (i = 0; i < mTextRows.size(); i++)
+
+ for (TextRowIterator i = mTextRows.begin(); i != mTextRows.end(); i++)
{
- std::string row = mTextRows[i];
- for (j = 0; j < row.size(); j++)
+ std::string row = *i;
+ for (unsigned int j = 0; j < row.size(); j++)
{
std::string character = row.substr(j, 1);
x += font->getWidth(character);
@@ -256,17 +265,16 @@ BrowserBox::draw(gcn::Graphics *graphics)
}
}
- unsigned int i;
int x = 0, y = 0;
int wrappedLines = 0;
TrueTypeFont *font = static_cast<TrueTypeFont*>(getFont());
graphics->setColor(BLACK);
- for (i = 0; i < mTextRows.size(); i++)
+ for (TextRowIterator i = mTextRows.begin(); i != mTextRows.end(); i++)
{
int selColor = BLACK;
int prevColor = selColor;
- std::string row = mTextRows[i];
+ std::string row = *(i);
bool wrapped = false;
x = 0;
diff --git a/src/gui/browserbox.h b/src/gui/browserbox.h
index 1c33e6f9..0a9032e4 100644
--- a/src/gui/browserbox.h
+++ b/src/gui/browserbox.h
@@ -74,6 +74,11 @@ class BrowserBox : public gcn::Widget, public gcn::MouseListener
void setHighlightMode(unsigned int highMode);
/**
+ * Sets the maximum numbers of rows in the browser box. 0 = no limit.
+ */
+ void setMaxRow(int max) {mMaxRows = max; };
+
+ /**
* Disable links & user defined colors to be used in chat input.
*/
void disableLinksAndUserColors();
@@ -144,7 +149,7 @@ class BrowserBox : public gcn::Widget, public gcn::MouseListener
};
private:
- typedef std::vector<std::string> TextRows;
+ typedef std::list<std::string> TextRows;
typedef TextRows::iterator TextRowIterator;
TextRows mTextRows;
@@ -158,6 +163,7 @@ class BrowserBox : public gcn::Widget, public gcn::MouseListener
bool mOpaque;
bool mUseLinksAndUserColors;
int mSelectedLink;
+ unsigned int mMaxRows;
};
#endif
diff --git a/src/gui/chat.cpp b/src/gui/chat.cpp
index 2fd68c71..f750df99 100644
--- a/src/gui/chat.cpp
+++ b/src/gui/chat.cpp
@@ -38,6 +38,7 @@
#include "../channelmanager.h"
#include "../channel.h"
+#include "../configuration.h"
#include "../game.h"
#include "../localplayer.h"
@@ -51,9 +52,6 @@ ChatWindow::ChatWindow():
Window(),
mTmpVisible(false)
{
- mItems = 0;
- mItemsKeep = 20;
-
setResizable(true);
setDefaultSize(0, (windowContainer->getHeight() - 123), 600, 100);
setTitleBarHeight(0);
@@ -66,6 +64,7 @@ ChatWindow::ChatWindow():
BrowserBox *textOutput = new BrowserBox(BrowserBox::AUTO_WRAP);
textOutput->setOpaque(false);
textOutput->disableLinksAndUserColors();
+ textOutput->setMaxRow((int) config.getValue("ChatLogLength", 0));
ScrollArea *scrollArea = new ScrollArea(textOutput);
scrollArea->setPosition(
scrollArea->getBorderSize(), scrollArea->getBorderSize());
@@ -126,11 +125,6 @@ ChatWindow::logic()
void
ChatWindow::chatLog(std::string line, int own, std::string channelName)
{
- // Delete overhead from the end of the list
- while ((int) mChatlog.size() > mItemsKeep) {
- mChatlog.pop_back();
- }
-
CHATLOG tmp;
tmp.own = own;
tmp.nick = "";
diff --git a/src/gui/chat.h b/src/gui/chat.h
index ee699cf2..304d5500 100644
--- a/src/gui/chat.h
+++ b/src/gui/chat.h
@@ -183,7 +183,7 @@ class ChatWindow : public Window, public gcn::ActionListener,
/** Called to add the channel to the channel manager */
void
addChannel(short channel, std::string channelName);
-
+
/** Called to remove the channel from the channel manager */
void
removeChannel(short channel);
@@ -225,8 +225,6 @@ class ChatWindow : public Window, public gcn::ActionListener,
int own;
};
- std::list<CHATLOG> mChatlog;
-
#if 0
/** Constructs failed messages for actions */
std::string const_msg(CHATSKILL);
@@ -250,4 +248,3 @@ class ChatWindow : public Window, public gcn::ActionListener,
extern ChatWindow *chatWindow;
#endif
-
diff --git a/src/main.cpp b/src/main.cpp
index 2a5c7498..0726f5dc 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -191,6 +191,7 @@ void initConfiguration(const Options &options)
config.setValue("fpslimit", 0);
config.setValue("updatehost", "http://updates.themanaworld.org");
config.setValue("customcursor", 1);
+ config.setValue("ChatLogLength", 64);
// Checking if the configuration file exists... otherwise create it with
// default options.
diff --git a/src/monster.cpp b/src/monster.cpp
index bc964b0b..9cbd28eb 100644
--- a/src/monster.cpp
+++ b/src/monster.cpp
@@ -93,6 +93,13 @@ Monster::handleAttack()
sound.playSfx(mi.getSound(MONSTER_EVENT_HIT));
}
+void
+Monster::takeDamage(int amount)
+{
+ if (amount > 0) sound.playSfx(getInfo().getSound(MONSTER_EVENT_HURT));
+ Being::takeDamage(amount);
+}
+
Being::TargetCursorSize
Monster::getTargetCursorSize() const
{
diff --git a/src/monster.h b/src/monster.h
index 4915520d..fc46e11a 100644
--- a/src/monster.h
+++ b/src/monster.h
@@ -47,6 +47,13 @@ class Monster : public Being
virtual void handleAttack();
/**
+ * Puts a damage bubble above this monster and plays the hurt sound
+ *
+ * @param amount The amount of damage.
+ */
+ virtual void takeDamage(int amount);
+
+ /**
* Returns the MonsterInfo, with static data about this monster.
*/
const MonsterInfo&