diff options
author | Philipp Sehmisch <crush@themanaworld.org> | 2009-03-29 18:33:44 +0200 |
---|---|---|
committer | Philipp Sehmisch <crush@themanaworld.org> | 2009-03-29 18:33:44 +0200 |
commit | 9587fb9b86ee4081ba14d23c1133bf1a09ee4578 (patch) | |
tree | 7682df3ec17534be553caae85ffa9e5a68c9a815 /src/gui | |
parent | 63b41440a0555c6b39141eab94ef4627f712b476 (diff) | |
parent | 8748f26234bba1e71bbe059147fb02256f8cec2a (diff) | |
download | mana-client-9587fb9b86ee4081ba14d23c1133bf1a09ee4578.tar.gz mana-client-9587fb9b86ee4081ba14d23c1133bf1a09ee4578.tar.bz2 mana-client-9587fb9b86ee4081ba14d23c1133bf1a09ee4578.tar.xz mana-client-9587fb9b86ee4081ba14d23c1133bf1a09ee4578.zip |
Merge branch 'master' of git@gitorious.org:tmw/mainline
Diffstat (limited to 'src/gui')
65 files changed, 428 insertions, 562 deletions
diff --git a/src/gui/browserbox.cpp b/src/gui/browserbox.cpp index 2f667237..0240b67b 100644 --- a/src/gui/browserbox.cpp +++ b/src/gui/browserbox.cpp @@ -244,9 +244,6 @@ void BrowserBox::mouseMoved(gcn::MouseEvent &event) void BrowserBox::draw(gcn::Graphics *graphics) { - if (!isVisible()) - return; - if (mOpaque) { graphics->setColor(guiPalette->getColor(Palette::BACKGROUND)); diff --git a/src/gui/buy.cpp b/src/gui/buy.cpp index 6df2ae25..6d336e4c 100644 --- a/src/gui/buy.cpp +++ b/src/gui/buy.cpp @@ -46,15 +46,8 @@ #include "utils/gettext.h" #include "utils/strprintf.h" -#ifdef TMWSERV_SUPPORT BuyDialog::BuyDialog(): -#else -BuyDialog::BuyDialog(Network *network): -#endif Window(_("Buy")), -#ifndef TMWSERV_SUPPORT - mNetwork(network), -#endif mMoney(0), mAmountItems(0), mMaxItems(0) { setWindowName("Buy"); @@ -199,8 +192,7 @@ void BuyDialog::action(const gcn::ActionEvent &event) Net::GameServer::Player::tradeWithNPC (mShopItems->at(selectedItem)->getId(), mAmountItems); #else - MessageOut outMsg(mNetwork); - outMsg.writeInt16(CMSG_NPC_BUY_REQUEST); + MessageOut outMsg(CMSG_NPC_BUY_REQUEST); outMsg.writeInt16(8); outMsg.writeInt16(mAmountItems); outMsg.writeInt16(mShopItems->at(selectedItem)->getId()); diff --git a/src/gui/buy.h b/src/gui/buy.h index 200394b9..1e022652 100644 --- a/src/gui/buy.h +++ b/src/gui/buy.h @@ -29,9 +29,6 @@ #include "../guichanfwd.h" -#ifndef TMWSERV_SUPPORT -class Network; -#endif class ShopItems; class ShopListBox; class ListBox; @@ -50,11 +47,7 @@ class BuyDialog : public Window, public gcn::ActionListener, * * @see Window::Window */ -#ifdef TMWSERV_SUPPORT BuyDialog(); -#else - BuyDialog(Network *network); -#endif /** * Destructor @@ -116,9 +109,6 @@ class BuyDialog : public Window, public gcn::ActionListener, */ void close(); private: -#ifdef EATHENA_SUPPORT - Network *mNetwork; -#endif gcn::Button *mBuyButton; gcn::Button *mQuitButton; gcn::Button *mAddMaxButton; diff --git a/src/gui/buysell.cpp b/src/gui/buysell.cpp index b9a6a1dc..a0e2fc93 100644 --- a/src/gui/buysell.cpp +++ b/src/gui/buysell.cpp @@ -19,20 +19,19 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "button.h" #include "buysell.h" -#include "../npc.h" +#include "npc.h" -#include "../net/messageout.h" -#ifdef EATHENA_SUPPORT -#include "../net/ea/protocol.h" -#endif +#include "gui/button.h" -#include "../utils/gettext.h" +#include "net/messageout.h" +#include "net/ea/protocol.h" -BuySellDialog::BuySellDialog(Network *network): - Window(_("Shop")), mNetwork(network) +#include "utils/gettext.h" + +BuySellDialog::BuySellDialog(): + Window(_("Shop")) { setWindowName("BuySell"); Button *buyButton = 0; @@ -96,10 +95,7 @@ void BuySellDialog::action(const gcn::ActionEvent &event) return; } -#ifdef EATHENA_SUPPORT - MessageOut outMsg(mNetwork); - outMsg.writeInt16(CMSG_NPC_BUY_SELL_REQUEST); + MessageOut outMsg(CMSG_NPC_BUY_SELL_REQUEST); outMsg.writeInt32(current_npc); outMsg.writeInt8(action); -#endif } diff --git a/src/gui/buysell.h b/src/gui/buysell.h index 4b137554..ff956e09 100644 --- a/src/gui/buysell.h +++ b/src/gui/buysell.h @@ -26,8 +26,6 @@ #include "window.h" -class Network; - /** * A dialog to choose between buying or selling at a shop. * @@ -42,7 +40,7 @@ class BuySellDialog : public Window, public gcn::ActionListener * * @see Window::Window */ - BuySellDialog(Network *network); + BuySellDialog(); /** * Check for current NPC @@ -55,9 +53,6 @@ class BuySellDialog : public Window, public gcn::ActionListener * Called when receiving actions from the widgets. */ void action(const gcn::ActionEvent &event); - - private: - Network *mNetwork; }; extern BuySellDialog *buySellDialog; diff --git a/src/gui/changeemaildialog.cpp b/src/gui/changeemaildialog.cpp index 0ed95bd7..14cfb1e7 100644 --- a/src/gui/changeemaildialog.cpp +++ b/src/gui/changeemaildialog.cpp @@ -40,14 +40,14 @@ ChangeEmailDialog::ChangeEmailDialog(Window *parent, LoginData *loginData): Window(_("Change Email Address"), true, parent), - mWrongDataNoticeListener(new WrongDataNoticeListener()), + mWrongDataNoticeListener(new WrongDataNoticeListener), mLoginData(loginData) { gcn::Label *accountLabel = new gcn::Label(strprintf(_("Account: %s"), mLoginData->username.c_str())); gcn::Label *newEmailLabel = new gcn::Label(_("Type New Email Address twice:")); - mFirstEmailField = new TextField(); - mSecondEmailField = new TextField(); + mFirstEmailField = new TextField; + mSecondEmailField = new TextField; mChangeEmailButton = new Button(_("Change Email Address"), "change_email", this); mCancelButton = new Button(_("Cancel"), "cancel", this); diff --git a/src/gui/changepassworddialog.cpp b/src/gui/changepassworddialog.cpp index 7c1e5bcd..4bc97326 100644 --- a/src/gui/changepassworddialog.cpp +++ b/src/gui/changepassworddialog.cpp @@ -41,16 +41,16 @@ ChangePasswordDialog::ChangePasswordDialog(Window *parent, LoginData *loginData): Window(_("Change Password"), true, parent), - mWrongDataNoticeListener(new WrongDataNoticeListener()), + mWrongDataNoticeListener(new WrongDataNoticeListener), mLoginData(loginData) { gcn::Label *accountLabel = new gcn::Label(strprintf(_("Account: %s"), mLoginData->username.c_str())); gcn::Label *oldPassLabel = new gcn::Label(_("Password:")); - mOldPassField = new PasswordField(); + mOldPassField = new PasswordField; gcn::Label *newPassLabel = new gcn::Label(_("Type New Password twice:")); - mFirstPassField = new PasswordField(); - mSecondPassField = new PasswordField(); + mFirstPassField = new PasswordField; + mSecondPassField = new PasswordField; mChangePassButton = new Button(_("Change Password"), "change_password", this); mCancelButton = new Button(_("Cancel"), "cancel", this); diff --git a/src/gui/char_select.cpp b/src/gui/char_select.cpp index 4ab3d9ef..bf885de9 100644 --- a/src/gui/char_select.cpp +++ b/src/gui/char_select.cpp @@ -19,50 +19,48 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include <string> - -#include <guichan/font.hpp> - -#include "button.h" -#include "char_select.h" -#include "confirm_dialog.h" -#include "label.h" -#include "ok_dialog.h" -#include "playerbox.h" -#include "textfield.h" +#include "gui/button.h" +#include "gui/char_select.h" +#include "gui/confirm_dialog.h" +#include "gui/label.h" +#include "gui/ok_dialog.h" +#include "gui/playerbox.h" +#include "gui/textfield.h" #ifdef TMWSERV_SUPPORT -#include "radiobutton.h" -#include "slider.h" +#include "gui/radiobutton.h" +#include "gui/slider.h" -#include "unregisterdialog.h" -#include "changepassworddialog.h" -#include "changeemaildialog.h" +#include "gui/unregisterdialog.h" +#include "gui/changepassworddialog.h" +#include "gui/changeemaildialog.h" -#include "../logindata.h" +#include "logindata.h" -#include "../net/tmwserv/accountserver/account.h" -#include "../net/tmwserv/charserverhandler.h" +#include "net/tmwserv/accountserver/account.h" +#include "net/tmwserv/charserverhandler.h" #else -#include "../net/ea/charserverhandler.h" +#include "net/ea/charserverhandler.h" #endif -#include "widgets/layout.h" +#include "gui/widgets/layout.h" + +#include "game.h" +#include "localplayer.h" +#include "main.h" +#include "units.h" -#include "../game.h" -#include "../localplayer.h" -#include "../main.h" -#include "../units.h" +#include "net/messageout.h" -#include "../net/messageout.h" +#include "resources/colordb.h" -#include "../resources/colordb.h" +#include "utils/gettext.h" +#include "utils/strprintf.h" +#include "utils/stringutils.h" -#include "../utils/gettext.h" -#include "../utils/strprintf.h" -#include "../utils/stringutils.h" +#include <guichan/font.hpp> -#define MAX_SLOT 2 +#include <string> // Defined in main.cpp, used here for setting the char create dialog extern CharServerHandler charServerHandler; @@ -100,12 +98,13 @@ void CharDeleteConfirm::action(const gcn::ActionEvent &event) CharSelectDialog::CharSelectDialog(LockedArray<LocalPlayer*> *charInfo, LoginData *loginData): Window(_("Account and Character Management")), - mCharInfo(charInfo), mCharSelected(false), mLoginData(loginData) + mCharInfo(charInfo), + mCharSelected(false), + mLoginData(loginData) #else -CharSelectDialog::CharSelectDialog(Network *network, - LockedArray<LocalPlayer*> *charInfo, +CharSelectDialog::CharSelectDialog(LockedArray<LocalPlayer*> *charInfo, Gender gender): - Window(_("Select Character")), mNetwork(network), + Window(_("Select Character")), mCharInfo(charInfo), mCharSelected(false), mGender(gender) @@ -257,12 +256,11 @@ void CharSelectDialog::action(const gcn::ActionEvent &event) { new CharDeleteConfirm(this); } - else if (n_character <= MAX_SLOT) + else if (n_character <= maxSlot) { // Start new character dialog CharCreateDialog *charCreateDialog = - new CharCreateDialog(this, mCharInfo->getPos(), - mNetwork, mGender); + new CharCreateDialog(this, mCharInfo->getPos(), mGender); charServerHandler.setCharCreateDialog(charCreateDialog); } } @@ -348,8 +346,7 @@ void CharSelectDialog::attemptCharDelete() Net::AccountServer::Account::deleteCharacter(mCharInfo->getPos()); #else // Request character deletion - MessageOut outMsg(mNetwork); - outMsg.writeInt16(0x0068); + MessageOut outMsg(0x0068); outMsg.writeInt32(mCharInfo->getEntry()->mCharId); outMsg.writeString("a@a.com", 40); #endif @@ -362,8 +359,7 @@ void CharSelectDialog::attemptCharSelect() Net::AccountServer::Account::selectCharacter(mCharInfo->getPos()); #else // Request character selection - MessageOut outMsg(mNetwork); - outMsg.writeInt16(0x0066); + MessageOut outMsg(0x0066); outMsg.writeInt8(mCharInfo->getPos()); #endif mCharInfo->lock(); @@ -400,13 +396,10 @@ bool CharSelectDialog::selectByName(const std::string &name) #ifdef TMWSERV_SUPPORT CharCreateDialog::CharCreateDialog(Window *parent, int slot): #else -CharCreateDialog::CharCreateDialog(Window *parent, int slot, Network *network, +CharCreateDialog::CharCreateDialog(Window *parent, int slot, Gender gender): #endif Window(_("Create Character"), true, parent), -#ifndef TMWSERV_SUPPORT - mNetwork(network), -#endif mSlot(slot) { mPlayer = new Player(0, 0, NULL); @@ -693,8 +686,7 @@ int CharCreateDialog::getDistributedPoints() void CharCreateDialog::attemptCharCreate() { // Send character infos - MessageOut outMsg(mNetwork); - outMsg.writeInt16(0x0067); + MessageOut outMsg(0x0067); outMsg.writeString(getName(), 24); outMsg.writeInt8(5); outMsg.writeInt8(5); diff --git a/src/gui/char_select.h b/src/gui/char_select.h index b29953d3..cf770010 100644 --- a/src/gui/char_select.h +++ b/src/gui/char_select.h @@ -32,8 +32,6 @@ #ifdef TMWSERV_SUPPORT #include "../logindata.h" -#else -class Network; #endif class LocalPlayer; @@ -56,8 +54,7 @@ class CharSelectDialog : public Window, public gcn::ActionListener CharSelectDialog(LockedArray<LocalPlayer*> *charInfo, LoginData *loginData); #else - CharSelectDialog(Network *network, - LockedArray<LocalPlayer*> *charInfo, + CharSelectDialog(LockedArray<LocalPlayer*> *charInfo, Gender gender); #endif @@ -70,9 +67,6 @@ class CharSelectDialog : public Window, public gcn::ActionListener bool selectByName(const std::string &name); private: -#ifdef EATHENA_SUPPORT - Network *mNetwork; -#endif LockedArray<LocalPlayer*> *mCharInfo; gcn::Button *mSelectButton; @@ -129,8 +123,7 @@ class CharCreateDialog : public Window, public gcn::ActionListener #ifdef TMWSERV_SUPPORT CharCreateDialog(Window *parent, int slot); #else - CharCreateDialog(Window *parent, int slot, Network *network, - Gender gender); + CharCreateDialog(Window *parent, int slot, Gender gender); #endif /** @@ -162,9 +155,6 @@ class CharCreateDialog : public Window, public gcn::ActionListener */ void attemptCharCreate(); -#ifdef EATHENA_SUPPORT - Network *mNetwork; -#endif gcn::TextField *mNameField; gcn::Label *mNameLabel; gcn::Button *mNextHairColorButton; diff --git a/src/gui/chat.cpp b/src/gui/chat.cpp index b0b15dbc..10993027 100644 --- a/src/gui/chat.cpp +++ b/src/gui/chat.cpp @@ -27,6 +27,7 @@ #include "gui/scrollarea.h" #include "gui/sdlinput.h" +#include "gui/widgets/chattab.h" #include "gui/widgets/tabbedarea.h" #include "gui/widgets/whispertab.h" @@ -39,13 +40,8 @@ #include <guichan/focushandler.hpp> -#ifdef TMWSERV_SUPPORT ChatWindow::ChatWindow(): - Window("Chat"), -#else -ChatWindow::ChatWindow(Network * network): - Window(""), mNetwork(network), -#endif + Window(_("Chat")), mTmpVisible(false) { setWindowName("Chat"); @@ -61,7 +57,7 @@ ChatWindow::ChatWindow(Network * network): mChatInput->setActionEventId("chatinput"); mChatInput->addActionListener(this); - mChatTabs = new TabbedArea(); + mChatTabs = new TabbedArea; add(mChatTabs); add(mChatInput); @@ -82,7 +78,7 @@ ChatWindow::ChatWindow(Network * network): // run the @assert command for the player again. Convenience for GMs. if (config.getValue(player_node->getName() + "GMassert", 0)) { std::string cmd = "@assert"; - chatSend(cmd); + chatInput(cmd); } #endif mRecorder = new Recorder(this); @@ -163,6 +159,28 @@ void ChatWindow::clearTab() clearTab(getFocused()); } +void ChatWindow::prevTab() +{ + int tab = mChatTabs->getSelectedTabIndex(); + + if (tab == 0) + tab = mChatTabs->getNumberOfTabs(); + tab--; + + mChatTabs->setSelectedTab(tab); +} + +void ChatWindow::nextTab() +{ + int tab = mChatTabs->getSelectedTabIndex(); + + tab++; + if (tab == mChatTabs->getNumberOfTabs()) + tab = 0; + + mChatTabs->setSelectedTab(tab); +} + void ChatWindow::action(const gcn::ActionEvent &event) { if (event.getId() == "chatinput") @@ -180,7 +198,7 @@ void ChatWindow::action(const gcn::ActionEvent &event) mCurHist = mHistory.end(); // Send the message to the server - chatSend(message); + chatInput(message); // Clear the text from the chat input mChatInput->setText(""); @@ -258,10 +276,10 @@ void ChatWindow::removeWhisper(std::string nick) mWhispers.erase(nick); } -void ChatWindow::chatSend(std::string &msg) +void ChatWindow::chatInput(std::string &msg) { ChatTab *tab = getFocused(); - tab->chatSend(msg); + tab->chatInput(msg); } void ChatWindow::doPresent() @@ -298,12 +316,12 @@ void ChatWindow::doPresent() mRecorder->record(timeStr.str() + _("Present: ") + response + "."); - localChatTab->chatLog(_("Attendance written to record log."), + getFocused()->chatLog(_("Attendance written to record log."), BY_SERVER, true); } else { - localChatTab->chatLog(_("Present: ") + response, BY_SERVER); + getFocused()->chatLog(_("Present: ") + response, BY_SERVER); } } @@ -377,6 +395,7 @@ void ChatWindow::setRecordingFile(const std::string &msg) void ChatWindow::whisper(std::string nick, std::string mes, bool own) { if (mes.length() == 0) return; + std::string playerName = player_node->getName(); std::string tempNick = nick; @@ -395,7 +414,7 @@ void ChatWindow::whisper(std::string nick, std::string mes, bool own) } if (own) - tab->chatSend(mes); + tab->chatInput(mes); else tab->chatLog(nick, mes); } diff --git a/src/gui/chat.h b/src/gui/chat.h index 177aa38f..3a2f7fdb 100644 --- a/src/gui/chat.h +++ b/src/gui/chat.h @@ -22,6 +22,8 @@ #ifndef CHAT_H #define CHAT_H +#include "window.h" + #include <list> #include <string> #include <map> @@ -31,10 +33,6 @@ #include <guichan/widget.hpp> #include <guichan/widgetlistener.hpp> -#include "widgets/chattab.h" - -#include "window.h" - class BrowserBox; class Channel; class ChatTab; @@ -42,19 +40,9 @@ class Recorder; class ScrollArea; class TabbedArea; class ItemLinkHandler; -#ifdef EATHENA_SUPPORT -class Network; -#endif +class Tab; class WhisperTab; -/** - * gets in between usernick and message text depending on - * message type - */ -#define CAT_NORMAL ": " -#define CAT_IS "" -#define CAT_WHISPER " whispers: " - #define DEFAULT_CHAT_WINDOW_SCROLL 7 // 1 means `1/8th of the window size'. /** One item in the chat log */ @@ -78,11 +66,7 @@ class ChatWindow : public Window, /** * Constructor. */ -#ifdef TMWSERV_SUPPORT ChatWindow(); -#else - ChatWindow(Network *network); -#endif /** * Destructor: used to write back values to the config file @@ -119,6 +103,16 @@ class ChatWindow : public Window, void clearTab(); /** + * Switch to the previous tab in order + */ + void prevTab(); + + /** + * Switch to the next tab in order + */ + void nextTab(); + + /** * Performs action. */ void action(const gcn::ActionEvent &event); @@ -142,7 +136,7 @@ class ChatWindow : public Window, * @param msg The message text which is to be sent. * */ - void chatSend(std::string &msg); + void chatInput(std::string &msg); /** Called when key is pressed */ void keyPressed(gcn::KeyEvent &event); @@ -199,7 +193,6 @@ class ChatWindow : public Window, void adjustTabSize(); #ifdef EATHENA_SUPPORT - Network *mNetwork; char mPartyPrefix; /**< Messages beginning with the prefix are sent to the party */ #endif diff --git a/src/gui/emotecontainer.cpp b/src/gui/emotecontainer.cpp index b4caf4f1..3425cde8 100644 --- a/src/gui/emotecontainer.cpp +++ b/src/gui/emotecontainer.cpp @@ -79,9 +79,6 @@ EmoteContainer::~EmoteContainer() void EmoteContainer::draw(gcn::Graphics *graphics) { - if (!isVisible()) - return; - int columns = getWidth() / gridWidth; // Have at least 1 column diff --git a/src/gui/emoteshortcutcontainer.cpp b/src/gui/emoteshortcutcontainer.cpp index 661f42a7..ae5eb859 100644 --- a/src/gui/emoteshortcutcontainer.cpp +++ b/src/gui/emoteshortcutcontainer.cpp @@ -76,9 +76,6 @@ EmoteShortcutContainer::~EmoteShortcutContainer() void EmoteShortcutContainer::draw(gcn::Graphics *graphics) { - if (!isVisible()) - return; - if (config.getValue("guialpha", 0.8) != mAlpha) { mAlpha = config.getValue("guialpha", 0.8); diff --git a/src/gui/equipmentwindow.cpp b/src/gui/equipmentwindow.cpp index 96500e88..0be33ca6 100644 --- a/src/gui/equipmentwindow.cpp +++ b/src/gui/equipmentwindow.cpp @@ -121,9 +121,6 @@ EquipmentWindow::~EquipmentWindow() void EquipmentWindow::draw(gcn::Graphics *graphics) { - if (!isVisible()) - return; - // Draw window graphics Window::draw(graphics); diff --git a/src/gui/guildwindow.cpp b/src/gui/guildwindow.cpp index c8a1872f..0d48b4f3 100644 --- a/src/gui/guildwindow.cpp +++ b/src/gui/guildwindow.cpp @@ -20,26 +20,26 @@ * $$ */ -#include "guildwindow.h" +#include "gui/guildwindow.h" -#include "button.h" -#include "chat.h" -#include "confirm_dialog.h" -#include "guildlistbox.h" -#include "scrollarea.h" -#include "textdialog.h" -#include "windowcontainer.h" +#include "gui/button.h" +#include "gui/confirm_dialog.h" +#include "gui/guildlistbox.h" +#include "gui/scrollarea.h" +#include "gui/textdialog.h" +#include "gui/windowcontainer.h" -#include "widgets/layout.h" -#include "widgets/tabbedarea.h" +#include "gui/widgets/chattab.h" +#include "gui/widgets/layout.h" +#include "gui/widgets/tabbedarea.h" -#include "../guild.h" -#include "../log.h" -#include "../localplayer.h" +#include "guild.h" +#include "log.h" +#include "localplayer.h" -#include "../net/tmwserv/chatserver/guild.h" -#include "../utils/dtor.h" -#include "../utils/gettext.h" +#include "net/tmwserv/chatserver/guild.h" +#include "utils/dtor.h" +#include "utils/gettext.h" #include <algorithm> @@ -64,7 +64,7 @@ GuildWindow::GuildWindow(): mGuildButton[1]->setEnabled(false); mGuildButton[2]->setEnabled(false); - mGuildTabs = new TabbedArea(); + mGuildTabs = new TabbedArea; place(0, 0, mGuildButton[0]); place(1, 0, mGuildButton[1]); @@ -169,7 +169,7 @@ void GuildWindow::action(const gcn::ActionEvent &event) void GuildWindow::newGuildTab(const std::string &guildName) { // Create new tab - GuildListBox *list = new GuildListBox(); + GuildListBox *list = new GuildListBox; list->setListModel(player_node->getGuild(guildName)); ScrollArea *sa = new ScrollArea(list); sa->setDimension(gcn::Rectangle(5, 5, 135, 250)); diff --git a/src/gui/inventorywindow.cpp b/src/gui/inventorywindow.cpp index 612c978a..51c1372c 100644 --- a/src/gui/inventorywindow.cpp +++ b/src/gui/inventorywindow.cpp @@ -57,7 +57,7 @@ InventoryWindow::InventoryWindow(int invSize): setResizable(false); setCloseButton(true); - setDefaultSize(375, 307, ImageRect::CENTER); + setDefaultSize(387, 307, ImageRect::CENTER); addKeyListener(this); std::string longestUseString = getFont()->getWidth(_("Equip")) > @@ -74,14 +74,13 @@ InventoryWindow::InventoryWindow(int invSize): mDropButton = new Button(_("Drop"), "drop", this); #ifdef TMWSERV_SUPPORT mSplitButton = new Button(_("Split"), "split", this); -#endif - mItems = new ItemContainer(player_node->getInventory(), 10, 5); +#else + mItems = new ItemContainer(player_node->getInventory(), 10, 10); +#endif mItems->addSelectionListener(this); - // The window is supposed to be exactly large enough for now mInvenScroll = new ScrollArea(mItems); - mInvenScroll->setVerticalScrollPolicy(gcn::ScrollArea::SHOW_NEVER); mInvenScroll->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER); mTotalWeight = -1; diff --git a/src/gui/itemcontainer.cpp b/src/gui/itemcontainer.cpp index abce257d..70cf8176 100644 --- a/src/gui/itemcontainer.cpp +++ b/src/gui/itemcontainer.cpp @@ -61,7 +61,7 @@ ItemContainer::ItemContainer(Inventory *inventory, mSwapItems(false), mDescItems(false) { - mItemPopup = new ItemPopup(); + mItemPopup = new ItemPopup; setFocusable(true); ResourceManager *resman = ResourceManager::getInstance(); @@ -281,9 +281,11 @@ void ItemContainer::mouseReleased(gcn::MouseEvent &event) }; int index = getSlotIndex(event.getX(), event.getY()); - if (index == Inventory::NO_SLOT_INDEX) return; + if (index == Inventory::NO_SLOT_INDEX) + return; Item *item = mInventory->getItem(index); - if (item == mSelectedItem) return; + if (item == mSelectedItem) + return; player_node->moveInvItem(mSelectedItem, index); setSelectedItem(NULL); mSelectionStatus = SEL_NONE; @@ -314,12 +316,12 @@ void ItemContainer::mouseExited(gcn::MouseEvent &event) mItemPopup->setVisible(false); } -int ItemContainer::getSlotIndex(const int posX, const int posY) const +int ItemContainer::getSlotIndex(int x, int y) const { - if (getDimension().isPointInRect(posX, posY)) + if (x < getWidth() && y < getHeight()) { // Takes into account, boxes are overlapping each other. - return (posY / (BOX_HEIGHT - 1)) * mGridColumns + (posX / (BOX_WIDTH - 1)); + return (y / (BOX_HEIGHT - 1)) * mGridColumns + (x / (BOX_WIDTH - 1)); } return Inventory::NO_SLOT_INDEX; } diff --git a/src/gui/itemcontainer.h b/src/gui/itemcontainer.h index a28ca392..b2857563 100644 --- a/src/gui/itemcontainer.h +++ b/src/gui/itemcontainer.h @@ -69,9 +69,12 @@ class ItemContainer : public gcn::Widget, void keyPressed(gcn::KeyEvent &event); void keyReleased(gcn::KeyEvent &event); + void mousePressed(gcn::MouseEvent &event); void mouseDragged(gcn::MouseEvent &event); void mouseReleased(gcn::MouseEvent &event); + void mouseMoved(gcn::MouseEvent &event); + void mouseExited(gcn::MouseEvent &event); /** * Returns the selected item. @@ -125,9 +128,6 @@ class ItemContainer : public gcn::Widget, */ void keyAction(); - void mouseExited(gcn::MouseEvent &event); - void mouseMoved(gcn::MouseEvent &event); - /** * Moves the highlight in the direction specified. * @@ -158,11 +158,11 @@ class ItemContainer : public gcn::Widget, /** * Gets the slot index based on the cursor position. * - * @param posX The X Coordinate position. - * @param posY The Y Coordinate position. + * @param x The X coordinate position. + * @param y The Y coordinate position. * @return The slot index on success, -1 on failure. */ - int getSlotIndex(int posX, int posY) const; + int getSlotIndex(int x, int y) const; Inventory *mInventory; int mGridColumns, mGridRows; diff --git a/src/gui/itemshortcutcontainer.cpp b/src/gui/itemshortcutcontainer.cpp index d4de3477..97c3b640 100644 --- a/src/gui/itemshortcutcontainer.cpp +++ b/src/gui/itemshortcutcontainer.cpp @@ -70,9 +70,6 @@ ItemShortcutContainer::~ItemShortcutContainer() void ItemShortcutContainer::draw(gcn::Graphics *graphics) { - if (!isVisible()) - return; - if (config.getValue("guialpha", 0.8) != mAlpha) { mAlpha = config.getValue("guialpha", 0.8); @@ -255,4 +252,3 @@ void ItemShortcutContainer::mouseExited(gcn::MouseEvent &event) { mItemPopup->setVisible(false); } - diff --git a/src/gui/listbox.cpp b/src/gui/listbox.cpp index dbd8e674..70b4fc55 100644 --- a/src/gui/listbox.cpp +++ b/src/gui/listbox.cpp @@ -38,7 +38,7 @@ ListBox::ListBox(gcn::ListModel *listModel): void ListBox::draw(gcn::Graphics *graphics) { - if (!mListModel || !isVisible()) + if (!mListModel) return; if (config.getValue("guialpha", 0.8) != mAlpha) diff --git a/src/gui/minimap.cpp b/src/gui/minimap.cpp index 6bca796d..bfd34390 100644 --- a/src/gui/minimap.cpp +++ b/src/gui/minimap.cpp @@ -45,6 +45,9 @@ Minimap::Minimap(): setDefaultSize(5, 25, 100, 100); setResizable(true); + setStickyButton(true); + setSticky(false); + loadWindowState(); } @@ -92,21 +95,13 @@ void Minimap::setMapImage(Image *img) void Minimap::toggle() { - mShow = !mShow; + setVisible(!isVisible(), true); } void Minimap::draw(gcn::Graphics *graphics) { - setVisible(mShow); - - if (!isVisible()) - return; - Window::draw(graphics); - if (!mShow) - return; - const gcn::Rectangle a = getChildrenArea(); graphics->pushClipArea(a); diff --git a/src/gui/npc_text.cpp b/src/gui/npc_text.cpp index 9fa57be8..31f48486 100644 --- a/src/gui/npc_text.cpp +++ b/src/gui/npc_text.cpp @@ -37,15 +37,8 @@ #include "../utils/gettext.h" -#ifdef TMWSERV_SUPPORT NpcTextDialog::NpcTextDialog() -#else -NpcTextDialog::NpcTextDialog(Network *network) -#endif : Window(_("NPC")) -#ifdef EATHENA_SUPPORT - , mNetwork(network) -#endif , mState(NPC_TEXT_STATE_WAITING) { setWindowName("NPCText"); @@ -136,8 +129,7 @@ void NpcTextDialog::nextDialog(int npcID) #ifdef TMWSERV_SUPPORT Net::GameServer::Player::talkToNPC(npcID, false); #else - MessageOut outMsg(mNetwork); - outMsg.writeInt16(CMSG_NPC_NEXT_REQUEST); + MessageOut outMsg(CMSG_NPC_NEXT_REQUEST); outMsg.writeInt32(npcID); #endif } @@ -145,8 +137,7 @@ void NpcTextDialog::nextDialog(int npcID) void NpcTextDialog::closeDialog(int npcID) { #ifdef EATHENA_SUPPORT - MessageOut outMsg(mNetwork); - outMsg.writeInt16(CMSG_NPC_CLOSE); + MessageOut outMsg(CMSG_NPC_CLOSE); outMsg.writeInt32(npcID); #endif } diff --git a/src/gui/npc_text.h b/src/gui/npc_text.h index 16c1d5fd..231ac684 100644 --- a/src/gui/npc_text.h +++ b/src/gui/npc_text.h @@ -30,9 +30,6 @@ #include "../npc.h" -#ifdef EATHENA_SUPPORT -class Network; -#endif class TextBox; /** @@ -48,11 +45,7 @@ class NpcTextDialog : public Window, public gcn::ActionListener * * @see Window::Window */ -#ifdef TMWSERV_SUPPORT NpcTextDialog(); -#else - NpcTextDialog(Network *network); -#endif /** * Called when receiving actions from the widgets. @@ -101,9 +94,6 @@ class NpcTextDialog : public Window, public gcn::ActionListener void widgetResized(const gcn::Event &event); private: -#ifdef EATHENA_SUPPORT - Network *mNetwork; -#endif gcn::ScrollArea *mScrollArea; TextBox *mTextBox; gcn::Button *mButton; diff --git a/src/gui/npcintegerdialog.cpp b/src/gui/npcintegerdialog.cpp index a7ae2748..4d2ae1ce 100644 --- a/src/gui/npcintegerdialog.cpp +++ b/src/gui/npcintegerdialog.cpp @@ -36,15 +36,8 @@ #include "../utils/gettext.h" #include "../utils/strprintf.h" -#ifdef TMWSERV_SUPPORT NpcIntegerDialog::NpcIntegerDialog() -#else -NpcIntegerDialog::NpcIntegerDialog(Network *network) -#endif : Window(_("NPC Number Request")) -#ifdef EATHENA_SUPPORT - , mNetwork(network) -#endif { setWindowName("NPCInteger"); mValueField = new IntTextField; @@ -127,8 +120,7 @@ void NpcIntegerDialog::action(const gcn::ActionEvent &event) NPC::isTalking = false; #ifdef EATHENA_SUPPORT - MessageOut outMsg(mNetwork); - outMsg.writeInt16(CMSG_NPC_INT_RESPONSE); + MessageOut outMsg(CMSG_NPC_INT_RESPONSE); outMsg.writeInt32(current_npc); outMsg.writeInt32(mValueField->getValue()); #endif diff --git a/src/gui/npcintegerdialog.h b/src/gui/npcintegerdialog.h index df74c904..bb3a8e20 100644 --- a/src/gui/npcintegerdialog.h +++ b/src/gui/npcintegerdialog.h @@ -26,9 +26,6 @@ #include "window.h" -#ifdef EATHENA_SUPPORT -class Network; -#endif class IntTextField; /** @@ -44,11 +41,7 @@ class NpcIntegerDialog : public Window, public gcn::ActionListener * * @see Window::Window */ -#ifdef TMWSERV_SUPPORT NpcIntegerDialog(); -#else - NpcIntegerDialog(Network *network); -#endif /** * Called when receiving actions from the widgets. @@ -93,9 +86,6 @@ class NpcIntegerDialog : public Window, public gcn::ActionListener void setVisible(bool visible); private: -#ifdef EATHENA_SUPPORT - Network *mNetwork; -#endif gcn::Button *mDecButton; gcn::Button *mIncButton; IntTextField *mValueField; diff --git a/src/gui/npclistdialog.cpp b/src/gui/npclistdialog.cpp index ff91c9fc..efac8954 100644 --- a/src/gui/npclistdialog.cpp +++ b/src/gui/npclistdialog.cpp @@ -41,15 +41,8 @@ #include "../utils/gettext.h" #include "../utils/strprintf.h" -#ifdef TMWSERV_SUPPORT NpcListDialog::NpcListDialog() -#else -NpcListDialog::NpcListDialog(Network *network) -#endif : Window("NPC") -#ifdef EATHENA_SUPPORT - , mNetwork(network) -#endif { setWindowName("NPCList"); setResizable(true); @@ -143,8 +136,7 @@ void NpcListDialog::action(const gcn::ActionEvent &event) #ifdef TMWSERV_SUPPORT Net::GameServer::Player::selectFromNPC(current_npc, choice); #else - MessageOut outMsg(mNetwork); - outMsg.writeInt16(CMSG_NPC_LIST_CHOICE); + MessageOut outMsg(CMSG_NPC_LIST_CHOICE); outMsg.writeInt32(current_npc); outMsg.writeInt8(choice); #endif diff --git a/src/gui/npclistdialog.h b/src/gui/npclistdialog.h index 6c1e02e3..fa297304 100644 --- a/src/gui/npclistdialog.h +++ b/src/gui/npclistdialog.h @@ -29,10 +29,6 @@ #include <vector> -#ifdef EATHENA_SUPPORT -class Network; -#endif - /** * The npc list dialog. * @@ -47,11 +43,7 @@ class NpcListDialog : public Window, public gcn::ActionListener, * * @see Window::Window */ -#ifdef TMWSERV_SUPPORT NpcListDialog(); -#else - NpcListDialog(Network *network); -#endif /** * Called when receiving actions from the widgets. @@ -94,9 +86,6 @@ class NpcListDialog : public Window, public gcn::ActionListener, void requestFocus(); private: -#ifdef EATHENA_SUPPORT - Network *mNetwork; -#endif gcn::ListBox *mItemList; std::vector<std::string> mItems; diff --git a/src/gui/npcpostdialog.cpp b/src/gui/npcpostdialog.cpp index 278bc397..5c083612 100644 --- a/src/gui/npcpostdialog.cpp +++ b/src/gui/npcpostdialog.cpp @@ -19,15 +19,17 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "npcpostdialog.h" -#include "textbox.h" -#include "textfield.h" -#include "button.h" -#include "scrollarea.h" -#include "chat.h" +#include "gui/npcpostdialog.h" -#include "../net/tmwserv/gameserver/player.h" -#include "../utils/gettext.h" +#include "gui/textbox.h" +#include "gui/textfield.h" +#include "gui/button.h" +#include "gui/scrollarea.h" + +#include "gui/widgets/chattab.h" + +#include "net/tmwserv/gameserver/player.h" +#include "utils/gettext.h" #include <guichan/widgets/label.hpp> @@ -39,7 +41,7 @@ NpcPostDialog::NpcPostDialog(): // create text field for receiver gcn::Label *senderText = new gcn::Label("To:"); senderText->setPosition(5, 5); - mSender = new TextField(); + mSender = new TextField; mSender->setPosition(senderText->getWidth() + 5, 5); mSender->setWidth(65); @@ -52,7 +54,7 @@ NpcPostDialog::NpcPostDialog(): sendButton->getY()); // create textfield for letter - mText = new TextBox(); + mText = new TextBox; mText->setHeight(400 - (mSender->getHeight() + sendButton->getHeight())); mText->setEditable(true); diff --git a/src/gui/npcstringdialog.cpp b/src/gui/npcstringdialog.cpp index c84de015..e5137d9c 100644 --- a/src/gui/npcstringdialog.cpp +++ b/src/gui/npcstringdialog.cpp @@ -36,15 +36,8 @@ #include "../utils/gettext.h" #include "../utils/strprintf.h" -#ifdef TMWSERV_SUPPORT NpcStringDialog::NpcStringDialog() -#else -NpcStringDialog::NpcStringDialog(Network *network) -#endif : Window(_("NPC Text Request")) -#ifdef EATHENA_SUPPORT - , mNetwork(network) -#endif { setWindowName("NPCString"); mValueField = new TextField(""); @@ -95,8 +88,7 @@ void NpcStringDialog::action(const gcn::ActionEvent &event) mValueField->setText(""); #ifdef EATHENA_SUPPORT - MessageOut outMsg(mNetwork); - outMsg.writeInt16(CMSG_NPC_STR_RESPONSE); + MessageOut outMsg(CMSG_NPC_STR_RESPONSE); outMsg.writeInt16(text.length() + 9); outMsg.writeInt32(current_npc); outMsg.writeString(text, text.length()); diff --git a/src/gui/npcstringdialog.h b/src/gui/npcstringdialog.h index 94cd59b2..37d46cc0 100644 --- a/src/gui/npcstringdialog.h +++ b/src/gui/npcstringdialog.h @@ -26,10 +26,6 @@ #include <guichan/actionlistener.hpp> -#ifdef EATHENA_SUPPORT -class Network; -#endif - /** * The npc integer input dialog. * @@ -43,11 +39,7 @@ class NpcStringDialog : public Window, public gcn::ActionListener * * @see Window::Window */ -#ifdef TMWSERV_SUPPORT NpcStringDialog(); -#else - NpcStringDialog(Network *network); -#endif /** * Called when receiving actions from the widgets. @@ -79,9 +71,6 @@ class NpcStringDialog : public Window, public gcn::ActionListener void setVisible(bool visible); private: -#ifdef EATHENA_SUPPORT - Network *mNetwork; -#endif gcn::TextField *mValueField; std::string mDefault; }; diff --git a/src/gui/partywindow.cpp b/src/gui/partywindow.cpp index 3f857b5c..f5cebdfd 100644 --- a/src/gui/partywindow.cpp +++ b/src/gui/partywindow.cpp @@ -19,13 +19,19 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "partywindow.h" -#include "chat.h" +#include "gui/partywindow.h" -#include "widgets/avatar.h" +#include "gui/widgets/avatar.h" +#include "gui/widgets/chattab.h" -#include "../utils/gettext.h" -#include "../net/tmwserv/chatserver/party.h" +#ifdef TMWSERV_SUPPORT +#include "net/tmwserv/chatserver/party.h" +#else +#include "net/ea/party.h" +#endif + +#include "utils/gettext.h" +#include "utils/strprintf.h" PartyWindow::PartyWindow() : Window(_("Party")) { @@ -106,7 +112,8 @@ void PartyWindow::removePartyMember(const std::string &memberName) } } -void PartyWindow::showPartyInvite(const std::string &inviter) +void PartyWindow::showPartyInvite(const std::string &inviter, + const std::string &partyName) { // check there isnt already an invite showing if (mPartyInviter != "") @@ -116,8 +123,15 @@ void PartyWindow::showPartyInvite(const std::string &inviter) return; } + std::string msg; // log invite - std::string msg = inviter + " has invited you to join their party"; + if (partyName.empty()) + msg = strprintf("%s has invited you to join their party", + inviter.c_str()); + else + msg = strprintf("%s has invited you to join the %s party", + inviter.c_str(), partyName.c_str()); + localChatTab->chatLog(msg, BY_SERVER); // show invite @@ -135,11 +149,21 @@ void PartyWindow::action(const gcn::ActionEvent &event) if (eventId == "yes") { localChatTab->chatLog("Accepted invite from " + mPartyInviter); +#ifdef TMWSERV_SUPPORT Net::ChatServer::Party::acceptInvite(mPartyInviter); +#else + eAthena::Party::respondToInvite(true); +#endif mPartyInviter = ""; } else if (eventId == "no") { + localChatTab->chatLog("Rejected invite from " + mPartyInviter); +#ifdef TMWSERV_SUPPORT + // TODO +#else + eAthena::Party::respondToInvite(false); +#endif mPartyInviter = ""; } } diff --git a/src/gui/partywindow.h b/src/gui/partywindow.h index b587cc42..64cfb582 100644 --- a/src/gui/partywindow.h +++ b/src/gui/partywindow.h @@ -77,7 +77,8 @@ class PartyWindow : public Window, gcn::ActionListener /** * Show party invite */ - void showPartyInvite(const std::string &inviter); + void showPartyInvite(const std::string &inviter, + const std::string &partyName = ""); /** * Handle events diff --git a/src/gui/playerbox.cpp b/src/gui/playerbox.cpp index 58ef4cd7..d00194bd 100644 --- a/src/gui/playerbox.cpp +++ b/src/gui/playerbox.cpp @@ -78,9 +78,6 @@ PlayerBox::~PlayerBox() void PlayerBox::draw(gcn::Graphics *graphics) { - if (!isVisible()) - return; - if (mPlayer) { // Draw character diff --git a/src/gui/popup.cpp b/src/gui/popup.cpp index 648a9d6a..46246639 100644 --- a/src/gui/popup.cpp +++ b/src/gui/popup.cpp @@ -108,9 +108,6 @@ void Popup::savePopupConfiguration() void Popup::draw(gcn::Graphics *graphics) { - if (!isVisible()) - return; - Graphics *g = static_cast<Graphics*>(graphics); g->drawImageRect(0, 0, getWidth(), getHeight(), mSkin->getBorder()); diff --git a/src/gui/popupmenu.cpp b/src/gui/popupmenu.cpp index 5b5b2b8c..1f36ef45 100644 --- a/src/gui/popupmenu.cpp +++ b/src/gui/popupmenu.cpp @@ -297,8 +297,7 @@ void PopupMenu::handleLink(const std::string &link) being && being->getType() == Being::PLAYER) { - MessageOut outMsg(player_node->getNetwork()); - outMsg.writeInt16(CMSG_PARTY_INVITE); + MessageOut outMsg(CMSG_PARTY_INVITE); outMsg.writeInt32(being->getId()); } #endif diff --git a/src/gui/radiobutton.cpp b/src/gui/radiobutton.cpp index 4a98e29a..d563a2db 100644 --- a/src/gui/radiobutton.cpp +++ b/src/gui/radiobutton.cpp @@ -69,9 +69,6 @@ RadioButton::~RadioButton() void RadioButton::drawBox(gcn::Graphics* graphics) { - if (!isVisible()) - return; - if (config.getValue("guialpha", 0.8) != mAlpha) { mAlpha = config.getValue("guialpha", 0.8); diff --git a/src/gui/scrollarea.cpp b/src/gui/scrollarea.cpp index a867822e..2fa087c1 100644 --- a/src/gui/scrollarea.cpp +++ b/src/gui/scrollarea.cpp @@ -170,9 +170,6 @@ void ScrollArea::logic() void ScrollArea::draw(gcn::Graphics *graphics) { - if (!isVisible()) - return; - if (mVBarVisible) { drawUpButton(graphics); diff --git a/src/gui/sell.cpp b/src/gui/sell.cpp index e7671110..1e1155a7 100644 --- a/src/gui/sell.cpp +++ b/src/gui/sell.cpp @@ -46,14 +46,8 @@ #include "utils/gettext.h" #include "utils/strprintf.h" -#ifdef TMWSERV_SUPPORT SellDialog::SellDialog(): Window(_("Sell")), -#else -SellDialog::SellDialog(Network *network): - Window(_("Sell")), - mNetwork(network), -#endif mMaxItems(0), mAmountItems(0) { setWindowName("Sell"); @@ -207,15 +201,13 @@ void SellDialog::action(const gcn::ActionEvent &event) (mShopItems->at(selectedItem)->getId(), mAmountItems); #else // Attempt sell - MessageOut outMsg(mNetwork); - ShopItem *item = mShopItems->at(selectedItem); int sellCount; mPlayerMoney += mAmountItems * mShopItems->at(selectedItem)->getPrice(); mMaxItems -= mAmountItems; while (mAmountItems > 0) { - outMsg.writeInt16(CMSG_NPC_SELL_REQUEST); + MessageOut outMsg(CMSG_NPC_SELL_REQUEST); outMsg.writeInt16(8); outMsg.writeInt16(item->getCurrentInvIndex()); // This order is important, item->getCurrentInvIndex() would return diff --git a/src/gui/sell.h b/src/gui/sell.h index b6388a1f..b3e59b4f 100644 --- a/src/gui/sell.h +++ b/src/gui/sell.h @@ -30,9 +30,6 @@ #include "window.h" class Item; -#ifdef EATHENA_SUPPORT -class Network; -#endif class ShopItems; class ShopListBox; @@ -49,11 +46,7 @@ class SellDialog : public Window, gcn::ActionListener, gcn::SelectionListener * * @see Window::Window */ -#ifdef TMWSERV_SUPPORT SellDialog(); -#else - SellDialog(Network *network); -#endif /** * Destructor @@ -111,9 +104,6 @@ class SellDialog : public Window, gcn::ActionListener, gcn::SelectionListener */ void updateButtonsAndLabels(); -#ifdef EATHENA_SUPPORT - Network *mNetwork; -#endif gcn::Button *mSellButton; gcn::Button *mQuitButton; gcn::Button *mAddMaxButton; diff --git a/src/gui/serverdialog.cpp b/src/gui/serverdialog.cpp index a57be06c..9d679acb 100644 --- a/src/gui/serverdialog.cpp +++ b/src/gui/serverdialog.cpp @@ -80,7 +80,7 @@ ServerDialog::ServerDialog(LoginData *loginData): mPortField = new TextField(toString(mLoginData->port)); // Add the most used servers from config - mMostUsedServersListModel = new ServersListModel(); + mMostUsedServersListModel = new ServersListModel; Server currentServer; std::string currentConfig = ""; for (int i=0; i<=MAX_SERVERLIST; i++) @@ -101,7 +101,7 @@ ServerDialog::ServerDialog(LoginData *loginData): mMostUsedServersListBox = new ListBox(NULL); mMostUsedServersListBox->setListModel(mMostUsedServersListModel); - mMostUsedServersScrollArea = new ScrollArea(); + mMostUsedServersScrollArea = new ScrollArea; mMostUsedServersDropDown = new DropDown(mMostUsedServersListModel, mMostUsedServersScrollArea, mMostUsedServersListBox); diff --git a/src/gui/setup_colors.cpp b/src/gui/setup_colors.cpp index caa53e2d..ed1b6d09 100644 --- a/src/gui/setup_colors.cpp +++ b/src/gui/setup_colors.cpp @@ -79,7 +79,7 @@ Setup_Colors::Setup_Colors() : mGradTypeSlider->addActionListener(this); mGradTypeSlider->setEnabled(false); - mGradTypeText = new Label(); + mGradTypeText = new Label; mRedLabel = new Label(_("Red: ")); diff --git a/src/gui/shoplistbox.cpp b/src/gui/shoplistbox.cpp index 8801c51a..b35c1d80 100644 --- a/src/gui/shoplistbox.cpp +++ b/src/gui/shoplistbox.cpp @@ -58,7 +58,7 @@ void ShopListBox::setPlayersMoney(int money) void ShopListBox::draw(gcn::Graphics *gcnGraphics) { - if (!mListModel || !isVisible()) + if (!mListModel) return; if (config.getValue("guialpha", 0.8) != mAlpha) diff --git a/src/gui/shortcutcontainer.cpp b/src/gui/shortcutcontainer.cpp index 9067e921..228a484e 100644 --- a/src/gui/shortcutcontainer.cpp +++ b/src/gui/shortcutcontainer.cpp @@ -42,12 +42,12 @@ void ShortcutContainer::widgetResized(const gcn::Event &event) if (mGridWidth < 1) mGridWidth = 1; - setHeight((mMaxItems / mGridWidth) * mBoxHeight); + mGridHeight = mMaxItems / mGridWidth; - mGridHeight = getHeight() / mBoxHeight; + if (mMaxItems % mGridWidth != 0 || mGridHeight < 1) + ++mGridHeight; - if (mGridHeight < 1) - mGridHeight = 1; + setHeight(mGridHeight * mBoxHeight); } int ShortcutContainer::getIndexFromGrid(int pointX, int pointY) const diff --git a/src/gui/skill.h b/src/gui/skill.h index 0600d106..0d6336f3 100644 --- a/src/gui/skill.h +++ b/src/gui/skill.h @@ -22,18 +22,19 @@ #ifndef SKILL_H #define SKILL_H +#include "gui/window.h" + #include <vector> #include <guichan/actionlistener.hpp> -#include "window.h" - struct SKILL { short id; /**< Index into "skill_db" array */ short lv, sp; }; class GuiTable; +class ScrollArea; class SkillGuiTableModel; /** diff --git a/src/gui/skilldialog.cpp b/src/gui/skilldialog.cpp index e30299d4..4afd92ac 100644 --- a/src/gui/skilldialog.cpp +++ b/src/gui/skilldialog.cpp @@ -19,28 +19,30 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include <guichan/widgets/label.hpp> -#include <guichan/widgets/container.hpp> -#include <guichan/widgets/icon.hpp> +#include "gui/skilldialog.h" + +#include "gui/icon.h" +#include "gui/button.h" +#include "gui/listbox.h" +#include "gui/scrollarea.h" +#include "gui/windowcontainer.h" +#include "gui/progressbar.h" -#include "skilldialog.h" +#include "gui/widgets/tabbedarea.h" -#include "icon.h" -#include "button.h" -#include "listbox.h" -#include "scrollarea.h" -#include "windowcontainer.h" -#include "progressbar.h" +#include "localplayer.h" -#include "widgets/tabbedarea.h" +#include "utils/dtor.h" +#include "utils/gettext.h" +#include "utils/stringutils.h" -#include "../localplayer.h" +#include <guichan/widgets/label.hpp> +#include <guichan/widgets/container.hpp> +#include <guichan/widgets/icon.hpp> -#include "../utils/dtor.h" -#include "../utils/gettext.h" -#include "../utils/stringutils.h" +#include <vector> -class Skill_Tab : public GCContainer, public gcn::ActionListener +class SkillTab : public GCContainer, public gcn::ActionListener { public: /** @@ -51,7 +53,7 @@ class Skill_Tab : public GCContainer, public gcn::ActionListener /** * Constructor */ - Skill_Tab(const std::string &type); + SkillTab(const std::string &type); /** * Update this tab @@ -102,21 +104,21 @@ SkillDialog::SkillDialog(): setCloseButton(true); setDefaultSize(windowContainer->getWidth() - 280, 30, 275, 425); - TabbedArea *panel = new TabbedArea(); + TabbedArea *panel = new TabbedArea; panel->setDimension(gcn::Rectangle(5, 5, 270, 420)); - Skill_Tab *tab; + SkillTab *tab; // Add each type of skill tab to the panel - tab = new Skill_Tab("Weapon"); + tab = new SkillTab("Weapon"); panel->addTab(_("Weapons"), tab); mTabs.push_back(tab); - tab = new Skill_Tab("Magic"); + tab = new SkillTab("Magic"); panel->addTab(_("Magic"), tab); mTabs.push_back(tab); - tab = new Skill_Tab("Craft"); + tab = new SkillTab("Craft"); panel->addTab(_("Crafts"), tab); mTabs.push_back(tab); @@ -153,14 +155,14 @@ void SkillDialog::draw(gcn::Graphics *g) void SkillDialog::update() { - for(std::list<Skill_Tab*>::const_iterator i = mTabs.begin(); + for(std::list<SkillTab*>::const_iterator i = mTabs.begin(); i != mTabs.end(); ++i) { (*i)->update(); } } -Skill_Tab::Skill_Tab(const std::string &type): type(type) +SkillTab::SkillTab(const std::string &type): type(type) { setOpaque(false); setDimension(gcn::Rectangle(0, 0, 270, 420)); @@ -200,7 +202,7 @@ Skill_Tab::Skill_Tab(const std::string &type): type(type) } -int Skill_Tab::getSkillNum() +int SkillTab::getSkillNum() { int skillNum = 0; @@ -222,7 +224,7 @@ int Skill_Tab::getSkillNum() else return skillNum; } -int Skill_Tab::getSkillBegin() +int SkillTab::getSkillBegin() { int skillBegin = 0; @@ -244,14 +246,14 @@ int Skill_Tab::getSkillBegin() else return skillBegin; } -Icon* Skill_Tab::getIcon(int index) +Icon* SkillTab::getIcon(int index) { int skillBegin = getSkillBegin(); std::string icon = LocalPlayer::getSkillInfo(index + skillBegin).icon; return new Icon(icon); } -void Skill_Tab::updateSkill(int index) +void SkillTab::updateSkill(int index) { int skillBegin = getSkillBegin(); @@ -306,7 +308,7 @@ void Skill_Tab::updateSkill(int index) } } -void Skill_Tab::update() +void SkillTab::update() { int skillNum = getSkillNum(); diff --git a/src/gui/skilldialog.h b/src/gui/skilldialog.h index b79be800..8d1f6a88 100644 --- a/src/gui/skilldialog.h +++ b/src/gui/skilldialog.h @@ -22,20 +22,19 @@ #ifndef SKILL_H #define SKILL_H -#include <vector> -#include <list> +#include "gui/window.h" +#include "gui/gccontainer.h" + +#include "guichanfwd.h" #include <guichan/listmodel.hpp> #include <guichan/actionlistener.hpp> -#include "window.h" -#include "gccontainer.h" - -#include "../guichanfwd.h" +#include <list> class ProgressBar; class Icon; -class Skill_Tab; +class SkillTab; /** * The skill dialog. @@ -71,7 +70,7 @@ class SkillDialog : public Window, public gcn::ActionListener void draw(gcn::Graphics *g); private: - std::list<Skill_Tab*> mTabs; + std::list<SkillTab*> mTabs; }; extern SkillDialog *skillDialog; diff --git a/src/gui/skin.cpp b/src/gui/skin.cpp index b16bdfe6..0130ad71 100644 --- a/src/gui/skin.cpp +++ b/src/gui/skin.cpp @@ -47,14 +47,16 @@ class SkinConfigListener : public ConfigListener } }; -Skin::Skin(ImageRect skin, Image *close, +Skin::Skin(ImageRect skin, Image *close, Image *stickyUp, Image *stickyDown, const std::string &filePath, const std::string &name): instances(0), mFilePath(filePath), mName(name), border(skin), - closeImage(close) + closeImage(close), + stickyImageUp(stickyUp), + stickyImageDown(stickyDown) { } @@ -219,7 +221,14 @@ Skin *SkinLoader::load(const std::string &filename, // Hard-coded for now until we update the above code to look for window buttons. Image *closeImage = resman->getImage("graphics/gui/close_button.png"); - Skin *skin = new Skin(border, closeImage, filename); + Image *sticky = resman->getImage("graphics/gui/sticky_button.png"); + Image *stickyImageUp = sticky->getSubImage(0, 0, 15, 15); + Image *stickyImageDown = sticky->getSubImage(15, 0, 15, 15); + + sticky->decRef(); + + Skin *skin = new Skin(border, closeImage, stickyImageUp, stickyImageDown, + filename); mSkins[filename] = skin; diff --git a/src/gui/skin.h b/src/gui/skin.h index df905b05..30f7f360 100644 --- a/src/gui/skin.h +++ b/src/gui/skin.h @@ -34,7 +34,7 @@ class Image; class Skin { public: - Skin(ImageRect skin, Image *close, + Skin(ImageRect skin, Image *close, Image *stickyUp, Image *stickyDown, const std::string &filePath, const std::string &name = ""); @@ -63,6 +63,12 @@ class Skin Image *getCloseImage() const { return closeImage; } /** + * Returns the image used by a sticky button for this skin. + */ + Image *getStickyImage(bool state) const + { return state ? stickyImageDown : stickyImageUp; } + + /** * Returns the number of instances which use this skin. */ int getNumberOfInstances() const { return instances; } @@ -89,6 +95,8 @@ class Skin std::string mName; /**< Name of the skin to use */ ImageRect border; /**< The window border and background */ Image *closeImage; /**< Close Button Image */ + Image *stickyImageUp; /**< Sticky Button Image */ + Image *stickyImageDown; /**< Sticky Button Image */ }; // Map containing all window skins diff --git a/src/gui/status.cpp b/src/gui/status.cpp index e298c3e2..e6f57de5 100644 --- a/src/gui/status.cpp +++ b/src/gui/status.cpp @@ -253,9 +253,6 @@ void StatusWindow::update() void StatusWindow::draw(gcn::Graphics *g) { - if (!isVisible()) - return; - update(); Window::draw(g); diff --git a/src/gui/storagewindow.cpp b/src/gui/storagewindow.cpp index 1289a4e7..8c25401d 100644 --- a/src/gui/storagewindow.cpp +++ b/src/gui/storagewindow.cpp @@ -51,9 +51,8 @@ #include "../utils/gettext.h" #include "../utils/strprintf.h" -StorageWindow::StorageWindow(Network *network, int invSize): +StorageWindow::StorageWindow(int invSize): Window(_("Storage")), - mNetwork(network), mMaxSlots(invSize), mItemDesc(false) { @@ -188,24 +187,21 @@ Item* StorageWindow::getSelectedItem() const return mItems->getSelectedItem(); } -void StorageWindow::addStore(Item* item, int ammount) +void StorageWindow::addStore(Item *item, int ammount) { - MessageOut outMsg(mNetwork); - outMsg.writeInt16(CMSG_MOVE_TO_STORAGE); - outMsg.writeInt16(item->getInvIndex()); + MessageOut outMsg(CMSG_MOVE_TO_STORAGE); + outMsg.writeInt16(item->getInvIndex() + INVENTORY_OFFSET); outMsg.writeInt32(ammount); } -void StorageWindow::removeStore(Item* item, int ammount) +void StorageWindow::removeStore(Item *item, int ammount) { - MessageOut outMsg(mNetwork); - outMsg.writeInt16(CSMG_MOVE_FROM_STORAGE); - outMsg.writeInt16(item->getInvIndex()); + MessageOut outMsg(CSMG_MOVE_FROM_STORAGE); + outMsg.writeInt16(item->getInvIndex() + STORAGE_OFFSET); outMsg.writeInt32(ammount); } void StorageWindow::close() { - MessageOut outMsg(mNetwork); - outMsg.writeInt16(CMSG_CLOSE_STORAGE); + MessageOut outMsg(CMSG_CLOSE_STORAGE); } diff --git a/src/gui/storagewindow.h b/src/gui/storagewindow.h index cc0df2af..de0937b5 100644 --- a/src/gui/storagewindow.h +++ b/src/gui/storagewindow.h @@ -31,7 +31,6 @@ class Item; class ItemContainer; -class Network; class ProgressBar; class TextBox; @@ -47,7 +46,7 @@ class StorageWindow : public Window, gcn::ActionListener, /** * Constructor. */ - StorageWindow(Network *network, int invSize = (STORAGE_SIZE - 1)); + StorageWindow(int invSize = (STORAGE_SIZE - 1)); /** * Destructor. @@ -88,7 +87,6 @@ class StorageWindow : public Window, gcn::ActionListener, void close(); private: - Network *mNetwork; ItemContainer *mItems; int mSlots; diff --git a/src/gui/table.cpp b/src/gui/table.cpp index 4dda9246..e98d76e5 100644 --- a/src/gui/table.cpp +++ b/src/gui/table.cpp @@ -265,7 +265,7 @@ void GuiTable::installActionListeners() // -- widget ops void GuiTable::draw(gcn::Graphics* graphics) { - if (!mModel || !isVisible()) + if (!mModel) return; if (config.getValue("guialpha", 0.8) != mAlpha) diff --git a/src/gui/textfield.cpp b/src/gui/textfield.cpp index c94710b3..48a00dcc 100644 --- a/src/gui/textfield.cpp +++ b/src/gui/textfield.cpp @@ -84,9 +84,6 @@ TextField::~TextField() void TextField::draw(gcn::Graphics *graphics) { - if (!isVisible()) - return; - if (isFocused()) { drawCaret(graphics, diff --git a/src/gui/trade.cpp b/src/gui/trade.cpp index 8aa3c3ea..e6df9ad8 100644 --- a/src/gui/trade.cpp +++ b/src/gui/trade.cpp @@ -24,7 +24,7 @@ #include <guichan/font.hpp> #include "button.h" -#include "chat.h" +#include "widgets/chattab.h" #include "inventorywindow.h" #include "item_amount.h" #include "itemcontainer.h" @@ -51,20 +51,12 @@ #include "../utils/stringutils.h" #include "../utils/strprintf.h" -#ifdef TMWSERV_SUPPORT TradeWindow::TradeWindow(): -#else -TradeWindow::TradeWindow(Network *network): -#endif Window(_("Trade: You")), -#ifdef EATHENA_SUPPORT - mNetwork(network), - mMyInventory(new Inventory(INVENTORY_SIZE, 2)), - mPartnerInventory(new Inventory(INVENTORY_SIZE, 2)) -#else mMyInventory(new Inventory(INVENTORY_SIZE)), - mPartnerInventory(new Inventory(INVENTORY_SIZE)), - mStatus(PREPARING) + mPartnerInventory(new Inventory(INVENTORY_SIZE)) +#ifdef TMWSERV_SUPPORT + , mStatus(PREPARING) #endif { setWindowName("Trade"); @@ -252,9 +244,8 @@ void TradeWindow::tradeItem(Item *item, int quantity) // function. Detect the actual server version, and re-enable this // for that version only. //addItem(item->getId(), true, quantity, item->isEquipment()); - MessageOut outMsg(mNetwork); - outMsg.writeInt16(CMSG_TRADE_ITEM_ADD_REQUEST); - outMsg.writeInt16(item->getInvIndex()); + MessageOut outMsg(CMSG_TRADE_ITEM_ADD_REQUEST); + outMsg.writeInt16(item->getInvIndex() + INVENTORY_OFFSET); outMsg.writeInt32(quantity); #endif } @@ -329,8 +320,7 @@ void TradeWindow::action(const gcn::ActionEvent &event) #ifdef TMWSERV_SUPPORT Net::GameServer::Player::acceptTrade(false); #else - MessageOut outMsg(mNetwork); - outMsg.writeInt16(CMSG_TRADE_CANCEL_REQUEST); + MessageOut outMsg(CMSG_TRADE_CANCEL_REQUEST); #endif } #ifdef EATHENA_SUPPORT @@ -342,8 +332,7 @@ void TradeWindow::action(const gcn::ActionEvent &event) { mMoneyField->setText(toString(tempInt)); - MessageOut outMsg(mNetwork); - outMsg.writeInt16(CMSG_TRADE_ITEM_ADD_REQUEST); + MessageOut outMsg(CMSG_TRADE_ITEM_ADD_REQUEST); outMsg.writeInt16(0); outMsg.writeInt32(tempInt); } @@ -352,8 +341,7 @@ void TradeWindow::action(const gcn::ActionEvent &event) mMoneyField->setText(""); } mMoneyField->setEnabled(false); - MessageOut outMsg(mNetwork); - outMsg.writeInt16(CMSG_TRADE_ADD_COMPLETE); + MessageOut outMsg(CMSG_TRADE_ADD_COMPLETE); } #endif else if (event.getId() == "trade") @@ -362,8 +350,7 @@ void TradeWindow::action(const gcn::ActionEvent &event) Net::GameServer::Player::acceptTrade(true); setStatus(PROPOSING); #else - MessageOut outMsg(mNetwork); - outMsg.writeInt16(CMSG_TRADE_OK); + MessageOut outMsg(CMSG_TRADE_OK); #endif } #ifdef TMWSERV_SUPPORT @@ -382,7 +369,6 @@ void TradeWindow::close() #ifdef TMWSERV_SUPPORT Net::GameServer::Player::acceptTrade(false); #else - MessageOut outMsg(mNetwork); - outMsg.writeInt16(CMSG_TRADE_CANCEL_REQUEST); + MessageOut outMsg(CMSG_TRADE_CANCEL_REQUEST); #endif } diff --git a/src/gui/trade.h b/src/gui/trade.h index 4c215ba6..e2767c5b 100644 --- a/src/gui/trade.h +++ b/src/gui/trade.h @@ -34,9 +34,6 @@ class Inventory; class Item; class ItemContainer; -#ifdef EATHENA_SUPPORT -class Network; -#endif class ScrollArea; /** @@ -50,11 +47,7 @@ class TradeWindow : public Window, gcn::ActionListener, gcn::SelectionListener /** * Constructor. */ -#ifdef TMWSERV_SUPPORT TradeWindow(); -#else - TradeWindow(Network *network); -#endif /** * Destructor. @@ -139,10 +132,6 @@ class TradeWindow : public Window, gcn::ActionListener, gcn::SelectionListener void setStatus(Status); #endif -#ifdef EATHENA_SUPPORT - Network *mNetwork; -#endif - typedef const std::auto_ptr<Inventory> InventoryPtr; InventoryPtr mMyInventory; InventoryPtr mPartnerInventory; diff --git a/src/gui/unregisterdialog.cpp b/src/gui/unregisterdialog.cpp index 7906afc1..c133c9f7 100644 --- a/src/gui/unregisterdialog.cpp +++ b/src/gui/unregisterdialog.cpp @@ -42,7 +42,7 @@ UnRegisterDialog::UnRegisterDialog(Window *parent, LoginData *loginData): Window("Unregister", true, parent), - mWrongDataNoticeListener(new WrongDataNoticeListener()), + mWrongDataNoticeListener(new WrongDataNoticeListener), mLoginData(loginData) { gcn::Label *userLabel = new gcn::Label(strprintf(_("Name: %s"), mLoginData->username.c_str())); diff --git a/src/gui/widgets/channeltab.cpp b/src/gui/widgets/channeltab.cpp index c17aec0a..375ead26 100644 --- a/src/gui/widgets/channeltab.cpp +++ b/src/gui/widgets/channeltab.cpp @@ -19,40 +19,18 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include <guichan/widgets/label.hpp> - #include "channeltab.h" -#include "../browserbox.h" -#include "../chatinput.h" -#include "../itemlinkhandler.h" -#include "../recorder.h" -#include "../scrollarea.h" - -#include "../../beingmanager.h" -#include "../../commandhandler.h" -#include "../../channel.h" -#include "../../configuration.h" -#include "../../game.h" -#include "../../localplayer.h" +#include "channel.h" #ifdef TMWSERV_SUPPORT -#include "../../net/tmwserv/chatserver/chatserver.h" -#include "../../net/tmwserv/gameserver/player.h" +#include "net/tmwserv/chatserver/chatserver.h" +#include "net/tmwserv/gameserver/player.h" #else -#include "../../party.h" -#include "../../net/messageout.h" -#include "../../net/ea/protocol.h" +#include "net/messageout.h" +#include "net/ea/protocol.h" #endif -#include "../../resources/iteminfo.h" -#include "../../resources/itemdb.h" - -#include "../../utils/dtor.h" -#include "../../utils/gettext.h" -#include "../../utils/strprintf.h" -#include "../../utils/stringutils.h" - ChannelTab::ChannelTab(Channel *channel) : ChatTab(channel->getName()), mChannel(channel) { @@ -63,7 +41,7 @@ ChannelTab::~ChannelTab() { } -void ChannelTab::sendChat(const std::string &msg) { +void ChannelTab::handleInput(const std::string &msg) { #ifdef TMSERV_SUPPORT Net::ChatServer::chat(getId(), msg); #endif diff --git a/src/gui/widgets/channeltab.h b/src/gui/widgets/channeltab.h index 04a11e29..8c98189b 100644 --- a/src/gui/widgets/channeltab.h +++ b/src/gui/widgets/channeltab.h @@ -48,7 +48,7 @@ class ChannelTab : public ChatTab */ ~ChannelTab(); - void sendChat(const std::string &msg); + void handleInput(const std::string &msg); private: Channel *mChannel; diff --git a/src/gui/widgets/chattab.cpp b/src/gui/widgets/chattab.cpp index 0594761d..c4563cc9 100644 --- a/src/gui/widgets/chattab.cpp +++ b/src/gui/widgets/chattab.cpp @@ -19,40 +19,37 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include <guichan/widgets/label.hpp> - #include "chattab.h" -#include "layouthelper.h" -#include "../browserbox.h" -#include "../chatinput.h" -#include "../itemlinkhandler.h" -#include "../recorder.h" -#include "../scrollarea.h" +#include "commandhandler.h" +#include "configuration.h" +#include "localplayer.h" -#include "../../commandhandler.h" -#include "../../configuration.h" -#include "../../localplayer.h" +#include "gui/browserbox.h" +#include "gui/itemlinkhandler.h" +#include "gui/recorder.h" +#include "gui/scrollarea.h" #ifdef TMWSERV_SUPPORT -#include "../../net/tmwserv/chatserver/chatserver.h" -#include "../../net/tmwserv/gameserver/player.h" +#include "net/tmwserv/chatserver/chatserver.h" +#include "net/tmwserv/gameserver/player.h" #else -#include "../../net/messageout.h" -#include "../../net/ea/protocol.h" +#include "net/messageout.h" +#include "net/ea/protocol.h" #endif -#include "../../resources/iteminfo.h" -#include "../../resources/itemdb.h" +#include "resources/iteminfo.h" +#include "resources/itemdb.h" -#include "../../utils/strprintf.h" -#include "../../utils/stringutils.h" +#include "utils/gettext.h" +#include "utils/strprintf.h" +#include "utils/stringutils.h" ChatTab::ChatTab(const std::string &name) : Tab() { setCaption(name); - mTextOutput = new BrowserBox; + mTextOutput = new BrowserBox(BrowserBox::AUTO_WRAP); mTextOutput->setOpaque(false); mTextOutput->setMaxRow((int) config.getValue("ChatLogLength", 0)); mTextOutput->setLinkHandler(chatWindow->mItemLinkHandler); @@ -160,10 +157,9 @@ void ChatTab::chatLog(std::string line, int own, bool ignoreRecord) break; #endif case ACT_WHISPER: - tmp.nick = strprintf(_("%s whispers:"), tmp.nick.c_str()); - tmp.nick += " "; - lineColor = "##W"; - break; + // Resend whisper through normal mechanism + chatWindow->whisper(tmp.nick, tmp.text); + return; case ACT_IS: tmp.nick += CAT_IS; lineColor = "##I"; @@ -221,10 +217,11 @@ void ChatTab::chatLog(std::string line, int own, bool ignoreRecord) void ChatTab::chatLog(std::string &nick, std::string &msg) { - chatLog(nick + ": " + msg, nick == player_node->getName() ? BY_PLAYER : BY_OTHER, false); + chatLog(nick + CAT_NORMAL + msg, nick == player_node->getName() ? + BY_PLAYER : BY_OTHER, false); } -void ChatTab::chatSend(std::string &msg) +void ChatTab::chatInput(std::string &msg) { trim(msg); @@ -242,9 +239,7 @@ void ChatTab::chatSend(std::string &msg) chatLog(_("Trying to send a blank party message."), BY_SERVER, true); return; } - MessageOut outMsg(chatWindow->mNetwork); - - outMsg.writeInt16(CMSG_PARTY_MESSAGE); + MessageOut outMsg(CMSG_PARTY_MESSAGE); outMsg.writeInt16(length + 4); outMsg.writeString(msg, length); return; @@ -282,16 +277,11 @@ void ChatTab::chatSend(std::string &msg) start = msg.find('[', start + 1); } - // Prepare ordinary message if (msg[0] != '/') - { - sendChat(msg); - } + handleInput(msg); else - { handleCommand(std::string(msg, 1)); - } } void ChatTab::scroll(int amount) @@ -308,22 +298,21 @@ void ChatTab::clearText() mTextOutput->clearRows(); } -void ChatTab::sendChat(std::string &msg) { +void ChatTab::handleInput(const std::string &msg) { #ifdef TMWSERV_SUPPORT Net::GameServer::Player::say(msg); #else - msg = player_node->getName() + " : " + msg; + std::string mes = player_node->getName() + " : " + msg; - MessageOut outMsg(chatWindow->mNetwork); - outMsg.writeInt16(CMSG_CHAT_MESSAGE); + MessageOut outMsg(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); + outMsg.writeInt16(mes.length() + 4 + 1); + outMsg.writeString(mes, mes.length() + 1); return; #endif } -void ChatTab::handleCommand(const std::string msg) +void ChatTab::handleCommand(std::string msg) { - commandHandler->handleCommand(msg); + commandHandler->handleCommand(msg, this); } diff --git a/src/gui/widgets/chattab.h b/src/gui/widgets/chattab.h index 3e64242c..52449f6f 100644 --- a/src/gui/widgets/chattab.h +++ b/src/gui/widgets/chattab.h @@ -22,11 +22,10 @@ #ifndef CHATTAB_H #define CHATTAB_H -#include <guichan/widgets/container.hpp> - -#include "tab.h" +#include "gui/widgets/tab.h" +#include "gui/chat.h" -#include "../chat.h" +#include <guichan/widgets/container.hpp> class BrowserBox; class Recorder; @@ -48,6 +47,13 @@ enum }; /** + * gets in between usernick and message text depending on + * message type + */ +#define CAT_NORMAL ": " +#define CAT_IS "" + +/** * A tab for the chat window. This is special to ease chat handling. */ class ChatTab : public Tab @@ -90,7 +96,7 @@ class ChatTab : public Tab * @param msg The message text which is to be sent. * */ - void chatSend(std::string &msg); + void chatInput(std::string &msg); /** * Scrolls the chat window @@ -105,10 +111,11 @@ class ChatTab : public Tab protected: friend class ChatWindow; + friend class WhisperWindow; - virtual void sendChat(std::string &msg); + virtual void handleInput(const std::string &msg); - virtual void handleCommand(const std::string msg); + virtual void handleCommand(std::string msg); ScrollArea *mScrollArea; BrowserBox *mTextOutput; diff --git a/src/gui/widgets/dropdown.cpp b/src/gui/widgets/dropdown.cpp index d8c66789..68c7e093 100644 --- a/src/gui/widgets/dropdown.cpp +++ b/src/gui/widgets/dropdown.cpp @@ -111,9 +111,6 @@ DropDown::~DropDown() void DropDown::draw(gcn::Graphics* graphics) { - if (!isVisible()) - return; - int h; if (mDroppedDown) diff --git a/src/gui/widgets/whispertab.cpp b/src/gui/widgets/whispertab.cpp index 1c63d1c9..9e6d9336 100644 --- a/src/gui/widgets/whispertab.cpp +++ b/src/gui/widgets/whispertab.cpp @@ -19,38 +19,27 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include <guichan/widgets/label.hpp> - #include "whispertab.h" -#include "../../beingmanager.h" -#include "../../commandhandler.h" -#include "../../channel.h" -#include "../../configuration.h" -#include "../../game.h" -#include "../../localplayer.h" +#include "localplayer.h" + +#include "gui/palette.h" #ifdef TMWSERV_SUPPORT -#include "../../net/tmwserv/chatserver/chatserver.h" -#include "../../net/tmwserv/gameserver/player.h" +#include "net/tmwserv/chatserver/chatserver.h" #else -#include "../../party.h" -#include "../../net/messageout.h" -#include "../../net/ea/protocol.h" +#include "net/messageout.h" +#include "net/ea/protocol.h" #endif -#include "../../resources/iteminfo.h" -#include "../../resources/itemdb.h" - -#include "../../utils/dtor.h" -#include "../../utils/gettext.h" -#include "../../utils/strprintf.h" -#include "../../utils/stringutils.h" +#include "utils/gettext.h" +#include "utils/strprintf.h" WhisperTab::WhisperTab(const std::string &nick) : ChatTab(nick), mNick(nick) { + setForegroundColor(guiPalette->getColor(Palette::WHISPER)); } WhisperTab::~WhisperTab() @@ -58,7 +47,7 @@ WhisperTab::~WhisperTab() chatWindow->removeWhisper(mNick); } -void WhisperTab::sendChat(const std::string &msg) { +void WhisperTab::handleInput(const std::string &msg) { if (msg.length() == 0) { chatLog(_("Cannot send empty chat!"), BY_SERVER, false); return; @@ -67,8 +56,7 @@ void WhisperTab::sendChat(const std::string &msg) { #ifdef TMWSERV_SUPPORT Net::ChatServer::privMsg(mNick, msg); #else - MessageOut outMsg(chatWindow->mNetwork); - outMsg.writeInt16(CMSG_CHAT_WHISPER); + MessageOut outMsg(CMSG_CHAT_WHISPER); outMsg.writeInt16(msg.length() + 28); outMsg.writeString(mNick, 24); outMsg.writeString(msg, msg.length()); @@ -78,7 +66,7 @@ void WhisperTab::sendChat(const std::string &msg) { msg.c_str()), BY_PLAYER, false); } -void WhisperTab::handleCommand(const std::string msg) +void WhisperTab::handleCommand(std::string msg) { if (msg == "close") delete this; diff --git a/src/gui/widgets/whispertab.h b/src/gui/widgets/whispertab.h index 1d2f968d..739ae159 100644 --- a/src/gui/widgets/whispertab.h +++ b/src/gui/widgets/whispertab.h @@ -46,9 +46,9 @@ class WhisperTab : public ChatTab ~WhisperTab(); - void sendChat(const std::string &msg); + void handleInput(const std::string &msg); - void handleCommand(const std::string msg); + void handleCommand(std::string msg); private: std::string mNick; diff --git a/src/gui/window.cpp b/src/gui/window.cpp index 3bc03fb8..1f9dab5b 100644 --- a/src/gui/window.cpp +++ b/src/gui/window.cpp @@ -48,6 +48,7 @@ Window::Window(const std::string &caption, bool modal, Window *parent, const std mShowTitle(true), mModal(modal), mCloseButton(false), + mStickyButton(false), mSticky(false), mMinWinWidth(100), mMinWinHeight(40), @@ -60,7 +61,7 @@ Window::Window(const std::string &caption, bool modal, Window *parent, const std throw GCN_EXCEPTION("Window::Window(): no windowContainer set"); if (instances == 0) - skinLoader = new SkinLoader(); + skinLoader = new SkinLoader; instances++; @@ -118,9 +119,6 @@ void Window::setWindowContainer(WindowContainer *wc) void Window::draw(gcn::Graphics *graphics) { - if (!isVisible()) - return; - Graphics *g = static_cast<Graphics*>(graphics); g->drawImageRect(0, 0, getWidth(), getHeight(), mSkin->getBorder()); @@ -138,8 +136,18 @@ void Window::draw(gcn::Graphics *graphics) { g->drawImage(mSkin->getCloseImage(), getWidth() - mSkin->getCloseImage()->getWidth() - getPadding(), - getPadding() - ); + getPadding()); + } + + // Draw Sticky Button + if (mStickyButton) + { + Image *button = mSkin->getStickyImage(mSticky); + int x = getWidth() - button->getWidth() - getPadding(); + if (mCloseButton) + x -= mSkin->getCloseImage()->getWidth(); + + g->drawImage(button, x, getPadding()); } drawChildren(graphics); @@ -286,6 +294,11 @@ bool Window::isResizable() const return mGrip; } +void Window::setStickyButton(bool flag) +{ + mStickyButton = flag; +} + void Window::setSticky(bool sticky) { mSticky = sticky; @@ -293,7 +306,12 @@ void Window::setSticky(bool sticky) void Window::setVisible(bool visible) { - gcn::Window::setVisible(isSticky() || visible); + setVisible(visible, false); +} + +void Window::setVisible(bool visible, bool forceSticky) +{ + gcn::Window::setVisible((!forceSticky && isSticky()) || visible); } void Window::scheduleDelete() @@ -326,6 +344,22 @@ void Window::mousePressed(gcn::MouseEvent &event) } } + // Handle sticky button + if (mStickyButton) + { + Image *button = mSkin->getStickyImage(mSticky); + int rx = getWidth() - button->getWidth() - getPadding(); + if (mCloseButton) + rx -= mSkin->getCloseImage()->getWidth(); + gcn::Rectangle stickyButtonRect(rx, getPadding(), + button->getWidth(), button->getHeight()); + + if (stickyButtonRect.isPointInRect(x, y)) + { + setSticky(!isSticky()); + } + } + // Handle window resizing mouseResize = getResizeHandles(event); } @@ -470,7 +504,12 @@ void Window::loadWindowState() setPosition((int) config.getValue(name + "WinX", mDefaultX), (int) config.getValue(name + "WinY", mDefaultY)); - setVisible((bool) config.getValue(name + "Visible", false)); + + if (mCloseButton) + setVisible((bool) config.getValue(name + "Visible", false)); + + if (mStickyButton) + setSticky((bool) config.getValue(name + "Sticky", isSticky())); if (skinName.compare(mSkin->getFilePath()) != 0) { @@ -507,7 +546,13 @@ void Window::saveWindowState() { config.setValue(mWindowName + "WinX", getX()); config.setValue(mWindowName + "WinY", getY()); - config.setValue(mWindowName + "Visible", isVisible()); + + if (mCloseButton) + config.setValue(mWindowName + "Visible", isVisible()); + + if (mStickyButton) + config.setValue(mWindowName + "Sticky", isSticky()); + config.setValue(mWindowName + "Skin", mSkin->getFilePath()); if (mGrip) diff --git a/src/gui/window.h b/src/gui/window.h index c41a4221..18a64532 100644 --- a/src/gui/window.h +++ b/src/gui/window.h @@ -145,16 +145,21 @@ class Window : public gcn::Window, gcn::WidgetListener void setShowTitle(bool flag) { mShowTitle = flag; } /** + * Sets whether or not the window has a sticky button. + */ + void setStickyButton(bool flag); + + /** * Sets whether the window is sticky. A sticky window will not have * its visibility set to false on a general setVisible(false) call. + * Use this to set the default before you call loadWindowState(). */ void setSticky(bool sticky); /** * Returns whether the window is sticky. */ - bool isSticky() const - { return mSticky; } + bool isSticky() const { return mSticky; } /** * Overloads window setVisible by Guichan to allow sticky window @@ -163,6 +168,12 @@ class Window : public gcn::Window, gcn::WidgetListener void setVisible(bool visible); /** + * Overloads window setVisible by Guichan to allow sticky window + * handling, or not, if you force the sticky state. + */ + void setVisible(bool visible, bool forceSticky); + + /** * Returns the parent window. * * @return The parent window or <code>NULL</code> if there is none. @@ -325,7 +336,8 @@ class Window : public gcn::Window, gcn::WidgetListener bool mShowTitle; /**< Window has a title bar */ bool mModal; /**< Window is modal */ bool mCloseButton; /**< Window has a close button */ - bool mSticky; /**< Window resists minimization */ + bool mStickyButton; /**< Window has a sticky button */ + bool mSticky; /**< Window resists hiding*/ int mMinWinWidth; /**< Minimum window width */ int mMinWinHeight; /**< Minimum window height */ int mMaxWinWidth; /**< Maximum window width */ |