From 9ef72eaa168ca047f91f1dce2d98ef2c243b31c2 Mon Sep 17 00:00:00 2001 From: Ira Rice Date: Tue, 27 Jan 2009 15:10:02 -0700 Subject: Removed the fairly useless buttonbox class, as well as removing the recorder's dependence upon it. This class should get a bit more work done to it to simplify it further, but right now, it preserves all of the same functionality. Signed-off-by: Ira Rice --- src/gui/chat.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/gui/chat.cpp') diff --git a/src/gui/chat.cpp b/src/gui/chat.cpp index 1a3cb2a4..068fad08 100644 --- a/src/gui/chat.cpp +++ b/src/gui/chat.cpp @@ -28,6 +28,7 @@ #include "chat.h" #include "chatinput.h" #include "itemlinkhandler.h" +#include "recorder.h" #include "scrollarea.h" #include "sdlinput.h" #include "windowcontainer.h" @@ -40,7 +41,6 @@ #include "../game.h" #include "../localplayer.h" #include "../party.h" -#include "../recorder.h" #include "../net/messageout.h" #include "../net/protocol.h" @@ -477,7 +477,7 @@ void ChatWindow::chatSend(const std::string &nick, std::string msg) else if (command == "whisper" || command == "msg" || command == "w") whisper(nick, msg); else if (command == "record") - mRecorder->respond(msg); + mRecorder->changeStatus(msg); else if (command == "toggle") { if (msg == "") @@ -850,7 +850,7 @@ void ChatWindow::help(const std::string & msg1, const std::string & msg2) } else if (msg1 == "record") { - mRecorder->help(msg2); + mRecorder->help2(); } else if (msg1 == "toggle") { -- cgit v1.2.3-70-g09d2 From 68f3b73a82999b8ee8c7937b9da8060af1f3b691 Mon Sep 17 00:00:00 2001 From: Ira Rice Date: Thu, 29 Jan 2009 08:55:59 -0700 Subject: If an item link isn't found, don't treat it as a link. Signed-off-by: Ira Rice --- src/being.cpp | 3 ++- src/gui/chat.cpp | 20 ++++++++------------ 2 files changed, 10 insertions(+), 13 deletions(-) (limited to 'src/gui/chat.cpp') diff --git a/src/being.cpp b/src/being.cpp index 9de03502..e2495bc0 100644 --- a/src/being.cpp +++ b/src/being.cpp @@ -193,7 +193,8 @@ void Being::setSpeech(const std::string &text, Uint32 time) } std::string::size_type position = mSpeech.find('|'); - mSpeech.erase(end, 1); + if (mSpeech[start + 1] == '@' && mSpeech[start + 2] == '@') + mSpeech.erase(end, 1); mSpeech.erase(start, (position - start) + 1); position = mSpeech.find('@'); diff --git a/src/gui/chat.cpp b/src/gui/chat.cpp index 068fad08..d790d292 100644 --- a/src/gui/chat.cpp +++ b/src/gui/chat.cpp @@ -376,14 +376,7 @@ void ChatWindow::chatSend(const std::string &nick, std::string msg) std::string temp = msg.substr(start+1, end - start - 1); - while (temp[0] == ' ') - { - temp = temp.substr(1, temp.size()); - } - while (temp[temp.size()] == ' ') - { - temp = temp.substr(0, temp.size() - 1); - } + trim(temp); for (unsigned int i = 0; i < temp.size(); i++) { @@ -391,10 +384,13 @@ void ChatWindow::chatSend(const std::string &nick, std::string msg) } const ItemInfo itemInfo = ItemDB::get(temp); - msg.insert(end, "@@"); - msg.insert(start+1, "|"); - msg.insert(start+1, toString(itemInfo.getId())); - msg.insert(start+1, "@@"); + if (itemInfo.getName() != _("Unknown item")) + { + msg.insert(end, "@@"); + msg.insert(start+1, "|"); + msg.insert(start+1, toString(itemInfo.getId())); + msg.insert(start+1, "@@"); + } } start = msg.find('[', start + 1); } -- cgit v1.2.3-70-g09d2 From 59cfd8a03f22f43539d47a55087ad5768e7a330f Mon Sep 17 00:00:00 2001 From: Ira Rice Date: Thu, 29 Jan 2009 09:27:45 -0700 Subject: Don't send empty chats (long lines of empty spaces). Signed-off-by: Ira Rice --- src/gui/chat.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/gui/chat.cpp') diff --git a/src/gui/chat.cpp b/src/gui/chat.cpp index d790d292..3a22581f 100644 --- a/src/gui/chat.cpp +++ b/src/gui/chat.cpp @@ -341,6 +341,11 @@ void ChatWindow::chatSend(const std::string &nick, std::string msg) * require server handling by proper packet. Probably * those if elses should be replaced by protocol calls */ + trim(msg); + + if (msg.compare("") == 0) + return; + // Send party message if (msg.at(0) == mPartyPrefix) { -- cgit v1.2.3-70-g09d2 From 5a217925e3088bfbb187d274ced159754e2397c2 Mon Sep 17 00:00:00 2001 From: Ira Rice Date: Thu, 29 Jan 2009 17:34:37 -0700 Subject: Trimmed out a few help functions from some subclasses, and moved them back to the chat class, where they really belong. Since the party class parses its own suboptions, I left the suboptions within that class. Signed-off-by: Ira Rice --- src/gui/chat.cpp | 13 +++++++++---- src/gui/recorder.cpp | 19 ++----------------- src/gui/recorder.h | 15 ++------------- src/party.cpp | 5 ----- src/party.h | 1 - 5 files changed, 13 insertions(+), 40 deletions(-) (limited to 'src/gui/chat.cpp') diff --git a/src/gui/chat.cpp b/src/gui/chat.cpp index 3a22581f..36e33160 100644 --- a/src/gui/chat.cpp +++ b/src/gui/chat.cpp @@ -478,7 +478,7 @@ void ChatWindow::chatSend(const std::string &nick, std::string msg) else if (command == "whisper" || command == "msg" || command == "w") whisper(nick, msg); else if (command == "record") - mRecorder->changeStatus(msg); + mRecorder->changeRecordingStatus(msg); else if (command == "toggle") { if (msg == "") @@ -804,10 +804,11 @@ void ChatWindow::help(const std::string & msg1, const std::string & msg2) 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(_("/party : Party commands."), BY_SERVER); chatLog(_("/msg : Alternate form for /whisper"), BY_SERVER); chatLog(_("/present: Get list of players present"), BY_SERVER); - mRecorder->help(); + chatLog(_("/record : Start recording the chat to an" + " external file."), BY_SERVER); chatLog(_("/toggle: Determine whether toggles the chat log."), BY_SERVER); chatLog(_("/where: Display map name"), BY_SERVER); @@ -851,7 +852,11 @@ void ChatWindow::help(const std::string & msg1, const std::string & msg2) } else if (msg1 == "record") { - mRecorder->help2(); + chatLog(_("Command: /record "), BY_SERVER); + chatLog(_("This command starts recording the chat log to the file " + "."), BY_SERVER); + chatLog(_("Command: /record"), BY_SERVER); + chatLog(_("This command finishes a recording session."), BY_SERVER); } else if (msg1 == "toggle") { diff --git a/src/gui/recorder.cpp b/src/gui/recorder.cpp index da67875b..02eddbe5 100644 --- a/src/gui/recorder.cpp +++ b/src/gui/recorder.cpp @@ -46,7 +46,7 @@ void Recorder::record(const std::string &msg) } } -void Recorder::changeStatus(const std::string &msg) +void Recorder::changeRecordingStatus(const std::string &msg) { std::string msgCopy = msg; trim(msgCopy); @@ -91,24 +91,9 @@ void Recorder::changeStatus(const std::string &msg) } } -void Recorder::help() const -{ - mChat->chatLog("/record : Start recording the chat.", BY_SERVER); -} - -void Recorder::help2() const -{ - mChat->chatLog("Command: /record ", BY_SERVER); - mChat->chatLog("This command starts recording the chat log to the file " - ".", BY_SERVER); - mChat->chatLog("Command: /record", BY_SERVER); - mChat->chatLog("This command finishes a recording session.", BY_SERVER); -} - void Recorder::action(const gcn::ActionEvent &event) { - if (event.getId() == "activate") - changeStatus(""); + changeRecordingStatus(""); } Recorder::~Recorder() diff --git a/src/gui/recorder.h b/src/gui/recorder.h index 6f917c25..420c4a2b 100644 --- a/src/gui/recorder.h +++ b/src/gui/recorder.h @@ -53,20 +53,9 @@ class Recorder : public Window, public gcn::ActionListener /* * Outputs the message to the recorder file * - * @param msg the line to write to the recorded file. - */ - void changeStatus(const std::string &msg); - - /* - * Displays a help message on how to use this class in the chat window. - */ - void help() const; - - /* - * Displays an extended help message on how to use this class in the - * chat window. + * @param msg The file to write out to. If null, then stop recording. */ - void help2() const; + void changeRecordingStatus(const std::string &msg); /* * Whether or not the recorder is in use. diff --git a/src/party.cpp b/src/party.cpp index ecb0ab2d..67262176 100644 --- a/src/party.cpp +++ b/src/party.cpp @@ -166,11 +166,6 @@ void Party::receiveChat(Being *being, const std::string &msg) mChat->chatLog(being->getName() + " : " + msg, BY_PARTY); } -void Party::help() -{ - mChat->chatLog(_("/party : Party commands."), BY_SERVER); -} - void Party::help(const std::string &msg) { if (msg == "") diff --git a/src/party.h b/src/party.h index 8d6dce47..5643f894 100644 --- a/src/party.h +++ b/src/party.h @@ -47,7 +47,6 @@ class Party void leftResponse(const std::string &nick); void receiveChat(Being *being, const std::string &msg); - void help(); void help(const std::string &msg); private: ChatWindow *mChat; -- cgit v1.2.3-70-g09d2 From 555e68e24f2bb7d38f7ce52ce9a43198c0ccedec Mon Sep 17 00:00:00 2001 From: Ira Rice Date: Wed, 4 Feb 2009 11:46:03 -0700 Subject: Went through the gui folder and revised the include statements to not include anything not needed by that specific widget or window. This appears to have cleaned up system performance a bit on my current setup, where it went from idling on 45% in game with opengl down to 30% now. Also moved iptostring to the tostring header, as importing all of network.h is a little overkill to use that function, and it goes along with the basic functions that are in that header file anyways. TODO: find out a way to get rid of warnings when a class doesn't use this function. Signed-off-by: Ira Rice --- aethyra.cbp | 1 - src/CMakeLists.txt | 1 - src/Makefile.am | 1 - src/extensions.h | 34 ------------------------------- src/gui/browserbox.h | 5 +---- src/gui/button.cpp | 12 +++++------ src/gui/button.h | 4 ---- src/gui/buy.h | 6 +++--- src/gui/buysell.h | 2 -- src/gui/char_select.cpp | 1 + src/gui/char_select.h | 9 +++------ src/gui/char_server.cpp | 17 +++++++--------- src/gui/char_server.h | 2 -- src/gui/chat.cpp | 43 +++++++++++++++++----------------------- src/gui/chat.h | 3 --- src/gui/chatinput.h | 2 -- src/gui/checkbox.h | 7 ++----- src/gui/colour.cpp | 2 -- src/gui/colour.h | 3 --- src/gui/confirm_dialog.cpp | 3 +++ src/gui/confirm_dialog.h | 9 ++++----- src/gui/connection.cpp | 7 ++++--- src/gui/debugwindow.cpp | 1 - src/gui/debugwindow.h | 4 ---- src/gui/emotecontainer.h | 2 -- src/gui/emoteshortcutcontainer.h | 4 ---- src/gui/emotewindow.cpp | 5 ----- src/gui/emotewindow.h | 2 -- src/gui/focushandler.h | 2 -- src/gui/gccontainer.h | 2 -- src/gui/gui.cpp | 25 +++++++++++++---------- src/gui/help.h | 2 -- src/gui/inttextfield.h | 2 -- src/gui/inventorywindow.cpp | 1 - src/gui/inventorywindow.h | 1 - src/gui/item_amount.cpp | 3 ++- src/gui/item_amount.h | 4 ---- src/gui/itemcontainer.cpp | 1 - src/gui/itemcontainer.h | 2 -- src/gui/itemlinkhandler.cpp | 6 +++--- src/gui/itempopup.cpp | 8 ++------ src/gui/itempopup.h | 7 +++---- src/gui/itemshortcutcontainer.h | 2 -- src/gui/listbox.cpp | 3 +-- src/gui/listbox.h | 2 -- src/gui/login.cpp | 1 + src/gui/login.h | 1 - src/gui/menuwindow.h | 2 -- src/gui/minimap.h | 2 -- src/gui/ministatus.h | 4 ---- src/gui/npc_text.cpp | 4 +--- src/gui/npc_text.h | 3 +-- src/gui/npcintegerdialog.cpp | 11 +++------- src/gui/npcintegerdialog.h | 5 ----- src/gui/npclistdialog.cpp | 2 ++ src/gui/npclistdialog.h | 5 ----- src/gui/npcstringdialog.cpp | 7 +------ src/gui/npcstringdialog.h | 5 ----- src/gui/ok_dialog.cpp | 7 +++++-- src/gui/ok_dialog.h | 6 ++---- src/gui/passwordfield.cpp | 2 -- src/gui/passwordfield.h | 4 ++-- src/gui/playerbox.cpp | 2 -- src/gui/playerbox.h | 2 -- src/gui/popupmenu.cpp | 4 ---- src/gui/progressbar.cpp | 4 ++-- src/gui/progressbar.h | 5 ++--- src/gui/radiobutton.h | 5 ++--- src/gui/recorder.cpp | 1 - src/gui/recorder.h | 2 -- src/gui/register.cpp | 8 ++------ src/gui/register.h | 4 +--- src/gui/scrollarea.cpp | 2 -- src/gui/scrollarea.h | 2 -- src/gui/sell.cpp | 8 +------- src/gui/sell.h | 4 ++-- src/gui/setup.cpp | 3 --- src/gui/setup_audio.h | 2 -- src/gui/setup_colours.cpp | 2 -- src/gui/setup_colours.h | 2 +- src/gui/setup_joystick.h | 2 -- src/gui/setup_keyboard.h | 1 - src/gui/setup_players.cpp | 4 +++- src/gui/setup_players.h | 11 +++++----- src/gui/setup_video.h | 2 -- src/gui/shop.h | 3 +-- src/gui/shoplistbox.cpp | 4 +--- src/gui/shoplistbox.h | 3 +-- src/gui/shortcutcontainer.cpp | 7 ------- src/gui/shortcutcontainer.h | 8 +++----- src/gui/shortcutwindow.cpp | 2 +- src/gui/shortcutwindow.h | 4 +--- src/gui/skill.cpp | 28 ++++++++++++-------------- src/gui/skill.h | 8 ++------ src/gui/slider.h | 2 -- src/gui/speechbubble.cpp | 13 ++---------- src/gui/speechbubble.h | 9 +++++---- src/gui/status.h | 4 ---- src/gui/table.cpp | 2 -- src/gui/table.h | 4 ---- src/gui/table_model.cpp | 3 --- src/gui/table_model.h | 5 ----- src/gui/textbox.cpp | 1 - src/gui/textbox.h | 5 ++--- src/gui/textfield.cpp | 4 ---- src/gui/textfield.h | 2 -- src/gui/trade.cpp | 2 -- src/gui/updatewindow.cpp | 6 +++--- src/gui/updatewindow.h | 2 -- src/gui/viewport.cpp | 5 ----- src/gui/viewport.h | 2 -- src/gui/widgets/dropdown.cpp | 2 ++ src/gui/widgets/dropdown.h | 7 ------- src/gui/widgets/resizegrip.h | 2 -- src/gui/widgets/tab.cpp | 2 -- src/gui/window.cpp | 2 -- src/gui/windowcontainer.h | 5 ++--- src/main.cpp | 1 + src/net/charserverhandler.cpp | 3 ++- src/net/loginhandler.cpp | 3 ++- src/net/network.cpp | 14 +------------ src/net/network.h | 3 --- src/utils/tostring.h | 15 ++++++++++++++ 123 files changed, 177 insertions(+), 438 deletions(-) delete mode 100644 src/extensions.h (limited to 'src/gui/chat.cpp') diff --git a/aethyra.cbp b/aethyra.cbp index 2ee2501b..c383dff3 100644 --- a/aethyra.cbp +++ b/aethyra.cbp @@ -106,7 +106,6 @@ - diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 8cd062c9..86deec0c 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -323,7 +323,6 @@ SET(SRCS engine.h equipment.cpp equipment.h - extensions.h floor_item.cpp floor_item.h flooritemmanager.cpp diff --git a/src/Makefile.am b/src/Makefile.am index 3aeecc02..c6a9a9c4 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -272,7 +272,6 @@ aethyra_SOURCES = gui/widgets/dropdown.cpp \ engine.h \ equipment.cpp \ equipment.h \ - extensions.h \ floor_item.cpp \ floor_item.h \ flooritemmanager.cpp \ diff --git a/src/extensions.h b/src/extensions.h deleted file mode 100644 index 5b95afc8..00000000 --- a/src/extensions.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Aethyra - * Copyright 2008 Lloyd Bryant - * - * This file is part of the Aethyra project. - * - * Aethyra 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. - * - * Aethyra 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 - * - */ - -#ifndef _EXTENSIONS_ -#define _EXTENSIONS_ - -struct EXTENSIONS -{ - bool aethyra_inventory; - bool aethyra_spells; - bool aethyra_misc; -}; - -extern struct EXTENSIONS extensions; -#endif diff --git a/src/gui/browserbox.h b/src/gui/browserbox.h index 4bdf224b..15c2ab89 100644 --- a/src/gui/browserbox.h +++ b/src/gui/browserbox.h @@ -22,15 +22,12 @@ #ifndef BROWSERBOX_H #define BROWSERBOX_H -#include +#include #include #include #include -#include "../guichanfwd.h" -#include "../main.h" - class LinkHandler; struct BROWSER_LINK { diff --git a/src/gui/button.cpp b/src/gui/button.cpp index d578202e..2e6bed0a 100644 --- a/src/gui/button.cpp +++ b/src/gui/button.cpp @@ -19,6 +19,12 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#include + +#include +#include +#include + #include "button.h" #include "../configuration.h" @@ -29,12 +35,6 @@ #include "../utils/dtor.h" -#include -#include -#include - -#include - int Button::mInstances = 0; float Button::mAlpha = config.getValue("guialpha", 0.8); diff --git a/src/gui/button.h b/src/gui/button.h index 1faf2455..abaf5c43 100644 --- a/src/gui/button.h +++ b/src/gui/button.h @@ -22,12 +22,8 @@ #ifndef BUTTON_H #define BUTTON_H -#include - #include -#include "../guichanfwd.h" - class ImageRect; /** diff --git a/src/gui/buy.h b/src/gui/buy.h index 423918ce..0f1cfede 100644 --- a/src/gui/buy.h +++ b/src/gui/buy.h @@ -25,9 +25,9 @@ #include #include -#include "window.h" +#include -#include "../guichanfwd.h" +#include "window.h" class Network; class ShopItems; @@ -40,7 +40,7 @@ class ListBox; * \ingroup Interface */ class BuyDialog : public Window, public gcn::ActionListener, - gcn::SelectionListener + public gcn::SelectionListener { public: /** diff --git a/src/gui/buysell.h b/src/gui/buysell.h index 60a6398d..e3cdc52a 100644 --- a/src/gui/buysell.h +++ b/src/gui/buysell.h @@ -26,8 +26,6 @@ #include "window.h" -#include "../guichanfwd.h" - /** * A dialog to choose between buying or selling at a shop. * diff --git a/src/gui/char_select.cpp b/src/gui/char_select.cpp index e556dfa0..4433b646 100644 --- a/src/gui/char_select.cpp +++ b/src/gui/char_select.cpp @@ -22,6 +22,7 @@ #include #include + #include #include "button.h" diff --git a/src/gui/char_select.h b/src/gui/char_select.h index 5d4ecfa8..23de061d 100644 --- a/src/gui/char_select.h +++ b/src/gui/char_select.h @@ -26,9 +26,8 @@ #include "window.h" -#include "../guichanfwd.h" -#include "../lockedarray.h" #include "../being.h" +#include "../lockedarray.h" class LocalPlayer; class Network; @@ -109,14 +108,12 @@ class CharCreateDialog : public Window, public gcn::ActionListener */ ~CharCreateDialog(); - void - action(const gcn::ActionEvent &event); + void action(const gcn::ActionEvent &event); /** * Unlocks the dialog, enabling the create character button again. */ - void - unlock(); + void unlock(); private: /** diff --git a/src/gui/char_server.cpp b/src/gui/char_server.cpp index 2e823b60..bc096379 100644 --- a/src/gui/char_server.cpp +++ b/src/gui/char_server.cpp @@ -28,10 +28,7 @@ #include "../main.h" #include "../serverinfo.h" -#include "../net/network.h" // TODO this is just for iptostring, move that? - #include "../utils/gettext.h" -#include "../utils/strprintf.h" #include "../utils/tostring.h" extern SERVER_INFO **server_info; @@ -39,7 +36,8 @@ extern SERVER_INFO **server_info; /** * The list model for the server list. */ -class ServerListModel : public gcn::ListModel { +class ServerListModel : public gcn::ListModel +{ public: virtual ~ServerListModel() {}; @@ -80,13 +78,12 @@ ServerSelectDialog::ServerSelectDialog(LoginData *loginData, int nextState): add(mOkButton); add(mCancelButton); - if (n_server == 0) { + if (n_server == 0) // Disable Ok button mOkButton->setEnabled(false); - } else { + else // Select first server mServerList->setSelected(1); - } setLocationRelativeTo(getParent()); setVisible(true); @@ -100,7 +97,8 @@ ServerSelectDialog::~ServerSelectDialog() void ServerSelectDialog::action(const gcn::ActionEvent &event) { - if (event.getId() == "ok") { + if (event.getId() == "ok") + { mOkButton->setEnabled(false); const SERVER_INFO *si = server_info[mServerList->getSelected()]; mLoginData->hostname = iptostring(si->address); @@ -108,9 +106,8 @@ void ServerSelectDialog::action(const gcn::ActionEvent &event) mLoginData->updateHost = si->updateHost; state = mNextState; } - else if (event.getId() == "cancel") { + else if (event.getId() == "cancel") state = LOGIN_STATE; - } } int ServerListModel::getNumberOfElements() diff --git a/src/gui/char_server.h b/src/gui/char_server.h index 9419c92d..49a5b47b 100644 --- a/src/gui/char_server.h +++ b/src/gui/char_server.h @@ -27,8 +27,6 @@ #include "window.h" -#include "../guichanfwd.h" - class LoginData; class ServerListModel; diff --git a/src/gui/chat.cpp b/src/gui/chat.cpp index 36e33160..a58600a8 100644 --- a/src/gui/chat.cpp +++ b/src/gui/chat.cpp @@ -20,7 +20,6 @@ */ #include -#include #include @@ -37,7 +36,6 @@ #include "../beingmanager.h" #include "../configuration.h" -#include "../extensions.h" #include "../game.h" #include "../localplayer.h" #include "../party.h" @@ -538,32 +536,27 @@ void ChatWindow::chatSend(const std::string &nick, std::string msg) * This will eventually be replaced by a GUI, so * we don't need to get too sophisticated */ - if (extensions.aethyra_spells) + MessageOut outMsg(mNetwork); + if (msg == "heal") { - MessageOut outMsg(mNetwork); - if (msg == "heal") - { - outMsg.writeInt16(0x03f3); - outMsg.writeInt16(0x01); - outMsg.writeInt32(0); - outMsg.writeInt8(0); - outMsg.writeInt8(0); - outMsg.writeString("", 24); - } - else if (msg == "gather") - { - outMsg.writeInt16(0x03f3); - outMsg.writeInt16(0x02); - outMsg.writeInt32(0); - outMsg.writeInt8(0); - outMsg.writeInt8(0); - outMsg.writeString("", 24); - } - else - chatLog(_("No such spell!"), BY_SERVER); + outMsg.writeInt16(0x03f3); + outMsg.writeInt16(0x01); + outMsg.writeInt32(0); + outMsg.writeInt8(0); + outMsg.writeInt8(0); + outMsg.writeString("", 24); + } + else if (msg == "gather") + { + outMsg.writeInt16(0x03f3); + outMsg.writeInt16(0x02); + outMsg.writeInt32(0); + outMsg.writeInt8(0); + outMsg.writeInt8(0); + outMsg.writeString("", 24); } else - chatLog(_("The current server doesn't support spells"), BY_SERVER); + chatLog(_("No such spell!"), BY_SERVER); } else if (command == "present") { diff --git a/src/gui/chat.h b/src/gui/chat.h index 176fccb7..872c0041 100644 --- a/src/gui/chat.h +++ b/src/gui/chat.h @@ -22,7 +22,6 @@ #ifndef CHAT_H #define CHAT_H -#include #include #include @@ -31,8 +30,6 @@ #include "window.h" -#include "../guichanfwd.h" - class BrowserBox; class Network; class Recorder; diff --git a/src/gui/chatinput.h b/src/gui/chatinput.h index d98e120b..a4a50502 100644 --- a/src/gui/chatinput.h +++ b/src/gui/chatinput.h @@ -26,8 +26,6 @@ #include "textfield.h" -#include "../guichanfwd.h" - /** * The chat input hides when it loses focus. It is also invisible by default. */ diff --git a/src/gui/checkbox.h b/src/gui/checkbox.h index 2e52fd0a..20adb43c 100644 --- a/src/gui/checkbox.h +++ b/src/gui/checkbox.h @@ -22,12 +22,8 @@ #ifndef CHECKBOX_H #define CHECKBOX_H -#include - #include -#include "../guichanfwd.h" - class Image; /** @@ -35,7 +31,8 @@ class Image; * * \ingroup GUI */ -class CheckBox : public gcn::CheckBox { +class CheckBox : public gcn::CheckBox +{ public: /** * Constructor. diff --git a/src/gui/colour.cpp b/src/gui/colour.cpp index 075e9861..58d9d1c6 100644 --- a/src/gui/colour.cpp +++ b/src/gui/colour.cpp @@ -19,8 +19,6 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ -#include - #include "colour.h" #include "../configuration.h" diff --git a/src/gui/colour.h b/src/gui/colour.h index 1e8ba3db..1648e1e8 100644 --- a/src/gui/colour.h +++ b/src/gui/colour.h @@ -22,14 +22,11 @@ #ifndef _COLOUR_H #define _COLOUR_H -#include #include #include #include -#include "../guichanfwd.h" - class Colour : public gcn::ListModel { public: diff --git a/src/gui/confirm_dialog.cpp b/src/gui/confirm_dialog.cpp index 643d5d7a..8bb9c578 100644 --- a/src/gui/confirm_dialog.cpp +++ b/src/gui/confirm_dialog.cpp @@ -21,7 +21,10 @@ #include +#include "button.h" #include "confirm_dialog.h" +#include "scrollarea.h" +#include "textbox.h" #include "../utils/gettext.h" diff --git a/src/gui/confirm_dialog.h b/src/gui/confirm_dialog.h index fb8290c8..3fa2b90d 100644 --- a/src/gui/confirm_dialog.h +++ b/src/gui/confirm_dialog.h @@ -24,19 +24,18 @@ #include -#include "button.h" -#include "scrollarea.h" -#include "textbox.h" #include "window.h" -#include "../guichanfwd.h" +class ScrollArea; +class TextBox; /** * An option dialog. * * \ingroup GUI */ -class ConfirmDialog : public Window, public gcn::ActionListener { +class ConfirmDialog : public Window, public gcn::ActionListener +{ public: /** * Constructor. diff --git a/src/gui/connection.cpp b/src/gui/connection.cpp index 15d85bbc..a69698e9 100644 --- a/src/gui/connection.cpp +++ b/src/gui/connection.cpp @@ -31,7 +31,8 @@ #include "../utils/gettext.h" -namespace { +namespace +{ struct ConnectionActionListener : public gcn::ActionListener { void action(const gcn::ActionEvent &event) { state = EXIT_STATE; } @@ -62,10 +63,10 @@ ConnectionDialog::ConnectionDialog(): void ConnectionDialog::logic() { mProgress += 0.005f; + if (mProgress > 1.0f) - { mProgress = 0.0f; - } + mProgressBar->setProgress(mProgress); Window::logic(); } diff --git a/src/gui/debugwindow.cpp b/src/gui/debugwindow.cpp index 223b7fbd..055d9963 100644 --- a/src/gui/debugwindow.cpp +++ b/src/gui/debugwindow.cpp @@ -23,7 +23,6 @@ #include -#include "button.h" #include "debugwindow.h" #include "gui.h" #include "viewport.h" diff --git a/src/gui/debugwindow.h b/src/gui/debugwindow.h index 00119d15..e089de27 100644 --- a/src/gui/debugwindow.h +++ b/src/gui/debugwindow.h @@ -22,14 +22,10 @@ #ifndef DEBUGWINDOW_H #define DEBUGWINDOW_H -#include - #include #include "window.h" -#include "../guichanfwd.h" - /** * The debug window. * diff --git a/src/gui/emotecontainer.h b/src/gui/emotecontainer.h index 8e52a206..5a2b8c2e 100644 --- a/src/gui/emotecontainer.h +++ b/src/gui/emotecontainer.h @@ -29,8 +29,6 @@ #include #include -#include "../guichanfwd.h" - class AnimatedSprite; class Image; diff --git a/src/gui/emoteshortcutcontainer.h b/src/gui/emoteshortcutcontainer.h index cffaee6f..e8d87b60 100644 --- a/src/gui/emoteshortcutcontainer.h +++ b/src/gui/emoteshortcutcontainer.h @@ -24,12 +24,8 @@ #include -#include - #include "shortcutcontainer.h" -#include "../guichanfwd.h" - class AnimatedSprite; class Image; diff --git a/src/gui/emotewindow.cpp b/src/gui/emotewindow.cpp index b4e9c735..3fa96a6d 100644 --- a/src/gui/emotewindow.cpp +++ b/src/gui/emotewindow.cpp @@ -19,16 +19,11 @@ * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include - -#include - #include "button.h" #include "gui.h" #include "emotewindow.h" #include "emotecontainer.h" #include "scrollarea.h" -#include "textbox.h" #include "widgets/layout.h" diff --git a/src/gui/emotewindow.h b/src/gui/emotewindow.h index 8e36e5ce..c642ff6f 100644 --- a/src/gui/emotewindow.h +++ b/src/gui/emotewindow.h @@ -27,8 +27,6 @@ #include "window.h" -#include "../guichanfwd.h" - class EmoteContainer; class TextBox; diff --git a/src/gui/focushandler.h b/src/gui/focushandler.h index 124b5472..b0639bd8 100644 --- a/src/gui/focushandler.h +++ b/src/gui/focushandler.h @@ -26,8 +26,6 @@ #include -#include "../guichanfwd.h" - /** * The focus handler. This focus handler does exactly the same as the Guichan * focus handler, but keeps a stack of modal widgets to be able to handle diff --git a/src/gui/gccontainer.h b/src/gui/gccontainer.h index 0a573645..da584a42 100644 --- a/src/gui/gccontainer.h +++ b/src/gui/gccontainer.h @@ -26,8 +26,6 @@ #include -#include "../guichanfwd.h" - /** * A garbage collecting container. Childs added to this container are * automatically deleted when the container is deleted. diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index 642e916b..7779a503 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -63,7 +63,8 @@ class GuiConfigListener : public ConfigListener void optionChanged(const std::string &name) { - if (name == "customcursor") { + if (name == "customcursor") + { bool bCustomCursor = config.getValue("customcursor", 1) == 1; mGui->setUseCustomCursor(bCustomCursor); } @@ -107,7 +108,8 @@ Gui::Gui(Graphics *graphics): // Set global font std::string path = resman->getPath("fonts/dejavusans.ttf"); - try { + try + { const int fontSize = config.getValue("fontSize", 11); mGuiFont = new TrueTypeFont(path, fontSize); } @@ -119,7 +121,8 @@ Gui::Gui(Graphics *graphics): // Set bold font path = resman->getPath("fonts/dejavusans-bold.ttf"); - try { + try + { const int fontSize = config.getValue("fontSize", 11); boldFont = new TrueTypeFont(path, fontSize); } @@ -132,7 +135,8 @@ Gui::Gui(Graphics *graphics): gcn::Widget::setGlobalFont(mGuiFont); // Load hits' colourful fonts - try { + try + { hitRedFont = new gcn::ImageFont("graphics/gui/hits_red.png", "0123456789crit! "); hitBlueFont = new gcn::ImageFont("graphics/gui/hits_blue.png", @@ -182,12 +186,13 @@ Gui::~Gui() void Gui::logic() { // Fade out mouse cursor after extended inactivity - if (mMouseInactivityTimer < 100 * 15) { + if (mMouseInactivityTimer < 100 * 15) + { ++mMouseInactivityTimer; mMouseCursorAlpha = std::min(1.0f, mMouseCursorAlpha + 0.05f); - } else { - mMouseCursorAlpha = std::max(0.0f, mMouseCursorAlpha - 0.005f); } + else + mMouseCursorAlpha = std::max(0.0f, mMouseCursorAlpha - 0.005f); gcn::Gui::logic(); } @@ -232,9 +237,8 @@ void Gui::setUseCustomCursor(bool customCursor) mMouseCursors = resman->getImageSet("graphics/gui/mouse.png", 40, 40); - if (!mMouseCursors) { + if (!mMouseCursors) logger->error("Unable to load mouse cursors."); - } } else { @@ -242,7 +246,8 @@ void Gui::setUseCustomCursor(bool customCursor) SDL_ShowCursor(SDL_ENABLE); // Unload the mouse cursor - if (mMouseCursors) { + if (mMouseCursors) + { mMouseCursors->decRef(); mMouseCursors = NULL; } diff --git a/src/gui/help.h b/src/gui/help.h index 2ba74c0a..98e3aa67 100644 --- a/src/gui/help.h +++ b/src/gui/help.h @@ -27,8 +27,6 @@ #include "linkhandler.h" #include "window.h" -#include "../guichanfwd.h" - class BrowserBox; /** diff --git a/src/gui/inttextfield.h b/src/gui/inttextfield.h index 2a913ef6..add78084 100644 --- a/src/gui/inttextfield.h +++ b/src/gui/inttextfield.h @@ -24,8 +24,6 @@ #include "textfield.h" -#include "../guichanfwd.h" - /** * TextBox which only accepts numbers as input. */ diff --git a/src/gui/inventorywindow.cpp b/src/gui/inventorywindow.cpp index d7cd7ccd..246219f4 100644 --- a/src/gui/inventorywindow.cpp +++ b/src/gui/inventorywindow.cpp @@ -33,7 +33,6 @@ #include "itemcontainer.h" #include "progressbar.h" #include "scrollarea.h" -#include "textbox.h" #include "viewport.h" #include "widgets/layout.h" diff --git a/src/gui/inventorywindow.h b/src/gui/inventorywindow.h index 2c19ce26..2694e90b 100644 --- a/src/gui/inventorywindow.h +++ b/src/gui/inventorywindow.h @@ -27,7 +27,6 @@ #include "window.h" -#include "../guichanfwd.h" #include "../localplayer.h" class Item; diff --git a/src/gui/item_amount.cpp b/src/gui/item_amount.cpp index d8682c95..92be3d6e 100644 --- a/src/gui/item_amount.cpp +++ b/src/gui/item_amount.cpp @@ -70,7 +70,8 @@ ItemAmountWindow::ItemAmountWindow(int usage, Window *parent, Item *item): resetAmount(); - switch (usage) { + switch (usage) + { case AMOUNT_TRADE_ADD: setCaption(_("Select amount of items to trade.")); okButton->setActionEventId("AddTrade"); diff --git a/src/gui/item_amount.h b/src/gui/item_amount.h index d8eedadb..618d7d51 100644 --- a/src/gui/item_amount.h +++ b/src/gui/item_amount.h @@ -22,14 +22,10 @@ #ifndef ITEM_AMOUNT_WINDOW_H #define ITEM_AMOUNT_WINDOW_H -#include - #include #include "window.h" -#include "../guichanfwd.h" - class IntTextField; class Item; diff --git a/src/gui/itemcontainer.cpp b/src/gui/itemcontainer.cpp index caae3dca..e655d3fc 100644 --- a/src/gui/itemcontainer.cpp +++ b/src/gui/itemcontainer.cpp @@ -35,7 +35,6 @@ #include "../log.h" #include "../resources/image.h" -#include "../resources/iteminfo.h" #include "../resources/resourcemanager.h" #include "../utils/tostring.h" diff --git a/src/gui/itemcontainer.h b/src/gui/itemcontainer.h index 5513faa7..f027de19 100644 --- a/src/gui/itemcontainer.h +++ b/src/gui/itemcontainer.h @@ -28,8 +28,6 @@ #include #include -#include "../guichanfwd.h" - class Image; class Inventory; class Item; diff --git a/src/gui/itemlinkhandler.cpp b/src/gui/itemlinkhandler.cpp index 34c12a0c..97c0b94f 100644 --- a/src/gui/itemlinkhandler.cpp +++ b/src/gui/itemlinkhandler.cpp @@ -19,6 +19,9 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#include +#include + #include #include "itemlinkhandler.h" @@ -27,9 +30,6 @@ #include "../resources/iteminfo.h" #include "../resources/itemdb.h" -#include -#include - ItemLinkHandler::ItemLinkHandler() { mItemPopup = new ItemPopup; diff --git a/src/gui/itempopup.cpp b/src/gui/itempopup.cpp index 80edd354..39a5ecf1 100644 --- a/src/gui/itempopup.cpp +++ b/src/gui/itempopup.cpp @@ -26,16 +26,15 @@ #include "gui.h" #include "itempopup.h" +#include "scrollarea.h" +#include "textbox.h" #include "windowcontainer.h" #include "widgets/layout.h" -#include "../resources/image.h" #include "../resources/iteminfo.h" -#include "../resources/resourcemanager.h" #include "../utils/gettext.h" -#include "../utils/strprintf.h" #include "../utils/tostring.h" ItemPopup::ItemPopup(): @@ -89,9 +88,6 @@ ItemPopup::ItemPopup(): add(mItemWeightScroll); setLocationRelativeTo(getParent()); - - // LEEOR / TODO: This causes an exception error. - //moveToBottom(getParent()); } void ItemPopup::setItem(const ItemInfo &item) diff --git a/src/gui/itempopup.h b/src/gui/itempopup.h index 3c8f575d..d9d37264 100644 --- a/src/gui/itempopup.h +++ b/src/gui/itempopup.h @@ -23,12 +23,11 @@ #ifndef ITEMPOPUP_H__ #define ITEMPOPUP_H__ -#include "scrollarea.h" -#include "textbox.h" #include "window.h" -#include "../guichanfwd.h" -#include "../item.h" +class ItemInfo; +class ScrollArea; +class TextBox; class ItemPopup : public Window { diff --git a/src/gui/itemshortcutcontainer.h b/src/gui/itemshortcutcontainer.h index d6a04d7b..22d94ec2 100644 --- a/src/gui/itemshortcutcontainer.h +++ b/src/gui/itemshortcutcontainer.h @@ -26,8 +26,6 @@ #include "shortcutcontainer.h" -#include "../guichanfwd.h" - class Image; class Item; class ItemPopup; diff --git a/src/gui/listbox.cpp b/src/gui/listbox.cpp index 643d234e..e56ddeeb 100644 --- a/src/gui/listbox.cpp +++ b/src/gui/listbox.cpp @@ -62,8 +62,7 @@ void ListBox::draw(gcn::Graphics *graphics) // Draw the list elements graphics->setColor(gcn::Color(0, 0, 0, 255)); - for (int i = 0, y = 0; - i < mListModel->getNumberOfElements(); + for (int i = 0, y = 0; i < mListModel->getNumberOfElements(); ++i, y += fontHeight) { graphics->drawText(mListModel->getElementAt(i), 1, y); diff --git a/src/gui/listbox.h b/src/gui/listbox.h index 15f7afb4..12fcb955 100644 --- a/src/gui/listbox.h +++ b/src/gui/listbox.h @@ -24,8 +24,6 @@ #include -#include "../guichanfwd.h" - class SelectionListener; /** diff --git a/src/gui/login.cpp b/src/gui/login.cpp index 408456ef..2e9ca57e 100644 --- a/src/gui/login.cpp +++ b/src/gui/login.cpp @@ -26,6 +26,7 @@ #include "button.h" #include "checkbox.h" +#include "listbox.h" #include "login.h" #include "ok_dialog.h" #include "passwordfield.h" diff --git a/src/gui/login.h b/src/gui/login.h index b85e5ae1..70f30d5c 100644 --- a/src/gui/login.h +++ b/src/gui/login.h @@ -22,7 +22,6 @@ #ifndef LOGIN_H #define LOGIN_H -#include #include #include diff --git a/src/gui/menuwindow.h b/src/gui/menuwindow.h index 9b784c35..9bb54e29 100644 --- a/src/gui/menuwindow.h +++ b/src/gui/menuwindow.h @@ -24,8 +24,6 @@ #include "window.h" -#include "../guichanfwd.h" - /** * The Button Menu. * diff --git a/src/gui/minimap.h b/src/gui/minimap.h index b4574ad5..3ce0aacd 100644 --- a/src/gui/minimap.h +++ b/src/gui/minimap.h @@ -24,8 +24,6 @@ #include "window.h" -#include "../guichanfwd.h" - class Image; /** diff --git a/src/gui/ministatus.h b/src/gui/ministatus.h index d2bcef1c..832475f1 100644 --- a/src/gui/ministatus.h +++ b/src/gui/ministatus.h @@ -22,12 +22,8 @@ #ifndef MINISTATUS_H #define MINISTATUS_H -#include - #include "window.h" -#include "../guichanfwd.h" - class ProgressBar; /** diff --git a/src/gui/npc_text.cpp b/src/gui/npc_text.cpp index 1e29b793..b4313b70 100644 --- a/src/gui/npc_text.cpp +++ b/src/gui/npc_text.cpp @@ -19,10 +19,8 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include - -#include "npc_text.h" #include "button.h" +#include "npc_text.h" #include "scrollarea.h" #include "textbox.h" diff --git a/src/gui/npc_text.h b/src/gui/npc_text.h index 4e0d33aa..a07aa04f 100644 --- a/src/gui/npc_text.h +++ b/src/gui/npc_text.h @@ -22,11 +22,10 @@ #ifndef NPC_TEXT_H #define NPC_TEXT_H -#include +#include #include -#include "scrollarea.h" #include "window.h" class TextBox; diff --git a/src/gui/npcintegerdialog.cpp b/src/gui/npcintegerdialog.cpp index 65a1a7f1..4444e04b 100644 --- a/src/gui/npcintegerdialog.cpp +++ b/src/gui/npcintegerdialog.cpp @@ -19,20 +19,15 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "npcintegerdialog.h" - -#include -#include - #include "button.h" #include "inttextfield.h" +#include "npcintegerdialog.h" + +#include "widgets/layout.h" #include "../npc.h" #include "../utils/gettext.h" -#include "../utils/tostring.h" - -#include "widgets/layout.h" NpcIntegerDialog::NpcIntegerDialog(): Window(_("NPC Number Request")) diff --git a/src/gui/npcintegerdialog.h b/src/gui/npcintegerdialog.h index 983c46fe..b9ce70be 100644 --- a/src/gui/npcintegerdialog.h +++ b/src/gui/npcintegerdialog.h @@ -22,16 +22,11 @@ #ifndef GUI_NPCINTEGERDIALOG_H #define GUI_NPCINTEGERDIALOG_H -#include -#include - #include #include #include "window.h" -#include "../guichanfwd.h" - class IntTextField; /** diff --git a/src/gui/npclistdialog.cpp b/src/gui/npclistdialog.cpp index bb815680..e6406422 100644 --- a/src/gui/npclistdialog.cpp +++ b/src/gui/npclistdialog.cpp @@ -21,8 +21,10 @@ #include +#include "button.h" #include "listbox.h" #include "npclistdialog.h" +#include "scrollarea.h" #include "widgets/layout.h" diff --git a/src/gui/npclistdialog.h b/src/gui/npclistdialog.h index ffeced3d..30167a5e 100644 --- a/src/gui/npclistdialog.h +++ b/src/gui/npclistdialog.h @@ -22,18 +22,13 @@ #ifndef GUI_NPCLISTDIALOG_H #define GUI_NPCLISTDIALOG_H -#include #include #include #include -#include "button.h" -#include "scrollarea.h" #include "window.h" -#include "../guichanfwd.h" - /** * The npc list dialog. * diff --git a/src/gui/npcstringdialog.cpp b/src/gui/npcstringdialog.cpp index ccb3c411..468326d6 100644 --- a/src/gui/npcstringdialog.cpp +++ b/src/gui/npcstringdialog.cpp @@ -19,18 +19,13 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "npcstringdialog.h" - -#include -#include - #include "button.h" +#include "npcstringdialog.h" #include "textfield.h" #include "../npc.h" #include "../utils/gettext.h" -#include "../utils/tostring.h" #include "widgets/layout.h" diff --git a/src/gui/npcstringdialog.h b/src/gui/npcstringdialog.h index 5aea2de0..aa39764d 100644 --- a/src/gui/npcstringdialog.h +++ b/src/gui/npcstringdialog.h @@ -22,16 +22,11 @@ #ifndef GUI_NPCSTRINGDIALOG_H #define GUI_NPCSTRINGDIALOG_H -#include -#include - #include #include #include "window.h" -#include "../guichanfwd.h" - /** * The npc integer input dialog. * diff --git a/src/gui/ok_dialog.cpp b/src/gui/ok_dialog.cpp index 7f63b152..0d1f658f 100644 --- a/src/gui/ok_dialog.cpp +++ b/src/gui/ok_dialog.cpp @@ -19,10 +19,13 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "ok_dialog.h" - #include +#include "button.h" +#include "ok_dialog.h" +#include "scrollarea.h" +#include "textbox.h" + #include "../utils/gettext.h" OkDialog::OkDialog(const std::string &title, const std::string &msg, diff --git a/src/gui/ok_dialog.h b/src/gui/ok_dialog.h index 78b3d44f..3a438513 100644 --- a/src/gui/ok_dialog.h +++ b/src/gui/ok_dialog.h @@ -24,12 +24,10 @@ #include -#include "button.h" -#include "scrollarea.h" -#include "textbox.h" #include "window.h" -#include "../guichanfwd.h" +class ScrollArea; +class TextBox; /** * An 'Ok' button dialog. diff --git a/src/gui/passwordfield.cpp b/src/gui/passwordfield.cpp index 09b6abda..345ee1c3 100644 --- a/src/gui/passwordfield.cpp +++ b/src/gui/passwordfield.cpp @@ -21,8 +21,6 @@ #include "passwordfield.h" -#include - PasswordField::PasswordField(const std::string& text): TextField(text) { diff --git a/src/gui/passwordfield.h b/src/gui/passwordfield.h index e01bedbd..89293b05 100644 --- a/src/gui/passwordfield.h +++ b/src/gui/passwordfield.h @@ -22,9 +22,9 @@ #ifndef PASSWORDFIELD_H #define PASSWORDFIELD_H -#include "textfield.h" +#include -#include "../guichanfwd.h" +#include "textfield.h" /** * A password field. diff --git a/src/gui/playerbox.cpp b/src/gui/playerbox.cpp index 20ed17f8..60003fb5 100644 --- a/src/gui/playerbox.cpp +++ b/src/gui/playerbox.cpp @@ -19,8 +19,6 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include - #include "playerbox.h" #include "../animatedsprite.h" diff --git a/src/gui/playerbox.h b/src/gui/playerbox.h index 70c41644..7c08defd 100644 --- a/src/gui/playerbox.h +++ b/src/gui/playerbox.h @@ -24,8 +24,6 @@ #include -#include "../guichanfwd.h" - class ImageRect; class Player; diff --git a/src/gui/popupmenu.cpp b/src/gui/popupmenu.cpp index bf7c803a..cf6a7188 100644 --- a/src/gui/popupmenu.cpp +++ b/src/gui/popupmenu.cpp @@ -20,9 +20,6 @@ */ #include -#include - -#include #include "browserbox.h" #include "chat.h" @@ -42,7 +39,6 @@ #include "../net/protocol.h" #include "../resources/itemdb.h" -#include "../resources/iteminfo.h" #include "../utils/gettext.h" #include "../utils/strprintf.h" diff --git a/src/gui/progressbar.cpp b/src/gui/progressbar.cpp index a1b847c8..867477e0 100644 --- a/src/gui/progressbar.cpp +++ b/src/gui/progressbar.cpp @@ -19,6 +19,8 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#include + #include "gui.h" #include "progressbar.h" @@ -28,8 +30,6 @@ #include "../resources/image.h" #include "../resources/resourcemanager.h" -#include - ImageRect ProgressBar::mBorder; int ProgressBar::mInstances = 0; float ProgressBar::mAlpha = config.getValue("guialpha", 0.8); diff --git a/src/gui/progressbar.h b/src/gui/progressbar.h index dd9cc896..2c1b22da 100644 --- a/src/gui/progressbar.h +++ b/src/gui/progressbar.h @@ -22,12 +22,11 @@ #ifndef PROGRESSBAR_H #define PROGRESSBAR_H +#include + #include #include -#include - -#include "../guichanfwd.h" class ImageRect; diff --git a/src/gui/radiobutton.h b/src/gui/radiobutton.h index 6ead9da0..3d952b3f 100644 --- a/src/gui/radiobutton.h +++ b/src/gui/radiobutton.h @@ -24,14 +24,13 @@ #include -#include "../guichanfwd.h" - class Image; /* * Guichan based RadioButton with custom look */ -class RadioButton : public gcn::RadioButton { +class RadioButton : public gcn::RadioButton +{ public: /* * Constructor. diff --git a/src/gui/recorder.cpp b/src/gui/recorder.cpp index 9db1df2a..1e7d8e13 100644 --- a/src/gui/recorder.cpp +++ b/src/gui/recorder.cpp @@ -28,7 +28,6 @@ #include "widgets/layout.h" -#include "../utils/gettext.h" #include "../utils/trim.h" Recorder::Recorder(ChatWindow *chat, const std::string &title, diff --git a/src/gui/recorder.h b/src/gui/recorder.h index 420c4a2b..707f08ab 100644 --- a/src/gui/recorder.h +++ b/src/gui/recorder.h @@ -29,8 +29,6 @@ #include "window.h" -#include "../guichanfwd.h" - #include "../utils/gettext.h" class ChatWindow; diff --git a/src/gui/register.cpp b/src/gui/register.cpp index 9c337d9e..cbf87e5b 100644 --- a/src/gui/register.cpp +++ b/src/gui/register.cpp @@ -19,15 +19,12 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include -#include - #include -#include "../main.h" #include "../configuration.h" #include "../log.h" #include "../logindata.h" +#include "../main.h" #include "button.h" #include "checkbox.h" @@ -38,12 +35,11 @@ #include "register.h" #include "textfield.h" -#include "../utils/tostring.h" - #include "widgets/layout.h" #include "../utils/gettext.h" #include "../utils/strprintf.h" +#include "../utils/tostring.h" /** * Listener used while dealing with wrong data. It is used to direct the focus diff --git a/src/gui/register.h b/src/gui/register.h index 4b95a07b..e58ac9db 100644 --- a/src/gui/register.h +++ b/src/gui/register.h @@ -22,15 +22,13 @@ #ifndef REGISTER_H #define REGISTER_H -#include +#include #include #include #include "window.h" -#include "../guichanfwd.h" - class LoginData; class OkDialog; class WrongDataNoticeListener; diff --git a/src/gui/scrollarea.cpp b/src/gui/scrollarea.cpp index a892f2d0..e69b681c 100644 --- a/src/gui/scrollarea.cpp +++ b/src/gui/scrollarea.cpp @@ -19,8 +19,6 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include - #include "scrollarea.h" #include "../configuration.h" diff --git a/src/gui/scrollarea.h b/src/gui/scrollarea.h index 4324deff..ccc1e178 100644 --- a/src/gui/scrollarea.h +++ b/src/gui/scrollarea.h @@ -24,8 +24,6 @@ #include -#include "../guichanfwd.h" - class Image; class ImageRect; diff --git a/src/gui/sell.cpp b/src/gui/sell.cpp index 7976e32e..e4be7921 100644 --- a/src/gui/sell.cpp +++ b/src/gui/sell.cpp @@ -19,30 +19,24 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include - #include #include "button.h" -#include "shoplistbox.h" #include "scrollarea.h" #include "sell.h" #include "shop.h" +#include "shoplistbox.h" #include "slider.h" #include "widgets/layout.h" -#include "../item.h" #include "../npc.h" #include "../net/messageout.h" #include "../net/protocol.h" -#include "../resources/iteminfo.h" - #include "../utils/gettext.h" #include "../utils/strprintf.h" -#include "../utils/tostring.h" SellDialog::SellDialog(Network *network): Window(_("Sell")), diff --git a/src/gui/sell.h b/src/gui/sell.h index 8e639a3d..c11a7b7c 100644 --- a/src/gui/sell.h +++ b/src/gui/sell.h @@ -25,9 +25,9 @@ #include #include -#include "window.h" +#include -#include "../guichanfwd.h" +#include "window.h" class Item; class Network; diff --git a/src/gui/setup.cpp b/src/gui/setup.cpp index d18f365c..19575cfb 100644 --- a/src/gui/setup.cpp +++ b/src/gui/setup.cpp @@ -19,9 +19,6 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include -#include - #include "button.h" #include "setup.h" #include "setup_audio.h" diff --git a/src/gui/setup_audio.h b/src/gui/setup_audio.h index 2f5cd736..9e951895 100644 --- a/src/gui/setup_audio.h +++ b/src/gui/setup_audio.h @@ -26,8 +26,6 @@ #include "setuptab.h" -#include "../guichanfwd.h" - class Setup_Audio : public SetupTab, public gcn::ActionListener { public: diff --git a/src/gui/setup_colours.cpp b/src/gui/setup_colours.cpp index 95e6fff0..07ec9086 100644 --- a/src/gui/setup_colours.cpp +++ b/src/gui/setup_colours.cpp @@ -19,8 +19,6 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ -#include - #include #include #include diff --git a/src/gui/setup_colours.h b/src/gui/setup_colours.h index 628efb43..f7984dd5 100644 --- a/src/gui/setup_colours.h +++ b/src/gui/setup_colours.h @@ -23,9 +23,9 @@ #define _SETUP_COLOURS_H #include -#include #include + #include #include diff --git a/src/gui/setup_joystick.h b/src/gui/setup_joystick.h index 2dc56439..eba8a2cc 100644 --- a/src/gui/setup_joystick.h +++ b/src/gui/setup_joystick.h @@ -26,8 +26,6 @@ #include "setuptab.h" -#include "../guichanfwd.h" - class Setup_Joystick : public SetupTab, public gcn::ActionListener { public: diff --git a/src/gui/setup_keyboard.h b/src/gui/setup_keyboard.h index d4966053..082fa84d 100644 --- a/src/gui/setup_keyboard.h +++ b/src/gui/setup_keyboard.h @@ -26,7 +26,6 @@ #include -#include "button.h" #include "setuptab.h" #include "../guichanfwd.h" diff --git a/src/gui/setup_players.cpp b/src/gui/setup_players.cpp index 932acee7..7e76055a 100644 --- a/src/gui/setup_players.cpp +++ b/src/gui/setup_players.cpp @@ -19,6 +19,7 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#include #include #include @@ -27,14 +28,15 @@ #include "checkbox.h" #include "listbox.h" #include "ok_dialog.h" +#include "scrollarea.h" #include "setup_players.h" +#include "table.h" #include "widgets/dropdown.h" #include "widgets/layouthelper.h" #include "../configuration.h" #include "../log.h" -#include "../player_relations.h" #include "../utils/gettext.h" diff --git a/src/gui/setup_players.h b/src/gui/setup_players.h index 22c8a9b6..393fc6aa 100644 --- a/src/gui/setup_players.h +++ b/src/gui/setup_players.h @@ -24,17 +24,16 @@ #include -#include "button.h" -#include "scrollarea.h" #include "setuptab.h" -#include "table.h" -#include "../guichanfwd.h" #include "../player_relations.h" +class GuiTable; class PlayerTableModel; +class StaticTableModel; -class Setup_Players : public SetupTab, public gcn::ActionListener, public PlayerRelationsListener +class Setup_Players : public SetupTab, + public gcn::ActionListener, public PlayerRelationsListener { public: Setup_Players(); @@ -60,7 +59,7 @@ private: gcn::CheckBox *mDefaultTrading; gcn::CheckBox *mDefaultWhisper; - Button *mDeleteButton; + gcn::Button *mDeleteButton; gcn::DropDown *mIgnoreActionChoicesBox; }; diff --git a/src/gui/setup_video.h b/src/gui/setup_video.h index d863fb64..303b5bfc 100644 --- a/src/gui/setup_video.h +++ b/src/gui/setup_video.h @@ -27,8 +27,6 @@ #include "setuptab.h" -#include "../guichanfwd.h" - class Setup_Video : public SetupTab, public gcn::ActionListener, public gcn::KeyListener { diff --git a/src/gui/shop.h b/src/gui/shop.h index 22b649d0..e0db4c59 100644 --- a/src/gui/shop.h +++ b/src/gui/shop.h @@ -27,10 +27,9 @@ #include -#include "../guichanfwd.h" #include "../shopitem.h" -#include "../resources/image.h" +class ShopItem; class ShopItems : public gcn::ListModel { diff --git a/src/gui/shoplistbox.cpp b/src/gui/shoplistbox.cpp index 3d17fd55..ba636112 100644 --- a/src/gui/shoplistbox.cpp +++ b/src/gui/shoplistbox.cpp @@ -19,14 +19,12 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include #include #include -#include #include -#include #include "colour.h" +#include "shop.h" #include "shoplistbox.h" #include "../configuration.h" diff --git a/src/gui/shoplistbox.h b/src/gui/shoplistbox.h index 12413585..cde4786e 100644 --- a/src/gui/shoplistbox.h +++ b/src/gui/shoplistbox.h @@ -23,9 +23,8 @@ #define SHOPLISTBOX_H #include "listbox.h" -#include "shop.h" -#include "../guichanfwd.h" +class ShopItems; /** * A list box, meant to be used inside a scroll area. Same as the Guichan list diff --git a/src/gui/shortcutcontainer.cpp b/src/gui/shortcutcontainer.cpp index 62b2d382..eae24785 100644 --- a/src/gui/shortcutcontainer.cpp +++ b/src/gui/shortcutcontainer.cpp @@ -22,15 +22,8 @@ #include "shortcutcontainer.h" #include "../configuration.h" -#include "../graphics.h" -#include "../inventory.h" -#include "../item.h" -#include "../itemshortcut.h" -#include "../keyboardconfig.h" -#include "../localplayer.h" #include "../resources/image.h" -#include "../resources/resourcemanager.h" #include "../utils/tostring.h" diff --git a/src/gui/shortcutcontainer.h b/src/gui/shortcutcontainer.h index b2d0cc78..f5f06163 100644 --- a/src/gui/shortcutcontainer.h +++ b/src/gui/shortcutcontainer.h @@ -26,12 +26,10 @@ #include #include -#include "../guichanfwd.h" - class Image; /** - * An item shortcut container. Used to quickly use items. + * A generic shortcut container. * * \ingroup GUI */ @@ -41,7 +39,7 @@ class ShortcutContainer : public gcn::Widget, { public: /** - * Constructor. Initializes the graphic. + * Constructor. Initializes the shortcut container. */ ShortcutContainer(); @@ -51,7 +49,7 @@ class ShortcutContainer : public gcn::Widget, ~ShortcutContainer(){} /** - * Draws the items. + * Draws the shortcuts */ virtual void draw(gcn::Graphics *graphics) = 0; diff --git a/src/gui/shortcutwindow.cpp b/src/gui/shortcutwindow.cpp index 3a7cf0e0..91b33b72 100644 --- a/src/gui/shortcutwindow.cpp +++ b/src/gui/shortcutwindow.cpp @@ -19,9 +19,9 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#include "scrollarea.h" #include "shortcutcontainer.h" #include "shortcutwindow.h" -#include "scrollarea.h" #include "../configuration.h" diff --git a/src/gui/shortcutwindow.h b/src/gui/shortcutwindow.h index 0168669e..2711ced5 100644 --- a/src/gui/shortcutwindow.h +++ b/src/gui/shortcutwindow.h @@ -24,10 +24,8 @@ #include "window.h" -#include "../guichanfwd.h" - -class ShortcutContainer; class ScrollArea; +class ShortcutContainer; /** * A window around the ItemShortcutContainer. diff --git a/src/gui/skill.cpp b/src/gui/skill.cpp index 732aaa12..4587e75a 100644 --- a/src/gui/skill.cpp +++ b/src/gui/skill.cpp @@ -19,13 +19,13 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include - #include #include "button.h" #include "listbox.h" +#include "scrollarea.h" #include "skill.h" +#include "table.h" #include "windowcontainer.h" #include "widgets/layout.h" @@ -124,9 +124,11 @@ SkillDialog::SkillDialog(): { initSkillinfo(); mTableModel = new SkillGuiTableModel(this); - mTable.setModel(mTableModel); - mTable.setOpaque(false); - mTable.setLinewiseSelection(true); + mTable = new GuiTable(mTableModel); + mTable->setOpaque(false); + mTable->setLinewiseSelection(true); + mTable->setActionEventId("skill"); + mTable->addActionListener(this); setWindowName(_("Skills")); setCloseButton(true); @@ -135,14 +137,12 @@ SkillDialog::SkillDialog(): setMinHeight(50 + mTableModel->getHeight()); setMinWidth(200); - ScrollArea *skillScrollArea = new ScrollArea(&mTable); + ScrollArea *skillScrollArea = new ScrollArea(mTable); mPointsLabel = new gcn::Label(strprintf(_("Skill points: %d"), 0)); mIncButton = new Button(_("Up"), _("inc"), this); mUseButton = new Button(_("Use"), _("use"), this); mUseButton->setEnabled(false); - mTable.setActionEventId("skill"); - skillScrollArea->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER); place(0, 0, skillScrollArea, 5).setPadding(3); @@ -153,14 +153,13 @@ SkillDialog::SkillDialog(): Layout &layout = getLayout(); layout.setRowHeight(0, Layout::AUTO_SET); - mTable.addActionListener(this); - setLocationRelativeTo(getParent()); loadWindowState(); } SkillDialog::~SkillDialog() { + delete mTable; } void SkillDialog::action(const gcn::ActionEvent &event) @@ -168,15 +167,14 @@ void SkillDialog::action(const gcn::ActionEvent &event) if (event.getId() == "inc") { // Increment skill - int selectedSkill = mTable.getSelectedRow(); + int selectedSkill = mTable->getSelectedRow(); if (selectedSkill >= 0) player_node->raiseSkill(mSkillList[selectedSkill]->id); } else if (event.getId() == "skill") { - mIncButton->setEnabled( - mTable.getSelectedRow() > -1 && - player_node->mSkillPoint > 0); + mIncButton->setEnabled(mTable->getSelectedRow() > -1 && + player_node->mSkillPoint > 0); } else if (event.getId() == "close") setVisible(false); @@ -187,7 +185,7 @@ void SkillDialog::update() mPointsLabel->setCaption(strprintf(_("Skill points: %d"), player_node->mSkillPoint)); - int selectedSkill = mTable.getSelectedRow(); + int selectedSkill = mTable->getSelectedRow(); if (selectedSkill >= 0) { diff --git a/src/gui/skill.h b/src/gui/skill.h index 45cfd059..91c2b640 100644 --- a/src/gui/skill.h +++ b/src/gui/skill.h @@ -25,19 +25,15 @@ #include #include -#include -#include "scrollarea.h" -#include "table.h" #include "window.h" -#include "../guichanfwd.h" - struct SKILL { short id; /**< Index into "skill_db" array */ short lv, sp; }; +class GuiTable; class SkillGuiTableModel; /** @@ -72,7 +68,7 @@ class SkillDialog : public Window, public gcn::ActionListener const std::vector& getSkills(void) const { return mSkillList; } private: - GuiTable mTable;//gcn::ListBox *mSkillListBox; + GuiTable *mTable; ScrollArea *skillScrollArea; SkillGuiTableModel *mTableModel; gcn::Label *mPointsLabel; diff --git a/src/gui/slider.h b/src/gui/slider.h index 12004f55..56ea334a 100644 --- a/src/gui/slider.h +++ b/src/gui/slider.h @@ -24,8 +24,6 @@ #include -#include "../guichanfwd.h" - class Image; /** diff --git a/src/gui/speechbubble.cpp b/src/gui/speechbubble.cpp index 7eedce1c..8e3fe3c7 100644 --- a/src/gui/speechbubble.cpp +++ b/src/gui/speechbubble.cpp @@ -25,19 +25,15 @@ #include #include "gui.h" +#include "scrollarea.h" #include "speechbubble.h" - -#include "../resources/image.h" -#include "../resources/resourcemanager.h" +#include "textbox.h" #include "../utils/gettext.h" -// TODO: Fix windows so that they can each load their own skins without the -// other windows overriding another window's skin. SpeechBubble::SpeechBubble(): Window(_("Speech"), false, NULL, "graphics/gui/speechbubble.xml") { - // Height == Top Graphic (14px) + 1 Row of Text (15px) + Bottom Graphic (17px) setContentSize(140, 46); setShowTitle(false); setTitleBarHeight(0); @@ -62,9 +58,6 @@ SpeechBubble::SpeechBubble(): add(mSpeechArea); setLocationRelativeTo(getParent()); - - // LEEOR / TODO: This causes an exception error. - //moveToBottom(getParent()); } void SpeechBubble::setCaption(const std::string &name, const gcn::Color &color) @@ -83,8 +76,6 @@ void SpeechBubble::setText(std::string mText) if (numRows > 2) { - // 15 == height of each line of text (based on font heights) - // 14 == speechbubble Top + Bottom graphic pixel heights setContentSize(mSpeechBox->getMinWidth() + fontHeight, (numRows * fontHeight) + 6); mSpeechArea->setDimension(gcn::Rectangle(4, fontHeight + 3, diff --git a/src/gui/speechbubble.h b/src/gui/speechbubble.h index 23733813..323e5cbb 100644 --- a/src/gui/speechbubble.h +++ b/src/gui/speechbubble.h @@ -20,13 +20,14 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef _LOM_SPEECHBUBBLE_H__ -#define _LOM_SPEECHBUBBLE_H__ +#ifndef SPEECHBUBBLE_H__ +#define SPEECHBUBBLE_H__ -#include "scrollarea.h" -#include "textbox.h" #include "window.h" +class ScrollArea; +class TextBox; + class SpeechBubble : public Window { public: diff --git a/src/gui/status.h b/src/gui/status.h index 1e1c4e98..00a48f4e 100644 --- a/src/gui/status.h +++ b/src/gui/status.h @@ -22,14 +22,10 @@ #ifndef STATUS_H #define STATUS_H -#include - #include #include "window.h" -#include "../guichanfwd.h" - class LocalPlayer; class ProgressBar; diff --git a/src/gui/table.cpp b/src/gui/table.cpp index bccdc900..9a5c0591 100644 --- a/src/gui/table.cpp +++ b/src/gui/table.cpp @@ -19,8 +19,6 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include - #include #include diff --git a/src/gui/table.h b/src/gui/table.h index bdb41e90..d63b1fb9 100644 --- a/src/gui/table.h +++ b/src/gui/table.h @@ -24,16 +24,12 @@ #include -#include #include #include -#include #include #include "table_model.h" -#include "../guichanfwd.h" - class GuiTableActionListener; /** diff --git a/src/gui/table_model.cpp b/src/gui/table_model.cpp index 5ee7e9ab..19e780f3 100644 --- a/src/gui/table_model.cpp +++ b/src/gui/table_model.cpp @@ -19,9 +19,6 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include - -#include #include #include "table_model.h" diff --git a/src/gui/table_model.h b/src/gui/table_model.h index a2a93887..1d966e8b 100644 --- a/src/gui/table_model.h +++ b/src/gui/table_model.h @@ -25,11 +25,6 @@ #include #include -#include -#include - -#include "../guichanfwd.h" - class TableModelListener { public: diff --git a/src/gui/textbox.cpp b/src/gui/textbox.cpp index e7986244..2a86d549 100644 --- a/src/gui/textbox.cpp +++ b/src/gui/textbox.cpp @@ -21,7 +21,6 @@ #include -#include #include #include "textbox.h" diff --git a/src/gui/textbox.h b/src/gui/textbox.h index 84dd6268..10a81fc0 100644 --- a/src/gui/textbox.h +++ b/src/gui/textbox.h @@ -24,8 +24,6 @@ #include -#include "../guichanfwd.h" - /** * A text box, meant to be used inside a scroll area. Same as the Guichan text * box except this one doesn't have a background or border, instead completely @@ -33,7 +31,8 @@ * * \ingroup GUI */ -class TextBox : public gcn::TextBox { +class TextBox : public gcn::TextBox +{ public: /** * Constructor. diff --git a/src/gui/textfield.cpp b/src/gui/textfield.cpp index 7e5004cc..99a95a2e 100644 --- a/src/gui/textfield.cpp +++ b/src/gui/textfield.cpp @@ -19,12 +19,8 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include - #include -#include - #include "sdlinput.h" #include "textfield.h" diff --git a/src/gui/textfield.h b/src/gui/textfield.h index 11a58824..73824615 100644 --- a/src/gui/textfield.h +++ b/src/gui/textfield.h @@ -24,8 +24,6 @@ #include -#include "../guichanfwd.h" - class ImageRect; class TextField; diff --git a/src/gui/trade.cpp b/src/gui/trade.cpp index c89e55a2..f901be5e 100644 --- a/src/gui/trade.cpp +++ b/src/gui/trade.cpp @@ -41,8 +41,6 @@ #include "../net/messageout.h" #include "../net/protocol.h" -#include "../resources/iteminfo.h" - #include "../utils/gettext.h" #include "../utils/strprintf.h" #include "../utils/tostring.h" diff --git a/src/gui/updatewindow.cpp b/src/gui/updatewindow.cpp index 67e05bbd..1f62bd2d 100644 --- a/src/gui/updatewindow.cpp +++ b/src/gui/updatewindow.cpp @@ -26,6 +26,9 @@ #include +// Curl should be included after Guichan to avoid Windows redefinitions +#include + #include "browserbox.h" #include "button.h" #include "progressbar.h" @@ -34,9 +37,6 @@ #include "widgets/layout.h" -// Curl should be included after Guichan to avoid Windows redefinitions -#include - #include "../configuration.h" #include "../log.h" #include "../main.h" diff --git a/src/gui/updatewindow.h b/src/gui/updatewindow.h index 6450ece2..4ada3c3a 100644 --- a/src/gui/updatewindow.h +++ b/src/gui/updatewindow.h @@ -29,8 +29,6 @@ #include "window.h" -#include "../guichanfwd.h" - #include "../utils/mutex.h" class BrowserBox; diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp index f258aba8..11a0004b 100644 --- a/src/gui/viewport.cpp +++ b/src/gui/viewport.cpp @@ -19,8 +19,6 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include - #include "gui.h" #include "popupmenu.h" #include "viewport.h" @@ -36,9 +34,6 @@ #include "../npc.h" #include "../textmanager.h" -#include "../resources/animation.h" -#include "../resources/image.h" -#include "../resources/imageset.h" #include "../resources/monsterinfo.h" #include "../resources/resourcemanager.h" diff --git a/src/gui/viewport.h b/src/gui/viewport.h index 5ed40166..e352f765 100644 --- a/src/gui/viewport.h +++ b/src/gui/viewport.h @@ -26,9 +26,7 @@ #include "windowcontainer.h" -#include "../being.h" #include "../configlistener.h" -#include "../guichanfwd.h" class Map; class FloorItem; diff --git a/src/gui/widgets/dropdown.cpp b/src/gui/widgets/dropdown.cpp index ac5cbaa2..31d35cb0 100644 --- a/src/gui/widgets/dropdown.cpp +++ b/src/gui/widgets/dropdown.cpp @@ -24,6 +24,8 @@ #include "dropdown.h" #include "../colour.h" +#include "../listbox.h" +#include "../scrollarea.h" #include "../../configuration.h" #include "../../graphics.h" diff --git a/src/gui/widgets/dropdown.h b/src/gui/widgets/dropdown.h index bff8bd1e..e5919dc7 100644 --- a/src/gui/widgets/dropdown.h +++ b/src/gui/widgets/dropdown.h @@ -22,15 +22,8 @@ #ifndef DROPDOWN_H #define DROPDOWN_H -#include - #include -#include "../listbox.h" -#include "../scrollarea.h" - -#include "../../guichanfwd.h" - class Image; class ImageRect; diff --git a/src/gui/widgets/resizegrip.h b/src/gui/widgets/resizegrip.h index 198954f6..620c133f 100644 --- a/src/gui/widgets/resizegrip.h +++ b/src/gui/widgets/resizegrip.h @@ -24,8 +24,6 @@ #include -#include "../../guichanfwd.h" - class Image; /** diff --git a/src/gui/widgets/tab.cpp b/src/gui/widgets/tab.cpp index 5465b431..22e952e7 100644 --- a/src/gui/widgets/tab.cpp +++ b/src/gui/widgets/tab.cpp @@ -19,8 +19,6 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include - #include #include "tab.h" diff --git a/src/gui/window.cpp b/src/gui/window.cpp index 35d47082..36828194 100644 --- a/src/gui/window.cpp +++ b/src/gui/window.cpp @@ -28,7 +28,6 @@ #include #include "gui.h" -#include "gccontainer.h" #include "window.h" #include "windowcontainer.h" @@ -37,7 +36,6 @@ #include "../configlistener.h" #include "../configuration.h" -#include "../graphics.h" #include "../log.h" #include "../resources/image.h" diff --git a/src/gui/windowcontainer.h b/src/gui/windowcontainer.h index a3e80223..62704d1b 100644 --- a/src/gui/windowcontainer.h +++ b/src/gui/windowcontainer.h @@ -24,15 +24,14 @@ #include -#include "../guichanfwd.h" - /** * A window container. This container adds functionality for more convenient * widget (windows in particular) destruction. * * \ingroup GUI */ -class WindowContainer : public gcn::Container { +class WindowContainer : public gcn::Container +{ public: /** * Do GUI logic. This functions adds automatic deletion of objects that diff --git a/src/main.cpp b/src/main.cpp index b933742a..65b61de2 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -54,6 +54,7 @@ #include "serverinfo.h" #include "sound.h" +#include "gui/button.h" #include "gui/char_server.h" #include "gui/char_select.h" #include "gui/colour.h" diff --git a/src/net/charserverhandler.cpp b/src/net/charserverhandler.cpp index b91a506a..bd3685f3 100644 --- a/src/net/charserverhandler.cpp +++ b/src/net/charserverhandler.cpp @@ -21,7 +21,6 @@ #include "charserverhandler.h" #include "messagein.h" -#include "network.h" #include "protocol.h" #include "../extensions.h" @@ -34,6 +33,8 @@ #include "../gui/char_select.h" #include "../gui/ok_dialog.h" +#include "../utils/tostring.h" + /* * Yeah, this is a global. Get over it. */ diff --git a/src/net/loginhandler.cpp b/src/net/loginhandler.cpp index db601214..6ad410ec 100644 --- a/src/net/loginhandler.cpp +++ b/src/net/loginhandler.cpp @@ -21,7 +21,6 @@ #include "loginhandler.h" #include "messagein.h" -#include "network.h" #include "protocol.h" #include "../log.h" @@ -29,6 +28,8 @@ #include "../main.h" #include "../serverinfo.h" +#include "../utils/tostring.h" + extern SERVER_INFO **server_info; LoginHandler::LoginHandler() diff --git a/src/net/network.cpp b/src/net/network.cpp index 941995c9..059da779 100644 --- a/src/net/network.cpp +++ b/src/net/network.cpp @@ -26,6 +26,7 @@ #include "network.h" #include "../log.h" +#include "../utils/tostring.h" /** Warning: buffers and other variables are shared, so there can be only one connection active at a time */ @@ -418,19 +419,6 @@ void Network::receive() SDLNet_FreeSocketSet(set); } -char *iptostring(int address) -{ - static char asciiIP[16]; - - sprintf(asciiIP, "%i.%i.%i.%i", - (unsigned char)(address), - (unsigned char)(address >> 8), - (unsigned char)(address >> 16), - (unsigned char)(address >> 24)); - - return asciiIP; -} - void Network::setError(const std::string& error) { logger->log("Network error: %s", error.c_str()); diff --git a/src/net/network.h b/src/net/network.h index c035f55c..02fe7538 100644 --- a/src/net/network.h +++ b/src/net/network.h @@ -115,7 +115,4 @@ class Network MessageHandlers mMessageHandlers; }; -/** Convert an address from int format to string */ -char *iptostring(int address); - #endif diff --git a/src/utils/tostring.h b/src/utils/tostring.h index 5ac1d3aa..eb86f99e 100644 --- a/src/utils/tostring.h +++ b/src/utils/tostring.h @@ -32,4 +32,19 @@ std::string toString(const T &arg) return ss.str(); } +// TODO: Is there a good way to suppress warnings from classes which don't use +// this function? +static char *iptostring(int address) +{ + static char asciiIP[16]; + + sprintf(asciiIP, "%i.%i.%i.%i", + (unsigned char)(address), + (unsigned char)(address >> 8), + (unsigned char)(address >> 16), + (unsigned char)(address >> 24)); + + return asciiIP; +} + #endif -- cgit v1.2.3-70-g09d2 From 9aae9a0b20f144859fc68e94b4fb9fdae6f15861 Mon Sep 17 00:00:00 2001 From: Ira Rice Date: Wed, 4 Feb 2009 12:11:00 -0700 Subject: Few more unneeded headers that weren't noticed originally in the last commit. Also, while the overall performance improved a little, it doesn't appear to be as drastic as the last commit was suggesting. Signed-off-by: Ira Rice --- src/gui/browserbox.cpp | 2 ++ src/gui/button.cpp | 3 --- src/gui/chat.cpp | 2 -- src/gui/listbox.cpp | 1 - src/gui/shoplistbox.cpp | 1 - src/gui/table.cpp | 2 +- src/gui/truetypefont.h | 1 - src/gui/window.cpp | 2 -- 8 files changed, 3 insertions(+), 11 deletions(-) (limited to 'src/gui/chat.cpp') diff --git a/src/gui/browserbox.cpp b/src/gui/browserbox.cpp index cd5479c8..c51852bb 100644 --- a/src/gui/browserbox.cpp +++ b/src/gui/browserbox.cpp @@ -21,6 +21,8 @@ #include +#include + #include "browserbox.h" #include "colour.h" #include "linkhandler.h" diff --git a/src/gui/button.cpp b/src/gui/button.cpp index 2e6bed0a..1d3a04e4 100644 --- a/src/gui/button.cpp +++ b/src/gui/button.cpp @@ -19,11 +19,8 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include - #include #include -#include #include "button.h" diff --git a/src/gui/chat.cpp b/src/gui/chat.cpp index a58600a8..f4d9763b 100644 --- a/src/gui/chat.cpp +++ b/src/gui/chat.cpp @@ -19,8 +19,6 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include - #include #include "browserbox.h" diff --git a/src/gui/listbox.cpp b/src/gui/listbox.cpp index e56ddeeb..b63d6424 100644 --- a/src/gui/listbox.cpp +++ b/src/gui/listbox.cpp @@ -22,7 +22,6 @@ #include #include #include -#include #include "colour.h" #include "listbox.h" diff --git a/src/gui/shoplistbox.cpp b/src/gui/shoplistbox.cpp index ba636112..b5761535 100644 --- a/src/gui/shoplistbox.cpp +++ b/src/gui/shoplistbox.cpp @@ -20,7 +20,6 @@ */ #include -#include #include #include "colour.h" diff --git a/src/gui/table.cpp b/src/gui/table.cpp index 9a5c0591..af42165a 100644 --- a/src/gui/table.cpp +++ b/src/gui/table.cpp @@ -19,8 +19,8 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include #include +#include #include "colour.h" #include "table.h" diff --git a/src/gui/truetypefont.h b/src/gui/truetypefont.h index 288be49a..bd338d84 100644 --- a/src/gui/truetypefont.h +++ b/src/gui/truetypefont.h @@ -25,7 +25,6 @@ #include #include -#include #ifndef __APPLE__ #include #else diff --git a/src/gui/window.cpp b/src/gui/window.cpp index 36828194..934bd9b3 100644 --- a/src/gui/window.cpp +++ b/src/gui/window.cpp @@ -25,8 +25,6 @@ #include -#include - #include "gui.h" #include "window.h" #include "windowcontainer.h" -- cgit v1.2.3-70-g09d2 From 1458c6b808afaf3af2f1f50f1988427edf64826c Mon Sep 17 00:00:00 2001 From: Ira Rice Date: Fri, 6 Feb 2009 17:38:12 -0700 Subject: Sanitized item links so that at no point is the internal representation of the item link shown. This should help make it easier for people to represent the square brackets with item links, and prevent people from forging item links when they never see the internal representation of an item link. Should also reduce confusion from people who haven't upgraded their clients as well, as they wonder what all the junk is around the item name. Signed-off-by: Ira Rice --- src/gui/chat.cpp | 4 ++-- src/gui/chat.h | 2 +- src/gui/popupmenu.cpp | 21 ++++++++++----------- 3 files changed, 13 insertions(+), 14 deletions(-) (limited to 'src/gui/chat.cpp') diff --git a/src/gui/chat.cpp b/src/gui/chat.cpp index f4d9763b..b53552a6 100644 --- a/src/gui/chat.cpp +++ b/src/gui/chat.cpp @@ -735,10 +735,10 @@ void ChatWindow::setInputText(std::string input_str) requestChatFocus(); } -void ChatWindow::addItemText(int itemId, const std::string &item) +void ChatWindow::addItemText(const std::string &item) { std::ostringstream text; - text << "[@@" << itemId << "|" << item << "@@] "; + text << "[" << item << "] "; mChatInput->setText(mChatInput->getText() + text.str()); requestChatFocus(); } diff --git a/src/gui/chat.h b/src/gui/chat.h index 872c0041..2fadb014 100644 --- a/src/gui/chat.h +++ b/src/gui/chat.h @@ -179,7 +179,7 @@ class ChatWindow : public Window, public gcn::ActionListener, void setInputText(std::string input_str); /** Called to add item to chat */ - void addItemText(int itemid, const std::string &item); + void addItemText(const std::string &item); /** Override to reset mTmpVisible */ void setVisible(bool visible); diff --git a/src/gui/popupmenu.cpp b/src/gui/popupmenu.cpp index cf6a7188..6c0e6ad6 100644 --- a/src/gui/popupmenu.cpp +++ b/src/gui/popupmenu.cpp @@ -75,27 +75,27 @@ void PopupMenu::showPopup(int x, int y, Being *being) // Players can be traded with. Later also attack, follow and // add as buddy will be options in this menu. const std::string &name = mBeing->getName(); - mBrowserBox->addRow(_("@@trade|Trade With ") + name + "@@"); - mBrowserBox->addRow(_("@@attack|Attack ") + name + "@@"); + mBrowserBox->addRow(strprintf(_("@@trade|Trade With %s@@"), name.c_str())); + mBrowserBox->addRow(strprintf(_("@@attack|Attack %s@@"), name.c_str())); mBrowserBox->addRow("##3---"); switch (player_relations.getRelation(name)) { case PlayerRelation::NEUTRAL: - mBrowserBox->addRow(_("@@friend|Befriend ") + name + "@@"); + mBrowserBox->addRow(strprintf(_("@@friend|Befriend %s@@"), name.c_str())); case PlayerRelation::FRIEND: - mBrowserBox->addRow(_("@@disregard|Disregard ") + name + "@@"); - mBrowserBox->addRow(_("@@ignore|Ignore ") + name + "@@"); + mBrowserBox->addRow(strprintf(_("@@disregard|Disregard %s@@"), name.c_str())); + mBrowserBox->addRow(strprintf(_("@@ignore|Ignore %s@@"), name.c_str())); break; case PlayerRelation::DISREGARDED: - mBrowserBox->addRow(_("@@unignore|Un-Ignore ") + name + "@@"); - mBrowserBox->addRow(_("@@ignore|Completely ignore ") + name + "@@"); + mBrowserBox->addRow(strprintf(_("@@unignore|Un-Ignore %s@@"), name.c_str())); + mBrowserBox->addRow(strprintf(_("@@ignore|Completely ignore %s@@"), name.c_str())); break; case PlayerRelation::IGNORED: - mBrowserBox->addRow(_("@@unignore|Un-Ignore ") + name + "@@"); + mBrowserBox->addRow(strprintf(_("@@unignore|Un-Ignore %s@@"), name.c_str())); break; } @@ -103,8 +103,7 @@ void PopupMenu::showPopup(int x, int y, Being *being) //mBrowserBox->addRow(_("@@buddy|Add ") + name + " to Buddy List@@"); mBrowserBox->addRow("##3---"); - mBrowserBox->addRow(_("@@party-invite|Invite ") + name + - " to party@@"); + mBrowserBox->addRow(strprintf(_("@@party-invite|Invite %s to party@@"), name.c_str())); } break; @@ -247,7 +246,7 @@ void PopupMenu::handleLink(const std::string& link) else if (link == "chat") { - chatWindow->addItemText(mItem->getId(), mItem->getInfo().getName()); + chatWindow->addItemText(mItem->getInfo().getName()); } else if (link == "drop") -- cgit v1.2.3-70-g09d2 From 876f55d0624008a87f0ee6cc2e40895a4fe9f90b Mon Sep 17 00:00:00 2001 From: Ira Rice Date: Fri, 6 Feb 2009 21:52:19 -0700 Subject: Fixed the help function so that the help commands on help commands would work. Signed-off-by: Ira Rice --- src/gui/chat.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'src/gui/chat.cpp') diff --git a/src/gui/chat.cpp b/src/gui/chat.cpp index b53552a6..067c9e08 100644 --- a/src/gui/chat.cpp +++ b/src/gui/chat.cpp @@ -434,7 +434,6 @@ void ChatWindow::chatSend(const std::string &nick, std::string msg) } else if (command == "help") { - msg.erase(0, 6); trim(msg); std::size_t space = msg.find(" "); std::string msg1; -- cgit v1.2.3-70-g09d2 From 1b8c088a48822641b53c2a304372471a128c2841 Mon Sep 17 00:00:00 2001 From: Ira Rice Date: Sat, 7 Feb 2009 12:18:52 -0700 Subject: Added a text color preview to the setup color tab. Signed-off-by: Ira Rice --- src/gui/browserbox.cpp | 4 ++-- src/gui/browserbox.h | 2 +- src/gui/chat.cpp | 2 -- src/gui/colour.cpp | 9 ++++++++ src/gui/colour.h | 6 ++++++ src/gui/scrollarea.cpp | 15 ++++++++------ src/gui/scrollarea.h | 4 ++-- src/gui/setup_colours.cpp | 52 +++++++++++++++++++++++++++++++++++++---------- src/gui/setup_colours.h | 16 ++++++++------- 9 files changed, 79 insertions(+), 31 deletions(-) (limited to 'src/gui/chat.cpp') diff --git a/src/gui/browserbox.cpp b/src/gui/browserbox.cpp index ecc22e5f..5895d557 100644 --- a/src/gui/browserbox.cpp +++ b/src/gui/browserbox.cpp @@ -28,10 +28,10 @@ #include "linkhandler.h" #include "truetypefont.h" -BrowserBox::BrowserBox(unsigned int mode): +BrowserBox::BrowserBox(unsigned int mode, bool opaque): gcn::Widget(), mMode(mode), mHighMode(UNDERLINE | BACKGROUND), - mOpaque(true), + mOpaque(opaque), mUseLinksAndUserColors(true), mSelectedLink(-1), mMaxRows(0) diff --git a/src/gui/browserbox.h b/src/gui/browserbox.h index 15c2ab89..5dde402e 100644 --- a/src/gui/browserbox.h +++ b/src/gui/browserbox.h @@ -46,7 +46,7 @@ class BrowserBox : public gcn::Widget, public gcn::MouseListener /** * Constructor. */ - BrowserBox(unsigned int mode = AUTO_SIZE); + BrowserBox(unsigned int mode = AUTO_SIZE, bool opaque = true); /** * Destructor. diff --git a/src/gui/chat.cpp b/src/gui/chat.cpp index 067c9e08..2363fc50 100644 --- a/src/gui/chat.cpp +++ b/src/gui/chat.cpp @@ -71,8 +71,6 @@ Window(""), mNetwork(network), mTmpVisible(false) mTextOutput->setLinkHandler(mItemLinkHandler); mScrollArea = new ScrollArea(mTextOutput); - mScrollArea->setPosition(mScrollArea->getFrameSize(), - mScrollArea->getFrameSize()); mScrollArea->setScrollPolicy(gcn::ScrollArea::SHOW_NEVER, gcn::ScrollArea::SHOW_ALWAYS); mScrollArea->setScrollAmount(0, 1); diff --git a/src/gui/colour.cpp b/src/gui/colour.cpp index 58d9d1c6..c4505c2f 100644 --- a/src/gui/colour.cpp +++ b/src/gui/colour.cpp @@ -93,6 +93,15 @@ std::string Colour::getElementAt(int i) return mColVector[i].text; } +char Colour::getColourCharAt(int i) +{ + if (i < 0 || i >= getNumberOfElements()) + { + return 'C'; + } + return mColVector[i].ch; +} + void Colour::addColour(const char c, const int rgb, const std::string &text) { int trueRgb = config.getValue("Colour" + text, rgb); diff --git a/src/gui/colour.h b/src/gui/colour.h index 1648e1e8..d0349b7d 100644 --- a/src/gui/colour.h +++ b/src/gui/colour.h @@ -87,6 +87,12 @@ class Colour : public gcn::ListModel */ int getColourAt(int i); + /** + * Get the character used by the colour for the element at index i in + * the current colour model + */ + char getColourCharAt(int i); + /** * Set the colour for the element at index i */ diff --git a/src/gui/scrollarea.cpp b/src/gui/scrollarea.cpp index e69b681c..09f7c5e7 100644 --- a/src/gui/scrollarea.cpp +++ b/src/gui/scrollarea.cpp @@ -35,15 +35,17 @@ ImageRect ScrollArea::background; ImageRect ScrollArea::vMarker; Image *ScrollArea::buttons[4][2]; -ScrollArea::ScrollArea(bool gc): +ScrollArea::ScrollArea(bool gc, bool opaque): gcn::ScrollArea(), + mOpaque(opaque), mGC(gc) { init(); } -ScrollArea::ScrollArea(gcn::Widget *widget, bool gc): +ScrollArea::ScrollArea(gcn::Widget *widget, bool gc, bool opaque): gcn::ScrollArea(widget), + mOpaque(opaque), mGC(gc) { init(); @@ -52,9 +54,8 @@ ScrollArea::ScrollArea(gcn::Widget *widget, bool gc): ScrollArea::~ScrollArea() { // Garbage collection - if (mGC) { + if (mGC) delete getContent(); - } instances--; @@ -88,8 +89,10 @@ void ScrollArea::init() const int bggridy[4] = {0, 3, 28, 31}; int a = 0, x, y; - for (y = 0; y < 3; y++) { - for (x = 0; x < 3; x++) { + for (y = 0; y < 3; y++) + { + for (x = 0; x < 3; x++) + { background.grid[a] = textbox->getSubImage( bggridx[x], bggridy[y], bggridx[x + 1] - bggridx[x] + 1, diff --git a/src/gui/scrollarea.h b/src/gui/scrollarea.h index ccc1e178..33ebc692 100644 --- a/src/gui/scrollarea.h +++ b/src/gui/scrollarea.h @@ -38,12 +38,12 @@ class ScrollArea : public gcn::ScrollArea /** * Constructor. */ - ScrollArea(bool gc = true); + ScrollArea(bool gc = true, bool opaque = true); /** * Constructor. */ - ScrollArea(gcn::Widget *content, bool gc = true); + ScrollArea(gcn::Widget *content, bool gc = true, bool opaque = true); /** * Destructor. diff --git a/src/gui/setup_colours.cpp b/src/gui/setup_colours.cpp index d0ab426a..acc28b1f 100644 --- a/src/gui/setup_colours.cpp +++ b/src/gui/setup_colours.cpp @@ -19,11 +19,15 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ +#include + #include #include #include +#include "browserbox.h" #include "colour.h" +#include "itemlinkhandler.h" #include "listbox.h" #include "scrollarea.h" #include "setup_colours.h" @@ -35,6 +39,7 @@ #include "../configuration.h" #include "../utils/gettext.h" +#include "../utils/tostring.h" Setup_Colours::Setup_Colours() : mSelected(-1) @@ -48,6 +53,18 @@ Setup_Colours::Setup_Colours() : mScroll = new ScrollArea(mColourBox); mScroll->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER); + mPreview = new BrowserBox(BrowserBox::AUTO_WRAP); + mPreview->setOpaque(false); + + // Replace this later with a more appropriate link handler. For now, this'll + // do, as it'll do nothing when clicked on. + mPreview->setLinkHandler(new ItemLinkHandler()); + + mPreviewBox = new ScrollArea(mPreview); + mPreviewBox->setHeight(20); + mPreviewBox->setScrollPolicy(gcn::ScrollArea::SHOW_NEVER, + gcn::ScrollArea::SHOW_NEVER); + mRedLabel = new gcn::Label(_("Red: ")); mRedText = new TextField(); @@ -96,16 +113,17 @@ Setup_Colours::Setup_Colours() : LayoutHelper h(this); ContainerPlacer place = h.getPlacer(0, 0); - place(0, 0, mScroll, 4, 3).setPadding(2); - place(0, 3, mRedLabel, 2); - place(2, 3, mRedSlider); - place(3, 3, mRedText).setPadding(1); - place(0, 4, mGreenLabel, 2); - place(2, 4, mGreenSlider); - place(3, 4, mGreenText).setPadding(1); - place(0, 5, mBlueLabel, 2); - place(2, 5, mBlueSlider); - place(3, 5, mBlueText).setPadding(1); + place(0, 0, mScroll, 4, 7).setPadding(2); + place(0, 7, mPreviewBox, 4).setPadding(2); + place(0, 8, mRedLabel, 2); + place(2, 8, mRedSlider); + place(3, 8, mRedText).setPadding(1); + place(0, 9, mGreenLabel, 2); + place(2, 9, mGreenSlider); + place(3, 9, mGreenText).setPadding(1); + place(0, 10, mBlueLabel, 2); + place(2, 10, mBlueSlider); + place(3, 10, mBlueText).setPadding(1); setDimension(gcn::Rectangle(0, 0, 290, 250)); } @@ -133,6 +151,18 @@ void Setup_Colours::action(const gcn::ActionEvent &event) { mSelected = mColourBox->getSelected(); int col = textColour->getColourAt(mSelected); + char ch = textColour->getColourCharAt(mSelected); + std::string msg; + + if (ch == '<') + msg = toString("@@|") + + _("This is what the color looks like") + "@@"; + else + msg = "##" + toString(ch) + + _("This is what the color looks like"); + + mPreview->clearRows(); + mPreview->addRow(msg); setEntry(mRedSlider, mRedText, col >> 16); setEntry(mGreenSlider, mGreenText, (col >> 8) & 0xff); setEntry(mBlueSlider, mBlueText, col & 0xff); @@ -167,7 +197,7 @@ void Setup_Colours::action(const gcn::ActionEvent &event) } } -void Setup_Colours::setEntry(Slider *s, TextField *t, int value) +void Setup_Colours::setEntry(gcn::Slider *s, TextField *t, int value) { s->setValue(value); char buffer[100]; diff --git a/src/gui/setup_colours.h b/src/gui/setup_colours.h index f7984dd5..f56daa60 100644 --- a/src/gui/setup_colours.h +++ b/src/gui/setup_colours.h @@ -29,13 +29,13 @@ #include #include -#include "scrollarea.h" #include "setuptab.h" -#include "slider.h" #include "textfield.h" #include "../guichanfwd.h" +class BrowserBox; + class Setup_Colours : public SetupTab, public gcn::ActionListener, public TextFieldListener { @@ -49,25 +49,27 @@ class Setup_Colours : public SetupTab, public gcn::ActionListener, void listen(const TextField *tf); private: gcn::ListBox *mColourBox; - ScrollArea *mScroll; + gcn::ScrollArea *mScroll; + BrowserBox *mPreview; + gcn::ScrollArea *mPreviewBox; int mSelected; gcn::Label *mRedLabel; - Slider *mRedSlider; + gcn::Slider *mRedSlider; TextField *mRedText; int mRedValue; gcn::Label *mGreenLabel; - Slider *mGreenSlider; + gcn::Slider *mGreenSlider; TextField *mGreenText; int mGreenValue; gcn::Label *mBlueLabel; - Slider *mBlueSlider; + gcn::Slider *mBlueSlider; TextField *mBlueText; int mBlueValue; - void setEntry(Slider *s, TextField *t, int value); + void setEntry(gcn::Slider *s, TextField *t, int value); void updateColour(); }; #endif -- cgit v1.2.3-70-g09d2