summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--data/graphics/gui/browserfont.pngbin0 -> 1193 bytes
-rw-r--r--data/help/about.txt14
-rw-r--r--data/help/changes.txt12
-rw-r--r--data/help/commands.txt40
-rw-r--r--data/help/header.txt9
-rw-r--r--data/help/index.txt32
-rw-r--r--data/help/skills.txt18
-rw-r--r--data/help/support.txt18
-rw-r--r--data/help/team.txt88
-rw-r--r--src/gui/browserbox.cpp318
-rw-r--r--src/gui/browserbox.h147
-rw-r--r--src/gui/linkhandler.h42
-rw-r--r--src/gui/popupmenu.cpp213
-rw-r--r--src/gui/popupmenu.h78
14 files changed, 890 insertions, 139 deletions
diff --git a/data/graphics/gui/browserfont.png b/data/graphics/gui/browserfont.png
new file mode 100644
index 00000000..f2ab759b
--- /dev/null
+++ b/data/graphics/gui/browserfont.png
Binary files differ
diff --git a/data/help/about.txt b/data/help/about.txt
index 51a14a16..49e904ce 100644
--- a/data/help/about.txt
+++ b/data/help/about.txt
@@ -1,17 +1,9 @@
- T H E M A N A W O R L D
- ==========================================
+ <- @@index|Back to Index@@
- Version: 0.0.13 Date: 5 June 2005
- Website: http://themanaworld.org
+##3 === ABOUT THE MANA WORLD ===
-
-@index-> Back to Index
-
-
- === ABOUT THE MANA WORLD ===
-
- The Mana World (TMW) is a serious effort to create an innovative free
+ ##2The Mana World (TMW)##P is a serious effort to create an innovative free
and open source MMORPG. TMW uses 2D graphics and aims to create a
large and diverse interactive world. It is licensed under the GPL,
making sure this game can't ever run away from you.
diff --git a/data/help/changes.txt b/data/help/changes.txt
index c1f03d8d..82761d4e 100644
--- a/data/help/changes.txt
+++ b/data/help/changes.txt
@@ -1,15 +1,7 @@
- T H E M A N A W O R L D
- ==========================================
+ <- @@index|Back to Index@@
- Version: 0.0.13 Date: 5 June 2005
- Website: http://themanaworld.org
-
-
-@index-> Back to Index
-
-
- === RECENT CHANGES ===
+##3 === RECENT CHANGES ===
- Added ability to trade items and money
- Added server field to login dialog
diff --git a/data/help/commands.txt b/data/help/commands.txt
index 994cb77c..c9eef010 100644
--- a/data/help/commands.txt
+++ b/data/help/commands.txt
@@ -1,15 +1,7 @@
- T H E M A N A W O R L D
- ==========================================
+ <- @@index|Back to Index@@
- Version: 0.0.13 Date: 5 June 2005
- Website: http://themanaworld.org
-
-
-@index-> Back to Index
-
-
- === COMMANDS ===
+##3 === COMMANDS ===
Use arrow keys (or left mouse button) to move around and the right
mouse button over NPC's feet to talk to them or over a monster to
@@ -17,18 +9,18 @@
Other keys:
- Left Ctrl attack
- Alt + 0-9 show emotions
- F1 show the online help
- F5 sit down / stand up
- F6 toggle debug pathfinding feature
- F7 play test sound
- G or Z pick up item
- Enter focus chat window / send message
- Alt + K show skills
- Alt + S show stats
- Alt + I show inventory
- Alt + E show equipment
- Alt + C show setup window
- Left Shift hold it when attacking to lock target for auto
+ ##2Left Ctrl##P attack
+ ##2Alt + 0-9##P show emotions
+ ##2F1##P show the in-game help
+ ##2F5##P sit down / stand up
+ ##2F6##P toggle debug pathfinding feature
+ ##2F7##P play test sound
+ ##2G or Z##P pick up item
+ ##2Enter##P focus chat window / send message
+ ##2Alt + K##P show skills
+ ##2Alt + S##P show stats
+ ##2Alt + I##P show inventory
+ ##2Alt + E##P show equipment
+ ##2Alt + C##P show setup window
+ ##2Left Shift##P hold it when attacking to lock target for auto
attack
diff --git a/data/help/header.txt b/data/help/header.txt
new file mode 100644
index 00000000..15cdb93f
--- /dev/null
+++ b/data/help/header.txt
@@ -0,0 +1,9 @@
+
+##1 T H E M A N A W O R L D
+##1 ==========================================
+
+ ##2Version:##6 0.0.14 ##2Date:##6 3 July 2005
+
+##2 Website: http://themanaworld.org
+
+
diff --git a/data/help/index.txt b/data/help/index.txt
index 68d86a5c..38dd55eb 100644
--- a/data/help/index.txt
+++ b/data/help/index.txt
@@ -1,26 +1,18 @@
- T H E M A N A W O R L D
- ==========================================
+##3 === INDEX ===
- Version: 0.0.13 Date: 5 June 2005
+ -> @@about|About The Mana World@@
+ -> @@team|Development Team@@
+ -> @@changes|Recent Changes@@
- Website: http://themanaworld.org
+ -> @@commands|Commands@@
+ -> @@skills|Skills@@
+ -> @@support|Support@@
- === INDEX ===
-@about-> About The Mana World
-@team-> Development Team
-@changes-> Recent Changes
+##3 === Powered By ===
-@commands-> Commands
-@skills-> Skills
-
-@support-> Support
-
-
- === Powered By ===
-
- SDL, SDL_image, SDL_mixer (Media framework)
- Guichan (GUI framework)
- libxml2 (XML parsing and writing)
- PhysFS (Data files)
+##2 SDL, SDL_image, SDL_mixer (Media framework)
+##2 Guichan (GUI framework)
+##2 libxml2 (XML parsing and writing)
+##2 PhysFS (Data files)
diff --git a/data/help/skills.txt b/data/help/skills.txt
index eba4082c..c1f88e40 100644
--- a/data/help/skills.txt
+++ b/data/help/skills.txt
@@ -1,21 +1,13 @@
- T H E M A N A W O R L D
- ==========================================
+ <- @@index|Back to Index@@
- Version: 0.0.13 Date: 5 June 2005
- Website: http://themanaworld.org
-
-
-@index-> Back to Index
-
-
- === SKILLS ===
+##3 === SKILLS ===
You can improve your skills by increasing job level. Each job level
gives you 1 point to spend on basic skills.
- Level 1: enables the ability to trade with others
- Level 2: enables the ability to express emotions
- Level 3: enables character to sit
+ ##2Level 1:##P enables the ability to trade with others
+ ##2Level 2:##P enables the ability to express emotions
+ ##2Level 3:##P enables character to sit
Other levels are still not implemented.
diff --git a/data/help/support.txt b/data/help/support.txt
index 195a6ea4..7ca460f4 100644
--- a/data/help/support.txt
+++ b/data/help/support.txt
@@ -1,25 +1,17 @@
- T H E M A N A W O R L D
- ==========================================
+ <- @@index|Back to Index@@
- Version: 0.0.13 Date: 5 June 2005
- Website: http://themanaworld.org
-
-
-@index-> Back to Index
-
-
- === SUPPORT ===
+##3 === SUPPORT ===
If you're having troubles, plase first of all read the FAQ. If you
can't find a solution to your problem, feel free to check our
Bugs/Support section of the forum:
- http://themanaworld.org/phpBB2/viewforum.php?f=3
+##2 http://themanaworld.org/phpBB2/viewforum.php?f=3
or come visit us on our IRC channel:
- #manaworld @ irc.freenode.net
+##2 #manaworld ##P@##2 irc.freenode.net
- Otherwise check the 'Development Team' section to have a list of
+ Otherwise see the @@team|Development Team@@ section to have a list of
developers and how to contact them.
diff --git a/data/help/team.txt b/data/help/team.txt
index 15fee77f..693d61bb 100644
--- a/data/help/team.txt
+++ b/data/help/team.txt
@@ -1,136 +1,128 @@
- T H E M A N A W O R L D
- ==========================================
+ <- @@index|Back to Index@@
- Version: 0.0.13 Date: 5 June 2005
- Website: http://themanaworld.org
+##3 === DEVELOPMENT TEAM ===
+##2 Project Leader:
-@index-> Back to Index
-
-
- === DEVELOPMENT TEAM ===
-
- Project Leader:
-
- Eugenio Favalli (aka ElvenProgrammer)
+ ##9Eugenio Favalli (aka ElvenProgrammer)
umperio@users.sourceforge.net
- Programmers:
-
- Bertram
- bertram25@users.sourceforge.net
- (SDL input, progress bar drawing, Debian package)
+##2 Programmers:
- Bjorn Lindeijer (aka Hammerbear)
+ ##9Bjorn Lindeijer (aka Hammerbear)
b_lindeijer@users.sourceforge.net
(various parts, GUI, graphics, A* and map rewrites)
- Eric Scrivner (aka zenogais)
+ ##9Eric Scrivner (aka zenogais)
bitshift2002@users.sourceforge.net
(resource manager)
- J. Avila (aka Javila)
+ ##9J. Avila (aka Javila)
javila@users.sourceforge.net
(various parts, GUI)
- Jan-Fabian Humann (aka Mra)
+ ##9Jan-Fabian Humann (aka Mra)
malastare@users.sourceforge.net
(some GUI parts)
- Kiyoshi Kyokai (aka Kiokay)
+ ##9Kiyoshi Kyokai (aka Kiokay)
kyokai@users.sourceforge.net
(game systems designer)
- Mateusz Kaduk (aka Usiu)
+ ##9Mateusz Kaduk (aka Usiu)
usiu@users.sourceforge.net
(several GUI parts)
- nym
+ ##9nym
nymacro@users.sourceforge.net
(several GUI parts)
- Shura
+ ##9Shura
kth5@users.sourceforge.net
(configuration, sound, misc. ports)
+ ##9Yohann Ferreira (aka Bertram)
+ bertram25@users.sourceforge.net
+ (SDL input, progress bar drawing, Debian package)
+
- Artists:
+##2 Artists:
- Clef
+ ##9Clef
(tiles, concepts)
- Frode Lindeijer (aka Modanung)
+ ##9Frode Lindeijer (aka Modanung)
f.lindeijer@xs4all.nl
(arts)
- Gnulia
+ ##9Gnulia
(conceptual art)
- Magick
+ ##9Magick
(music and sound effects)
- Neko-mon
+ ##9Neko-mon
(player sprites, various things)
- Neorice
+ ##9Neorice
(monster sprites, tiles)
- Pajarico
+ ##9Pajarico
pajarico@users.sourceforge.net
(conceptual arts)
- Romulo Fernandes
+ ##9Romulo Fernandes
razor85@users.sourceforge.net
(arts)
- Rotonen
+ ##9Rotonen
rotonen@users.sourceforge.net
(backstory, art director, music, sound)
- Talaroc
+ ##9Talaroc
talaroc@users.sourceforge.net
(sprites)
- Ti Sing Hao
+ ##9Ti Sing Hao
(music)
- Misc. thanks:
+##2 Misc. thanks:
- David Smith (aka catfish_man)
+ ##9David Smith (aka catfish_man)
catfish_man@users.sourceforge.net
(Mac package)
- Igor Morgado (aka imorgado)
+ ##9Igor Morgado (aka imorgado)
imorgado@users.sourceforge.net
(tester)
- maci
+ ##9maci
maci321@users.sourceforge.net
(technical support)
- Rodney Dawes (aka dobey)
+ ##9Rodney Dawes (aka dobey)
dobey@users.sourceforge.net
(Mac package)
- Ultramichy
+ ##9Ultramichy
(hosting test server)
- Inactive/retired:
+##2 Inactive/retired:
- Chetic
+ ##9Chetic
chetic@users.sourceforge.net
(maps)
- Simon Edwardsson (aka SimEdw)
+ ##9Simon Edwardsson (aka SimEdw)
simonedw@users.sourceforge.net
(network code, Mac package)
- Sull
+ ##9Sull
(hosting CVS and related services)
- Vlady
+ ##9Vlady
(several items)
diff --git a/src/gui/browserbox.cpp b/src/gui/browserbox.cpp
new file mode 100644
index 00000000..06094139
--- /dev/null
+++ b/src/gui/browserbox.cpp
@@ -0,0 +1,318 @@
+/*
+ * The Mana World
+ * Copyright 2004 The Mana World Development Team
+ *
+ * This file is part of The Mana World.
+ *
+ * The Mana World is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * any later version.
+ *
+ * The Mana World is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with The Mana World; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * $Id$
+ */
+
+#include "browserbox.h"
+
+int BrowserBox::instances = 0;
+gcn::ImageFont* BrowserBox::browserFont;
+
+BrowserBox::BrowserBox(unsigned int mode):
+ gcn::Widget()
+{
+ mMode = mode;
+ setOpaque(true);
+ setHighlightMode(BOTH);
+ mSelectedLink = -1;
+ setFocusable(true);
+ addMouseListener(this);
+
+ if (instances == 0)
+ {
+ browserFont = new gcn::ImageFont(
+ TMW_DATADIR "data/graphics/gui/browserfont.png",
+ " abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567"
+ "89:@!\"$%&/=?^+*#[]{}()<>_;'.,\\|-~`");
+ }
+ instances++;
+}
+
+BrowserBox::~BrowserBox()
+{
+ instances--;
+ if (instances == 0)
+ {
+ // Clean up static resource font
+ delete browserFont;
+ }
+}
+
+void BrowserBox::setLinkHandler(LinkHandler* linkHandler)
+{
+ mLinkHandler = linkHandler;
+}
+
+void BrowserBox::setOpaque(bool opaque)
+{
+ mOpaque = opaque;
+}
+
+void BrowserBox::setHighlightMode(unsigned int highMode)
+{
+ mHighMode = highMode;
+}
+
+void BrowserBox::addRow(const std::string& row)
+{
+ std::string tmp = row;
+ std::string newRow;
+ BROWSER_LINK bLink;
+ int idx1, idx2, idx3;
+
+ // Check for links in format "@@link|Caption@@"
+ idx1 = tmp.find("@@");
+ while (idx1 >= 0)
+ {
+ idx2 = tmp.find("|", idx1);
+ idx3 = tmp.find("@@", idx2);
+ bLink.link = tmp.substr(idx1 + 2, idx2 - (idx1 + 2));
+ bLink.caption = tmp.substr(idx2 + 1, idx3 - (idx2 + 1));
+ bLink.y1 = mTextRows.size() * browserFont->getHeight();
+ bLink.y2 = bLink.y1 + browserFont->getHeight();
+
+ newRow += tmp.substr(0, idx1);
+
+ std::string tmp2 = newRow;
+ idx1 = tmp2.find("##");
+ while (idx1 >= 0)
+ {
+ tmp2.erase(idx1, 3);
+ idx1 = tmp2.find("##");
+ }
+ bLink.x1 = browserFont->getWidth(tmp2) - 1;
+ bLink.x2 = bLink.x1 + browserFont->getWidth(bLink.caption) + 1;
+
+ mLinks.push_back(bLink);
+
+ newRow += "##L" + bLink.caption;
+
+ tmp.erase(0, idx3 + 2);
+ if(tmp != "")
+ {
+ newRow += "##P";
+ }
+ idx1 = tmp.find("@@");
+ }
+
+ newRow += tmp;
+ mTextRows.push_back(newRow);
+
+ // Auto size mode
+ if (mMode == AUTO_SIZE)
+ {
+ std::string plain = newRow;
+ for (idx1 = plain.find("##"); idx1 >= 0; idx1 = plain.find("##"))
+ plain.erase(idx1, 3);
+
+ // Adjust the BrowserBox size
+ int w = browserFont->getWidth(plain);
+ if (w > getWidth())
+ setWidth(w);
+ }
+ setHeight(browserFont->getHeight() * mTextRows.size());
+}
+
+void BrowserBox::clearRows()
+{
+ mTextRows.clear();
+ mLinks.clear();
+ setWidth(0);
+ mSelectedLink = -1;
+}
+
+void BrowserBox::mousePress(int mx, int my, int button)
+{
+ if ((button == gcn::MouseInput::LEFT) && mLinkHandler)
+ {
+ for (unsigned int i = 0; i < mLinks.size(); i++)
+ {
+ if ((mx >= mLinks[i].x1) && (mx < mLinks[i].x2) &&
+ (my > mLinks[i].y1) && (my < mLinks[i].y2))
+ {
+ mLinkHandler->handleLink(mLinks[i].link);
+ return;
+ }
+ }
+ }
+}
+
+void BrowserBox::mouseMotion(int mx, int my)
+{
+ for (unsigned int i = 0; i < mLinks.size(); i++)
+ {
+ if ((mx >= mLinks[i].x1) && (mx < mLinks[i].x2) &&
+ (my > mLinks[i].y1) && (my < mLinks[i].y2))
+ {
+ mSelectedLink = (int) i;
+ return;
+ }
+ else
+ {
+ mSelectedLink = -1;
+ }
+ }
+}
+
+void BrowserBox::draw(gcn::Graphics* graphics)
+{
+ if (mOpaque)
+ {
+ graphics->setColor(gcn::Color(BGCOLOR));
+ graphics->fillRectangle(gcn::Rectangle(0, 0, getWidth(), getHeight()));
+ }
+
+ if (mSelectedLink >= 0)
+ {
+ if ((mHighMode == BACKGROUND) || (mHighMode == BOTH))
+ {
+ graphics->setColor(gcn::Color(HIGHLIGHT));
+ graphics->fillRectangle(gcn::Rectangle(
+ mLinks[mSelectedLink].x1,
+ mLinks[mSelectedLink].y1,
+ mLinks[mSelectedLink].x2 - mLinks[mSelectedLink].x1,
+ mLinks[mSelectedLink].y2 - mLinks[mSelectedLink].y1));
+ }
+
+ if ((mHighMode == UNDERLINE) || (mHighMode == BOTH))
+ {
+ graphics->setColor(gcn::Color(LINK));
+ graphics->drawLine(
+ mLinks[mSelectedLink].x1,
+ mLinks[mSelectedLink].y2,
+ mLinks[mSelectedLink].x2,
+ mLinks[mSelectedLink].y2);
+ }
+ }
+
+ unsigned int i, j;
+ int x = 0, y = 0;
+ int wrappedLines = 0;
+ for (i = 0; i < mTextRows.size(); i++)
+ {
+ int selColor = BLACK;
+ int prevColor = selColor;
+ std::string row = mTextRows[i];
+ x = 0;
+
+ for (j = 0; j < row.size(); j++)
+ {
+ // Check for color change in format "##x", x = [L,P,0..9]
+ if ((row.at(j) == '#') && (row.at(j + 1) == '#'))
+ {
+ switch (row.at(j + 2))
+ {
+ case 'L': // Link color
+ prevColor = selColor;
+ selColor = LINK;
+ break;
+ case 'P': // Previous color
+ selColor = prevColor;
+ break;
+ case '1':
+ prevColor = selColor;
+ selColor = RED;
+ break;
+ case '2':
+ prevColor = selColor;
+ selColor = GREEN;
+ break;
+ case '3':
+ prevColor = selColor;
+ selColor = BLUE;
+ break;
+ case '4':
+ prevColor = selColor;
+ selColor = ORANGE;
+ break;
+ case '5':
+ prevColor = selColor;
+ selColor = YELLOW;
+ break;
+ case '6':
+ prevColor = selColor;
+ selColor = PINK;
+ break;
+ case '7':
+ prevColor = selColor;
+ selColor = PURPLE;
+ break;
+ case '8':
+ prevColor = selColor;
+ selColor = GRAY;
+ break;
+ case '9':
+ prevColor = selColor;
+ selColor = BROWN;
+ break;
+ case '0':
+ default:
+ prevColor = selColor;
+ selColor = BLACK;
+ }
+ j += 3;
+
+ if (j == row.size())
+ {
+ break;
+ }
+ }
+ graphics->setColor(gcn::Color(selColor));
+
+ // Check for line separators in format "---"
+ if ((j <= 3) && (row.at(j) == '-') && (row.at(j + 1) == '-') &&
+ (row.at(j + 2) == '-'))
+ {
+ for (x = 0; x < getWidth(); x++)
+ {
+ browserFont->drawGlyph(graphics, '-', x, y);
+ x += browserFont->getWidth('-') - 2;
+ }
+ break;
+ }
+ // Draw each char
+ else
+ {
+ browserFont->drawGlyph(graphics, row.at(j), x, y);
+ x += browserFont->getWidth(row.at(j));
+
+ // Auto wrap mode
+ if (mMode == AUTO_WRAP)
+ {
+ /** NOTE (by Javila): this is just a simple example and
+ * will force text wrap at widget width!!!
+ * Maybe it can need improvements.
+ */
+ if ((x + 2 * browserFont->getWidth('~')) > getWidth())
+ {
+ browserFont->drawGlyph(graphics, '~',
+ getWidth() - browserFont->getWidth('~'), y);
+ x = 15; // Ident in new line
+ y += browserFont->getHeight();
+ wrappedLines++;
+ }
+ }
+ }
+ }
+ y += browserFont->getHeight();
+ setHeight((mTextRows.size() + wrappedLines) * browserFont->getHeight());
+ }
+}
diff --git a/src/gui/browserbox.h b/src/gui/browserbox.h
new file mode 100644
index 00000000..8ac5a54c
--- /dev/null
+++ b/src/gui/browserbox.h
@@ -0,0 +1,147 @@
+/*
+ * The Mana World
+ * Copyright 2004 The Mana World Development Team
+ *
+ * This file is part of The Mana World.
+ *
+ * The Mana World is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * any later version.
+ *
+ * The Mana World is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with The Mana World; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * $Id$
+ */
+
+#ifndef __TMW_BROWSERBOX_H__
+#define __TMW_BROWSERBOX_H__
+
+#include <guichan.hpp>
+#include "window.h"
+#include "linkhandler.h"
+
+struct BROWSER_LINK {
+ int x1, x2, y1, y2; /**< Where link is placed */
+ std::string link;
+ std::string caption;
+};
+
+/**
+ * A simple browser box able to handle links and forward events to the
+ * parent conteiner.
+ */
+class BrowserBox : public gcn::Widget, public gcn::MouseListener
+{
+ public:
+ /**
+ * Constructor.
+ */
+ BrowserBox(unsigned int mode = AUTO_SIZE);
+
+ /**
+ * Destructor.
+ */
+ ~BrowserBox();
+
+ /**
+ * Sets the handler for links.
+ */
+ void setLinkHandler(LinkHandler* linkHandler);
+
+ /**
+ * Sets the BrowserBox opacity.
+ */
+ void setOpaque(bool opaque);
+
+ /**
+ * Sets the Highlight mode for links.
+ */
+ void setHighlightMode(unsigned int highMode);
+
+ /**
+ * Adds a text row to the browser.
+ */
+ void addRow(const std::string& row);
+
+ /**
+ * Remove all rows.
+ */
+ void clearRows();
+
+ /**
+ * Handles mouse actions.
+ */
+ void mousePress(int mx, int my, int button);
+ void mouseMotion(int mx, int my);
+
+ /**
+ * Draws the browser box.
+ */
+ void draw(gcn::Graphics* graphics);
+
+ /**
+ * BrowserBox modes.
+ */
+ enum {
+ AUTO_SIZE,
+ AUTO_WRAP /**< Maybe it needs a fix or to be redone. */
+ };
+
+ /**
+ * BrowserBox colors.
+ *
+ * NOTES (by Javila):
+ * - color values is "0x" prefix followed by HTML color style.
+ * - we can add up to 10 different colors: [0..9].
+ * - we need a link and a highlighted link colors.
+ * - not all colors will be fine with all backgrounds due transparent
+ * windows and widgets. So, I think it's better keep BrowserBox
+ * opaque (white background) by default.
+ */
+ enum {
+ BLACK = 0x000000, /**< Color 0 */
+ RED = 0xff0000, /**< Color 1 */
+ GREEN = 0x1fa052, /**< Color 2 */
+ BLUE = 0x0000ff, /**< Color 3 */
+ ORANGE = 0xe0980e, /**< Color 4 */
+ YELLOW = 0xf1dc27, /**< Color 5 */
+ PINK = 0xff00d8, /**< Color 6 */
+ PURPLE = 0x8415e2, /**< Color 7 */
+ GRAY = 0x919191, /**< Color 8 */
+ BROWN = 0x8e4c17, /**< Color 9 */
+ BGCOLOR = 0xffffff, /**< Bg color for opacity */
+ LINK = 0xe50d0d, /**< Color L */
+ HIGHLIGHT = 0xcacaca /**< Bg color for highlighted link */
+ };
+
+ /**
+ * Highlight modes for links.
+ */
+ enum {
+ UNDERLINE,
+ BACKGROUND,
+ BOTH
+ };
+
+ private:
+ std::vector<std::string> mTextRows;
+ std::vector<BROWSER_LINK> mLinks;
+ LinkHandler *mLinkHandler;
+ unsigned int mMode;
+ unsigned int mHighMode;
+ bool mOpaque;
+ int mSelectedLink;
+
+ static int instances; /**< Number of Window instances */
+ static gcn::ImageFont* browserFont;
+};
+
+#endif
diff --git a/src/gui/linkhandler.h b/src/gui/linkhandler.h
new file mode 100644
index 00000000..05a0a99b
--- /dev/null
+++ b/src/gui/linkhandler.h
@@ -0,0 +1,42 @@
+/*
+ * The Mana World
+ * Copyright 2004 The Mana World Development Team
+ *
+ * This file is part of The Mana World.
+ *
+ * The Mana World is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * any later version.
+ *
+ * The Mana World is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with The Mana World; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * $Id$
+ */
+
+#ifndef _TMW_LINK_HANDLER_H
+#define _TMW_LINK_HANDLER_H
+
+/**
+ * A simple interface to windows that need to handle links from BrowserBox
+ * widget.
+ */
+class LinkHandler
+{
+ public:
+ virtual ~LinkHandler() { }
+
+ virtual void handleLink(const std::string& link) { }
+
+ protected:
+ LinkHandler() { }
+};
+
+#endif
diff --git a/src/gui/popupmenu.cpp b/src/gui/popupmenu.cpp
new file mode 100644
index 00000000..c56bdfc8
--- /dev/null
+++ b/src/gui/popupmenu.cpp
@@ -0,0 +1,213 @@
+/*
+ * The Mana World
+ * Copyright 2004 The Mana World Development Team
+ *
+ * This file is part of The Mana World.
+ *
+ * The Mana World is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * any later version.
+ *
+ * The Mana World is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with The Mana World; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * $Id$
+ */
+
+#include "popupmenu.h"
+#include "../graphics.h"
+#include "../engine.h"
+#include "../game.h"
+#include <iostream>
+
+PopupMenu::PopupMenu():
+ Window()
+{
+ setResizable(false);
+ setTitleBarHeight(0);
+
+ browserBox = new BrowserBox();
+ browserBox->setPosition(4, 4);
+ browserBox->setHighlightMode(BrowserBox::BACKGROUND);
+ browserBox->setOpaque(false);
+ add(browserBox);
+ browserBox->setLinkHandler(this);
+
+ being = NULL;
+ floorItem = NULL;
+ mX = -1;
+ mY = -1;
+}
+
+PopupMenu::~PopupMenu()
+{
+ delete browserBox;
+ delete being;
+ delete floorItem;
+}
+
+void PopupMenu::setVisible(bool visible)
+{
+ if (visible == false)
+ {
+ if (hasFocus())
+ {
+ mFocusHandler->focusNone();
+ }
+ setPosition(screen->w, screen->h);
+ }
+
+ mVisible = visible;
+}
+
+void PopupMenu::showPopup(int mx, int my)
+{
+ being = findNode(mx, my);
+ floorItem = find_floor_item_by_id(find_floor_item_by_cor(mx, my));
+ mX = mx;
+ mY = mY;
+ browserBox->clearRows();
+
+ if (being)
+ {
+ if (being->isMonster())
+ {
+ browserBox->addRow("@@attack|Attack Monster@@");
+ }
+ else if (being->isNpc())
+ {
+ browserBox->addRow("@@talk|Talk To NPC@@");
+ }
+ else if (being->isPlayer())
+ {
+ std::string name = being->name;
+ //browserBox->addRow("@@attack|Attack " + name + "@@");
+ browserBox->addRow("@@trade|Trade With " + name + "@@");
+ browserBox->addRow("@@follow|Follow " + name + "@@");
+ browserBox->addRow("@@buddy|Add " + name + " to Buddy List@@");
+ }
+ }
+ else if (floorItem)
+ {
+ std::string name = itemDb->getItemInfo(floorItem->id)->getName();
+ browserBox->addRow("@@pickup|Pick Up " + name + "@@");
+ }
+ else
+ {
+ browserBox->addRow("@@walk|Walk To@@");
+ }
+ //browserBox->addRow("@@look|Look To@@");
+ browserBox->addRow("##3---");
+ browserBox->addRow("@@cancel|Cancel@@");
+
+ setContentSize(browserBox->getWidth() + 8, browserBox->getHeight() + 8);
+ mx = (mx - camera_x) * 32 + 25;
+ my = (my - camera_y) * 32 + 25;
+ if (screen->w < (mx + getWidth() + 5))
+ mx -= (getWidth() + 50);
+ if (screen->h < (my + getHeight() + 5))
+ my -= (getHeight() + 50);
+ setPosition(mx, my);
+ setVisible(true);
+}
+
+void PopupMenu::draw(gcn::Graphics* graphics)
+{
+ int x, y;
+ getAbsolutePosition(x, y);
+
+ ((Graphics*) graphics)->drawImageRect(x, y, getWidth(), getHeight(),
+ border);
+
+ if (mContent != NULL)
+ {
+ graphics->pushClipArea(getContentDimension());
+ graphics->pushClipArea(gcn::Rectangle(
+ 0, 0, mContent->getWidth(), mContent->getHeight()));
+ mContent->draw(graphics);
+ graphics->popClipArea();
+ graphics->popClipArea();
+ }
+}
+
+void PopupMenu::handleLink(const std::string& link)
+{
+ // Attack action
+ if ((link == "attack") && being)
+ {
+ if (being->isMonster() && (being->action != MONSTER_DEAD))
+ {
+ autoTarget = being;
+ attack(being);
+ }
+ }
+
+ // Talk To action
+ else if ((link == "talk") && being && being->isNpc() &&
+ (current_npc == 0))
+ {
+ WFIFOW(0) = net_w_value(0x0090);
+ WFIFOL(2) = net_l_value(being->id);
+ WFIFOB(6) = 0;
+ WFIFOSET(7);
+ current_npc = being->id;
+ }
+
+ // Trade action
+ else if ((link == "trade") && being && being->isPlayer())
+ {
+ WFIFOW(0) = net_w_value(0x00e4);
+ WFIFOL(2) = net_l_value(being->id);
+ WFIFOSET(6);
+ }
+
+ // Follow Player action
+ else if (link == "follow")
+ {
+ }
+
+ // Add Buddy action
+ else if (link == "buddy")
+ {
+ }
+
+ // Pick Up Floor Item action
+ else if ((link == "pickup") && floorItem)
+ {
+ WFIFOW(0) = net_w_value(0x009f);
+ WFIFOL(2) = net_l_value(floorItem->int_id);
+ WFIFOSET(6);
+ }
+
+ // Walk To action
+ else if ((link == "walk") && (mX != -1) && (mY != -1))
+ {
+ //walk(mX, mY, 0);
+ //player_node->setDestination(mX, mY);
+ }
+
+ // Look To action
+ else if (link == "look")
+ {
+ }
+
+ // Unknown actions
+ else
+ {
+ std::cout << link << std::endl;
+ }
+
+ setVisible(false);
+
+ being = NULL;
+ floorItem = NULL;
+ mX = -1;
+ mY = -1;
+}
diff --git a/src/gui/popupmenu.h b/src/gui/popupmenu.h
new file mode 100644
index 00000000..77c8931a
--- /dev/null
+++ b/src/gui/popupmenu.h
@@ -0,0 +1,78 @@
+/*
+ * The Mana World
+ * Copyright 2004 The Mana World Development Team
+ *
+ * This file is part of The Mana World.
+ *
+ * The Mana World is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * any later version.
+ *
+ * The Mana World is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with The Mana World; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * $Id$
+ */
+
+#ifndef _TMW_POPUP_MENU_H
+#define _TMW_POPUP_MENU_H
+
+#include <guichan.hpp>
+#include "window.h"
+#include "linkhandler.h"
+#include "browserbox.h"
+#include "../being.h"
+#include "../floor_item.h"
+
+/**
+ * Window showing popup menu.
+ */
+class PopupMenu : public Window, public LinkHandler
+{
+ public:
+ /**
+ * Constructor.
+ */
+ PopupMenu();
+
+ /**
+ * Destructor.
+ */
+ ~PopupMenu();
+
+ /**
+ * Sets the visibility of popup
+ */
+ void setVisible(bool visible);
+
+ /**
+ * Shows the related popup menu specifies by the mouse click coords.
+ */
+ void showPopup(int mx, int my);
+
+ /**
+ * Draws updated popup menu
+ */
+ void draw(gcn::Graphics* graphics);
+
+ /**
+ * Handles link action.
+ */
+ void handleLink(const std::string& link);
+
+ private:
+ BrowserBox* browserBox;
+ int mX, mY;
+
+ Being* being;
+ FloorItem* floorItem;
+};
+
+#endif