diff options
author | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2008-12-17 20:10:51 +0100 |
---|---|---|
committer | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2008-12-17 20:10:51 +0100 |
commit | 1b3cb122be1a418ce82b66fb9ce1ecf3aa5813fb (patch) | |
tree | 02556c7271844901a023b84b0fa84982ccff9bff /src/gui | |
parent | 3dba40474d5b1525e8723139ae7be7576967feea (diff) | |
download | mana-1b3cb122be1a418ce82b66fb9ce1ecf3aa5813fb.tar.gz mana-1b3cb122be1a418ce82b66fb9ce1ecf3aa5813fb.tar.bz2 mana-1b3cb122be1a418ce82b66fb9ce1ecf3aa5813fb.tar.xz mana-1b3cb122be1a418ce82b66fb9ce1ecf3aa5813fb.zip |
Code reformatting
Mainly making sure 'const std::string &' is used everywhere instead of
'std::string const &'. The former has always been the preferred order in
this project.
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/chat.cpp | 49 | ||||
-rw-r--r-- | src/gui/chat.h | 31 | ||||
-rw-r--r-- | src/gui/npclistdialog.cpp | 2 | ||||
-rw-r--r-- | src/gui/npclistdialog.h | 2 | ||||
-rw-r--r-- | src/gui/widgets/avatar.cpp | 16 | ||||
-rw-r--r-- | src/gui/widgets/avatar.h | 8 | ||||
-rw-r--r-- | src/gui/window.cpp | 7 | ||||
-rw-r--r-- | src/gui/window.h | 2 |
8 files changed, 45 insertions, 72 deletions
diff --git a/src/gui/chat.cpp b/src/gui/chat.cpp index c9663192..5bd661d6 100644 --- a/src/gui/chat.cpp +++ b/src/gui/chat.cpp @@ -97,7 +97,7 @@ ChatWindow::~ChatWindow() delete mChatTabs; } -const std::string& ChatWindow::getFocused() const +const std::string &ChatWindow::getFocused() const { return mChatTabs->getSelectedTab()->getCaption(); } @@ -151,8 +151,7 @@ void ChatWindow::logic() } } -void -ChatWindow::chatLog(std::string line, int own, std::string channelName) +void ChatWindow::chatLog(std::string line, int own, std::string channelName) { if(channelName.empty()) channelName = getFocused(); @@ -240,8 +239,7 @@ ChatWindow::chatLog(std::string line, int own, std::string channelName) scroll->logic(); } -void -ChatWindow::action(const gcn::ActionEvent &event) +void ChatWindow::action(const gcn::ActionEvent &event) { if (event.getId() == "chatinput") { @@ -274,8 +272,7 @@ ChatWindow::action(const gcn::ActionEvent &event) } } -void -ChatWindow::requestChatFocus() +void ChatWindow::requestChatFocus() { // Make sure chatWindow is visible if (!isVisible()) @@ -295,13 +292,12 @@ ChatWindow::requestChatFocus() mChatInput->requestFocus(); } -bool -ChatWindow::isInputFocused() +bool ChatWindow::isInputFocused() { return mChatInput->isFocused(); } -void ChatWindow::chatSend(std::string const &msg) +void ChatWindow::chatSend(const std::string &msg) { if (msg.empty()) return; @@ -327,20 +323,17 @@ void ChatWindow::chatSend(std::string const &msg) } } -void -ChatWindow::removeChannel(short channelId) +void ChatWindow::removeChannel(short channelId) { removeChannel(channelManager->findById(channelId)); } -void -ChatWindow::removeChannel(const std::string &channelName) +void ChatWindow::removeChannel(const std::string &channelName) { removeChannel(channelManager->findByName(channelName)); } -void -ChatWindow::removeChannel(Channel *channel) +void ChatWindow::removeChannel(Channel *channel) { if (channel) { @@ -356,8 +349,7 @@ ChatWindow::removeChannel(Channel *channel) } } -void -ChatWindow::createNewChannelTab(const std::string &channelName) +void ChatWindow::createNewChannelTab(const std::string &channelName) { // Create new channel BrowserBox *textOutput = new BrowserBox(BrowserBox::AUTO_WRAP); @@ -384,8 +376,9 @@ ChatWindow::createNewChannelTab(const std::string &channelName) logic(); } -void -ChatWindow::sendToChannel(short channelId, const std::string &user, const std::string &msg) +void ChatWindow::sendToChannel(short channelId, + const std::string &user, + const std::string &msg) { Channel *channel = channelManager->findById(channelId); if (channel) @@ -395,8 +388,7 @@ ChatWindow::sendToChannel(short channelId, const std::string &user, const std::s } } -void -ChatWindow::keyPressed(gcn::KeyEvent &event) +void ChatWindow::keyPressed(gcn::KeyEvent &event) { if (event.getKey().getValue() == Key::DOWN && mCurHist != mHistory.end()) @@ -421,15 +413,13 @@ ChatWindow::keyPressed(gcn::KeyEvent &event) } } -void -ChatWindow::setInputText(std::string input_str) +void ChatWindow::setInputText(std::string input_str) { mChatInput->setText(input_str + " "); requestChatFocus(); } -void -ChatWindow::setVisible(bool isVisible) +void ChatWindow::setVisible(bool isVisible) { Window::setVisible(isVisible); @@ -440,11 +430,8 @@ ChatWindow::setVisible(bool isVisible) mTmpVisible = false; } -bool -ChatWindow::tabExists(const std::string &tabName) +bool ChatWindow::tabExists(const std::string &tabName) { Tab *tab = mChatTabs->getTab(tabName); - if (tab) - return true; - return false; + return tab != 0; } diff --git a/src/gui/chat.h b/src/gui/chat.h index a41b11fb..8ca0e4c9 100644 --- a/src/gui/chat.h +++ b/src/gui/chat.h @@ -118,41 +118,34 @@ class ChatWindow : public Window, * @param msg The message text which is to be sent. * */ - void chatSend(std::string const &msg); + void chatSend(const std::string &msg); /** Called to remove the channel from the channel manager */ - void - removeChannel(short channelId); + void removeChannel(short channelId); - void - removeChannel(const std::string &channelName); + void removeChannel(const std::string &channelName); - void - removeChannel(Channel *channel); + void removeChannel(Channel *channel); /** Called to create a new channel tab */ - void - createNewChannelTab(const std::string &channelName); + void createNewChannelTab(const std::string &channelName); /** Called to output text to a specific channel */ - void - sendToChannel(short channel, const std::string &user, const std::string &msg); + void sendToChannel(short channel, + const std::string &user, + const std::string &msg); /** Called when key is pressed */ - void - keyPressed(gcn::KeyEvent &event); + void keyPressed(gcn::KeyEvent &event); /** Called to set current text */ - void - setInputText(std::string input_str); + void setInputText(std::string input_str); /** Override to reset mTmpVisible */ - void - setVisible(bool visible); + void setVisible(bool visible); /** Check if tab with that name already exists */ - bool - tabExists(const std::string &tabName); + bool tabExists(const std::string &tabName); void logic(); diff --git a/src/gui/npclistdialog.cpp b/src/gui/npclistdialog.cpp index 57783d96..c55255ea 100644 --- a/src/gui/npclistdialog.cpp +++ b/src/gui/npclistdialog.cpp @@ -76,7 +76,7 @@ std::string NpcListDialog::getElementAt(int i) return mItems[i]; } -void NpcListDialog::addItem(std::string const &item) +void NpcListDialog::addItem(const std::string &item) { mItems.push_back(item); } diff --git a/src/gui/npclistdialog.h b/src/gui/npclistdialog.h index 9d970ac2..65281f58 100644 --- a/src/gui/npclistdialog.h +++ b/src/gui/npclistdialog.h @@ -73,7 +73,7 @@ class NpcListDialog : public Window, public gcn::ActionListener, /** * Adds an item to the option list. */ - void addItem(std::string const &); + void addItem(const std::string &); /** * Resets the list by removing all items. diff --git a/src/gui/widgets/avatar.cpp b/src/gui/widgets/avatar.cpp index 68ce5243..9fcd00a6 100644 --- a/src/gui/widgets/avatar.cpp +++ b/src/gui/widgets/avatar.cpp @@ -33,23 +33,17 @@ Avatar::Avatar(const std::string &name): mLabel = new gcn::Label(name); mLabel->setSize(85, 12); mLabel->setPosition(25, 0); - mStatusOffline = ResourceManager::getInstance()->getImage("graphics/gui/circle-gray.png"); - mStatusOnline = ResourceManager::getInstance()->getImage("graphics/gui/circle-green.png"); + ResourceManager *resman = ResourceManager::getInstance(); + mStatusOffline = resman->getImage("graphics/gui/circle-gray.png"); + mStatusOnline = resman->getImage("graphics/gui/circle-green.png"); mStatus = new Icon(mStatusOffline); mStatus->setSize(25, 12); mStatus->setPosition(0, 0); } -void Avatar::setOnline(bool status) +void Avatar::setOnline(bool online) { - if (status) - { - mStatus->setImage(mStatusOnline); - } - else - { - mStatus->setImage(mStatusOffline); - } + mStatus->setImage(online ? mStatusOnline : mStatusOffline); } void Avatar::draw(gcn::Graphics *g) diff --git a/src/gui/widgets/avatar.h b/src/gui/widgets/avatar.h index 0f657895..c6151020 100644 --- a/src/gui/widgets/avatar.h +++ b/src/gui/widgets/avatar.h @@ -33,18 +33,18 @@ class Avatar : public gcn::Widget { public: /** - * Constructor + * Constructor. * @param name Character name */ Avatar(const std::string &name); /** - * Set the avatar online status + * Set the avatar online status. */ - void setOnline(bool status); + void setOnline(bool online); /** - * Draws the Avatar + * Draws the avatar. */ void draw(gcn::Graphics *g); diff --git a/src/gui/window.cpp b/src/gui/window.cpp index 37c61520..9dc70189 100644 --- a/src/gui/window.cpp +++ b/src/gui/window.cpp @@ -129,7 +129,7 @@ Window::~Window() { logger->log("UNLOAD: Window::~Window(\"%s\")", getCaption().c_str()); - std::string const &name = mConfigName; + const std::string &name = mConfigName; if (!name.empty()) { // Saving X, Y and Width and Height for resizables in the config @@ -179,10 +179,9 @@ void Window::setWindowContainer(WindowContainer *wc) void Window::draw(gcn::Graphics *graphics) { - if(mAlphaChanged) + if (mAlphaChanged) setGuiAlpha(); - Graphics *g = static_cast<Graphics*>(graphics); //g->drawImageRect(0, 0, getWidth(), getHeight(), border); @@ -467,7 +466,7 @@ void Window::mouseDragged(gcn::MouseEvent &event) } } -void Window::loadWindowState(std::string const &name) +void Window::loadWindowState(const std::string &name) { mConfigName = name; diff --git a/src/gui/window.h b/src/gui/window.h index 22355572..493bce37 100644 --- a/src/gui/window.h +++ b/src/gui/window.h @@ -198,7 +198,7 @@ class Window : public gcn::Window, gcn::WidgetListener * Don't forget to set these default values and resizable before * calling this function. */ - void loadWindowState(std::string const &); + void loadWindowState(const std::string &); /** * Set the default win pos and size. |