summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authorDouglas Boffey <DougABoffey@netscape.net>2008-09-04 16:56:10 +0000
committerDouglas Boffey <DougABoffey@netscape.net>2008-09-04 16:56:10 +0000
commit7946cd875877870e7cab002cba099d21cf9fc063 (patch)
tree38dd4c1c4a766edda7b3156e2bc1af08dbd94a6a /src/gui
parent27e8d20ad8b5590995d1d4af3563f8956f180373 (diff)
downloadmana-client-7946cd875877870e7cab002cba099d21cf9fc063.tar.gz
mana-client-7946cd875877870e7cab002cba099d21cf9fc063.tar.bz2
mana-client-7946cd875877870e7cab002cba099d21cf9fc063.tar.xz
mana-client-7946cd875877870e7cab002cba099d21cf9fc063.zip
Added code to change text colouring
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/browserbox.cpp72
-rw-r--r--src/gui/browserbox.h27
-rw-r--r--src/gui/chat.cpp995
-rw-r--r--src/gui/setup.cpp12
-rw-r--r--src/gui/tabbedcontainer.cpp25
-rw-r--r--src/gui/tabbedcontainer.h11
-rw-r--r--src/gui/textfield.cpp68
-rw-r--r--src/gui/textfield.h47
8 files changed, 714 insertions, 543 deletions
diff --git a/src/gui/browserbox.cpp b/src/gui/browserbox.cpp
index 4f771a7e..b7d08cab 100644
--- a/src/gui/browserbox.cpp
+++ b/src/gui/browserbox.cpp
@@ -29,6 +29,7 @@
#include "browserbox.h"
#include "linkhandler.h"
+#include "colour.h"
#ifdef USE_OPENGL
#include "../configuration.h"
@@ -135,12 +136,12 @@ void BrowserBox::addRow(const std::string &row)
mLinks.push_back(bLink);
- newRow += "##L" + bLink.caption;
+ newRow += "##<" + bLink.caption;
tmp.erase(0, idx3 + 2);
if(tmp != "")
{
- newRow += "##P";
+ newRow += "##>";
}
idx1 = tmp.find("@@");
}
@@ -290,7 +291,8 @@ BrowserBox::draw(gcn::Graphics *graphics)
if ((mHighMode & UNDERLINE))
{
- graphics->setColor(gcn::Color(LINK));
+ bool valid;
+ graphics->setColor(gcn::Color(textColour->getColour('<', valid)));
graphics->drawLine(
mLinks[mSelectedLink].x1,
mLinks[mSelectedLink].y2,
@@ -317,58 +319,26 @@ BrowserBox::draw(gcn::Graphics *graphics)
if ( (mUseLinksAndUserColors && (j + 3) <= row.size()) ||
(!mUseLinksAndUserColors && (j == 0)) )
{
- // Check for color change in format "##x", x = [L,P,0..9]
+ // Check for color change in format "##x"
if ((row.at(j) == '#') && (row.at(j + 1) == '#'))
{
- switch (row.at(j + 2))
+ char c = row.at(j + 2);
+ if (c == '>')
{
- 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:
+ selColor = prevColor;
+ }
+ else
+ {
+ bool valid;
+ int rgb = textColour->getColour(c, valid);
+ if (c == '<')
+ {
prevColor = selColor;
- selColor = BLACK;
+ }
+ if (valid)
+ {
+ selColor = rgb;
+ }
}
j += 3;
diff --git a/src/gui/browserbox.h b/src/gui/browserbox.h
index 636fe5a0..c671d835 100644
--- a/src/gui/browserbox.h
+++ b/src/gui/browserbox.h
@@ -113,30 +113,13 @@ class BrowserBox : public gcn::Widget, public gcn::MouseListener
};
/**
- * 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.
+ * Some colours used in the browser box
*/
+
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 */
+ BLACK = 0x000000,
+ BGCOLOR = 0xffffff,
+ HIGHLIGHT = 0xcacaca
};
/**
diff --git a/src/gui/chat.cpp b/src/gui/chat.cpp
index c2377f65..8d9dac9d 100644
--- a/src/gui/chat.cpp
+++ b/src/gui/chat.cpp
@@ -45,8 +45,10 @@
#include "../utils/trim.h"
-ChatWindow::ChatWindow(Network * network):
-Window(""), mNetwork(network), mTmpVisible(false)
+ChatWindow::ChatWindow(Network *network):
+ Window(""),
+ mNetwork(network),
+ mTmpVisible(false)
{
setWindowName("Chat");
@@ -63,10 +65,10 @@ Window(""), mNetwork(network), mTmpVisible(false)
mTextOutput->disableLinksAndUserColors();
mTextOutput->setMaxRow((int) config.getValue("ChatLogLength", 0));
mScrollArea = new ScrollArea(mTextOutput);
- mScrollArea->setPosition(mScrollArea->getFrameSize(),
- mScrollArea->getFrameSize());
- mScrollArea->setScrollPolicy(gcn::ScrollArea::SHOW_NEVER,
- gcn::ScrollArea::SHOW_ALWAYS);
+ mScrollArea->setPosition(
+ mScrollArea->getFrameSize(), mScrollArea->getFrameSize());
+ mScrollArea->setScrollPolicy(
+ gcn::ScrollArea::SHOW_NEVER, gcn::ScrollArea::SHOW_ALWAYS);
mScrollArea->setOpaque(false);
add(mScrollArea);
@@ -94,79 +96,81 @@ ChatWindow::~ChatWindow()
}
void
- ChatWindow::logic()
+ChatWindow::logic()
{
// todo: only do this when the size changes (updateWidgets?)
const gcn::Rectangle area = getChildrenArea();
mChatInput->setPosition(mChatInput->getFrameSize(),
- area.height - mChatInput->getHeight() -
- mChatInput->getFrameSize());
+ area.height - mChatInput->getHeight() -
+ mChatInput->getFrameSize());
mChatInput->setWidth(area.width - 2 * mChatInput->getFrameSize());
mScrollArea->setWidth(area.width - 2 * mScrollArea->getFrameSize());
mScrollArea->setHeight(area.height - 2 * mScrollArea->getFrameSize() -
- mChatInput->getHeight() - 5);
+ mChatInput->getHeight() - 5);
mScrollArea->logic();
}
-void ChatWindow::chatLog(std::string line, int own, bool ignoreRecord)
+void
+ChatWindow::chatLog(std::string line, int own, bool ignoreRecord)
{
// Trim whitespace
trim(line);
CHATLOG tmp;
- tmp.own = own;
+ tmp.own = own;
tmp.nick = "";
tmp.text = line;
// Fix the owner of welcome message.
- if (line.substr(0, 7) == "Welcome") {
- own = BY_SERVER;
+ if (line.substr(0, 7) == "Welcome")
+ {
+ own = BY_SERVER;
}
std::string::size_type pos = line.find(" : ");
if (pos != std::string::npos) {
- tmp.nick = line.substr(0, pos);
- tmp.text = line.substr(pos + 3);
+ tmp.nick = line.substr(0, pos);
+ tmp.text = line.substr(pos + 3);
}
- std::string lineColor = "##0"; // Equiv. to BrowserBox::BLACK
+ std::string lineColor = "##C";
switch (own) {
- case BY_GM:
- tmp.nick += std::string("Global announcement: ");
- lineColor = "##1"; // Equiv. to BrowserBox::RED
- break;
- case BY_PLAYER:
- tmp.nick += CAT_NORMAL;
- lineColor = "##2"; // Equiv. to BrowserBox::GREEN
- break;
- case BY_OTHER:
- tmp.nick += CAT_NORMAL;
- lineColor = "##0"; // Equiv. to BrowserBox::BLACK
- break;
- case BY_SERVER:
- tmp.nick = "Server: ";
- tmp.text = line;
- lineColor = "##7"; // Equiv. to BrowserBox::PURPLE
- break;
- case BY_PARTY:
- tmp.nick += CAT_NORMAL;
- lineColor = "##6"; // Equiv. to BrowserBox::PINK
- break;
- case ACT_WHISPER:
- tmp.nick += CAT_WHISPER;
- lineColor = "##3"; // Equiv. to BrowserBox::BLUE
- break;
- case ACT_IS:
- tmp.nick += CAT_IS;
- lineColor = "##5"; // Equiv. to BrowserBox::YELLOW
- break;
- case BY_LOGGER:
- tmp.nick = "";
- tmp.text = line;
- lineColor = "##8"; // Equiv. to BrowserBox::GRAY
- break;
+ case BY_GM:
+ tmp.nick += std::string("Global announcement: ");
+ lineColor = "##G";
+ break;
+ case BY_PLAYER:
+ tmp.nick += CAT_NORMAL;
+ lineColor = "##Y";
+ break;
+ case BY_OTHER:
+ tmp.nick += CAT_NORMAL;
+ lineColor = "##C";
+ break;
+ case BY_SERVER:
+ tmp.nick = "Server: ";
+ tmp.text = line;
+ lineColor = "##S";
+ break;
+ case BY_PARTY:
+ tmp.nick += CAT_NORMAL;
+ lineColor = "##P";
+ break;
+ case ACT_WHISPER:
+ tmp.nick += CAT_WHISPER;
+ lineColor = "##W";
+ break;
+ case ACT_IS:
+ tmp.nick += CAT_IS;
+ lineColor = "##I";
+ break;
+ case BY_LOGGER:
+ tmp.nick = "";
+ tmp.text = line;
+ lineColor = "##L";
+ break;
}
// Get the current system time
@@ -175,360 +179,411 @@ void ChatWindow::chatLog(std::string line, int own, bool ignoreRecord)
// Format the time string properly
std::stringstream timeStr;
- timeStr << "[" << ((((t / 60) / 60) % 24 < 10) ? "0" : "")
- << (int) (((t / 60) / 60) % 24)
- << ":" << (((t / 60) % 60 < 10) ? "0" : "")
- << (int) ((t / 60) % 60)
- << "] ";
+ 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 + tmp.text;
// 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 (mScrollArea->getVerticalScrollAmount() ==
- mScrollArea->getVerticalMaxScroll()) {
- mTextOutput->addRow(line);
- mScrollArea->setVerticalScrollAmount(mScrollArea->
- getVerticalMaxScroll());
- } else {
- mTextOutput->addRow(line);
+ if (mScrollArea->getVerticalScrollAmount() == mScrollArea->getVerticalMaxScroll())
+ {
+ mTextOutput->addRow(line);
+ mScrollArea->setVerticalScrollAmount(mScrollArea->getVerticalMaxScroll());
+ }
+ else
+ {
+ mTextOutput->addRow(line);
}
mRecorder->record(line.substr(3));
}
-void ChatWindow::chatLog(CHATSKILL act)
+void
+ChatWindow::chatLog(CHATSKILL act)
{
chatLog(const_msg(act), BY_SERVER);
}
-void ChatWindow::action(const gcn::ActionEvent & event)
+void
+ChatWindow::action(const gcn::ActionEvent &event)
{
- if (event.getId() == "chatinput") {
- std::string message = mChatInput->getText();
-
- if (!message.empty()) {
- // If message different from previous, put it in the history
- if (mHistory.empty() || message != mHistory.back()) {
- mHistory.push_back(message);
- }
- // Reset history iterator
- mCurHist = mHistory.end();
-
- // Send the message to the server
- chatSend(player_node->getName(), message);
-
- // Clear the text from the chat input
- mChatInput->setText("");
- }
- if (message.empty() || !mReturnToggles) {
- // 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);
- }
- }
+ if (event.getId() == "chatinput")
+ {
+ std::string message = mChatInput->getText();
+
+ if (!message.empty()) {
+ // If message different from previous, put it in the history
+ if (mHistory.empty() || message != mHistory.back()) {
+ mHistory.push_back(message);
+ }
+
+ // Reset history iterator
+ mCurHist = mHistory.end();
+
+ // Send the message to the server
+ chatSend(player_node->getName(), message);
+
+ // Clear the text from the chat input
+ mChatInput->setText("");
+ }
+ if (message.empty() || !mReturnToggles)
+ {
+ // 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);
+ 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;
+ /*
+ * 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
mChatInput->setVisible(true);
mChatInput->requestFocus();
}
-bool ChatWindow::isInputFocused()
+bool
+ChatWindow::isInputFocused()
{
return mChatInput->isFocused();
}
-void ChatWindow::chatSend(const std::string & nick, std::string msg)
+void
+ChatWindow::chatSend(const std::string &nick, std::string msg)
{
/* Some messages are managed client side, while others
* require server handling by proper packet. Probably
* those if elses should be replaced by protocol calls */
// Send party message
- if (msg.at(0) == mPartyPrefix) {
- msg.erase(0, 1);
- std::size_t length = msg.length() + 1;
-
- if (length == 0) {
- chatLog("Trying to send a blank party message.", BY_SERVER);
- return;
- }
- MessageOut outMsg(mNetwork);
-
- outMsg.writeInt16(CMSG_PARTY_MESSAGE);
- outMsg.writeInt16(length + 4);
- outMsg.writeString(msg, length);
- return;
+ if (msg.at(0) == mPartyPrefix)
+ {
+ msg.erase(0, 1);
+ std::size_t length = msg.length() + 1;
+
+ if (length == 0)
+ {
+ chatLog("Trying to send a blank party message.", BY_SERVER);
+ return;
+ }
+ MessageOut outMsg(mNetwork);
+
+ outMsg.writeInt16(CMSG_PARTY_MESSAGE);
+ outMsg.writeInt16(length + 4);
+ outMsg.writeString(msg, length);
+ return;
}
// Prepare ordinary message
if (msg.substr(0, 1) != "/") {
- msg = nick + " : " + msg;
+ msg = nick + " : " + msg;
- MessageOut outMsg(mNetwork);
- outMsg.writeInt16(CMSG_CHAT_MESSAGE);
- // Added + 1 in order to let eAthena parse admin commands correctly
- outMsg.writeInt16(msg.length() + 4 + 1);
- outMsg.writeString(msg, msg.length() + 1);
- return;
+ MessageOut outMsg(mNetwork);
+ outMsg.writeInt16(CMSG_CHAT_MESSAGE);
+ // Added + 1 in order to let eAthena parse admin commands correctly
+ outMsg.writeInt16(msg.length() + 4 + 1);
+ outMsg.writeString(msg, msg.length() + 1);
+ return;
}
msg.erase(0, 1);
trim(msg);
std::size_t space = msg.find(" ");
std::string command = msg.substr(0, space);
- if (space == std::string::npos) {
- msg = "";
- } else {
- msg = msg.substr(space);
- trim(msg);
- }
-
- if (command == "announce") {
- MessageOut outMsg(mNetwork);
- outMsg.writeInt16(0x0099);
- outMsg.writeInt16(msg.length() + 4);
- outMsg.writeString(msg, msg.length());
- return;
- }
- if (command == "help") {
- std::size_t space = msg.find(" ");
- std::string msg1;
- if (space == std::string::npos) {
- msg1 = "";
- } else {
- msg1 = msg.substr(space + 1, msg.length());
- msg = msg.substr(0, space);
- }
- if (msg != "" && msg.at(0) == '/') {
- msg.erase(0, 1);
- }
- while (msg1 != "" && msg1.at(0) == ' ') {
- msg1.erase(0, 1);
- }
- help(msg, msg1);
- return;
- }
- if (command == "where") {
- // Display the current map, X, and Y
- std::ostringstream where;
- where << map_path << " " << player_node->mX << " " << player_node->mY;
- chatLog(where.str(), BY_SERVER);
- return;
- }
- if (command == "who") {
- MessageOut outMsg(mNetwork);
- outMsg.writeInt16(0x00c1);
- return;
- }
- if (command == "clear") {
- mTextOutput->clearRows();
- return;
- }
- if (command == "whisper") {
- std::string recvnick = "";
-
- if (msg.substr(0, 1) == "\"") {
- const std::string::size_type pos = msg.find('"', 1);
- if (pos != std::string::npos) {
- recvnick = msg.substr(1, pos - 1);
- msg.erase(0, pos + 2);
- }
- } else {
- const std::string::size_type pos = msg.find(" ");
- if (pos != std::string::npos) {
- recvnick = msg.substr(0, pos);
- msg.erase(0, pos + 1);
- }
- }
-
- MessageOut outMsg(mNetwork);
- outMsg.writeInt16(CMSG_CHAT_WHISPER);
- outMsg.writeInt16(msg.length() + 28);
- outMsg.writeString(recvnick, 24);
- outMsg.writeString(msg, msg.length());
-
- chatLog("Whispering to " + recvnick + " : " + msg, BY_PLAYER);
- return;
- }
- if (command == "record") {
+ if (space == std::string::npos)
+ {
+ msg = "";
+ }
+ else
+ {
+ msg = msg.substr(space);
+ trim(msg);
+ }
+
+ if (command == "announce")
+ {
+ MessageOut outMsg(mNetwork);
+ outMsg.writeInt16(0x0099);
+ outMsg.writeInt16(msg.length() + 4);
+ outMsg.writeString(msg, msg.length());
+ return;
+ }
+ if (command == "help")
+ {
+ std::size_t space = msg.find(" ");
+ std::string msg1;
+ if (space == std::string::npos)
+ {
+ msg1 = "";
+ }
+ else
+ {
+ msg1 = msg.substr(space + 1, msg.length());
+ msg = msg.substr(0, space);
+ }
+ if (msg != "" && msg.at(0) == '/')
+ {
+ msg.erase(0, 1);
+ }
+ while (msg1 != "" && msg1.at(0) == ' ')
+ {
+ msg1.erase(0, 1);
+ }
+ help(msg, msg1);
+ return;
+ }
+ if (command == "where")
+ {
+ chatLog(map_path, BY_SERVER);
+ return;
+ }
+ if (command == "who")
+ {
+ MessageOut outMsg(mNetwork);
+ outMsg.writeInt16(0x00c1);
+ return;
+ }
+ if (command == "clear")
+ {
+ mTextOutput->clearRows();
+ return;
+ }
+ if (command == "whisper")
+ {
+ std::string recvnick = "";
+
+ if (msg.substr(0,1) == "\"")
+ {
+ const std::string::size_type pos = msg.find('"', 1);
+ if (pos != std::string::npos) {
+ recvnick = msg.substr(1, pos - 1);
+ msg.erase(0, pos + 2);
+ }
+ }
+ else
+ {
+ const std::string::size_type pos = msg.find(" ");
+ if (pos != std::string::npos) {
+ recvnick = msg.substr(0, pos);
+ msg.erase(0, pos + 1);
+ }
+ }
+
+ MessageOut outMsg(mNetwork);
+ outMsg.writeInt16(CMSG_CHAT_WHISPER);
+ outMsg.writeInt16(msg.length() + 28);
+ outMsg.writeString(recvnick, 24);
+ outMsg.writeString(msg, msg.length());
+
+ chatLog("Whispering to " + recvnick + " : " + msg, BY_PLAYER);
+ return;
+ }
+ if (command == "record")
+ {
mRecorder->respond(msg);
- return;
- }
- if (command == "toggle") {
- if (msg == "") {
- chatLog(mReturnToggles ? "Return toggles chat."
- : "Message closes chat.", BY_SERVER);
- return;
- }
- msg = msg.substr(0, 1);
- if (msg == "1" || msg == "y" || msg == "t" || msg == "Y" || msg == "T") {
- chatLog("Return now toggles chat.", BY_SERVER);
- mReturnToggles = true;
- return;
- }
- if (msg == "0" || msg == "n" || msg == "f" || msg == "N" || msg == "F") {
- chatLog("Message now closes chat.", BY_SERVER);
- mReturnToggles = false;
- return;
- }
- chatLog("Options to /toggle are \"yes\", \"no\", \"true\", \"false\", "
- "\"1\", \"0\".", BY_SERVER);
- return;
- }
- if (command == "party") {
- if (msg == "") {
- chatLog("Unknown party command... Type \"/help\" party for more "
- "information.", BY_SERVER);
- return;
- }
- const std::string::size_type space = msg.find(" ");
- std::string rest = (space == std::string::npos ? ""
- : msg.substr(space + 1, msg.length()));
- if (rest != "") {
- msg = msg.substr(0, space);
- while (msg != "" && msg[0] == ' ') {
- msg = msg.substr(1, msg.length());
- }
- }
- party(msg, rest);
- return;
- }
- if (command == "present") {
- Beings & beings = beingManager->getAll();
- std::string response = "";
- for (BeingIterator bi = beings.begin(), be = beings.end();
- bi != be; ++bi) {
- if ((*bi)->getType() == Being::PLAYER) {
- if (response != "") {
- response += ", ";
- }
- response += (*bi)->getName();
- }
- }
- if (mRecorder->isRecording()) {
- // Get the current system time
- time_t t;
- time(&t);
-
- // Format the time string properly
- std::stringstream timeStr;
- timeStr << "[" << ((((t / 60) / 60) % 24 < 10) ? "0" : "")
- << (int) (((t / 60) / 60) % 24)
- << ":" << (((t / 60) % 60 < 10) ? "0" : "")
- << (int) ((t / 60) % 60)
- << "] ";
-
-
- mRecorder->record(timeStr.str() + "Present: " + response + ".");
- chatLog("Attendance written to record log.", BY_SERVER, true);
- } else {
- chatLog("Present: " + response, BY_SERVER);
- }
- return;
+ return;
+ }
+ if (command == "toggle")
+ {
+ if (msg == "")
+ {
+ chatLog(mReturnToggles ? "Return toggles chat."
+ : "Message closes chat.", BY_SERVER);
+ return;
+ }
+ msg = msg.substr(0, 1);
+ if (msg == "1" || msg == "y" || msg == "t" || msg == "Y" || msg == "T")
+ {
+ chatLog("Return now toggles chat.", BY_SERVER);
+ mReturnToggles = true;
+ return;
+ }
+ if (msg == "0" || msg == "n" || msg == "f" || msg == "N" || msg == "F")
+ {
+ chatLog("Message now closes chat.", BY_SERVER);
+ mReturnToggles = false;
+ return;
+ }
+ chatLog("Options to /toggle are \"yes\", \"no\", \"true\", \"false\", "
+ "\"1\", \"0\".", BY_SERVER);
+ return;
+ }
+ if (command == "party")
+ {
+ if (msg == "")
+ {
+ chatLog("Unknown party command... Type \"/help\" party for more "
+ "information.", BY_SERVER);
+ return;
+ }
+ const std::string::size_type space = msg.find(" ");
+ std::string rest = (space == std::string::npos ? ""
+ : msg.substr(space + 1, msg.length()));
+ if (rest != "")
+ {
+ msg = msg.substr(0, space);
+ while (msg != "" && msg[0] == ' ')
+ {
+ msg = msg.substr(1, msg.length());
+ }
+ }
+ party(msg, rest);
+ return;
+ }
+ if (command == "present")
+ {
+ Beings &beings = beingManager->getAll();
+ std::string response = "";
+ for (BeingIterator bi = beings.begin(), be = beings.end();
+ bi != be;
+ ++bi)
+ {
+ if ((*bi)->getType() == Being::PLAYER)
+ {
+ if (response != "")
+ {
+ response += ", ";
+ }
+ response += (*bi)->getName();
+ }
+ }
+ if (mRecorder->isRecording())
+ {
+ // Get the current system time
+ time_t t;
+ time(&t);
+
+ // Format the time string properly
+ std::stringstream timeStr;
+ timeStr << "["
+ << ((((t / 60) / 60) % 24 < 10) ? "0" : "")
+ << (int)(((t / 60) / 60) % 24)
+ << ":"
+ << (((t / 60) % 60 < 10) ? "0" : "")
+ << (int)((t / 60) % 60)
+ << "] ";
+
+
+ mRecorder->record(timeStr.str() + "Present: " + response + ".");
+ chatLog("Attendance written to record log.", BY_SERVER, true);
+ }
+ else
+ {
+ chatLog("Present: " + response, BY_SERVER);
+ }
+ return;
}
chatLog("Unknown command", BY_SERVER);
}
-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) {
- switch (act.bskill) {
- case BSKILL_TRADE:
- msg = "Trade failed!";
- break;
- case BSKILL_EMOTE:
- msg = "Emote failed!";
- break;
- case BSKILL_SIT:
- msg = "Sit failed!";
- break;
- case BSKILL_CREATECHAT:
- msg = "Chat creating failed!";
- break;
- case BSKILL_JOINPARTY:
- msg = "Could not join party!";
- break;
- case BSKILL_SHOUT:
- msg = "Cannot shout!";
- break;
- }
-
- switch (act.reason) {
- case RFAIL_SKILLDEP:
- msg += " You have not yet reached a high enough level!";
- break;
- case RFAIL_INSUFHP:
- msg += " Insufficient HP!";
- break;
- case RFAIL_INSUFSP:
- msg += " Insufficient SP!";
- break;
- case RFAIL_NOMEMO:
- msg += " You have no memos!";
- break;
- case RFAIL_SKILLDELAY:
- msg += " You cannot do that right now!";
- break;
- case RFAIL_ZENY:
- msg += " Seems you need more Zeny... ;-)";
- break;
- case RFAIL_WEAPON:
- msg += " You cannot use this skill with that kind of weapon!";
- break;
- case RFAIL_REDGEM:
- msg += " You need another red gem!";
- break;
- case RFAIL_BLUEGEM:
- msg += " You need another blue gem!";
- break;
- case RFAIL_OVERWEIGHT:
- msg += " You're carrying to much to do this!";
- break;
- default:
- msg += " Huh? What's that?";
- break;
- }
+ switch (act.bskill) {
+ case BSKILL_TRADE :
+ msg = "Trade failed!";
+ break;
+ case BSKILL_EMOTE :
+ msg = "Emote failed!";
+ break;
+ case BSKILL_SIT :
+ msg = "Sit failed!";
+ break;
+ case BSKILL_CREATECHAT :
+ msg = "Chat creating failed!";
+ break;
+ case BSKILL_JOINPARTY :
+ msg = "Could not join party!";
+ break;
+ case BSKILL_SHOUT :
+ msg = "Cannot shout!";
+ break;
+ }
+
+ switch (act.reason) {
+ case RFAIL_SKILLDEP :
+ msg += " You have not yet reached a high enough level!";
+ break;
+ case RFAIL_INSUFHP :
+ msg += " Insufficient HP!";
+ break;
+ case RFAIL_INSUFSP :
+ msg += " Insufficient SP!";
+ break;
+ case RFAIL_NOMEMO :
+ msg += " You have no memos!";
+ break;
+ case RFAIL_SKILLDELAY :
+ msg += " You cannot do that right now!";
+ break;
+ case RFAIL_ZENY :
+ msg += " Seems you need more Zeny... ;-)";
+ break;
+ case RFAIL_WEAPON :
+ msg += " You cannot use this skill with that kind of weapon!";
+ break;
+ case RFAIL_REDGEM :
+ msg += " You need another red gem!";
+ break;
+ case RFAIL_BLUEGEM :
+ msg += " You need another blue gem!";
+ break;
+ case RFAIL_OVERWEIGHT :
+ msg += " You're carrying to much to do this!";
+ break;
+ default :
+ msg += " Huh? What's that?";
+ break;
+ }
} else {
- switch (act.skill) {
- case SKILL_WARP:
- msg = "Warp failed...";
- break;
- case SKILL_STEAL:
- msg = "Could not steal anything...";
- break;
- case SKILL_ENVENOM:
- msg = "Poison had no effect...";
- break;
- }
+ switch(act.skill) {
+ case SKILL_WARP :
+ msg = "Warp failed...";
+ break;
+ case SKILL_STEAL :
+ msg = "Could not steal anything...";
+ break;
+ case SKILL_ENVENOM :
+ msg = "Poison had no effect...";
+ break;
+ }
}
return msg;
}
-void ChatWindow::scroll(int amount)
+void
+ChatWindow::scroll(int amount)
{
if (!isVisible())
- return;
+ return;
int range = mScrollArea->getHeight() / 8 * amount;
gcn::Rectangle scr;
@@ -537,34 +592,41 @@ void ChatWindow::scroll(int amount)
mTextOutput->showPart(scr);
}
-void ChatWindow::keyPressed(gcn::KeyEvent & event)
+void
+ChatWindow::keyPressed(gcn::KeyEvent &event)
{
if (event.getKey().getValue() == gcn::Key::DOWN &&
- mCurHist != mHistory.end()) {
- // Move forward through the history
- HistoryIterator prevHist = mCurHist++;
- if (mCurHist != mHistory.end()) {
- mChatInput->setText(*mCurHist);
- mChatInput->setCaretPosition(mChatInput->getText().length());
- } else {
- mCurHist = prevHist;
- }
- } else if (event.getKey().getValue() == gcn::Key::UP &&
- mCurHist != mHistory.begin() && mHistory.size() > 0) {
- // Move backward through the history
- mCurHist--;
- mChatInput->setText(*mCurHist);
- mChatInput->setCaretPosition(mChatInput->getText().length());
+ mCurHist != mHistory.end())
+ {
+ // Move forward through the history
+ HistoryIterator prevHist = mCurHist++;
+ if (mCurHist != mHistory.end()) {
+ mChatInput->setText(*mCurHist);
+ mChatInput->setCaretPosition(mChatInput->getText().length());
+ }
+ else {
+ mCurHist = prevHist;
+ }
+ }
+ else if (event.getKey().getValue() == gcn::Key::UP &&
+ mCurHist != mHistory.begin() && mHistory.size() > 0)
+ {
+ // Move backward through the history
+ mCurHist--;
+ mChatInput->setText(*mCurHist);
+ mChatInput->setCaretPosition(mChatInput->getText().length());
}
}
-void ChatWindow::setInputText(std::string input_str)
+void
+ChatWindow::setInputText(std::string input_str)
{
- mChatInput->setText(input_str + " ");
- requestChatFocus();
+ mChatInput->setText(input_str + " ");
+ requestChatFocus();
}
-void ChatWindow::setVisible(bool isVisible)
+void
+ChatWindow::setVisible(bool isVisible)
{
Window::setVisible(isVisible);
@@ -576,64 +638,78 @@ void ChatWindow::setVisible(bool isVisible)
mTmpVisible = false;
}
-void ChatWindow::party(const std::string & command, const std::string & rest)
+void
+ChatWindow::party(const std::string &command, const std::string &rest)
{
- if (command == "prefix") {
- if (rest == "") {
- char temp[2] = ".";
- *temp = mPartyPrefix;
- chatLog("The current party prefix is " + std::string(temp),
- BY_SERVER);
- return;
- }
- if (rest.length() != 1) {
- chatLog("Party prefix must be one character long.", BY_SERVER);
- } else {
- if (rest == "/") {
- chatLog("Cannot use a '/' as the prefix.", BY_SERVER);
- } else {
- mPartyPrefix = rest.at(0);
- chatLog("Changing prefix to " + rest, BY_SERVER);
- }
- }
- return;
+ if (command == "prefix")
+ {
+ if (rest == "")
+ {
+ char temp[2] = ".";
+ *temp = mPartyPrefix;
+ chatLog("The current party prefix is " + std::string(temp),
+ BY_SERVER);
+ return;
+ }
+ if (rest.length() != 1)
+ {
+ chatLog("Party prefix must be one character long.", BY_SERVER);
+ }
+ else
+ {
+ if (rest == "/")
+ {
+ chatLog("Cannot use a '/' as the prefix.", BY_SERVER);
+ }
+ else
+ {
+ mPartyPrefix = rest.at(0);
+ chatLog("Changing prefix to " + rest, BY_SERVER);
+ }
+ }
+ return;
}
mParty->respond(command, rest);
}
-void ChatWindow::help(const std::string & msg1, const std::string & msg2)
+void
+ChatWindow::help(const std::string &msg1, const std::string &msg2)
{
chatLog("-- Help --", BY_SERVER);
- if (msg1 == "") {
- chatLog("/announce: Global announcement (GM only)", BY_SERVER);
- chatLog("/clear: Clears this window", BY_SERVER);
- chatLog("/help: Display this help.", BY_SERVER);
- mParty->help();
- chatLog("/present: Get list of players present", BY_SERVER);
- mRecorder->help();
- chatLog("/toggle: Determine whether <return> toggles the chat log.",
- BY_SERVER);
- chatLog("/where: Display map name", BY_SERVER);
- chatLog("/whisper <nick> <message>: Sends a private <message>"
- " to <nick>", BY_SERVER);
- chatLog("/who: Display number of online users", BY_SERVER);
- chatLog("For more information, type /help <command>", BY_SERVER);
- return;
- }
- if (msg1 == "announce") {
- chatLog("Command: /announce <msg>", BY_SERVER);
- chatLog("*** only available to a GM ***", BY_SERVER);
- chatLog("This command sends the message <msg> to "
- "all players currently online.", BY_SERVER);
- return;
- }
- if (msg1 == "clear") {
- chatLog("Command: /clear", BY_SERVER);
- chatLog("This command clears the chat log of previous chat.",
- BY_SERVER);
- return;
- }
- if (msg1 == "help") {
+ if (msg1 == "")
+ {
+ chatLog("/announce: Global announcement (GM only)", BY_SERVER);
+ chatLog("/clear: Clears this window", BY_SERVER);
+ chatLog("/help: Display this help.", BY_SERVER);
+ mParty->help();
+ chatLog("/present: Get list of players present", BY_SERVER);
+ mRecorder->help();
+ chatLog("/toggle: Determine whether <return> toggles the chat log.",
+ BY_SERVER);
+ chatLog("/where: Display map name", BY_SERVER);
+ chatLog("/whisper <nick> <message>: Sends a private <message>"
+ " to <nick>", BY_SERVER);
+ chatLog("/who: Display number of online users", BY_SERVER);
+ chatLog("For more information, type /help <command>", BY_SERVER);
+ return;
+ }
+ if (msg1 == "announce")
+ {
+ chatLog("Command: /announce <msg>", BY_SERVER);
+ chatLog("*** only available to a GM ***", BY_SERVER);
+ chatLog("This command sends the message <msg> to "
+ "all players currently online.", BY_SERVER);
+ return;
+ }
+ if (msg1 == "clear")
+ {
+ chatLog("Command: /clear", BY_SERVER);
+ chatLog("This command clears the chat log of previous chat.",
+ BY_SERVER);
+ return;
+ }
+ if (msg1 == "help")
+ {
chatLog("Command: /help", BY_SERVER);
chatLog("This command displays a list of all commands available.",
BY_SERVER);
@@ -641,51 +717,58 @@ void ChatWindow::help(const std::string & msg1, const std::string & msg2)
chatLog("This command displays help on <command>.", BY_SERVER);
return;
}
- if (msg1 == "party") {
+ if (msg1 == "party")
+ {
mParty->help(msg2);
- return;
- }
- if (msg1 == "present") {
- chatLog("Command: /present", BY_SERVER);
- chatLog("This command gets a list of players within hearing "
- "and sends it to either the record log if recording, or the "
- "chat log otherwise.", BY_SERVER);
- return;
- }
- if (msg1 == "record") {
+ return;
+ }
+ if (msg1 == "present")
+ {
+ chatLog("Command: /present", BY_SERVER);
+ chatLog("This command gets a list of players within hearing "
+ "and sends it to either the record log if recording, or the "
+ "chat log otherwise.", BY_SERVER);
+ return;
+ }
+ if (msg1 == "record")
+ {
mRecorder->help(msg2);
- return;
- }
- if (msg1 == "toggle") {
- chatLog("Command: /toggle <state>", BY_SERVER);
- chatLog("This command sets whether the return key should toggle the "
- "chat log, or whether the chat log turns off automatically.",
- BY_SERVER);
- chatLog("<state> can be one of \"1\", \"yes\", \"true\" to turn "
- "the toggle on, or \"0\", \"no\", \"false\" to turn the "
- "toggle off.", BY_SERVER);
- chatLog("Command: /toggle", BY_SERVER);
- chatLog("This command displays the return toggle status.", BY_SERVER);
- return;
- }
- if (msg1 == "where") {
- chatLog("Command: /where", BY_SERVER);
- chatLog("This command displays the name of the current map.",
- BY_SERVER);
- return;
- }
- if (msg1 == "whisper") {
- chatLog("Command: /whisper <nick> <msg>", BY_SERVER);
- chatLog("This command sends the message <msg> to <nick.", BY_SERVER);
- chatLog("If the <nick> has spaces in it, enclose it in "
- "double quotes (\").", BY_SERVER);
- return;
- }
- if (msg1 == "who") {
- chatLog("Command: /who", BY_SERVER);
- chatLog("This command displays the number of players currently "
- "online.", BY_SERVER);
- return;
+ return;
+ }
+ if (msg1 == "toggle")
+ {
+ chatLog("Command: /toggle <state>", BY_SERVER);
+ chatLog("This command sets whether the return key should toggle the "
+ "chat log, or whether the chat log turns off automatically.",
+ BY_SERVER);
+ chatLog("<state> can be one of \"1\", \"yes\", \"true\" to turn "
+ "the toggle on, or \"0\", \"no\", \"false\" to turn the "
+ "toggle off.", BY_SERVER);
+ chatLog("Command: /toggle", BY_SERVER);
+ chatLog("This command displays the return toggle status.", BY_SERVER);
+ return;
+ }
+ if (msg1 == "where")
+ {
+ chatLog("Command: /where", BY_SERVER);
+ chatLog("This command displays the name of the current map.",
+ BY_SERVER);
+ return;
+ }
+ if (msg1 == "whisper")
+ {
+ chatLog("Command: /whisper <nick> <msg>", BY_SERVER);
+ chatLog("This command sends the message <msg> to <nick.", BY_SERVER);
+ chatLog("If the <nick> has spaces in it, enclose it in "
+ "double quotes (\").", BY_SERVER);
+ return;
+ }
+ if (msg1 == "who")
+ {
+ chatLog("Command: /who", BY_SERVER);
+ chatLog("This command displays the number of players currently "
+ "online.", BY_SERVER);
+ return;
}
chatLog("Unknown command.", BY_SERVER);
chatLog("Type /help for a list of commands.", BY_SERVER);
diff --git a/src/gui/setup.cpp b/src/gui/setup.cpp
index ce843452..9c562b68 100644
--- a/src/gui/setup.cpp
+++ b/src/gui/setup.cpp
@@ -31,6 +31,7 @@
#include "setup_video.h"
#include "setup_keyboard.h"
#include "setup_players.h"
+#include "setup_colours.h"
#include "tabbedcontainer.h"
#include "../utils/dtor.h"
@@ -49,21 +50,22 @@ Setup::Setup():
{
setCloseButton(true);
int width = 310;
- int height = 265;
+ int height = 290;
setContentSize(width, height);
const char *buttonNames[] = {
"Apply", "Cancel", "Reset Windows", 0
};
int x = width;
- for (const char **curBtn = buttonNames; *curBtn; ++curBtn) {
+ for (const char **curBtn = buttonNames; *curBtn; ++curBtn)
+ {
Button *btn = new Button(*curBtn, *curBtn, this);
x -= btn->getWidth() + 5;
btn->setPosition(x, height - btn->getHeight() - 5);
add(btn);
}
- TabbedContainer *panel = new TabbedContainer();
+ TabbedContainer *panel = new TabbedContainer(width, 5, 20, 45, 5, 3);
panel->setDimension(gcn::Rectangle(5, 5, width, height - 40));
panel->setOpaque(false);
@@ -85,6 +87,10 @@ Setup::Setup():
panel->addTab(tab, "Keyboard");
mTabs.push_back(tab);
+ tab = new Setup_Colours();
+ panel->addTab(tab, "Colours");
+ mTabs.push_back(tab);
+
tab = new Setup_Players();
panel->addTab(tab, "Players");
mTabs.push_back(tab);
diff --git a/src/gui/tabbedcontainer.cpp b/src/gui/tabbedcontainer.cpp
index 71e0f3c4..fc3efbd5 100644
--- a/src/gui/tabbedcontainer.cpp
+++ b/src/gui/tabbedcontainer.cpp
@@ -30,11 +30,17 @@
#include "../utils/tostring.h"
#include "../utils/dtor.h"
-#define TABWIDTH 60
-#define TABHEIGHT 20
-
-TabbedContainer::TabbedContainer():
- mActiveContent(0)
+TabbedContainer::TabbedContainer(int width, int padX, int buttonHeight,
+ int height, int padY, int buttonsPerRow):
+ mActiveContent(0),
+ mWidth(width),
+ mPadX(padX),
+ mButtonHeight(buttonHeight),
+ mHeight(height),
+ mPadY(padY),
+ mButtonsPerRow(buttonsPerRow),
+
+ mButtonWidth((width - (buttonsPerRow - 1) * padX) / buttonsPerRow - padX)
{
}
@@ -52,13 +58,14 @@ void TabbedContainer::addTab(gcn::Widget *widget, const std::string &caption)
Button *tab = new Button(caption, toString(tabNumber), this);
- tab->setSize(TABWIDTH, TABHEIGHT);
- add(tab, TABWIDTH * tabNumber, 0);
+ tab->setSize(mButtonWidth, mButtonHeight);
+ add(tab, (mButtonWidth + mPadX) * (tabNumber % mButtonsPerRow),
+ (mButtonHeight + mPadY) * (tabNumber / mButtonsPerRow));
mTabs[caption] = tab;
mContents.push_back(widget);
- widget->setPosition(0, TABHEIGHT);
+ widget->setPosition(0, mHeight);
// If this is the first tab in this container, make it visible
if (!mActiveContent) {
@@ -83,7 +90,7 @@ void TabbedContainer::logic()
if (mActiveContent) {
mActiveContent->setSize(
getWidth() - 2 * mActiveContent->getFrameSize(),
- getHeight() - TABHEIGHT - 2 * mActiveContent->getFrameSize());
+ getHeight() - mHeight - 2 * mActiveContent->getFrameSize());
}
Container::logic();
diff --git a/src/gui/tabbedcontainer.h b/src/gui/tabbedcontainer.h
index 14f27aba..b004edc2 100644
--- a/src/gui/tabbedcontainer.h
+++ b/src/gui/tabbedcontainer.h
@@ -37,7 +37,8 @@
class TabbedContainer : public gcn::Container, public gcn::ActionListener
{
public:
- TabbedContainer();
+ TabbedContainer(int width, int padX, int buttonHeight,
+ int height, int padY, int buttonsPerRow);
~TabbedContainer();
void addTab(gcn::Widget *widget, const std::string &caption);
@@ -62,6 +63,14 @@ class TabbedContainer : public gcn::Container, public gcn::ActionListener
std::map<gcn::Widget*, std::string> mWidgets;
gcn::Widget *mActiveContent;
+
+ int mWidth; /**< The total width of all buttons */
+ int mPadX; /**< The horizontal gap between buttons */
+ int mButtonHeight; /**< The height of each button */
+ int mHeight; /**< Height of the panel */
+ int mPadY; /**< The vertical gap between buttons */
+ int mButtonsPerRow; /**< The number of buttons on each row */
+ int mButtonWidth; /**< The width of each button */
};
#endif
diff --git a/src/gui/textfield.cpp b/src/gui/textfield.cpp
index 95291267..21c3adbc 100644
--- a/src/gui/textfield.cpp
+++ b/src/gui/textfield.cpp
@@ -38,7 +38,9 @@ int TextField::instances = 0;
ImageRect TextField::skin;
TextField::TextField(const std::string& text):
- gcn::TextField(text)
+ gcn::TextField(text),
+ mNumeric(false),
+ mListener(0)
{
setFrameSize(2);
@@ -102,3 +104,67 @@ void TextField::drawFrame(gcn::Graphics *graphics)
static_cast<Graphics*>(graphics)->drawImageRect(0, 0, w, h, skin);
}
+
+void TextField::setNumeric(bool numeric)
+{
+ mNumeric = numeric;
+ if (!numeric)
+ {
+ return;
+ }
+ const char *text = mText.c_str();
+ for (const char *textPtr = text; *textPtr; ++textPtr)
+ {
+ if (*textPtr < '0' || *textPtr > '9')
+ {
+ setText(mText.substr(0, textPtr - text));
+ return;
+ }
+ }
+}
+
+void TextField::keyPressed(gcn::KeyEvent &keyEvent)
+{
+ if (mNumeric)
+ {
+ while (true)
+ {
+ const gcn::Key &key = keyEvent.getKey();
+ if (key.isNumber())
+ {
+ break;
+ }
+ int value = key.getValue();
+ if (value == gcn::Key::LEFT || value == gcn::Key::RIGHT ||
+ value == gcn::Key::HOME || value == gcn::Key::END ||
+ value == gcn::Key::BACKSPACE || value == gcn::Key::DELETE)
+ {
+ break;
+ }
+ return;
+ }
+ }
+ gcn::TextField::keyPressed(keyEvent);
+ if (mListener)
+ {
+ mListener->listen(this);
+ }
+}
+
+int TextField::getValue() const
+{
+ if (!mNumeric)
+ {
+ return 0;
+ }
+ int value = atoi(mText.c_str());
+ if (value < mMinimum)
+ {
+ return mMinimum;
+ }
+ if (value > mMaximum)
+ {
+ return mMaximum;
+ }
+ return value;
+}
diff --git a/src/gui/textfield.h b/src/gui/textfield.h
index 39bcbf85..0fc53f39 100644
--- a/src/gui/textfield.h
+++ b/src/gui/textfield.h
@@ -28,6 +28,14 @@
class ImageRect;
+class TextField;
+
+class TextFieldListener
+{
+ public:
+ virtual void listen(const TextField *value) = 0;
+};
+
/**
* A text field.
*
@@ -55,9 +63,48 @@ class TextField : public gcn::TextField {
*/
void drawFrame(gcn::Graphics *graphics);
+ /**
+ * Determine whether the field should be numeric or not
+ */
+ void setNumeric(bool numeric);
+
+ /**
+ * Set the range on the field if it is numeric
+ */
+ void setRange(int min, int max) {mMinimum = min; mMaximum = max; }
+
+ /**
+ * Restrict keyboard input if numeric
+ */
+ void keyPressed(gcn::KeyEvent &keyEvent);
+
+ /**
+ * Set the minimum value for a range
+ */
+ void setMinimum(int min) {mMinimum = min; }
+
+ /**
+ * Set the maximum value for a range
+ */
+ void setMaximum(int max) {mMaximum = max; }
+
+ /**
+ * Return the value for a numeric field
+ */
+ int getValue() const;
+
+ /**
+ * Add a listener
+ */
+ void addListener(TextFieldListener *listener) {mListener = listener; }
+
private:
static int instances;
static ImageRect skin;
+ bool mNumeric;
+ int mMinimum;
+ int mMaximum;
+ TextFieldListener *mListener;
};
#endif