diff options
author | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2009-02-09 22:30:00 +0100 |
---|---|---|
committer | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2009-02-09 22:31:11 +0100 |
commit | 07f7d52f661a74e6d0c780ca53e724651e3dcc48 (patch) | |
tree | b55b8c0d04a1544ace42f00642adfde4ad045d94 /src/gui | |
parent | 6c29cfa167820635ea602b5cc31dcfeb7b04478c (diff) | |
download | mana-07f7d52f661a74e6d0c780ca53e724651e3dcc48.tar.gz mana-07f7d52f661a74e6d0c780ca53e724651e3dcc48.tar.bz2 mana-07f7d52f661a74e6d0c780ca53e724651e3dcc48.tar.xz mana-07f7d52f661a74e6d0c780ca53e724651e3dcc48.zip |
Mostly whitespace fixes
Removed tab characters and trailing spaces and added spaces between
"if(", "for(", "while(" and "switch(".
Diffstat (limited to 'src/gui')
32 files changed, 274 insertions, 277 deletions
diff --git a/src/gui/browserbox.cpp b/src/gui/browserbox.cpp index 6fd0482a..dbecf72b 100644 --- a/src/gui/browserbox.cpp +++ b/src/gui/browserbox.cpp @@ -101,7 +101,7 @@ void BrowserBox::addRow(const std::string &row) newRow += "##<" + bLink.caption; tmp.erase(0, idx3 + 2); - if(tmp != "") + if (tmp != "") { newRow += "##>"; } diff --git a/src/gui/buttonbox.cpp b/src/gui/buttonbox.cpp index d29f3c58..44d65f58 100644 --- a/src/gui/buttonbox.cpp +++ b/src/gui/buttonbox.cpp @@ -23,13 +23,13 @@ #include "buttonbox.h" ButtonBox::ButtonBox(const std::string &title, const std::string &buttonTxt, - ButtonBoxListener *listener) : - Window(title), - mListener(listener) + ButtonBoxListener *listener) : + Window(title), + mListener(listener) { Button *button = new Button(buttonTxt, "activate", this); setContentSize(button->getWidth() + 10, - button->getHeight() + 10); + button->getHeight() + 10); button->setPosition(5, 5); add(button); } @@ -38,6 +38,6 @@ void ButtonBox::action(const gcn::ActionEvent &event) { if (event.getId() == "activate") { - mListener->buttonBoxRespond(); + mListener->buttonBoxRespond(); } } diff --git a/src/gui/buttonbox.h b/src/gui/buttonbox.h index 6d0e46b6..91dfad34 100644 --- a/src/gui/buttonbox.h +++ b/src/gui/buttonbox.h @@ -33,37 +33,35 @@ class ButtonBoxListener { public: - - /* - * function that ButtonBox calls when the button has been pressed - */ - virtual void buttonBoxRespond() = 0; + /* + * function that ButtonBox calls when the button has been pressed + */ + virtual void buttonBoxRespond() = 0; }; class ButtonBox : public Window, public gcn::ActionListener { public: + /* + * Constructor. + * + * @param title is the text that appears at the top of the box + * @param buttonTxt is the text that appears on the button + * @param listener points to the class that should respond to the + * button press + */ + ButtonBox(const std::string &title, const std::string &buttonTxt, + ButtonBoxListener *listener); - /* - * Constructor - * - * @param title is the text that appears at the top of the box - * @param buttonTxt is the text that appears on the button - * @param listener points to the class that should respond to the - * button press - */ - ButtonBox(const std::string &title, const std::string &buttonTxt, - ButtonBoxListener *listener); - - /* - * called when the button is pressed - * - * @param event is the event that is generated - */ - void action(const gcn::ActionEvent &event); + /* + * called when the button is pressed + * + * @param event is the event that is generated + */ + void action(const gcn::ActionEvent &event); private: - - ButtonBoxListener *mListener; + ButtonBoxListener *mListener; }; + #endif diff --git a/src/gui/char_select.cpp b/src/gui/char_select.cpp index e556dfa0..dcb05aa1 100644 --- a/src/gui/char_select.cpp +++ b/src/gui/char_select.cpp @@ -91,8 +91,8 @@ CharSelectDialog::CharSelectDialog(Network *network, mJobLevelLabel = new gcn::Label(strprintf(_("Job Level: %d"), 0)); mMoneyLabel = new gcn::Label(strprintf(_("Money: %d"), 0)); - const std::string tempString = getFont()->getWidth(_("New")) < - getFont()->getWidth(_("Delete")) ? + const std::string tempString = getFont()->getWidth(_("New")) < + getFont()->getWidth(_("Delete")) ? _("Delete") : _("New"); mPreviousButton = new Button(_("Previous"), "previous", this); @@ -228,7 +228,7 @@ bool CharSelectDialog::selectByName(const std::string &name) unsigned int oldPos = mCharInfo->getPos(); mCharInfo->select(0); - do + do { LocalPlayer *player = mCharInfo->getEntry(); @@ -306,15 +306,15 @@ CharCreateDialog::~CharCreateDialog() void CharCreateDialog::action(const gcn::ActionEvent &event) { int numberOfColors = ColorDB::size(); - if (event.getId() == "create") + if (event.getId() == "create") { - if (getName().length() >= 4) + if (getName().length() >= 4) { // Attempt to create the character mCreateButton->setEnabled(false); attemptCharCreate(); } - else + else { new OkDialog("Error", "Your name needs to be at least 4 characters.", this); @@ -323,18 +323,18 @@ void CharCreateDialog::action(const gcn::ActionEvent &event) else if (event.getId() == "cancel") scheduleDelete(); else if (event.getId() == "nextcolor") - mPlayer->setHairStyle(mPlayer->getHairStyle(), + mPlayer->setHairStyle(mPlayer->getHairStyle(), (mPlayer->getHairColor() + 1) % numberOfColors); else if (event.getId() == "prevcolor") - mPlayer->setHairStyle(mPlayer->getHairStyle(), - (mPlayer->getHairColor() + numberOfColors - 1) % + mPlayer->setHairStyle(mPlayer->getHairStyle(), + (mPlayer->getHairColor() + numberOfColors - 1) % numberOfColors); else if (event.getId() == "nextstyle") - mPlayer->setHairStyle(mPlayer->getHairStyle() + 1, + mPlayer->setHairStyle(mPlayer->getHairStyle() + 1, mPlayer->getHairColor()); else if (event.getId() == "prevstyle") - mPlayer->setHairStyle(mPlayer->getHairStyle() + - mPlayer->getNumOfHairstyles() - 1, + mPlayer->setHairStyle(mPlayer->getHairStyle() + + mPlayer->getNumOfHairstyles() - 1, mPlayer->getHairColor()); } diff --git a/src/gui/chat.cpp b/src/gui/chat.cpp index c9c3e9bc..4fb92ac5 100644 --- a/src/gui/chat.cpp +++ b/src/gui/chat.cpp @@ -75,7 +75,7 @@ Window(""), mNetwork(network), mTmpVisible(false) mTextOutput->setLinkHandler(mItemLinkHandler); mScrollArea = new ScrollArea(mTextOutput); - mScrollArea->setPosition(mScrollArea->getFrameSize(), + mScrollArea->setPosition(mScrollArea->getFrameSize(), mScrollArea->getFrameSize()); mScrollArea->setScrollPolicy(gcn::ScrollArea::SHOW_NEVER, gcn::ScrollArea::SHOW_ALWAYS); @@ -144,7 +144,7 @@ void ChatWindow::chatLog(std::string line, int own, bool ignoreRecord) } std::string lineColor = "##C"; - switch (own) + switch (own) { case BY_GM: if (tmp.nick.empty()) @@ -224,7 +224,7 @@ void ChatWindow::chatLog(std::string line, int own, bool ignoreRecord) // adding a row, otherwise the max will always be a row higher // at comparison. if (mScrollArea->getVerticalScrollAmount() == - mScrollArea->getVerticalMaxScroll()) + mScrollArea->getVerticalMaxScroll()) { mTextOutput->addRow(line); mScrollArea->setVerticalScrollAmount(mScrollArea-> @@ -345,7 +345,7 @@ void ChatWindow::chatSend(const std::string &nick, std::string msg) * those if elses should be replaced by protocol calls */ // Send party message - if (msg.at(0) == mPartyPrefix) + if (msg.at(0) == mPartyPrefix) { msg.erase(0, 1); std::size_t length = msg.length() + 1; @@ -371,7 +371,7 @@ void ChatWindow::chatSend(const std::string &nick, std::string msg) if (end != std::string::npos) { // Catch multiple embeds and ignore them so it doesn't crash the client. - while ((msg.find('[', start + 1) != std::string::npos) && + while ((msg.find('[', start + 1) != std::string::npos) && (msg.find('[', start + 1) < end)) { start = msg.find('[', start + 1); @@ -403,7 +403,7 @@ void ChatWindow::chatSend(const std::string &nick, std::string msg) } // Prepare ordinary message - if (msg.substr(0, 1) != "/") + if (msg.substr(0, 1) != "/") { msg = nick + " : " + msg; @@ -431,14 +431,14 @@ void ChatWindow::chatSend(const std::string &nick, std::string msg) trim(msg); } - if (command == "announce") + if (command == "announce") { MessageOut outMsg(mNetwork); outMsg.writeInt16(0x0099); outMsg.writeInt16(msg.length() + 4); outMsg.writeString(msg, msg.length()); } - else if (command == "help") + else if (command == "help") { msg.erase(0, 6); trim(msg); @@ -492,16 +492,16 @@ void ChatWindow::chatSend(const std::string &nick, std::string msg) msg = msg.substr(0, 1); - if (msg == "1" || - msg == "y" || msg == "Y" || + if (msg == "1" || + msg == "y" || msg == "Y" || msg == "t" || msg == "T") { chatLog(_("Return now toggles chat."), BY_SERVER); mReturnToggles = true; return; } - else if (msg == "0" || - msg == "n" || msg == "N" || + else if (msg == "0" || + msg == "n" || msg == "N" || msg == "f" || msg == "F") { chatLog(_("Message now closes chat."), BY_SERVER); @@ -800,7 +800,7 @@ void ChatWindow::party(const std::string & command, const std::string & rest) void ChatWindow::help(const std::string & msg1, const std::string & msg2) { chatLog(_("-- Help --"), BY_SERVER); - if (msg1 == "") + if (msg1 == "") { chatLog(_("/announce: Global announcement (GM only)"), BY_SERVER); chatLog(_("/clear: Clears this window"), BY_SERVER); @@ -839,25 +839,25 @@ void ChatWindow::help(const std::string & msg1, const std::string & msg2) chatLog(_("Command: /help <command>"), BY_SERVER); chatLog(_("This command displays help on <command>."), BY_SERVER); } - else if (msg1 == "party") + else if (msg1 == "party") { mParty->help(msg2); } - else if (msg1 == "present") + else if (msg1 == "present") { chatLog(_("Command: /present"), BY_SERVER); chatLog(_("This command gets a list of players within hearing and " "sends it to either the record log if recording, or the chat " "log otherwise."), BY_SERVER); } - else if (msg1 == "record") + else if (msg1 == "record") { mRecorder->help(msg2); } - else if (msg1 == "toggle") + else if (msg1 == "toggle") { chatLog(_("Command: /toggle <state>"), BY_SERVER); - chatLog(_("This command sets whether the return key should toggle the" + chatLog(_("This command sets whether the return key should toggle the" "chat log, or whether the chat log turns off automatically."), BY_SERVER); chatLog(_("<state> can be one of \"1\", \"yes\", \"true\" to " diff --git a/src/gui/confirm_dialog.cpp b/src/gui/confirm_dialog.cpp index 569fd93f..ce0a8a68 100644 --- a/src/gui/confirm_dialog.cpp +++ b/src/gui/confirm_dialog.cpp @@ -53,7 +53,7 @@ ConfirmDialog::ConfirmDialog(const std::string &title, const std::string &msg, // 15 == height of each line of text (based on font heights) // 14 == row top + bottom graphic pixel heights setContentSize(mTextBox->getMinWidth() + 15, 15 + (numRows * 15) + noButton->getHeight()); - mTextArea->setDimension(gcn::Rectangle(4, 5, mTextBox->getMinWidth() + 5, + mTextArea->setDimension(gcn::Rectangle(4, 5, mTextBox->getMinWidth() + 5, 3 + (numRows * 14))); } else diff --git a/src/gui/equipmentwindow.cpp b/src/gui/equipmentwindow.cpp index 1fb2b601..40496381 100644 --- a/src/gui/equipmentwindow.cpp +++ b/src/gui/equipmentwindow.cpp @@ -120,7 +120,7 @@ void EquipmentWindow::draw(gcn::Graphics *graphics) graphics->drawText(toString(item->getQuantity()), mEquipBox[i].posX + (BOX_WIDTH / 2), mEquipBox[i].posY - getFont()->getHeight(), - gcn::Graphics::CENTER); + gcn::Graphics::CENTER); } } diff --git a/src/gui/inventorywindow.cpp b/src/gui/inventorywindow.cpp index 58c13910..3b868610 100644 --- a/src/gui/inventorywindow.cpp +++ b/src/gui/inventorywindow.cpp @@ -59,11 +59,11 @@ InventoryWindow::InventoryWindow(int invSize): // If you adjust these defaults, don't forget to adjust the trade window's. setDefaultSize(115, 25, 375, 300); - std::string longestUseString = getFont()->getWidth(_("Equip")) > + std::string longestUseString = getFont()->getWidth(_("Equip")) > getFont()->getWidth(_("Use")) ? _("Equip") : _("Use"); - if (getFont()->getWidth(longestUseString) < + if (getFont()->getWidth(longestUseString) < getFont()->getWidth(_("Unequip"))) { longestUseString = _("Unequip"); @@ -140,7 +140,7 @@ void InventoryWindow::logic() // Adjust progress bars mSlotsBar->setProgress((float) player_node->getInventory()->getNumberOfSlotsUsed() / mMaxSlots); - mWeightBar->setProgress((float) player_node->mTotalWeight / + mWeightBar->setProgress((float) player_node->mTotalWeight / player_node->mMaxWeight); mSlotsBar->setText(strprintf("%s/%d", mUsedSlots.c_str(), mMaxSlots)); diff --git a/src/gui/itemcontainer.h b/src/gui/itemcontainer.h index 1fa76343..1905e820 100644 --- a/src/gui/itemcontainer.h +++ b/src/gui/itemcontainer.h @@ -44,7 +44,7 @@ namespace gcn { * * \ingroup GUI */ -class ItemContainer : public gcn::Widget, +class ItemContainer : public gcn::Widget, public gcn::MouseListener, public gcn::WidgetListener { diff --git a/src/gui/itempopup.cpp b/src/gui/itempopup.cpp index 8235d640..2d3797c9 100644 --- a/src/gui/itempopup.cpp +++ b/src/gui/itempopup.cpp @@ -114,7 +114,7 @@ void ItemPopup::setItem(const ItemInfo &item) mItemName->setCaption(item.getName()); mItemDesc->setTextWrapped(item.getDescription()); mItemEffect->setTextWrapped(item.getEffect()); - mItemWeight->setTextWrapped(_("Weight: ") + toString(item.getWeight()) + + mItemWeight->setTextWrapped(_("Weight: ") + toString(item.getWeight()) + _(" grams")); int numRowsDesc = mItemDesc->getNumberOfRows(); @@ -130,22 +130,22 @@ void ItemPopup::setItem(const ItemInfo &item) mItemWeightScroll->setDimension(gcn::Rectangle(2, 0, 196, numRowsWeight * getFont()->getHeight())); - if(item.getEffect() == "") + if (item.getEffect() == "") { - setContentSize(200, (numRowsDesc * getFont()->getHeight() + + setContentSize(200, (numRowsDesc * getFont()->getHeight() + (3 * getFont()->getHeight()))); - mItemWeightScroll->setPosition(2, + mItemWeightScroll->setPosition(2, (numRowsDesc * getFont()->getHeight()) + (2 * getFont()->getHeight())); } else { - setContentSize(200, (numRowsDesc * getFont()->getHeight()) + + setContentSize(200, (numRowsDesc * getFont()->getHeight()) + (numRowsEffect * getFont()->getHeight()) + (3 * getFont()->getHeight())); - mItemWeightScroll->setPosition(2, + mItemWeightScroll->setPosition(2, (numRowsDesc * getFont()->getHeight()) + (numRowsEffect * getFont()->getHeight()) + (2 * getFont()->getHeight())); @@ -165,9 +165,9 @@ unsigned int ItemPopup::getNumRows() void ItemPopup::view(int x, int y) { if (windowContainer->getWidth() < (x + getWidth() + 5)) - x = windowContainer->getWidth() - getWidth(); + x = windowContainer->getWidth() - getWidth(); if ((y - getHeight() - 5) < 0) - y = 0; + y = 0; else y = y - getHeight() - 5; setPosition(x, y); diff --git a/src/gui/itempopup.h b/src/gui/itempopup.h index b6120af8..d4ad0e20 100644 --- a/src/gui/itempopup.h +++ b/src/gui/itempopup.h @@ -20,8 +20,8 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef ITEMPOPUP_H__ -#define ITEMPOPUP_H__ +#ifndef ITEMPOPUP_H +#define ITEMPOPUP_H #include "scrollarea.h" #include "textbox.h" @@ -48,4 +48,4 @@ class ItemPopup : public Window ScrollArea *mItemWeightScroll; }; -#endif // ITEMPOPUP_H__ +#endif // ITEMPOPUP_H diff --git a/src/gui/login.cpp b/src/gui/login.cpp index 8de2867c..bf1727ac 100644 --- a/src/gui/login.cpp +++ b/src/gui/login.cpp @@ -54,7 +54,7 @@ LoginDialog::LoginDialog(LoginData *loginData): gcn::Label *portLabel = new gcn::Label(_("Port:")); gcn::Label *dropdownLabel = new gcn::Label(_("Recent:")); std::vector<std::string> dfltServer; - dfltServer.push_back("server.themanaworld.org"); + dfltServer.push_back("server.themanaworld.org"); dfltServer.push_back("server.themanaworld.org"); std::vector<std::string> dfltPort; dfltPort.push_back("21001"); diff --git a/src/gui/login.h b/src/gui/login.h index b85e5ae1..b7abbb2a 100644 --- a/src/gui/login.h +++ b/src/gui/login.h @@ -76,29 +76,29 @@ class LoginDialog : public Window, public gcn::ActionListener, */ bool canSubmit(); - /** - * Function to decide whether string is an unsigned short or not - * - * @param str the string to parse - * - * @return true is str is an unsigned short, false otherwise - */ - static bool isUShort(const std::string &str); - - /** - * Converts string to an unsigned short (undefined if invalid) - * - * @param str the string to parse - * - * @return the value str represents - */ - static unsigned short getUShort(const std::string &str); + /** + * Function to decide whether string is an unsigned short or not + * + * @param str the string to parse + * + * @return true is str is an unsigned short, false otherwise + */ + static bool isUShort(const std::string &str); + + /** + * Converts string to an unsigned short (undefined if invalid) + * + * @param str the string to parse + * + * @return the value str represents + */ + static unsigned short getUShort(const std::string &str); DropDown *mServerDropDown; gcn::TextField *mUserField; gcn::TextField *mPassField; gcn::TextField *mServerField; - gcn::TextField *mPortField; + gcn::TextField *mPortField; gcn::CheckBox *mKeepCheck; gcn::Button *mOkButton; gcn::Button *mCancelButton; @@ -114,26 +114,25 @@ class LoginDialog : public Window, public gcn::ActionListener, { private: std::vector<std::string> mServers; - std::vector<std::string> mPorts; + std::vector<std::string> mPorts; std::string mConfigPrefix; int mMaxEntries; void saveEntry(const std::string &server, - const std::string &port, int &saved); + const std::string &port, int &saved); public: DropDownList(std::string prefix, std::vector<std::string> dfltServer, - std::vector<std::string> dfltPort, + std::vector<std::string> dfltPort, int maxEntries); void save(const std::string &server, const std::string &port); int getNumberOfElements(); std::string getElementAt(int i); - std::string getServerAt(int i); - std::string getPortAt(int i); + std::string getServerAt(int i); + std::string getPortAt(int i); }; DropDownList *mServerList; gcn::ListBox *mServerListBox; ScrollArea *mServerScrollArea; - }; #endif diff --git a/src/gui/minimap.cpp b/src/gui/minimap.cpp index 7802b583..cc9173ef 100644 --- a/src/gui/minimap.cpp +++ b/src/gui/minimap.cpp @@ -64,9 +64,9 @@ void Minimap::setMapImage(Image *img) const int offsetX = 2 * getPadding(); const int offsetY = getTitleBarHeight() + getPadding(); const int titleWidth = getFont()->getWidth(getCaption()) + 15; - const int mapWidth = mMapImage->getWidth() < 100 ? + const int mapWidth = mMapImage->getWidth() < 100 ? mMapImage->getWidth() + offsetX : 100; - const int mapHeight = mMapImage->getHeight() < 100 ? + const int mapHeight = mMapImage->getHeight() < 100 ? mMapImage->getHeight() + offsetY : 100; setMinWidth(mapWidth > titleWidth ? mapWidth : titleWidth); diff --git a/src/gui/ministatus.cpp b/src/gui/ministatus.cpp index 915db961..39813883 100644 --- a/src/gui/ministatus.cpp +++ b/src/gui/ministatus.cpp @@ -109,7 +109,7 @@ void MiniStatusWindow::update() // Displays the number of monsters to next lvl // (disabled for now but interesting idea) /* - if(config.getValue("xpBarMonsterCounterExp", 0)!=0) + if (config.getValue("xpBarMonsterCounterExp", 0)!=0) { updatedText << " | " << (int)(((float)player_node->mXpForNextLevel - (float)player_node->mXp) diff --git a/src/gui/ok_dialog.cpp b/src/gui/ok_dialog.cpp index dc66a900..018fa489 100644 --- a/src/gui/ok_dialog.cpp +++ b/src/gui/ok_dialog.cpp @@ -50,7 +50,7 @@ OkDialog::OkDialog(const std::string &title, const std::string &msg, // 15 == height of each line of text (based on font heights) // 14 == row top + bottom graphic pixel heights setContentSize(mTextBox->getMinWidth() + 15, 15 + (numRows * 15) + okButton->getHeight()); - mTextArea->setDimension(gcn::Rectangle(4, 5, mTextBox->getMinWidth() + 5, + mTextArea->setDimension(gcn::Rectangle(4, 5, mTextBox->getMinWidth() + 5, 3 + (numRows * 14))); } else diff --git a/src/gui/passwordfield.h b/src/gui/passwordfield.h index e01bedbd..bc50e267 100644 --- a/src/gui/passwordfield.h +++ b/src/gui/passwordfield.h @@ -31,7 +31,7 @@ * * \ingroup GUI */ -class PasswordField : public TextField +class PasswordField : public TextField { public: /** diff --git a/src/gui/popupmenu.cpp b/src/gui/popupmenu.cpp index 9b0c2370..8cb22c55 100644 --- a/src/gui/popupmenu.cpp +++ b/src/gui/popupmenu.cpp @@ -75,53 +75,53 @@ void PopupMenu::showPopup(int x, int y, Being *being) switch (being->getType()) { - case Being::PLAYER: - { - // Players can be traded with. Later also attack, follow and - // add as buddy will be options in this menu. - const std::string &name = being->getName(); - mBrowserBox->addRow(_("@@trade|Trade With ") + name + "@@"); - mBrowserBox->addRow(_("@@attack|Attack ") + name + "@@"); - - mBrowserBox->addRow("##3---"); - - switch (player_relations.getRelation(name)) { - case PlayerRelation::NEUTRAL: - mBrowserBox->addRow(_("@@friend|Befriend ") + name + "@@"); - - case PlayerRelation::FRIEND: - mBrowserBox->addRow(_("@@disregard|Disregard ") + name + "@@"); - mBrowserBox->addRow(_("@@ignore|Ignore ") + name + "@@"); - break; - - case PlayerRelation::DISREGARDED: - mBrowserBox->addRow(_("@@unignore|Un-Ignore ") + name + "@@"); - mBrowserBox->addRow(_("@@ignore|Completely ignore ") + name + "@@"); - break; - - case PlayerRelation::IGNORED: - mBrowserBox->addRow(_("@@unignore|Un-Ignore ") + name + "@@"); - break; - } - - //mBrowserBox->addRow(_("@@follow|Follow ") + name + "@@"); - //mBrowserBox->addRow(_("@@buddy|Add ") + name + " to Buddy List@@"); - - mBrowserBox->addRow("##3---"); - mBrowserBox->addRow(_("@@party-invite|Invite ") + name + - " to party@@"); - } - break; - - case Being::NPC: - // NPCs can be talked to (single option, candidate for removal - // unless more options would be added) - mBrowserBox->addRow(_("@@talk|Talk To NPC@@")); - break; - - default: - /* Other beings aren't interesting... */ - break; + case Being::PLAYER: + { + // Players can be traded with. Later also attack, follow and + // add as buddy will be options in this menu. + const std::string &name = being->getName(); + mBrowserBox->addRow(_("@@trade|Trade With ") + name + "@@"); + mBrowserBox->addRow(_("@@attack|Attack ") + name + "@@"); + + mBrowserBox->addRow("##3---"); + + switch (player_relations.getRelation(name)) { + case PlayerRelation::NEUTRAL: + mBrowserBox->addRow(_("@@friend|Befriend ") + name + "@@"); + + case PlayerRelation::FRIEND: + mBrowserBox->addRow(_("@@disregard|Disregard ") + name + "@@"); + mBrowserBox->addRow(_("@@ignore|Ignore ") + name + "@@"); + break; + + case PlayerRelation::DISREGARDED: + mBrowserBox->addRow(_("@@unignore|Un-Ignore ") + name + "@@"); + mBrowserBox->addRow(_("@@ignore|Completely ignore ") + name + "@@"); + break; + + case PlayerRelation::IGNORED: + mBrowserBox->addRow(_("@@unignore|Un-Ignore ") + name + "@@"); + break; + } + + //mBrowserBox->addRow(_("@@follow|Follow ") + name + "@@"); + //mBrowserBox->addRow(_("@@buddy|Add ") + name + " to Buddy List@@"); + + mBrowserBox->addRow("##3---"); + mBrowserBox->addRow(_("@@party-invite|Invite ") + name + + " to party@@"); + } + break; + + case Being::NPC: + // NPCs can be talked to (single option, candidate for removal + // unless more options would be added) + mBrowserBox->addRow(_("@@talk|Talk To NPC@@")); + break; + + default: + /* Other beings aren't interesting... */ + break; } //browserBox->addRow("@@look|Look To@@"); @@ -153,28 +153,28 @@ void PopupMenu::handleLink(const std::string& link) // Talk To action if (link == "talk" && - being != NULL && - being->getType() == Being::NPC && - current_npc == 0) + being != NULL && + being->getType() == Being::NPC && + current_npc == 0) { - dynamic_cast<NPC*>(being)->talk(); + dynamic_cast<NPC*>(being)->talk(); } // Trade action else if (link == "trade" && - being != NULL && - being->getType() == Being::PLAYER) + being != NULL && + being->getType() == Being::PLAYER) { - player_node->trade(being); - tradePartnerName = being->getName(); + player_node->trade(being); + tradePartnerName = being->getName(); } // Attack action else if (link == "attack" && - being != NULL && - being->getType() == Being::PLAYER) + being != NULL && + being->getType() == Being::PLAYER) { - player_node->attack(being, true); + player_node->attack(being, true); } else if (link == "unignore" && @@ -199,10 +199,10 @@ void PopupMenu::handleLink(const std::string& link) } else if (link == "friend" && - being != NULL && - being->getType() == Being::PLAYER) + being != NULL && + being->getType() == Being::PLAYER) { - player_relations.setRelation(being->getName(), PlayerRelation::FRIEND); + player_relations.setRelation(being->getName(), PlayerRelation::FRIEND); } /* @@ -215,16 +215,16 @@ void PopupMenu::handleLink(const std::string& link) // Add Buddy action else if ((link == "buddy") && being != NULL && being->isPlayer()) { - if (!buddyWindow->isVisible()) - buddyWindow->setVisible(true); + if (!buddyWindow->isVisible()) + buddyWindow->setVisible(true); - buddyWindow->addBuddy(being->getName()); + buddyWindow->addBuddy(being->getName()); }*/ // Pick Up Floor Item action else if ((link == "pickup") && mFloorItem != NULL) { - player_node->pickUp(mFloorItem); + player_node->pickUp(mFloorItem); } // Look To action @@ -234,46 +234,46 @@ void PopupMenu::handleLink(const std::string& link) else if (link == "use") { - assert(mItem); - if (mItem->isEquipment()) - { - if (mItem->isEquipped()) - { - player_node->unequipItem(mItem); - } - else - { - player_node->equipItem(mItem); - } - } - else - { - player_node->useItem(mItem); - } + assert(mItem); + if (mItem->isEquipment()) + { + if (mItem->isEquipped()) + { + player_node->unequipItem(mItem); + } + else + { + player_node->equipItem(mItem); + } + } + else + { + player_node->useItem(mItem); + } } else if (link == "chat") { - chatWindow->addItemText(mItem->getId(), mItem->getInfo().getName()); + chatWindow->addItemText(mItem->getId(), mItem->getInfo().getName()); } else if (link == "drop") { - new ItemAmountWindow(AMOUNT_ITEM_DROP, inventoryWindow, mItem); + new ItemAmountWindow(AMOUNT_ITEM_DROP, inventoryWindow, mItem); } else if (link == "party-invite" && - being != NULL && - being->getType() == Being::PLAYER) + being != NULL && + being->getType() == Being::PLAYER) { - MessageOut outMsg(player_node->getNetwork()); - outMsg.writeInt16(CMSG_PARTY_INVITE); - outMsg.writeInt32(being->getId()); + MessageOut outMsg(player_node->getNetwork()); + outMsg.writeInt16(CMSG_PARTY_INVITE); + outMsg.writeInt32(being->getId()); } // Unknown actions else { - std::cout << link << std::endl; + std::cout << link << std::endl; } setVisible(false); @@ -311,9 +311,9 @@ void PopupMenu::showPopup(int x, int y) { setContentSize(mBrowserBox->getWidth() + 8, mBrowserBox->getHeight() + 8); if (windowContainer->getWidth() < (x + getWidth() + 5)) - x = windowContainer->getWidth() - getWidth(); + x = windowContainer->getWidth() - getWidth(); if (windowContainer->getHeight() < (y + getHeight() + 5)) - y = windowContainer->getHeight() - getHeight(); + y = windowContainer->getHeight() - getHeight(); setPosition(x, y); setVisible(true); requestMoveToTop(); diff --git a/src/gui/register.cpp b/src/gui/register.cpp index 9c337d9e..bf45b711 100644 --- a/src/gui/register.cpp +++ b/src/gui/register.cpp @@ -255,21 +255,21 @@ bool RegisterDialog::isUShort(const std::string &str) { if (str == "") { - return false; + return false; } unsigned long l = 0; for (std::string::const_iterator strPtr = str.begin(), strEnd = str.end(); - strPtr != strEnd; ++strPtr) + strPtr != strEnd; ++strPtr) { - if (*strPtr < '0' || *strPtr > '9') + if (*strPtr < '0' || *strPtr > '9') { - return false; - } - l = l * 10 + (*strPtr - '0'); // *strPtr - '0' will never be negative - if (l > 65535) - { - return false; - } + return false; + } + l = l * 10 + (*strPtr - '0'); // *strPtr - '0' will never be negative + if (l > 65535) + { + return false; + } } return true; } @@ -278,9 +278,9 @@ unsigned short RegisterDialog::getUShort(const std::string &str) { unsigned long l = 0; for (std::string::const_iterator strPtr = str.begin(), strEnd = str.end(); - strPtr != strEnd; ++strPtr) + strPtr != strEnd; ++strPtr) { - l = l * 10 + (*strPtr - '0'); + l = l * 10 + (*strPtr - '0'); } return static_cast<unsigned short>(l); } diff --git a/src/gui/register.h b/src/gui/register.h index 4b95a07b..8ba377fa 100644 --- a/src/gui/register.h +++ b/src/gui/register.h @@ -74,29 +74,29 @@ class RegisterDialog : public Window, public gcn::ActionListener, */ bool canSubmit() const; - /** - * Function to decide whether string is an unsigned short or not - * - * @param str the string to parse - * - * @return true if str is an unsigned short, false otherwise - */ - static bool isUShort(const std::string &str); - - /** - * Converts string to an unsigned short (undefined if invalid) - * - * @param str the string to parse - * - * @return the value str represents - */ - static unsigned short getUShort(const std::string &str); + /** + * Function to decide whether string is an unsigned short or not + * + * @param str the string to parse + * + * @return true if str is an unsigned short, false otherwise + */ + static bool isUShort(const std::string &str); + + /** + * Converts string to an unsigned short (undefined if invalid) + * + * @param str the string to parse + * + * @return the value str represents + */ + static unsigned short getUShort(const std::string &str); gcn::TextField *mUserField; gcn::TextField *mPasswordField; gcn::TextField *mConfirmField; gcn::TextField *mServerField; - gcn::TextField *mPortField; + gcn::TextField *mPortField; gcn::Button *mRegisterButton; gcn::Button *mCancelButton; diff --git a/src/gui/scrollarea.cpp b/src/gui/scrollarea.cpp index 1d7f8472..3ee27064 100644 --- a/src/gui/scrollarea.cpp +++ b/src/gui/scrollarea.cpp @@ -108,9 +108,9 @@ void ScrollArea::init() int vsgridy[4] = {0, 4, 15, 19}; a = 0; - for (y = 0; y < 3; y++) + for (y = 0; y < 3; y++) { - for (x = 0; x < 3; x++) + for (x = 0; x < 3; x++) { vMarker.grid[a] = vscroll->getSubImage( vsgridx[x], vsgridy[y], @@ -202,7 +202,7 @@ void ScrollArea::drawFrame(gcn::Graphics *graphics) int w = getWidth() + bs * 2; int h = getHeight() + bs * 2; - if (mOpaque) + if (mOpaque) { static_cast<Graphics*>(graphics)-> drawImageRect(0, 0, w, h, background); @@ -213,11 +213,11 @@ void ScrollArea::setOpaque(bool opaque) { mOpaque = opaque; - if (mOpaque) + if (mOpaque) { setFrameSize(2); } - else + else { setFrameSize(0); } @@ -228,7 +228,7 @@ void ScrollArea::drawButton(gcn::Graphics *graphics, BUTTON_DIR dir) int state = 0; gcn::Rectangle dim; - switch(dir) + switch (dir) { case UP: state = mUpButtonPressed ? 1 : 0; diff --git a/src/gui/sdlinput.cpp b/src/gui/sdlinput.cpp index f68dc9c8..51442798 100644 --- a/src/gui/sdlinput.cpp +++ b/src/gui/sdlinput.cpp @@ -228,7 +228,7 @@ int SDLInput::convertMouseButton(int button) int SDLInput::convertKeyCharacter(SDL_Event event) { SDL_keysym keysym = event.key.keysym; - + int value = keysym.unicode; switch (keysym.sym) diff --git a/src/gui/shortcutcontainer.cpp b/src/gui/shortcutcontainer.cpp index d03bc809..e7675c7d 100644 --- a/src/gui/shortcutcontainer.cpp +++ b/src/gui/shortcutcontainer.cpp @@ -43,7 +43,7 @@ ShortcutContainer::ShortcutContainer(): void ShortcutContainer::widgetResized(const gcn::Event &event) { mGridWidth = getWidth() / mBoxWidth; - if (mGridWidth < 1) + if (mGridWidth < 1) { mGridWidth = 1; } @@ -52,7 +52,7 @@ void ShortcutContainer::widgetResized(const gcn::Event &event) (mMaxItems % mGridWidth > 0 ? 1 : 0)) * mBoxHeight); mGridHeight = getHeight() / mBoxHeight; - if (mGridHeight < 1) + if (mGridHeight < 1) { mGridHeight = 1; } @@ -62,7 +62,7 @@ int ShortcutContainer::getIndexFromGrid(int pointX, int pointY) const { const gcn::Rectangle tRect = gcn::Rectangle( 0, 0, mGridWidth * mBoxWidth, mGridHeight * mBoxHeight); - if (!tRect.isPointInRect(pointX, pointY)) + if (!tRect.isPointInRect(pointX, pointY)) { return -1; } diff --git a/src/gui/shortcutwindow.cpp b/src/gui/shortcutwindow.cpp index 3a7cf0e0..799fc35b 100644 --- a/src/gui/shortcutwindow.cpp +++ b/src/gui/shortcutwindow.cpp @@ -46,9 +46,9 @@ ShortcutWindow::ShortcutWindow(const char *title, ShortcutContainer *content) const int width = (int) config.getValue("screenwidth", 800); const int height = (int) config.getValue("screenheight", 600); - setDefaultSize(width - mItems->getBoxWidth() - border, - height - (mItems->getBoxHeight() * mItems->getMaxItems()) - - border, mItems->getBoxWidth() + border, + setDefaultSize(width - mItems->getBoxWidth() - border, + height - (mItems->getBoxHeight() * mItems->getMaxItems()) - + border, mItems->getBoxWidth() + border, (mItems->getBoxHeight() * mItems->getMaxItems()) + border); mScrollArea = new ScrollArea(mItems); diff --git a/src/gui/speechbubble.cpp b/src/gui/speechbubble.cpp index aad5e16e..84eeb7d4 100644 --- a/src/gui/speechbubble.cpp +++ b/src/gui/speechbubble.cpp @@ -90,7 +90,7 @@ void SpeechBubble::setText(std::string mText) setContentSize(mSpeechBox->getMinWidth() + fontHeight, (numRows * fontHeight) + 6); mSpeechArea->setDimension(gcn::Rectangle(4, fontHeight + 3, - mSpeechBox->getMinWidth() + 5, + mSpeechBox->getMinWidth() + 5, (numRows * fontHeight))); } else @@ -99,7 +99,7 @@ void SpeechBubble::setText(std::string mText) if (width < getFont()->getWidth(mText)) width = getFont()->getWidth(mText); setContentSize(width + fontHeight, (fontHeight * 2) + 6); - mSpeechArea->setDimension(gcn::Rectangle(4, fontHeight + 3, + mSpeechArea->setDimension(gcn::Rectangle(4, fontHeight + 3, width, fontHeight)); } } diff --git a/src/gui/speechbubble.h b/src/gui/speechbubble.h index cd83a864..9606f8f7 100644 --- a/src/gui/speechbubble.h +++ b/src/gui/speechbubble.h @@ -19,8 +19,8 @@ * 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" @@ -29,19 +29,18 @@ class SpeechBubble : public Window { public: - - SpeechBubble(); + SpeechBubble(); void setCaption(const std::string &name, const gcn::Color &color = 0x000000); - void setText(std::string mText); - void setLocation(int x, int y); - unsigned int getNumRows(); + void setText(std::string mText); + void setLocation(int x, int y); + unsigned int getNumRows(); private: gcn::Label *mCaption; - TextBox *mSpeechBox; - ScrollArea *mSpeechArea; + TextBox *mSpeechBox; + ScrollArea *mSpeechArea; }; #endif diff --git a/src/gui/status.cpp b/src/gui/status.cpp index 69f6baa1..526fa6b1 100644 --- a/src/gui/status.cpp +++ b/src/gui/status.cpp @@ -200,7 +200,7 @@ StatusWindow::StatusWindow(LocalPlayer *player): add(mStatsTitleLabel); add(mStatsTotalLabel); add(mStatsCostLabel); - for(int i = 0; i < 6; i++) + for (int i = 0; i < 6; i++) { add(mStatsLabel[i]); add(mStatsDisplayLabel[i]); diff --git a/src/gui/table_model.cpp b/src/gui/table_model.cpp index e69ee808..33dd8cb2 100644 --- a/src/gui/table_model.cpp +++ b/src/gui/table_model.cpp @@ -54,7 +54,7 @@ void TableModel::signalAfterUpdate() #define WIDGET_AT(row, column) (((row) * mColumns) + (column)) #define DYN_SIZE(h) ((h) >= 0) // determines whether this size is tagged for auto-detection -StaticTableModel::StaticTableModel(int row, int column, +StaticTableModel::StaticTableModel(int row, int column, gcn::Color backgroundColor, bool opacity) : mRows(row), mColumns(column), diff --git a/src/gui/trade.cpp b/src/gui/trade.cpp index c89e55a2..b20b7c86 100644 --- a/src/gui/trade.cpp +++ b/src/gui/trade.cpp @@ -127,7 +127,7 @@ void TradeWindow::addMoney(int amount) void TradeWindow::addItem(int id, bool own, int quantity, bool equipment) { - if (own) + if (own) { mMyItemContainer->setWidth(mMyScroll->getWidth()); mMyInventory->addItem(id, quantity, equipment); @@ -141,7 +141,7 @@ void TradeWindow::addItem(int id, bool own, int quantity, bool equipment) void TradeWindow::removeItem(int id, bool own) { - if (own) + if (own) mMyInventory->removeItem(id); else mPartnerInventory->removeItem(id); diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp index 326a7189..fe058c0a 100644 --- a/src/gui/viewport.cpp +++ b/src/gui/viewport.cpp @@ -176,7 +176,7 @@ void Viewport::draw(gcn::Graphics *gcnGraphics) // Find a path from the player to the mouse, and draw it. This is for debug // purposes. - if (mShowDebugPath) + if (mShowDebugPath) { // Get the current mouse position int mouseX, mouseY; @@ -275,7 +275,8 @@ void Viewport::mousePressed(gcn::MouseEvent &event) mPopupMenu->showPopup(event.getX(), event.getY(), being); return; } - else if((floorItem = floorItemManager->findByCoordinates(tilex, tiley))) + else if ((floorItem = floorItemManager->findByCoordinates(tilex, + tiley))) { mPopupMenu->showPopup(event.getX(), event.getY(), floorItem); return; @@ -294,7 +295,7 @@ void Viewport::mousePressed(gcn::MouseEvent &event) { Being *being; FloorItem *item; - + // Interact with some being // if ((being = beingManager->findBeing(tilex, tiley))) if ((being = beingManager->findBeingByPixel(x, y))) @@ -342,7 +343,7 @@ void Viewport::mousePressed(gcn::MouseEvent &event) { // Find the being nearest to the clicked position Being *target = beingManager->findBeingByPixel(x, y); - + if (target) { player_node->setTarget(target); diff --git a/src/gui/window.cpp b/src/gui/window.cpp index e0e88b31..e97e9416 100644 --- a/src/gui/window.cpp +++ b/src/gui/window.cpp @@ -82,7 +82,7 @@ Window::Window(const std::string& caption, bool modal, Window *parent, const std { logger->log("Window::Window(\"%s\")", caption.c_str()); - if (!windowContainer) + if (!windowContainer) { throw GCN_EXCEPTION("Window::Window(): no windowContainer set"); } @@ -133,7 +133,7 @@ Window::~Window() config.setValue(name + "WinY", getY()); config.setValue(name + "Visible", isVisible()); - if (mGrip) + if (mGrip) { config.setValue(name + "WinWidth", getWidth()); config.setValue(name + "WinHeight", getHeight()); @@ -152,7 +152,7 @@ Window::~Window() instances--; // Clean up static resources - for( int i = 0; i < 9; i++ ) + for (int i = 0; i < 9; i++) { delete border.grid[i]; border.grid[i] = NULL; @@ -523,7 +523,7 @@ int Window::getResizeHandles(gcn::MouseEvent &event) void Window::setGuiAlpha() { //logger->log("Window::setGuiAlpha: Alpha Value %f", config.getValue("guialpha", 0.8)); - for(int i = 0; i < 9; i++) + for (int i = 0; i < 9; i++) { //logger->log("Window::setGuiAlpha: Border Image (%i)", i); border.grid[i]->setAlpha(config.getValue("guialpha", 0.8)); @@ -532,7 +532,7 @@ void Window::setGuiAlpha() mAlphaChanged = false; } -void Window::loadSkin(const std::string filename) +void Window::loadSkin(const std::string &filename) { const std::string windowId = Window::getId(); @@ -542,7 +542,7 @@ void Window::loadSkin(const std::string filename) logger->log("Loading Window ID '%s'.", windowId.c_str()); - if(filename == "") + if (filename.empty()) logger->error("Window::loadSkin(): Invalid File Name."); // TODO: @@ -560,7 +560,7 @@ void Window::loadSkin(const std::string filename) std::string skinSetImage; skinSetImage = XML::getProperty(rootNode, "image", ""); Image *dBorders = NULL; - if(skinSetImage != "") + if (!skinSetImage.empty()) { logger->log("Window::loadSkin(): <skinset> defines '%s' as a skin image.", skinSetImage.c_str()); dBorders = resman->getImage("graphics/gui/" + skinSetImage);//"graphics/gui/speech_bubble.png"); @@ -594,7 +594,7 @@ void Window::loadSkin(const std::string filename) std::string partType; partType = XML::getProperty(partNode, "type", "unknown"); // TOP ROW - if(partType == "top-left-corner") + if (partType == "top-left-corner") { const int xPos = XML::getProperty(partNode, "xpos", 0); const int yPos = XML::getProperty(partNode, "ypos", 0); @@ -603,7 +603,7 @@ void Window::loadSkin(const std::string filename) border.grid[0] = dBorders->getSubImage(xPos, yPos, width, height); } - else if(partType == "top-edge") + else if (partType == "top-edge") { const int xPos = XML::getProperty(partNode, "xpos", 0); const int yPos = XML::getProperty(partNode, "ypos", 0); @@ -612,7 +612,7 @@ void Window::loadSkin(const std::string filename) border.grid[1] = dBorders->getSubImage(xPos, yPos, width, height); } - else if(partType == "top-right-corner") + else if (partType == "top-right-corner") { const int xPos = XML::getProperty(partNode, "xpos", 0); const int yPos = XML::getProperty(partNode, "ypos", 0); @@ -623,7 +623,7 @@ void Window::loadSkin(const std::string filename) } // MIDDLE ROW - else if(partType == "left-edge") + else if (partType == "left-edge") { const int xPos = XML::getProperty(partNode, "xpos", 0); const int yPos = XML::getProperty(partNode, "ypos", 0); @@ -632,7 +632,7 @@ void Window::loadSkin(const std::string filename) border.grid[3] = dBorders->getSubImage(xPos, yPos, width, height); } - else if(partType == "bg-quad") + else if (partType == "bg-quad") { const int xPos = XML::getProperty(partNode, "xpos", 0); const int yPos = XML::getProperty(partNode, "ypos", 0); @@ -641,7 +641,7 @@ void Window::loadSkin(const std::string filename) border.grid[4] = dBorders->getSubImage(xPos, yPos, width, height); } - else if(partType == "right-edge") + else if (partType == "right-edge") { const int xPos = XML::getProperty(partNode, "xpos", 0); const int yPos = XML::getProperty(partNode, "ypos", 0); @@ -652,7 +652,7 @@ void Window::loadSkin(const std::string filename) } // BOTTOM ROW - else if(partType == "bottom-left-corner") + else if (partType == "bottom-left-corner") { const int xPos = XML::getProperty(partNode, "xpos", 0); const int yPos = XML::getProperty(partNode, "ypos", 0); @@ -661,7 +661,7 @@ void Window::loadSkin(const std::string filename) border.grid[6] = dBorders->getSubImage(xPos, yPos, width, height); } - else if(partType == "bottom-edge") + else if (partType == "bottom-edge") { const int xPos = XML::getProperty(partNode, "xpos", 0); const int yPos = XML::getProperty(partNode, "ypos", 0); @@ -670,7 +670,7 @@ void Window::loadSkin(const std::string filename) border.grid[7] = dBorders->getSubImage(xPos, yPos, width, height); } - else if(partType == "bottom-right-corner") + else if (partType == "bottom-right-corner") { const int xPos = XML::getProperty(partNode, "xpos", 0); const int yPos = XML::getProperty(partNode, "ypos", 0); diff --git a/src/gui/window.h b/src/gui/window.h index deaf984c..518de6e9 100644 --- a/src/gui/window.h +++ b/src/gui/window.h @@ -263,7 +263,7 @@ class Window : public gcn::Window, gcn::WidgetListener /** * Loads a window skin */ - void loadSkin(const std::string filename); + void loadSkin(const std::string &filename); /** * Adds a widget to the window and sets it at given cell. |