summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2012-08-28 01:59:04 +0300
committerAndrei Karas <akaras@inbox.ru>2012-08-28 01:59:04 +0300
commitc79403e1341ac533df1771b866d1f5cee15e12b5 (patch)
tree5bed6dfb44f7fce0432bd7a7a28d2d23db07ce80 /src/gui
parent7c79aa2b8e484319e3e511fa21db6d2448347024 (diff)
downloadmv-c79403e1341ac533df1771b866d1f5cee15e12b5.tar.gz
mv-c79403e1341ac533df1771b866d1f5cee15e12b5.tar.bz2
mv-c79403e1341ac533df1771b866d1f5cee15e12b5.tar.xz
mv-c79403e1341ac533df1771b866d1f5cee15e12b5.zip
Add const to more classes.
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/registerdialog.cpp27
-rw-r--r--src/gui/registerdialog.h4
-rw-r--r--src/gui/sdlfont.cpp35
-rw-r--r--src/gui/sdlfont.h11
-rw-r--r--src/gui/sdlinput.cpp6
-rw-r--r--src/gui/sdlinput.h4
-rw-r--r--src/gui/selldialog.cpp17
-rw-r--r--src/gui/selldialog.h9
-rw-r--r--src/gui/serverdialog.cpp52
-rw-r--r--src/gui/serverdialog.h17
-rw-r--r--src/gui/setup.cpp14
-rw-r--r--src/gui/setup.h4
-rw-r--r--src/gui/setup_audio.cpp2
-rw-r--r--src/gui/setup_colors.cpp21
-rw-r--r--src/gui/setup_colors.h3
-rw-r--r--src/gui/setup_input.cpp2
-rw-r--r--src/gui/setup_input.h2
-rw-r--r--src/gui/setup_joystick.cpp2
-rw-r--r--src/gui/setup_joystick.h2
-rw-r--r--src/gui/setup_relations.cpp31
-rw-r--r--src/gui/setup_theme.cpp2
-rw-r--r--src/gui/setup_video.cpp9
-rw-r--r--src/gui/shopwindow.cpp71
-rw-r--r--src/gui/shopwindow.h25
-rw-r--r--src/gui/shortcutwindow.cpp18
-rw-r--r--src/gui/shortcutwindow.h9
-rw-r--r--src/gui/skilldialog.cpp95
-rw-r--r--src/gui/skilldialog.h11
28 files changed, 268 insertions, 237 deletions
diff --git a/src/gui/registerdialog.cpp b/src/gui/registerdialog.cpp
index cf86f973a..8710ad9c6 100644
--- a/src/gui/registerdialog.cpp
+++ b/src/gui/registerdialog.cpp
@@ -49,7 +49,7 @@ WrongDataNoticeListener::WrongDataNoticeListener():
{
}
-void WrongDataNoticeListener::setTarget(gcn::TextField *textField)
+void WrongDataNoticeListener::setTarget(gcn::TextField *const textField)
{
mTarget = textField;
}
@@ -60,7 +60,7 @@ void WrongDataNoticeListener::action(const gcn::ActionEvent &event)
mTarget->requestFocus();
}
-RegisterDialog::RegisterDialog(LoginData *data):
+RegisterDialog::RegisterDialog(LoginData *const data):
Window(_("Register"), false, nullptr, "register.xml"),
mEmailField(nullptr),
mMaleButton(nullptr),
@@ -71,9 +71,9 @@ RegisterDialog::RegisterDialog(LoginData *data):
{
int optionalActions = Net::getLoginHandler()->supportedOptionalActions();
- gcn::Label *userLabel = new Label(_("Name:"));
- gcn::Label *passwordLabel = new Label(_("Password:"));
- gcn::Label *confirmLabel = new Label(_("Confirm:"));
+ gcn::Label *const userLabel = new Label(_("Name:"));
+ gcn::Label *const passwordLabel = new Label(_("Password:"));
+ gcn::Label *const confirmLabel = new Label(_("Confirm:"));
mUserField = new TextField(mLoginData->username);
mPasswordField = new PasswordField(mLoginData->password);
mConfirmField = new PasswordField;
@@ -114,7 +114,7 @@ RegisterDialog::RegisterDialog(LoginData *data):
if (optionalActions & Net::LoginHandler::SetEmailOnRegister)
{
- gcn::Label *emailLabel = new Label(_("Email:"));
+ gcn::Label *const emailLabel = new Label(_("Email:"));
mEmailField = new TextField;
placer(0, row, emailLabel);
placer(1, row, mEmailField, 3).setPadding(2);
@@ -173,10 +173,14 @@ void RegisterDialog::action(const gcn::ActionEvent &event)
std::string errorMsg;
int error = 0;
- unsigned int minUser = Net::getLoginHandler()->getMinUserNameLength();
- unsigned int maxUser = Net::getLoginHandler()->getMaxUserNameLength();
- unsigned int minPass = Net::getLoginHandler()->getMinPasswordLength();
- unsigned int maxPass = Net::getLoginHandler()->getMaxPasswordLength();
+ const unsigned int minUser = Net::getLoginHandler()
+ ->getMinUserNameLength();
+ const unsigned int maxUser = Net::getLoginHandler()
+ ->getMaxUserNameLength();
+ const unsigned int minPass = Net::getLoginHandler()
+ ->getMinPasswordLength();
+ const unsigned int maxPass = Net::getLoginHandler()
+ ->getMaxPasswordLength();
if (user.length() < minUser)
{
@@ -234,7 +238,8 @@ void RegisterDialog::action(const gcn::ActionEvent &event)
mWrongDataNoticeListener->setTarget(this->mPasswordField);
}
- OkDialog *dlg = new OkDialog(_("Error"), errorMsg, DIALOG_ERROR);
+ OkDialog *const dlg = new OkDialog(
+ _("Error"), errorMsg, DIALOG_ERROR);
dlg->addActionListener(mWrongDataNoticeListener);
}
else
diff --git a/src/gui/registerdialog.h b/src/gui/registerdialog.h
index 188390bba..ada378251 100644
--- a/src/gui/registerdialog.h
+++ b/src/gui/registerdialog.h
@@ -49,7 +49,7 @@ class WrongDataNoticeListener : public gcn::ActionListener
{
public:
WrongDataNoticeListener();
- void setTarget(gcn::TextField *textField);
+ void setTarget(gcn::TextField *const textField);
void action(const gcn::ActionEvent &event);
private:
gcn::TextField *mTarget;
@@ -70,7 +70,7 @@ class RegisterDialog : public Window, public gcn::ActionListener,
*
* @see Window::Window
*/
- RegisterDialog(LoginData *loginData);
+ RegisterDialog(LoginData *const loginData);
/**
* Destructor
diff --git a/src/gui/sdlfont.cpp b/src/gui/sdlfont.cpp
index dc24e0e35..ed3a6b295 100644
--- a/src/gui/sdlfont.cpp
+++ b/src/gui/sdlfont.cpp
@@ -64,7 +64,7 @@ class SDLTextChunk
return (chunk.text == text && chunk.color == color);
}
- void generate(TTF_Font *font, float alpha)
+ void generate(TTF_Font *const font, const float alpha)
{
SDL_Color sdlCol;
sdlCol.b = static_cast<uint8_t>(color.b);
@@ -74,7 +74,7 @@ class SDLTextChunk
getSafeUtf8String(text, strBuf);
// SDL_Surface *surface = TTF_RenderUTF8_Solid(
- SDL_Surface *surface = TTF_RenderUTF8_Blended(
+ SDL_Surface *const surface = TTF_RenderUTF8_Blended(
font, strBuf, sdlCol);
if (!surface)
@@ -96,11 +96,11 @@ typedef std::list<SDLTextChunk>::iterator CacheIterator;
static int fontCounter;
-SDLFont::SDLFont(std::string filename, int size, int style) :
+SDLFont::SDLFont(std::string filename, const int size, const int style) :
mCreateCounter(0),
mDeleteCounter(0)
{
- ResourceManager *resman = ResourceManager::getInstance();
+ ResourceManager *const resman = ResourceManager::getInstance();
if (fontCounter == 0 && TTF_Init() == -1)
{
@@ -149,9 +149,9 @@ SDLFont::~SDLFont()
}
}
-void SDLFont::loadFont(std::string filename, int size, int style)
+void SDLFont::loadFont(std::string filename, const int size, const int style)
{
- ResourceManager *resman = ResourceManager::getInstance();
+ ResourceManager *const resman = ResourceManager::getInstance();
if (fontCounter == 0 && TTF_Init() == -1)
{
@@ -161,7 +161,8 @@ void SDLFont::loadFont(std::string filename, int size, int style)
}
fixDirSeparators(filename);
- TTF_Font *font = TTF_OpenFont(resman->getPath(filename).c_str(), size);
+ TTF_Font *const font = TTF_OpenFont(
+ resman->getPath(filename).c_str(), size);
if (!font)
{
@@ -187,14 +188,14 @@ void SDLFont::clear()
}
}
-void SDLFont::drawString(gcn::Graphics *graphics,
+void SDLFont::drawString(gcn::Graphics *const graphics,
const std::string &text,
- int x, int y)
+ const int x, const int y)
{
if (text.empty())
return;
- Graphics *g = dynamic_cast<Graphics *>(graphics);
+ Graphics *const g = dynamic_cast<Graphics *const>(graphics);
gcn::Color col = g->getColor();
const float alpha = static_cast<float>(col.a) / 255.0f;
@@ -206,8 +207,8 @@ void SDLFont::drawString(gcn::Graphics *graphics,
SDLTextChunk chunk(text, col);
- unsigned char chr = text[0];
- std::list<SDLTextChunk> *cache = &mCache[chr];
+ const unsigned char chr = text[0];
+ std::list<SDLTextChunk> *const cache = &mCache[chr];
bool found = false;
@@ -255,7 +256,7 @@ void SDLFont::drawString(gcn::Graphics *graphics,
}
else if (cache->front().img)
{
- Image *image = cache->front().img;
+ Image *const image = cache->front().img;
image->setAlpha(alpha);
g->drawImage(image, x, y);
}
@@ -275,7 +276,7 @@ void SDLFont::slowLogic()
}
}
-void SDLFont::createSDLTextChunk(SDLTextChunk *chunk)
+void SDLFont::createSDLTextChunk(SDLTextChunk *const chunk)
{
if (!chunk || chunk->text.empty())
return;
@@ -292,8 +293,8 @@ int SDLFont::getWidth(const std::string &text) const
if (text.empty())
return 0;
- unsigned char chr = text[0];
- std::list<SDLTextChunk> *cache = &mCache[chr];
+ const unsigned char chr = text[0];
+ std::list<SDLTextChunk> *const cache = &mCache[chr];
#ifdef DEBUG_FONT
int cnt = 0;
@@ -336,7 +337,7 @@ void SDLFont::doClean()
{
for (unsigned int f = 0; f < CACHES_NUMBER; f ++)
{
- std::list<SDLTextChunk> *cache = &mCache[f];
+ std::list<SDLTextChunk> *const cache = &mCache[f];
const size_t size = cache->size();
#ifdef DEBUG_FONT_COUNTERS
logger->log("ptr: %d, size: %d", f, size);
diff --git a/src/gui/sdlfont.h b/src/gui/sdlfont.h
index a7bea343f..a736c70e0 100644
--- a/src/gui/sdlfont.h
+++ b/src/gui/sdlfont.h
@@ -53,16 +53,17 @@ class SDLFont : public gcn::Font
* @param filename Font filename.
* @param size Font size.
*/
- SDLFont(std::string filename, int size, int style = 0);
+ SDLFont(std::string filename, const int size, const int style = 0);
/**
* Destructor.
*/
~SDLFont();
- void loadFont(std::string filename, int size, int style = 0);
+ void loadFont(std::string filename, const int size,
+ const int style = 0);
- void createSDLTextChunk(SDLTextChunk *chunk);
+ void createSDLTextChunk(SDLTextChunk *const chunk);
virtual int getWidth(const std::string &text) const;
@@ -74,9 +75,9 @@ class SDLFont : public gcn::Font
/**
* @see Font::drawString
*/
- void drawString(gcn::Graphics *graphics,
+ void drawString(gcn::Graphics *const graphics,
const std::string &text,
- int x, int y);
+ const int x, const int y);
void clear();
diff --git a/src/gui/sdlinput.cpp b/src/gui/sdlinput.cpp
index 2b6b8363b..2c4e8cbea 100644
--- a/src/gui/sdlinput.cpp
+++ b/src/gui/sdlinput.cpp
@@ -220,7 +220,7 @@ void SDLInput::pushInput(const SDL_Event &event)
} // end switch
}
-int SDLInput::convertMouseButton(int button)
+int SDLInput::convertMouseButton(const int button)
{
switch (button)
{
@@ -236,9 +236,9 @@ int SDLInput::convertMouseButton(int button)
}
}
-int SDLInput::convertKeyCharacter(SDL_Event event)
+int SDLInput::convertKeyCharacter(const SDL_Event event)
{
- SDL_keysym keysym = event.key.keysym;
+ const SDL_keysym keysym = event.key.keysym;
int value = keysym.unicode;
diff --git a/src/gui/sdlinput.h b/src/gui/sdlinput.h
index b6b41fe5c..db082ef2a 100644
--- a/src/gui/sdlinput.h
+++ b/src/gui/sdlinput.h
@@ -173,7 +173,7 @@ protected:
* @param button an SDL mouse button.
* @return a Guichan mouse button.
*/
- int convertMouseButton(int button);
+ static int convertMouseButton(const int button);
/**
* Converts an SDL event key to a key value.
@@ -182,7 +182,7 @@ protected:
* @return a key value.
* @see Key
*/
- int convertKeyCharacter(SDL_Event event);
+ static int convertKeyCharacter(SDL_Event event);
std::queue<KeyInput> mKeyInputQueue;
std::queue<gcn::MouseInput> mMouseInputQueue;
diff --git a/src/gui/selldialog.cpp b/src/gui/selldialog.cpp
index 41649a901..8f8969883 100644
--- a/src/gui/selldialog.cpp
+++ b/src/gui/selldialog.cpp
@@ -47,7 +47,7 @@
SellDialog::DialogList SellDialog::instances;
-SellDialog::SellDialog(int npcId):
+SellDialog::SellDialog(const int npcId):
Window(_("Sell"), false, nullptr, "sell.xml"),
mNpcId(npcId), mMaxItems(0), mAmountItems(0), mNick("")
{
@@ -148,7 +148,7 @@ void SellDialog::reset()
updateButtonsAndLabels();
}
-void SellDialog::addItem(const Item *item, int price)
+void SellDialog::addItem(const Item *const item, const int price)
{
if (!item)
return;
@@ -159,7 +159,8 @@ void SellDialog::addItem(const Item *item, int price)
mShopItemList->adjustSize();
}
-void SellDialog::addItem(int id, unsigned char color, int amount, int price)
+void SellDialog::addItem(const int id, const unsigned char color,
+ const int amount, const int price)
{
mShopItems->addItem(id, color, amount, price);
mShopItemList->adjustSize();
@@ -174,7 +175,7 @@ void SellDialog::action(const gcn::ActionEvent &event)
return;
}
- int selectedItem = mShopItemList->getSelected();
+ const int selectedItem = mShopItemList->getSelected();
// The following actions require a valid item selection
if (selectedItem == -1 ||
@@ -212,7 +213,7 @@ void SellDialog::action(const gcn::ActionEvent &event)
if (mNpcId != -1)
{
// Attempt sell
- ShopItem *item = mShopItems->at(selectedItem);
+ ShopItem *const item = mShopItems->at(selectedItem);
int sellCount, itemIndex;
mPlayerMoney +=
mAmountItems * mShopItems->at(selectedItem)->getPrice();
@@ -258,7 +259,7 @@ void SellDialog::action(const gcn::ActionEvent &event)
}
else
{
- ShopItem *item = mShopItems->at(selectedItem);
+ ShopItem *const item = mShopItems->at(selectedItem);
Net::getBuySellHandler()->sendSellRequest(mNick,
item, mAmountItems);
@@ -279,7 +280,7 @@ void SellDialog::valueChanged(const gcn::SelectionEvent &event A_UNUSED)
mSlider->gcn::Slider::setScale(1, mMaxItems);
}
-void SellDialog::setMoney(int amount)
+void SellDialog::setMoney(const int amount)
{
mPlayerMoney = amount;
mShopItemList->setPlayersMoney(amount);
@@ -287,7 +288,7 @@ void SellDialog::setMoney(int amount)
void SellDialog::updateButtonsAndLabels()
{
- int selectedItem = mShopItemList->getSelected();
+ const int selectedItem = mShopItemList->getSelected();
int income = 0;
ShopItem *item = nullptr;
diff --git a/src/gui/selldialog.h b/src/gui/selldialog.h
index 8b1d73ce3..5c1e7300d 100644
--- a/src/gui/selldialog.h
+++ b/src/gui/selldialog.h
@@ -57,7 +57,7 @@ class SellDialog : public Window,
*
* @see Window::Window
*/
- SellDialog(int npcId);
+ SellDialog(const int npcId);
/**
* Constructor.
@@ -79,7 +79,7 @@ class SellDialog : public Window,
/**
* Adds an item to the inventory.
*/
- void addItem(const Item *item, int price);
+ void addItem(const Item *const item, const int price);
/**
* Called when receiving actions from the widgets.
@@ -96,14 +96,15 @@ class SellDialog : public Window,
/**
* Gives Player's Money amount
*/
- void setMoney(int amount);
+ void setMoney(const int amount);
/**
* Sets the visibility of this window.
*/
void setVisible(bool visible);
- void addItem(int id, unsigned char color, int amount, int price);
+ void addItem(const int id, const unsigned char color,
+ const int amount, const int price);
/**
* Returns true if any instances exist.
diff --git a/src/gui/serverdialog.cpp b/src/gui/serverdialog.cpp
index 1dad557b1..ed682c487 100644
--- a/src/gui/serverdialog.cpp
+++ b/src/gui/serverdialog.cpp
@@ -60,7 +60,7 @@
static const int MAX_SERVERLIST = 15;
-static std::string serverTypeToString(ServerInfo::Type type)
+static std::string serverTypeToString(const ServerInfo::Type type)
{
switch (type)
{
@@ -87,7 +87,7 @@ static std::string serverTypeToString(ServerInfo::Type type)
}
}
-static unsigned short defaultPortForServerType(ServerInfo::Type type)
+static unsigned short defaultPortForServerType(const ServerInfo::Type type)
{
switch (type)
{
@@ -112,7 +112,8 @@ static unsigned short defaultPortForServerType(ServerInfo::Type type)
}
}
-ServersListModel::ServersListModel(ServerInfos *servers, ServerDialog *parent):
+ServersListModel::ServersListModel(ServerInfos *const servers,
+ ServerDialog *const parent) :
mServers(servers),
mVersionStrings(servers->size(), VersionString(0, "")),
mParent(parent)
@@ -136,7 +137,8 @@ std::string ServersListModel::getElementAt(int elementIndex)
return myServer;
}
-void ServersListModel::setVersionString(int index, const std::string &version)
+void ServersListModel::setVersionString(const int index,
+ const std::string &version)
{
if (index >= static_cast<int>(mVersionStrings.size()))
return;
@@ -147,15 +149,15 @@ void ServersListModel::setVersionString(int index, const std::string &version)
}
else
{
- int width = gui->getFont()->getWidth(version);
- mVersionStrings[index] = VersionString(width, version);
+ mVersionStrings[index] = VersionString(
+ gui->getFont()->getWidth(version), version);
}
}
class ServersListBox : public ListBox
{
public:
- ServersListBox(ServersListModel *model) :
+ ServersListBox(ServersListModel *const model) :
ListBox(model),
mHighlightColor(Theme::getThemeColor(Theme::HIGHLIGHT)),
mTextColor(Theme::getThemeColor(Theme::TEXT)),
@@ -169,7 +171,8 @@ public:
if (!mListModel)
return;
- ServersListModel *model = static_cast<ServersListModel*>(mListModel);
+ ServersListModel *const model = static_cast<ServersListModel *const>(
+ mListModel);
updateAlpha();
@@ -237,7 +240,8 @@ private:
};
-ServerDialog::ServerDialog(ServerInfo *serverInfo, const std::string &dir):
+ServerDialog::ServerDialog(ServerInfo *const serverInfo,
+ const std::string &dir) :
Window(_("Choose Your Server"), false, nullptr, "server.xml"),
mDir(dir),
// mDownloadStatus(DOWNLOADING_PREPARING),
@@ -264,11 +268,11 @@ ServerDialog::ServerDialog(ServerInfo *serverInfo, const std::string &dir):
mServersList = new ServersListBox(mServersListModel);
mServersList->addMouseListener(this);
- ScrollArea *usedScroll = new ScrollArea(mServersList,
+ ScrollArea *const usedScroll = new ScrollArea(mServersList,
getOptionBool("showbackground"), "server_background.xml");
usedScroll->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER);
- int n = 0;
+ const int n = 0;
mDescription = new Label(std::string());
@@ -341,7 +345,7 @@ void ServerDialog::connectToSelectedServer()
if (Client::getState() == STATE_CONNECT_SERVER)
return;
- int index = mServersList->getSelected();
+ const int index = mServersList->getSelected();
if (index < 0)
return;
@@ -399,13 +403,13 @@ void ServerDialog::action(const gcn::ActionEvent &event)
}
else if (eventId == "editEntry")
{
- int index = mServersList->getSelected();
+ const int index = mServersList->getSelected();
if (index >= 0)
new EditServerDialog(this, mServers.at(index), index);
}
else if (eventId == "remove")
{
- int index = mServersList->getSelected();
+ const int index = mServersList->getSelected();
if (index >= 0)
{
mServersList->setSelected(0);
@@ -437,7 +441,7 @@ void ServerDialog::keyPressed(gcn::KeyEvent &keyEvent)
case Input::KEY_GUI_DELETE:
{
- int index = mServersList->getSelected();
+ const int index = mServersList->getSelected();
if (index >= 0)
{
mServersList->setSelected(0);
@@ -449,7 +453,7 @@ void ServerDialog::keyPressed(gcn::KeyEvent &keyEvent)
case Input::KEY_GUI_BACKSPACE:
{
- int index = mServersList->getSelected();
+ const int index = mServersList->getSelected();
if (index >= 0)
new EditServerDialog(this, mServers.at(index), index);
return;
@@ -546,11 +550,11 @@ void ServerDialog::downloadServerList()
config.setValue("serverslistupdate", getDateString());
}
-void ServerDialog::loadServers(bool addNew)
+void ServerDialog::loadServers(const bool addNew)
{
XML::Document doc(mDir + "/" + branding.getStringValue(
"onlineServerFile"), false);
- XmlNodePtr rootNode = doc.rootNode();
+ const XmlNodePtr rootNode = doc.rootNode();
if (!rootNode || !xmlNameEqual(rootNode, "serverlist"))
{
@@ -558,7 +562,7 @@ void ServerDialog::loadServers(bool addNew)
return;
}
- int ver = XML::getProperty(rootNode, "version", 0);
+ const int ver = XML::getProperty(rootNode, "version", 0);
if (ver != 1)
{
logger->log("Error: unsupported online server list version: %d",
@@ -593,7 +597,7 @@ void ServerDialog::loadServers(bool addNew)
std::string version = XML::getProperty(serverNode, "minimumVersion",
std::string());
- bool meetsMinimumVersion = (compareStrI(version, PACKAGE_VERSION)
+ const bool meetsMinimumVersion = (compareStrI(version, PACKAGE_VERSION)
<= 0);
// For display in the list
@@ -685,7 +689,7 @@ void ServerDialog::loadCustomServers()
}
void ServerDialog::saveCustomServers(const ServerInfo &currentServer,
- int index)
+ const int index)
{
// Make sure the current server is mentioned first
if (currentServer.isValid())
@@ -746,7 +750,7 @@ int ServerDialog::downloadUpdate(void *ptr, DownloadStatus status,
if (!ptr || status == DOWNLOAD_STATUS_CANCELLED)
return -1;
- ServerDialog *sd = reinterpret_cast<ServerDialog*>(ptr);
+ ServerDialog *const sd = reinterpret_cast<ServerDialog*>(ptr);
bool finished = false;
if (!sd->mDownload)
@@ -798,12 +802,12 @@ int ServerDialog::downloadUpdate(void *ptr, DownloadStatus status,
return 0;
}
-void ServerDialog::updateServer(ServerInfo server, int index)
+void ServerDialog::updateServer(ServerInfo server, const int index)
{
saveCustomServers(server, index);
}
-bool ServerDialog::needUpdateServers()
+bool ServerDialog::needUpdateServers() const
{
if (mServers.empty() || config.getStringValue("serverslistupdate")
!= getDateString())
diff --git a/src/gui/serverdialog.h b/src/gui/serverdialog.h
index b6a45dfd9..d493a86b9 100644
--- a/src/gui/serverdialog.h
+++ b/src/gui/serverdialog.h
@@ -55,7 +55,8 @@ class ServersListModel : public gcn::ListModel
public:
typedef std::pair<int, std::string> VersionString;
- ServersListModel(ServerInfos *servers, ServerDialog *parent);
+ ServersListModel(ServerInfos *const servers,
+ ServerDialog *const parent);
/**
* Used to get number of line in the list
@@ -70,10 +71,10 @@ class ServersListModel : public gcn::ListModel
/**
* Used to get the corresponding Server struct
*/
- const ServerInfo &getServer(int elementIndex) const
+ const ServerInfo &getServer(const int elementIndex) const
{ return mServers->at(elementIndex); }
- void setVersionString(int index, const std::string &version);
+ void setVersionString(const int index, const std::string &version);
private:
typedef std::vector<VersionString> VersionStrings;
@@ -100,7 +101,7 @@ class ServerDialog : public Window,
*
* @see Window::Window
*/
- ServerDialog(ServerInfo *serverInfo, const std::string &dir);
+ ServerDialog(ServerInfo *const serverInfo, const std::string &dir);
/**
* Destructor
@@ -123,7 +124,7 @@ class ServerDialog : public Window,
void logic();
- void updateServer(ServerInfo server, int index);
+ void updateServer(ServerInfo server, const int index);
void connectToSelectedServer();
@@ -141,14 +142,14 @@ class ServerDialog : public Window,
*/
void downloadServerList();
- void loadServers(bool addNew = true);
+ void loadServers(const bool addNew = true);
void loadCustomServers();
void saveCustomServers(const ServerInfo &currentServer = ServerInfo(),
- int index = -1);
+ const int index = -1);
- bool needUpdateServers();
+ bool needUpdateServers() const;
static int downloadUpdate(void *ptr, DownloadStatus status,
size_t total, size_t remaining);
diff --git a/src/gui/setup.cpp b/src/gui/setup.cpp
index b849823d9..161b2326d 100644
--- a/src/gui/setup.cpp
+++ b/src/gui/setup.cpp
@@ -58,7 +58,7 @@ Setup::Setup():
setStickyButtonLock(true);
int width = 620;
- int height = 450;
+ const int height = 450;
if (config.getIntValue("screenwidth") >= 730)
width += 100;
@@ -76,9 +76,9 @@ Setup::Setup():
};
int x = width;
const int buttonPadding = getOption("buttonPadding", 5);
- for (const char **curBtn = buttonNames; *curBtn; ++ curBtn)
+ for (const char ** curBtn = buttonNames; *curBtn; ++ curBtn)
{
- Button *btn = new Button(gettext(*curBtn), *curBtn, this);
+ Button *const btn = new Button(gettext(*curBtn), *curBtn, this);
x -= btn->getWidth() + buttonPadding;
btn->setPosition(x, height - btn->getHeight() - buttonPadding);
add(btn);
@@ -109,13 +109,13 @@ Setup::Setup():
i_end = mTabs.end();
i != i_end; ++i)
{
- SetupTab *tab = *i;
+ SetupTab *const tab = *i;
mPanel->addTab(tab->getName(), tab);
}
add(mPanel);
- Label *version = new Label(FULL_VERSION);
+ Label *const version = new Label(FULL_VERSION);
// version->setPosition(9, height - version->getHeight() - 9);
if (mResetWindows)
{
@@ -175,7 +175,7 @@ void Setup::action(const gcn::ActionEvent &event)
}
}
-void Setup::setInGame(bool inGame)
+void Setup::setInGame(const bool inGame)
{
mResetWindows->setEnabled(inGame);
}
@@ -190,7 +190,7 @@ void Setup::externalUpdate()
}
}
-void Setup::registerWindowForReset(Window *window)
+void Setup::registerWindowForReset(Window *const window)
{
mWindowsToReset.push_back(window);
}
diff --git a/src/gui/setup.h b/src/gui/setup.h
index 975cf297b..71b9594b6 100644
--- a/src/gui/setup.h
+++ b/src/gui/setup.h
@@ -60,11 +60,11 @@ class Setup : public Window, public gcn::ActionListener
/**
* Enables the reset button when in game.
*/
- void setInGame(bool inGame);
+ void setInGame(const bool inGame);
void externalUpdate();
- void registerWindowForReset(Window *window);
+ void registerWindowForReset(Window *const window);
void clearWindowsForReset()
{ mWindowsToReset.clear(); }
diff --git a/src/gui/setup_audio.cpp b/src/gui/setup_audio.cpp
index c5efa63ad..b649bc23d 100644
--- a/src/gui/setup_audio.cpp
+++ b/src/gui/setup_audio.cpp
@@ -145,7 +145,7 @@ void Setup_Audio::apply()
sound.init();
if (viewport && config.getBoolValue("playMusic"))
{
- Map *map = viewport->getMap();
+ const Map *const map = viewport->getMap();
if (map)
sound.playMusic(map->getMusicFile());
}
diff --git a/src/gui/setup_colors.cpp b/src/gui/setup_colors.cpp
index 09468a4a9..80cb89d8a 100644
--- a/src/gui/setup_colors.cpp
+++ b/src/gui/setup_colors.cpp
@@ -243,9 +243,9 @@ void Setup_Colors::valueChanged(const gcn::SelectionEvent &event A_UNUSED)
return;
mSelected = mColorBox->getSelected();
- int type = userPalette->getColorTypeAt(mSelected);
+ const int type = userPalette->getColorTypeAt(mSelected);
const gcn::Color *col = &userPalette->getColor(type);
- Palette::GradientType grad = userPalette->getGradientType(type);
+ const Palette::GradientType grad = userPalette->getGradientType(type);
const int delay = userPalette->getGradientDelay(type);
mPreview->clearRows();
@@ -345,7 +345,8 @@ void Setup_Colors::valueChanged(const gcn::SelectionEvent &event A_UNUSED)
mGradTypeSlider->setEnabled(true);
}
-void Setup_Colors::setEntry(gcn::Slider *s, TextField *t, int value)
+void Setup_Colors::setEntry(gcn::Slider *const s, TextField *const t,
+ const int value)
{
if (s)
s->setValue(value);
@@ -369,8 +370,8 @@ void Setup_Colors::cancel()
return;
userPalette->rollback();
- int type = userPalette->getColorTypeAt(mSelected);
- const gcn::Color *col = &userPalette->getColor(type);
+ const int type = userPalette->getColorTypeAt(mSelected);
+ const gcn::Color *const col = &userPalette->getColor(type);
mGradTypeSlider->setValue(userPalette->getGradientType(type));
const int delay = userPalette->getGradientDelay(type);
setEntry(mGradDelaySlider, mGradDelayText, delay);
@@ -404,8 +405,8 @@ void Setup_Colors::updateGradType()
return;
mSelected = mColorBox->getSelected();
- int type = userPalette->getColorTypeAt(mSelected);
- Palette::GradientType grad = userPalette->getGradientType(type);
+ const int type = userPalette->getColorTypeAt(mSelected);
+ const Palette::GradientType grad = userPalette->getGradientType(type);
mGradTypeText->setCaption(
(grad == Palette::STATIC) ? _("Static") :
@@ -432,10 +433,10 @@ void Setup_Colors::updateColor()
if (mSelected == -1 || !userPalette)
return;
- int type = userPalette->getColorTypeAt(mSelected);
- Palette::GradientType grad = static_cast<Palette::GradientType>(
+ const int type = userPalette->getColorTypeAt(mSelected);
+ const Palette::GradientType grad = static_cast<Palette::GradientType>(
static_cast<int>(mGradTypeSlider->getValue()));
- int delay = static_cast<int>(mGradDelaySlider->getValue());
+ const int delay = static_cast<int>(mGradDelaySlider->getValue());
userPalette->setGradient(type, grad);
userPalette->setGradientDelay(type, delay);
diff --git a/src/gui/setup_colors.h b/src/gui/setup_colors.h
index 6ef8b0b2d..534ba5e86 100644
--- a/src/gui/setup_colors.h
+++ b/src/gui/setup_colors.h
@@ -88,7 +88,8 @@ class Setup_Colors : public SetupTab,
TextField *mBlueText;
int mBlueValue;
- void setEntry(gcn::Slider *s, TextField *t, int value);
+ static void setEntry(gcn::Slider *const s, TextField *const t,
+ const int value);
void updateColor();
void updateGradType();
};
diff --git a/src/gui/setup_input.cpp b/src/gui/setup_input.cpp
index 2d5795e71..82480e0e0 100644
--- a/src/gui/setup_input.cpp
+++ b/src/gui/setup_input.cpp
@@ -386,7 +386,7 @@ void Setup_Input::fixTranslation(SetupActionData *const actionDatas,
}
}
-void Setup_Input::fixTranslations()
+void Setup_Input::fixTranslations() const
{
fixTranslation(setupActionData1, static_cast<int>(Input::KEY_SHORTCUT_1),
static_cast<int>(Input::KEY_SHORTCUT_20), "Item Shortcut %d");
diff --git a/src/gui/setup_input.h b/src/gui/setup_input.h
index e0c14be7f..f3e2f7113 100644
--- a/src/gui/setup_input.h
+++ b/src/gui/setup_input.h
@@ -80,7 +80,7 @@ class Setup_Input : public SetupTab
std::string keyToString(const int index) const;
private:
- void fixTranslations();
+ void fixTranslations() const;
void fixTranslation(SetupActionData *const actionDatas,
const int actionStart, const int actionEnd,
diff --git a/src/gui/setup_joystick.cpp b/src/gui/setup_joystick.cpp
index cb3ff9341..acc8407bb 100644
--- a/src/gui/setup_joystick.cpp
+++ b/src/gui/setup_joystick.cpp
@@ -127,7 +127,7 @@ void Setup_Joystick::action(const gcn::ActionEvent &event)
}
}
-void Setup_Joystick::setTempEnabled(bool sel)
+void Setup_Joystick::setTempEnabled(const bool sel)
{
Joystick::setEnabled(sel);
mCalibrateButton->setEnabled(sel);
diff --git a/src/gui/setup_joystick.h b/src/gui/setup_joystick.h
index d4f54d489..35a21080a 100644
--- a/src/gui/setup_joystick.h
+++ b/src/gui/setup_joystick.h
@@ -50,7 +50,7 @@ class Setup_Joystick : public SetupTab
void action(const gcn::ActionEvent &event);
- void setTempEnabled(bool sel);
+ void setTempEnabled(const bool sel);
private:
gcn::Label *mCalibrateLabel;
diff --git a/src/gui/setup_relations.cpp b/src/gui/setup_relations.cpp
index 635adebe2..b8b8627f1 100644
--- a/src/gui/setup_relations.cpp
+++ b/src/gui/setup_relations.cpp
@@ -141,7 +141,7 @@ public:
signalBeforeUpdate();
freeWidgets();
- StringVect *player_names = player_relations.getPlayers();
+ StringVect *const player_names = player_relations.getPlayers();
if (!player_names)
return;
@@ -154,10 +154,10 @@ public:
player_names->size()); r < sz; ++r)
{
std::string name = (*player_names)[r];
- gcn::Widget *widget = new Label(name);
+ gcn::Widget *const widget = new Label(name);
mWidgets.push_back(widget);
- gcn::DropDown *choicebox = new DropDown(mListModel);
+ gcn::DropDown *const choicebox = new DropDown(mListModel);
choicebox->setSelected(player_relations.getRelation(name));
mWidgets.push_back(choicebox);
}
@@ -165,10 +165,10 @@ public:
signalAfterUpdate();
}
- virtual void updateModelInRow(int row)
+ virtual void updateModelInRow(const int row)
{
- gcn::DropDown *choicebox = static_cast<gcn::DropDown *>(
- getElementAt(row, RELATION_CHOICE_COLUMN));
+ const gcn::DropDown *const choicebox = static_cast<gcn::DropDown *>(
+ getElementAt(row, RELATION_CHOICE_COLUMN));
player_relations.setRelation(getPlayerAt(row),
static_cast<PlayerRelation::Relation>(
choicebox->getSelected()));
@@ -189,7 +189,7 @@ public:
mWidgets.clear();
}
- std::string getPlayerAt(int index) const
+ std::string getPlayerAt(const int index) const
{
if (index < 0 || index >= static_cast<signed>(mPlayers->size()))
return "";
@@ -265,7 +265,7 @@ Setup_Relations::Setup_Relations():
mPlayerTable->setLinewiseSelection(true);
mPlayerTable->addActionListener(this);
- gcn::Label *ignore_action_label = new Label(_("When ignoring:"));
+ gcn::Label *const ignore_action_label = new Label(_("When ignoring:"));
mIgnoreActionChoicesBox->setActionEventId(ACTION_STRATEGY);
mIgnoreActionChoicesBox->addActionListener(this);
@@ -333,9 +333,8 @@ void Setup_Relations::apply()
{
player_relations.store();
- unsigned int old_default_relations = player_relations.getDefault() &
- ~(PlayerRelation::TRADE |
- PlayerRelation::WHISPER);
+ const unsigned int old_default_relations = player_relations.getDefault() &
+ ~(PlayerRelation::TRADE | PlayerRelation::WHISPER);
player_relations.setDefault(old_default_relations
| (mDefaultTrading->isSelected() ?
PlayerRelation::TRADE : 0)
@@ -363,7 +362,7 @@ void Setup_Relations::action(const gcn::ActionEvent &event)
// embarrassing.)
player_relations.removeListener(this);
- int row = mPlayerTable->getSelectedRow();
+ const int row = mPlayerTable->getSelectedRow();
if (row >= 0)
mPlayerTableModel->updateModelInRow(row);
@@ -372,7 +371,7 @@ void Setup_Relations::action(const gcn::ActionEvent &event)
}
else if (event.getId() == ACTION_DELETE)
{
- int player_index = mPlayerTable->getSelectedRow();
+ const int player_index = mPlayerTable->getSelectedRow();
if (player_index < 0)
return;
@@ -383,9 +382,9 @@ void Setup_Relations::action(const gcn::ActionEvent &event)
}
else if (event.getId() == ACTION_STRATEGY)
{
- PlayerIgnoreStrategy *s =
+ PlayerIgnoreStrategy *const s =
(*player_relations.getPlayerIgnoreStrategies())[
- mIgnoreActionChoicesBox->getSelected()];
+ mIgnoreActionChoicesBox->getSelected()];
player_relations.setPlayerIgnoreStrategy(s);
}
@@ -404,7 +403,7 @@ void Setup_Relations::updatedPlayer(const std::string &name A_UNUSED)
void Setup_Relations::updateAll()
{
- PlayerTableModel *model = new PlayerTableModel();
+ PlayerTableModel *const model = new PlayerTableModel();
mPlayerTable->setModel(model);
delete mPlayerTableModel;
mPlayerTableModel = model;
diff --git a/src/gui/setup_theme.cpp b/src/gui/setup_theme.cpp
index bcc360d14..8b53e73b7 100644
--- a/src/gui/setup_theme.cpp
+++ b/src/gui/setup_theme.cpp
@@ -322,7 +322,7 @@ void Setup_Theme::action(const gcn::ActionEvent &event)
}
else if (event.getId() == ACTION_LANG)
{
- int id = mLangDropDown->getSelected();
+ const int id = mLangDropDown->getSelected();
if (id < 0 || id >= langs_count)
mLang = "";
else
diff --git a/src/gui/setup_video.cpp b/src/gui/setup_video.cpp
index 68e4c8e76..6daf87bf2 100644
--- a/src/gui/setup_video.cpp
+++ b/src/gui/setup_video.cpp
@@ -132,7 +132,8 @@ static bool modeSorter(std::string mode1, std::string mode2)
ModeListModel::ModeListModel()
{
/* Get available fullscreen/hardware modes */
- SDL_Rect **modes = SDL_ListModes(nullptr, SDL_FULLSCREEN | SDL_HWSURFACE);
+ SDL_Rect **const modes = SDL_ListModes(nullptr,
+ SDL_FULLSCREEN | SDL_HWSURFACE);
/* Check which modes are available */
if (modes == static_cast<SDL_Rect **>(nullptr))
@@ -169,7 +170,7 @@ ModeListModel::ModeListModel()
void ModeListModel::addCustomMode(std::string mode)
{
StringVectCIter it = mVideoModes.begin();
- StringVectCIter it_end = mVideoModes.end();
+ const StringVectCIter it_end = mVideoModes.end();
while (it != it_end)
{
if (*it == mode)
@@ -241,7 +242,7 @@ Setup_Video::Setup_Video():
{
setName(_("Video"));
- ScrollArea *scrollArea = new ScrollArea(mModeList,
+ ScrollArea *const scrollArea = new ScrollArea(mModeList,
true, "setup_video_background.xml");
scrollArea->setWidth(150);
scrollArea->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER);
@@ -548,7 +549,7 @@ void Setup_Video::action(const gcn::ActionEvent &event)
}
else if (id == "detect")
{
- int val = graphicsManager.startDetection();
+ const int val = graphicsManager.startDetection();
if (val >= 0 && val <= 2)
mOpenGLDropDown->setSelected(val);
}
diff --git a/src/gui/shopwindow.cpp b/src/gui/shopwindow.cpp
index 2037cb789..e05cee111 100644
--- a/src/gui/shopwindow.cpp
+++ b/src/gui/shopwindow.cpp
@@ -242,12 +242,12 @@ void ShopWindow::action(const gcn::ActionEvent &event)
if (mSelectedItem < 1)
return;
- Inventory *inv = PlayerInfo::getInventory();
+ const Inventory *const inv = PlayerInfo::getInventory();
if (!inv)
return;
//+++ need support for colors
- Item *item = inv->findItem(mSelectedItem, 0);
+ Item *const item = inv->findItem(mSelectedItem, 0);
if (item)
{
if (event.getId() == "add buy")
@@ -269,7 +269,7 @@ void ShopWindow::startTrade()
if (!actorSpriteManager || !tradeWindow)
return;
- Being *being = actorSpriteManager->findBeingByName(
+ Being *const being = actorSpriteManager->findBeingByName(
mTradeNick, Being::PLAYER);
tradeWindow->clear();
if (mTradeMoney)
@@ -308,11 +308,12 @@ void ShopWindow::setVisible(bool visible)
Window::setVisible(visible);
}
-void ShopWindow::addBuyItem(Item *item, int amount, int price)
+void ShopWindow::addBuyItem(const Item *const item, const int amount,
+ const int price)
{
if (!mBuyShopItems || !item)
return;
- bool emp = isShopEmpty();
+ const bool emp = isShopEmpty();
mBuyShopItems->addItemNoDup(item->getId(),
item->getColor(), amount, price);
if (emp && player_node)
@@ -321,11 +322,12 @@ void ShopWindow::addBuyItem(Item *item, int amount, int price)
updateButtonsAndLabels();
}
-void ShopWindow::addSellItem(Item *item, int amount, int price)
+void ShopWindow::addSellItem(const Item *const item, const int amount,
+ const int price)
{
if (!mBuyShopItems || !item)
return;
- bool emp = isShopEmpty();
+ const bool emp = isShopEmpty();
mSellShopItems->addItemNoDup(item->getId(),
item->getColor(), amount, price);
if (emp && player_node)
@@ -412,7 +414,7 @@ void ShopWindow::saveList()
for (std::vector<ShopItem*>::const_iterator it = items.begin(),
it_end = items.end(); it != it_end; ++it)
{
- ShopItem *item = *(it);
+ ShopItem *const item = *(it);
if (item)
mapItems[item->getId()] = item;
}
@@ -423,8 +425,8 @@ void ShopWindow::saveList()
{
if (!(*it))
continue;
- ShopItem *sellItem = *(it);
- ShopItem *buyItem = mapItems[sellItem->getId()];
+ const ShopItem *const sellItem = *(it);
+ const ShopItem *const buyItem = mapItems[sellItem->getId()];
shopFile << sellItem->getId();
if (buyItem)
@@ -445,7 +447,7 @@ void ShopWindow::saveList()
for (std::map<int, ShopItem*>::const_iterator mapIt = mapItems.begin(),
mapIt_end = mapItems.end(); mapIt != mapIt_end; ++mapIt)
{
- ShopItem *buyItem = (*mapIt).second;
+ const ShopItem *const buyItem = (*mapIt).second;
if (buyItem)
{
shopFile << buyItem->getId();
@@ -458,7 +460,7 @@ void ShopWindow::saveList()
shopFile.close();
}
-void ShopWindow::announce(ShopItems *list, int mode)
+void ShopWindow::announce(ShopItems *const list, const int mode)
{
if (!list)
return;
@@ -486,7 +488,7 @@ void ShopWindow::announce(ShopItems *list, int mode)
for (std::vector<ShopItem*>::const_iterator it = items.begin(),
it_end = items.end(); it != it_end; ++it)
{
- ShopItem *item = *(it);
+ const ShopItem *const item = *(it);
if (item->getQuantity() > 1)
{
if (mAnnounceLinks->isSelected())
@@ -522,7 +524,7 @@ void ShopWindow::announce(ShopItems *list, int mode)
Net::getChatHandler()->talk(data);
}
-void ShopWindow::giveList(const std::string &nick, int mode)
+void ShopWindow::giveList(const std::string &nick, const int mode)
{
if (!checkFloodCounter(mLastRequestTimeList))
return;
@@ -543,7 +545,7 @@ void ShopWindow::giveList(const std::string &nick, int mode)
if (!list)
return;
- Inventory *inv = PlayerInfo::getInventory();
+ const Inventory *const inv = PlayerInfo::getInventory();
if (!inv)
return;
@@ -552,14 +554,14 @@ void ShopWindow::giveList(const std::string &nick, int mode)
for (std::vector<ShopItem*>::const_iterator it = items.begin(),
it_end = items.end(); it != it_end; ++it)
{
- ShopItem *item = *(it);
+ const ShopItem *const item = *(it);
if (!item)
continue;
if (mode == SELL)
{
//+++ need support for colors
- Item *item2 = inv->findItem(item->getId(), 0);
+ const Item *const item2 = inv->findItem(item->getId(), 0);
if (item2)
{
int amount = item->getQuantity();
@@ -598,7 +600,7 @@ void ShopWindow::giveList(const std::string &nick, int mode)
}
void ShopWindow::sendMessage(const std::string &nick,
- std::string data, bool random)
+ std::string data, const bool random)
{
if (!chatWindow)
return;
@@ -618,7 +620,7 @@ void ShopWindow::sendMessage(const std::string &nick,
//here was true
}
-void ShopWindow::showList(const std::string &nick, std::string data)
+void ShopWindow::showList(const std::string &nick, std::string data) const
{
BuyDialog *buyDialog = nullptr;
SellDialog *sellDialog = nullptr;
@@ -637,7 +639,7 @@ void ShopWindow::showList(const std::string &nick, std::string data)
return;
}
- Inventory *inv = PlayerInfo::getInventory();
+ const Inventory *const inv = PlayerInfo::getInventory();
if (!inv)
return;
@@ -651,8 +653,8 @@ void ShopWindow::showList(const std::string &nick, std::string data)
if (f + 9 > data.length())
break;
- int id = decodeStr(data.substr(f, 2));
- int price = decodeStr(data.substr(f + 2, 4));
+ const int id = decodeStr(data.substr(f, 2));
+ const int price = decodeStr(data.substr(f + 2, 4));
int amount = decodeStr(data.substr(f + 6, 3));
//+++ need impliment colors?
if (buyDialog && amount > 0)
@@ -660,7 +662,7 @@ void ShopWindow::showList(const std::string &nick, std::string data)
if (sellDialog)
{
//+++ need support for colors
- Item *item = inv->findItem(id, 0);
+ const Item *const item = inv->findItem(id, 0);
if (item)
{
if (item->getQuantity() < amount)
@@ -674,7 +676,8 @@ void ShopWindow::showList(const std::string &nick, std::string data)
}
}
-void ShopWindow::processRequest(std::string nick, std::string data, int mode)
+void ShopWindow::processRequest(std::string nick, std::string data,
+ const int mode)
{
if (!player_node || !mTradeNick.empty() || PlayerInfo::isTrading()
|| !actorSpriteManager
@@ -683,7 +686,7 @@ void ShopWindow::processRequest(std::string nick, std::string data, int mode)
return;
}
- Inventory *inv = PlayerInfo::getInventory();
+ const Inventory *const inv = PlayerInfo::getInventory();
if (!inv)
return;
@@ -733,7 +736,7 @@ void ShopWindow::processRequest(std::string nick, std::string data, int mode)
if (mode == BUY)
{
//+++ need support for colors
- Item *item2 = inv->findItem(mTradeItem->getId(), 0);
+ const Item *const item2 = inv->findItem(mTradeItem->getId(), 0);
if (!item2 || item2->getQuantity() < amount
|| !findShopItem(mTradeItem, SELL))
{
@@ -763,8 +766,8 @@ void ShopWindow::processRequest(std::string nick, std::string data, int mode)
}
else
{
- ConfirmDialog *confirmDlg = new ConfirmDialog(_("Request for Trade"),
- strprintf(_("%s wants to %s %s do you "
+ ConfirmDialog *const confirmDlg = new ConfirmDialog
+ (_("Request for Trade"), strprintf(_("%s wants to %s %s do you "
"accept?"), nick.c_str(), msg.c_str(),
mTradeItem->getInfo().getName().c_str()), true);
confirmDlg->addActionListener(this);
@@ -781,7 +784,7 @@ void ShopWindow::updateTimes()
}
}
-bool ShopWindow::checkFloodCounter(int &counterTime)
+bool ShopWindow::checkFloodCounter(int &counterTime) const
{
if (!counterTime || counterTime > cur_time)
counterTime = cur_time;
@@ -792,7 +795,7 @@ bool ShopWindow::checkFloodCounter(int &counterTime)
return true;
}
-bool ShopWindow::findShopItem(ShopItem *shopItem, int mode)
+bool ShopWindow::findShopItem(const ShopItem *const shopItem, const int mode)
{
if (!shopItem)
return false;
@@ -814,7 +817,7 @@ bool ShopWindow::findShopItem(ShopItem *shopItem, int mode)
for (std::vector<ShopItem*>::const_iterator it = items.begin(),
it_end = items.end(); it != it_end; ++ it)
{
- ShopItem *item = *(it);
+ const ShopItem *const item = *(it);
if (!item)
continue;
@@ -828,19 +831,19 @@ bool ShopWindow::findShopItem(ShopItem *shopItem, int mode)
return false;
}
-int ShopWindow::sumAmount(Item *shopItem)
+int ShopWindow::sumAmount(const Item *const shopItem)
{
if (!player_node || !shopItem)
return 0;
- Inventory *inv = PlayerInfo::getInventory();
+ const Inventory *const inv = PlayerInfo::getInventory();
if (!inv)
return 0;
int sum = 0;
for (unsigned f = 0; f < inv->getSize(); f ++)
{
- Item *item = inv->getItem(f);
+ const Item *const item = inv->getItem(f);
if (item && item->getId() == shopItem->getId())
sum += item->getQuantity();
}
diff --git a/src/gui/shopwindow.h b/src/gui/shopwindow.h
index dc9ae324b..58725afcf 100644
--- a/src/gui/shopwindow.h
+++ b/src/gui/shopwindow.h
@@ -97,20 +97,22 @@ class ShopWindow : public Window, public gcn::ActionListener,
static bool isActive()
{ return !instances.empty(); }
- void setItemSelected(int id)
+ void setItemSelected(const int id)
{ mSelectedItem = id; updateButtonsAndLabels(); }
- void addBuyItem(Item *item, int amount, int price);
+ void addBuyItem(const Item *const item, const int amount,
+ const int price);
- void addSellItem(Item *item, int amount, int price);
+ void addSellItem(const Item *const item, const int amount,
+ const int price);
void loadList();
void saveList();
- void announce(ShopItems *list, int mode);
+ void announce(ShopItems *const list, const int mode);
- void giveList(const std::string &nick, int mode);
+ void giveList(const std::string &nick, const int mode);
void setAcceptPlayer(std::string name)
{ mAcceptPlayer = name; }
@@ -119,19 +121,20 @@ class ShopWindow : public Window, public gcn::ActionListener,
{ return mAcceptPlayer; }
void sendMessage(const std::string &nick, std::string data,
- bool random = false);
+ const bool random = false);
- void showList(const std::string &nick, std::string data);
+ void showList(const std::string &nick, std::string data) const;
- void processRequest(std::string nick, std::string data, int mode);
+ void processRequest(std::string nick, std::string data,
+ const int mode);
- bool findShopItem(ShopItem *shopItem, int mode);
+ bool findShopItem(const ShopItem *const shopItem, const int mode);
- int sumAmount(Item *shopItem);
+ static int sumAmount(const Item *const shopItem);
void updateTimes();
- bool checkFloodCounter(int &counterTime);
+ bool checkFloodCounter(int &counterTime) const;
bool isShopEmpty();
diff --git a/src/gui/shortcutwindow.cpp b/src/gui/shortcutwindow.cpp
index 16e71e6b7..1c9525eeb 100644
--- a/src/gui/shortcutwindow.cpp
+++ b/src/gui/shortcutwindow.cpp
@@ -41,7 +41,7 @@ int ShortcutWindow::mBoxesWidth = 0;
class ShortcutTab : public Tab
{
public:
- ShortcutTab(std::string name, ShortcutContainer* content)
+ ShortcutTab(std::string name, ShortcutContainer *const content)
{
setCaption(name);
mContent = content;
@@ -51,7 +51,7 @@ class ShortcutTab : public Tab
};
ShortcutWindow::ShortcutWindow(const std::string &title,
- ShortcutContainer *content,
+ ShortcutContainer *const content,
std::string skinFile,
int width, int height) :
Window("Window", false, nullptr, skinFile)
@@ -101,7 +101,7 @@ ShortcutWindow::ShortcutWindow(const std::string &title,
}
ShortcutWindow::ShortcutWindow(const std::string &title, std::string skinFile,
- int width, int height) :
+ const int width, const int height) :
Window("Window", false, nullptr, skinFile)
{
setWindowName(title);
@@ -148,16 +148,16 @@ ShortcutWindow::~ShortcutWindow()
mItems = nullptr;
}
-void ShortcutWindow::addTab(std::string name, ShortcutContainer *content)
+void ShortcutWindow::addTab(std::string name, ShortcutContainer *const content)
{
- ScrollArea *scroll = new ScrollArea(content, false);
+ ScrollArea *const scroll = new ScrollArea(content, false);
scroll->setPosition(SCROLL_PADDING, SCROLL_PADDING);
scroll->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER);
- Tab *tab = new ShortcutTab(name, content);
+ Tab *const tab = new ShortcutTab(name, content);
mTabs->addTab(tab, scroll);
}
-int ShortcutWindow::getTabIndex()
+int ShortcutWindow::getTabIndex() const
{
if (!mTabs)
return 0;
@@ -170,11 +170,11 @@ void ShortcutWindow::widgetHidden(const gcn::Event &event)
mItems->widgetHidden(event);
if (mTabs)
{
- ScrollArea *scroll = static_cast<ScrollArea*>(
+ ScrollArea *const scroll = static_cast<ScrollArea *const>(
mTabs->getCurrentWidget());
if (scroll)
{
- ShortcutContainer *content = static_cast<ShortcutContainer*>(
+ ShortcutContainer *const content = static_cast<ShortcutContainer*>(
scroll->getContent());
if (content)
diff --git a/src/gui/shortcutwindow.h b/src/gui/shortcutwindow.h
index bdff5ab0d..9d50665b4 100644
--- a/src/gui/shortcutwindow.h
+++ b/src/gui/shortcutwindow.h
@@ -40,21 +40,22 @@ class ShortcutWindow : public Window
/**
* Constructor.
*/
- ShortcutWindow(const std::string &title, ShortcutContainer *content,
+ ShortcutWindow(const std::string &title,
+ ShortcutContainer *const content,
std::string skinFile = "",
int width = 0, int height = 0);
ShortcutWindow(const std::string &title, std::string skinFile = "",
- int width = 0, int height = 0);
+ const int width = 0, const int height = 0);
/**
* Destructor.
*/
~ShortcutWindow();
- void addTab(std::string name, ShortcutContainer *content);
+ void addTab(std::string name, ShortcutContainer *const content);
- int getTabIndex();
+ int getTabIndex() const;
void widgetHidden(const gcn::Event &event);
diff --git a/src/gui/skilldialog.cpp b/src/gui/skilldialog.cpp
index 6195b92fc..5bd18f540 100644
--- a/src/gui/skilldialog.cpp
+++ b/src/gui/skilldialog.cpp
@@ -66,7 +66,7 @@ public:
int getNumberOfElements()
{ return static_cast<int>(mVisibleSkills.size()); }
- SkillInfo *getSkillAt(int i) const
+ SkillInfo *getSkillAt(const int i) const
{ return mVisibleSkills.at(i); }
std::string getElementAt(int i)
@@ -79,7 +79,7 @@ public:
void updateVisibilities();
- void addSkill(SkillInfo *info)
+ void addSkill(SkillInfo *const info)
{ mSkills.push_back(info); }
private:
@@ -90,7 +90,7 @@ private:
class SkillListBox : public ListBox
{
public:
- SkillListBox(SkillModel *model):
+ SkillListBox(SkillModel *const model):
ListBox(model),
mModel(model),
mPopup(new TextPopup()),
@@ -107,7 +107,7 @@ public:
mPopup = nullptr;
}
- SkillInfo *getSelectedInfo()
+ SkillInfo *getSelectedInfo() const
{
const int selected = getSelected();
if (!mListModel || selected < 0
@@ -124,11 +124,11 @@ public:
if (!mListModel)
return;
- SkillModel* model = static_cast<SkillModel*>(mListModel);
+ SkillModel *const model = static_cast<SkillModel*>(mListModel);
updateAlpha();
- Graphics *graphics = static_cast<Graphics*>(gcnGraphics);
+ Graphics *const graphics = static_cast<Graphics *const>(gcnGraphics);
mHighlightColor.a = static_cast<int>(mAlpha * 255.0f);
graphics->setColor(mHighlightColor);
@@ -147,7 +147,7 @@ public:
i < model->getNumberOfElements();
++i, y += getRowHeight())
{
- SkillInfo *e = model->getSkillAt(i);
+ SkillInfo *const e = model->getSkillAt(i);
if (e)
e->draw(graphics, y, getWidth());
@@ -163,10 +163,10 @@ public:
if (!viewport)
return;
- int y = event.getY() / getRowHeight();
+ const int y = event.getY() / getRowHeight();
if (!mModel || y >= mModel->getNumberOfElements())
return;
- SkillInfo *skill = mModel->getSkillAt(y);
+ const SkillInfo *const skill = mModel->getSkillAt(y);
if (!skill)
return;
@@ -189,7 +189,7 @@ private:
class SkillTab : public Tab
{
public:
- SkillTab(const std::string &name, SkillListBox *listBox):
+ SkillTab(const std::string &name, SkillListBox *const listBox) :
mListBox(listBox)
{
setCaption(name);
@@ -201,7 +201,7 @@ public:
mListBox = nullptr;
}
- SkillInfo *getSelectedInfo()
+ SkillInfo *getSelectedInfo() const
{
if (mListBox)
return mListBox->getSelectedInfo();
@@ -256,23 +256,25 @@ void SkillDialog::action(const gcn::ActionEvent &event)
{
if (event.getId() == "inc")
{
- SkillTab *tab = static_cast<SkillTab*>(mTabs->getSelectedTab());
+ const SkillTab *const tab = static_cast<const SkillTab *const>(
+ mTabs->getSelectedTab());
if (tab)
{
- if (SkillInfo *info = tab->getSelectedInfo())
+ if (const SkillInfo *const info = tab->getSelectedInfo())
Net::getPlayerHandler()->increaseSkill(info->id);
}
}
else if (event.getId() == "sel")
{
- SkillTab *tab = static_cast<SkillTab*>(mTabs->getSelectedTab());
+ const SkillTab *const tab = static_cast<const SkillTab *const>(
+ mTabs->getSelectedTab());
if (tab)
{
- if (SkillInfo *info = tab->getSelectedInfo())
+ if (const SkillInfo *const info = tab->getSelectedInfo())
{
mUseButton->setEnabled(info->range > 0);
- int num = itemShortcutWindow->getTabIndex();
+ const int num = itemShortcutWindow->getTabIndex();
if (num >= 0 && num < static_cast<int>(SHORTCUT_TABS)
&& itemShortcut[num])
{
@@ -288,13 +290,14 @@ void SkillDialog::action(const gcn::ActionEvent &event)
}
else if (event.getId() == "use")
{
- SkillTab *tab = static_cast<SkillTab*>(mTabs->getSelectedTab());
+ const SkillTab *const tab = static_cast<const SkillTab *const>(
+ mTabs->getSelectedTab());
if (tab)
{
- const SkillInfo *info = tab->getSelectedInfo();
+ const SkillInfo *const info = tab->getSelectedInfo();
if (info && player_node && player_node->getTarget())
{
- const Being *being = player_node->getTarget();
+ const Being *const being = player_node->getTarget();
if (being)
{
Net::getSpecialHandler()->useBeing(info->level,
@@ -309,13 +312,13 @@ void SkillDialog::action(const gcn::ActionEvent &event)
}
}
-std::string SkillDialog::update(int id)
+std::string SkillDialog::update(const int id)
{
- SkillMap::const_iterator i = mSkills.find(id);
+ const SkillMap::const_iterator i = mSkills.find(id);
if (i != mSkills.end())
{
- SkillInfo *info = i->second;
+ SkillInfo *const info = i->second;
if (info)
{
info->update();
@@ -351,7 +354,7 @@ void SkillDialog::loadSkills(const std::string &file)
return;
XML::Document doc(file);
- XmlNodePtr root = doc.rootNode();
+ const XmlNodePtr root = doc.rootNode();
int setCount = 0;
std::string setName;
@@ -365,11 +368,11 @@ void SkillDialog::loadSkills(const std::string &file)
if (Net::getNetworkType() != ServerInfo::MANASERV)
{
- SkillModel *model = new SkillModel();
+ SkillModel *const model = new SkillModel();
if (!mDefaultModel)
mDefaultModel = model;
- SkillInfo *skill = new SkillInfo;
+ SkillInfo *const skill = new SkillInfo;
skill->id = 1;
skill->name = _("basic");
skill->dispName = _("Skill: basic, Id: 1");
@@ -410,7 +413,7 @@ void SkillDialog::loadSkills(const std::string &file)
setName = XML::getProperty(set, "name",
strprintf(_("Skill Set %d"), setCount));
- SkillModel *model = new SkillModel();
+ SkillModel *const model = new SkillModel();
if (!mDefaultModel)
mDefaultModel = model;
@@ -418,12 +421,13 @@ void SkillDialog::loadSkills(const std::string &file)
{
if (xmlNameEqual(node, "skill"))
{
- int id = atoi(XML::getProperty(node, "id", "-1").c_str());
+ const int id = atoi(XML::getProperty(
+ node, "id", "-1").c_str());
std::string name = XML::langProperty(node, "name",
strprintf(_("Skill %d"), id));
std::string icon = XML::getProperty(node, "icon", "");
- SkillInfo *skill = new SkillInfo;
+ SkillInfo *const skill = new SkillInfo;
skill->id = static_cast<short unsigned>(id);
skill->name = name;
skill->dispName = strprintf(_("Skill: %s, Id: %d"),
@@ -464,13 +468,14 @@ void SkillDialog::loadSkills(const std::string &file)
update();
}
-bool SkillDialog::updateSkill(int id, int range, bool modifiable)
+bool SkillDialog::updateSkill(const int id, const int range,
+ const bool modifiable)
{
- SkillMap::const_iterator it = mSkills.find(id);
+ const SkillMap::const_iterator it = mSkills.find(id);
if (it != mSkills.end())
{
- SkillInfo *info = it->second;
+ SkillInfo *const info = it->second;
if (info)
{
info->modifiable = modifiable;
@@ -482,11 +487,12 @@ bool SkillDialog::updateSkill(int id, int range, bool modifiable)
return false;
}
-void SkillDialog::addSkill(int id, int level, int range, bool modifiable)
+void SkillDialog::addSkill(const int id, const int level, const int range,
+ const bool modifiable)
{
if (mDefaultModel)
{
- SkillInfo *skill = new SkillInfo;
+ SkillInfo *const skill = new SkillInfo;
skill->id = static_cast<short unsigned>(id);
skill->name = "Unknown skill Id: " + toString(id);
skill->dispName = "Unknown skill Id: " + toString(id);
@@ -538,7 +544,7 @@ SkillInfo::~SkillInfo()
void SkillInfo::setIcon(const std::string &iconPath)
{
- ResourceManager *res = ResourceManager::getInstance();
+ ResourceManager *const res = ResourceManager::getInstance();
if (!iconPath.empty())
{
icon = res->getImage(iconPath);
@@ -553,12 +559,12 @@ void SkillInfo::setIcon(const std::string &iconPath)
void SkillInfo::update()
{
- int baseLevel = PlayerInfo::getStatBase(
+ const int baseLevel = PlayerInfo::getStatBase(
static_cast<PlayerInfo::Attribute>(id));
- int effLevel = PlayerInfo::getStatEffective(
+ const int effLevel = PlayerInfo::getStatEffective(
static_cast<PlayerInfo::Attribute>(id));
- std::pair<int, int> exp = PlayerInfo::getStatExperience(
+ const std::pair<int, int> exp = PlayerInfo::getStatExperience(
static_cast<PlayerInfo::Attribute>(id));
if (!modifiable && baseLevel == 0 && effLevel == 0 && exp.second == 0)
@@ -573,7 +579,7 @@ void SkillInfo::update()
return;
}
- bool updateVisibility = !visible;
+ const bool updateVisibility = !visible;
visible = true;
if (effLevel != baseLevel)
@@ -609,7 +615,7 @@ void SkillInfo::update()
model->updateVisibilities();
}
-void SkillInfo::draw(Graphics *graphics, int y, int width)
+void SkillInfo::draw(Graphics *const graphics, const int y, const int width)
{
graphics->drawImage(icon, 1, y);
graphics->drawText(name, 34, y);
@@ -643,12 +649,12 @@ void SkillDialog::widgetResized(const gcn::Event &event)
mTabs->fixSize();
}
-void SkillDialog::useItem(int itemId)
+void SkillDialog::useItem(const int itemId)
{
- const SkillInfo *info = mSkills[itemId - SKILL_MIN_ID];
+ const SkillInfo *const info = mSkills[itemId - SKILL_MIN_ID];
if (info && player_node && player_node->getTarget())
{
- const Being *being = player_node->getTarget();
+ const Being *const being = player_node->getTarget();
if (being)
{
Net::getSpecialHandler()->useBeing(info->level,
@@ -659,10 +665,11 @@ void SkillDialog::useItem(int itemId)
void SkillDialog::updateTabSelection()
{
- SkillTab *tab = static_cast<SkillTab*>(mTabs->getSelectedTab());
+ const SkillTab *const tab = static_cast<SkillTab*>(
+ mTabs->getSelectedTab());
if (tab)
{
- if (SkillInfo *info = tab->getSelectedInfo())
+ if (const SkillInfo *const info = tab->getSelectedInfo())
mUseButton->setEnabled(info->range > 0);
else
mUseButton->setEnabled(false);
diff --git a/src/gui/skilldialog.h b/src/gui/skilldialog.h
index d5c332740..09781d4ac 100644
--- a/src/gui/skilldialog.h
+++ b/src/gui/skilldialog.h
@@ -71,7 +71,7 @@ struct SkillInfo
void update();
- void draw(Graphics *graphics, int y, int width);
+ void draw(Graphics *const graphics, const int y, const int width);
};
typedef std::vector<SkillInfo*> SkillList;
@@ -96,7 +96,7 @@ class SkillDialog : public Window, public gcn::ActionListener
/**
* Update the given skill's display
*/
- std::string update(int id);
+ std::string update(const int id);
/**
* Update other parts of the display
@@ -105,9 +105,10 @@ class SkillDialog : public Window, public gcn::ActionListener
void loadSkills(const std::string &file);
- bool updateSkill(int id, int range, bool modifiable);
+ bool updateSkill(const int id, const int range, const bool modifiable);
- void addSkill(int id, int level, int range, bool modifiable);
+ void addSkill(const int id, const int level, const int range,
+ const bool modifiable);
SkillInfo* getSkill(int id);
@@ -116,7 +117,7 @@ class SkillDialog : public Window, public gcn::ActionListener
void widgetResized(const gcn::Event &event);
- void useItem(int itemId);
+ void useItem(const int itemId);
void updateTabSelection();