summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/charcreatedialog.cpp3
-rw-r--r--src/gui/charselectdialog.cpp5
-rw-r--r--src/gui/chatwindow.cpp16
-rw-r--r--src/gui/editserverdialog.cpp9
-rw-r--r--src/gui/gui.cpp4
-rw-r--r--src/gui/inventorywindow.cpp16
-rw-r--r--src/gui/logindialog.cpp9
-rw-r--r--src/gui/npcpostdialog.cpp10
-rw-r--r--src/gui/npcpostdialog.h2
-rw-r--r--src/gui/outfitwindow.cpp3
-rw-r--r--src/gui/sdlinput.cpp1
-rw-r--r--src/gui/serverdialog.cpp5
-rw-r--r--src/gui/setup_input.cpp80
-rw-r--r--src/gui/setup_input.h15
-rw-r--r--src/gui/setup_relations.cpp5
-rw-r--r--src/gui/setupactiondata.h4
-rw-r--r--src/gui/statuspopup.cpp5
-rw-r--r--src/gui/statuspopup.h5
-rw-r--r--src/gui/tradewindow.cpp3
-rw-r--r--src/gui/updaterwindow.cpp18
-rw-r--r--src/gui/viewport.cpp16
-rw-r--r--src/gui/widgets/browserbox.cpp3
-rw-r--r--src/gui/widgets/emoteshortcutcontainer.cpp2
-rw-r--r--src/gui/worldselectdialog.cpp9
24 files changed, 139 insertions, 109 deletions
diff --git a/src/gui/charcreatedialog.cpp b/src/gui/charcreatedialog.cpp
index 5c27b7440..e90a12a0d 100644
--- a/src/gui/charcreatedialog.cpp
+++ b/src/gui/charcreatedialog.cpp
@@ -434,7 +434,8 @@ void CharCreateDialog::setAttributes(const StringVect &labels,
int w = 480;
int h = 350;
- for (unsigned i = 0, sz = labels.size(); i < sz; i++)
+ for (unsigned i = 0, sz = static_cast<unsigned>(labels.size());
+ i < sz; i++)
{
mAttributeLabel[i] = new Label(labels[i]);
mAttributeLabel[i]->setWidth(70);
diff --git a/src/gui/charselectdialog.cpp b/src/gui/charselectdialog.cpp
index 77c8ea55d..1d82c09d6 100644
--- a/src/gui/charselectdialog.cpp
+++ b/src/gui/charselectdialog.cpp
@@ -211,7 +211,8 @@ void CharSelectDialog::action(const gcn::ActionEvent &event)
// Check if a button of a character was pressed
const gcn::Widget *sourceParent = event.getSource()->getParent();
int selected = -1;
- for (size_t i = 0, sz = mCharacterEntries.size(); i < sz; ++i)
+ for (unsigned int i = 0, sz = static_cast<unsigned int>(
+ mCharacterEntries.size()); i < sz; ++i)
{
if (mCharacterEntries[i] == sourceParent)
{
@@ -540,7 +541,7 @@ bool CharSelectDialog::selectByName(const std::string &name,
if (mCharacterEntries[i])
mCharacterEntries[i]->requestFocus();
if (selAction == Choose)
- attemptCharacterSelect(i);
+ attemptCharacterSelect(static_cast<int>(i));
return true;
}
}
diff --git a/src/gui/chatwindow.cpp b/src/gui/chatwindow.cpp
index 21613bc73..cb3ed8da8 100644
--- a/src/gui/chatwindow.cpp
+++ b/src/gui/chatwindow.cpp
@@ -753,8 +753,8 @@ void ChatWindow::mouseReleased(gcn::MouseEvent &event A_UNUSED)
void ChatWindow::keyPressed(gcn::KeyEvent &event)
{
const int key = event.getKey().getValue();
- int actionId = static_cast<KeyEvent*>(&event)->getActionId();
- if (actionId == Input::KEY_GUI_DOWN)
+ const int actionId = static_cast<KeyEvent*>(&event)->getActionId();
+ if (actionId == static_cast<int>(Input::KEY_GUI_DOWN))
{
if (mCurHist != mHistory.end())
{
@@ -778,7 +778,7 @@ void ChatWindow::keyPressed(gcn::KeyEvent &event)
mChatInput->setText("");
}
}
- else if (actionId == Input::KEY_GUI_UP &&
+ else if (actionId == static_cast<int>(Input::KEY_GUI_UP) &&
mCurHist != mHistory.begin() && !mHistory.empty())
{
// Move backward through the history
@@ -787,7 +787,7 @@ void ChatWindow::keyPressed(gcn::KeyEvent &event)
mChatInput->setCaretPosition(static_cast<unsigned>(
mChatInput->getText().length()));
}
- else if (actionId == Input::KEY_GUI_INSERT &&
+ else if (actionId == static_cast<int>(Input::KEY_GUI_INSERT) &&
mChatInput->getText() != "")
{
// Add the current message to the history and clear the text
@@ -796,18 +796,18 @@ void ChatWindow::keyPressed(gcn::KeyEvent &event)
mCurHist = mHistory.end();
mChatInput->setText("");
}
- else if (actionId == Input::KEY_GUI_TAB &&
+ else if (actionId == static_cast<int>(Input::KEY_GUI_TAB) &&
mChatInput->getText() != "")
{
autoComplete();
return;
}
- else if (actionId == Input::KEY_GUI_CANCEL &&
+ else if (actionId == static_cast<int>(Input::KEY_GUI_CANCEL) &&
mChatInput->isVisible())
{
mChatInput->processVisible(false);
}
- else if (actionId == Input::KEY_CHAT_PREV_HISTORY &&
+ else if (actionId == static_cast<int>(Input::KEY_CHAT_PREV_HISTORY) &&
mChatInput->isVisible())
{
ChatTab *tab = getFocused();
@@ -839,7 +839,7 @@ void ChatWindow::keyPressed(gcn::KeyEvent &event)
mChatInput->getText().length()));
}
}
- else if (actionId == Input::KEY_CHAT_NEXT_HISTORY &&
+ else if (actionId == static_cast<int>(Input::KEY_CHAT_NEXT_HISTORY) &&
mChatInput->isVisible())
{
ChatTab *tab = getFocused();
diff --git a/src/gui/editserverdialog.cpp b/src/gui/editserverdialog.cpp
index 28103e350..9701e2b3d 100644
--- a/src/gui/editserverdialog.cpp
+++ b/src/gui/editserverdialog.cpp
@@ -269,14 +269,15 @@ void EditServerDialog::action(const gcn::ActionEvent &event)
void EditServerDialog::keyPressed(gcn::KeyEvent &keyEvent)
{
- int actionId = static_cast<KeyEvent*>(&keyEvent)->getActionId();
+ const int actionId = static_cast<KeyEvent*>(
+ &keyEvent)->getActionId();
- if (actionId == Input::KEY_GUI_CANCEL)
+ if (actionId == static_cast<int>(Input::KEY_GUI_CANCEL))
{
scheduleDelete();
}
- else if (actionId == Input::KEY_GUI_SELECT
- || actionId == Input::KEY_GUI_SELECT2)
+ else if (actionId == static_cast<int>(Input::KEY_GUI_SELECT)
+ || actionId == static_cast<int>(Input::KEY_GUI_SELECT2))
{
action(gcn::ActionEvent(nullptr, mOkButton->getActionEventId()));
}
diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp
index 84a13ddba..fe6163877 100644
--- a/src/gui/gui.cpp
+++ b/src/gui/gui.cpp
@@ -366,8 +366,8 @@ bool Gui::handleKeyInput2()
// If the key event hasn't been consumed and
// tabbing is enable check for tab press and
// change focus.
- if (!keyEventConsumed && mTabbing
- && keyInput.getActionId() == Input::KEY_GUI_TAB
+ if (!keyEventConsumed && mTabbing && keyInput.getActionId()
+ == static_cast<int>(Input::KEY_GUI_TAB)
&& keyInput.getType() == gcn::KeyInput::PRESSED)
{
if (keyInput.isShiftPressed())
diff --git a/src/gui/inventorywindow.cpp b/src/gui/inventorywindow.cpp
index 093ca7c24..16adbbb75 100644
--- a/src/gui/inventorywindow.cpp
+++ b/src/gui/inventorywindow.cpp
@@ -363,7 +363,7 @@ void InventoryWindow::action(const gcn::ActionEvent &event)
}
else
{
- if (inputManager.isActionActive(Input::KEY_MOD))
+ if (inputManager.isActionActive(static_cast<int>(Input::KEY_MOD)))
{
Net::getInventoryHandler()->dropItem(
item, item->getQuantity());
@@ -414,10 +414,10 @@ void InventoryWindow::mouseClicked(gcn::MouseEvent &event)
gui->resetClickCount();
const bool mod = (isStorageActive() && inputManager.isActionActive(
- Input::KEY_MOD));
+ static_cast<int>(Input::KEY_MOD)));
const bool mod2 = (tradeWindow && tradeWindow->isVisible()
- && inputManager.isActionActive(Input::KEY_MOD));
+ && inputManager.isActionActive(static_cast<int>(Input::KEY_MOD)));
if (!mod && !mod2 && event.getButton() == gcn::MouseEvent::RIGHT)
{
@@ -534,14 +534,20 @@ void InventoryWindow::mouseClicked(gcn::MouseEvent &event)
void InventoryWindow::keyPressed(gcn::KeyEvent &event)
{
- if (static_cast<KeyEvent*>(&event)->getActionId() == Input::KEY_GUI_MOD)
+ if (static_cast<KeyEvent*>(&event)->getActionId()
+ == static_cast<int>(Input::KEY_GUI_MOD))
+ {
mSplit = true;
+ }
}
void InventoryWindow::keyReleased(gcn::KeyEvent &event)
{
- if (static_cast<KeyEvent*>(&event)->getActionId() == Input::KEY_GUI_MOD)
+ if (static_cast<KeyEvent*>(&event)->getActionId()
+ == static_cast<int>(Input::KEY_GUI_MOD))
+ {
mSplit = false;
+ }
}
void InventoryWindow::valueChanged(const gcn::SelectionEvent &event A_UNUSED)
diff --git a/src/gui/logindialog.cpp b/src/gui/logindialog.cpp
index 65b1541f8..0ae29a730 100644
--- a/src/gui/logindialog.cpp
+++ b/src/gui/logindialog.cpp
@@ -315,13 +315,14 @@ void LoginDialog::keyPressed(gcn::KeyEvent &keyEvent)
return;
}
- int actionId = static_cast<KeyEvent*>(&keyEvent)->getActionId();
- if (actionId == Input::KEY_GUI_CANCEL)
+ const int actionId = static_cast<KeyEvent*>(
+ &keyEvent)->getActionId();
+ if (actionId == static_cast<int>(Input::KEY_GUI_CANCEL))
{
action(gcn::ActionEvent(nullptr, mServerButton->getActionEventId()));
}
- else if (actionId == Input::KEY_GUI_SELECT
- || actionId == Input::KEY_GUI_SELECT2)
+ else if (actionId == static_cast<int>(Input::KEY_GUI_SELECT)
+ || actionId == static_cast<int>(Input::KEY_GUI_SELECT2))
{
action(gcn::ActionEvent(nullptr, mLoginButton->getActionEventId()));
}
diff --git a/src/gui/npcpostdialog.cpp b/src/gui/npcpostdialog.cpp
index f1c2cacea..7871ba09c 100644
--- a/src/gui/npcpostdialog.cpp
+++ b/src/gui/npcpostdialog.cpp
@@ -38,7 +38,7 @@
NpcPostDialog::DialogList NpcPostDialog::instances;
-NpcPostDialog::NpcPostDialog(int npcId):
+NpcPostDialog::NpcPostDialog(const int npcId):
Window(_("NPC"), false, nullptr, "npcpost.xml"),
ActionListener(),
mNpcId(npcId),
@@ -48,16 +48,16 @@ NpcPostDialog::NpcPostDialog(int npcId):
setContentSize(400, 180);
// create text field for receiver
- gcn::Label *senderText = new Label(_("To:"));
+ gcn::Label *const senderText = new Label(_("To:"));
senderText->setPosition(5, 5);
mSender->setPosition(senderText->getWidth() + 5, 5);
mSender->setWidth(65);
// create button for sending
- Button *sendButton = new Button(_("Send"), "send", this);
+ Button *const sendButton = new Button(_("Send"), "send", this);
sendButton->setPosition(400 - sendButton->getWidth(),
170 - sendButton->getHeight());
- Button *cancelButton = new Button(_("Cancel"), "cancel", this);
+ Button *const cancelButton = new Button(_("Cancel"), "cancel", this);
cancelButton->setPosition(sendButton->getX()
- (cancelButton->getWidth() + 2), sendButton->getY());
@@ -66,7 +66,7 @@ NpcPostDialog::NpcPostDialog(int npcId):
mText->setEditable(true);
// create scroll box for letter text
- ScrollArea *scrollArea = new ScrollArea(mText);
+ ScrollArea *const scrollArea = new ScrollArea(mText);
scrollArea->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER);
scrollArea->setDimension(gcn::Rectangle(
5, mSender->getHeight() + 5,
diff --git a/src/gui/npcpostdialog.h b/src/gui/npcpostdialog.h
index b00f7bda0..af5e735a2 100644
--- a/src/gui/npcpostdialog.h
+++ b/src/gui/npcpostdialog.h
@@ -36,7 +36,7 @@ public:
/**
* Constructor
*/
- NpcPostDialog(int npcId);
+ NpcPostDialog(const int npcId);
~NpcPostDialog();
diff --git a/src/gui/outfitwindow.cpp b/src/gui/outfitwindow.cpp
index 2127bc6cf..2c4e913f8 100644
--- a/src/gui/outfitwindow.cpp
+++ b/src/gui/outfitwindow.cpp
@@ -518,7 +518,8 @@ std::string OutfitWindow::keyName(int number)
{
if (number < 0 || number >= SHORTCUT_EMOTES)
return "";
- return inputManager.getKeyStringLong(Input::KEY_EMOTE_1 + number);
+ return inputManager.getKeyStringLong(static_cast<int>(
+ Input::KEY_EMOTE_1) + number);
}
void OutfitWindow::next()
diff --git a/src/gui/sdlinput.cpp b/src/gui/sdlinput.cpp
index 7d484e082..2b6b8363b 100644
--- a/src/gui/sdlinput.cpp
+++ b/src/gui/sdlinput.cpp
@@ -58,6 +58,7 @@
#include "gui/sdlinput.h"
+#include "keydata.h"
#include "keyinput.h"
#include "inputmanager.h"
diff --git a/src/gui/serverdialog.cpp b/src/gui/serverdialog.cpp
index 28e0c43e6..6e6f99841 100644
--- a/src/gui/serverdialog.cpp
+++ b/src/gui/serverdialog.cpp
@@ -636,7 +636,8 @@ void ServerDialog::loadServers(bool addNew)
MutexLocker tempLock(&mMutex);
// Add the server to the local list if it's not already present
bool found = false;
- for (unsigned int i = 0, sz = mServers.size(); i < sz; i++)
+ for (unsigned int i = 0, sz = static_cast<unsigned int>(
+ mServers.size()); i < sz; i++)
{
if (mServers[i] == server)
{
@@ -713,7 +714,7 @@ void ServerDialog::saveCustomServers(const ServerInfo &currentServer,
int savedServerCount = 0;
- for (unsigned i = 0, sz = mServers.size();
+ for (unsigned i = 0, sz = static_cast<unsigned>(mServers.size());
i < sz && savedServerCount < MAX_SERVERLIST; ++ i)
{
const ServerInfo &server = mServers.at(i);
diff --git a/src/gui/setup_input.cpp b/src/gui/setup_input.cpp
index 7d7c1842b..2d5795e71 100644
--- a/src/gui/setup_input.cpp
+++ b/src/gui/setup_input.cpp
@@ -54,7 +54,6 @@ class KeyListModel : public gcn::ListModel
{
public:
KeyListModel() :
- gcn::ListModel(),
mDataNum(0),
mSize(0)
{
@@ -75,13 +74,13 @@ class KeyListModel : public gcn::ListModel
/**
* Sets element from container.
*/
- void setElementAt(int i, const std::string &caption)
+ void setElementAt(const int i, const std::string &caption)
{ setupActionData[selectedData][i].text = caption; }
- void setSize(int size)
+ void setSize(const int size)
{ mSize = size; }
- void setDataNum(int num)
+ void setDataNum(const int num)
{ mDataNum = num; }
private:
@@ -89,17 +88,22 @@ class KeyListModel : public gcn::ListModel
int mSize;
};
-Setup_Input::Setup_Input():
+Setup_Input::Setup_Input() :
+ SetupTab(),
mKeyListModel(new KeyListModel),
mKeyList(new ListBox(mKeyListModel)),
+ mAssignKeyButton(new Button(_("Assign"), "assign", this)),
+ mUnassignKeyButton(new Button(_("Unassign"), "unassign", this)),
+ mDefaultButton(new Button(_("Default"), "default", this)),
+ mResetKeysButton(new Button(_("Reset all keys"), "resetkeys", this)),
+ mTabs(new TabStrip(config.getIntValue("fontSize") + 10)),
mKeySetting(false),
- mActionDataSize(nullptr)
+ mActionDataSize(new int [9])
{
inputManager.setSetupInput(this);
setName(_("Input"));
selectedData = 0;
- mActionDataSize = new int [9];
for (int f = 0; f < setupGroups; f ++)
{
@@ -115,25 +119,20 @@ Setup_Input::Setup_Input():
mKeyList->addActionListener(this);
- ScrollArea *scrollArea = new ScrollArea(mKeyList,
+ ScrollArea *const scrollArea = new ScrollArea(mKeyList,
true, "setup_input_background.xml");
scrollArea->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER);
- mAssignKeyButton = new Button(_("Assign"), "assign", this);
mAssignKeyButton->addActionListener(this);
mAssignKeyButton->setEnabled(false);
- mUnassignKeyButton = new Button(_("Unassign"), "unassign", this);
mUnassignKeyButton->addActionListener(this);
mUnassignKeyButton->setEnabled(false);
- mResetKeysButton = new Button(_("Reset all keys"), "resetkeys", this);
mResetKeysButton->addActionListener(this);
- mDefaultButton = new Button(_("Default"), "default", this);
mDefaultButton->addActionListener(this);
- mTabs = new TabStrip(config.getIntValue("fontSize") + 10);
mTabs->addActionListener(this);
mTabs->setActionEventId("tabs_");
int k = 0;
@@ -217,11 +216,11 @@ void Setup_Input::action(const gcn::ActionEvent &event)
{
if (!mKeySetting)
{
- int i(mKeyList->getSelected());
+ const int i(mKeyList->getSelected());
if (i >= 0 && i < mActionDataSize[selectedData])
{
if (setupActionData[selectedData][i].actionId
- == Input::KEY_NO_VALUE)
+ == static_cast<int>(Input::KEY_NO_VALUE))
{
mAssignKeyButton->setEnabled(false);
mUnassignKeyButton->setEnabled(false);
@@ -239,11 +238,11 @@ void Setup_Input::action(const gcn::ActionEvent &event)
mKeySetting = true;
mAssignKeyButton->setEnabled(false);
keyboard.setEnabled(false);
- int i(mKeyList->getSelected());
+ const int i(mKeyList->getSelected());
if (i >= 0 && i < mActionDataSize[selectedData])
{
const SetupActionData &key = setupActionData[selectedData][i];
- int ik = key.actionId;
+ const int ik = key.actionId;
inputManager.setNewKeyIndex(ik);
mKeyListModel->setElementAt(i, std::string(
gettext(key.name.c_str())) + ": ?");
@@ -251,15 +250,15 @@ void Setup_Input::action(const gcn::ActionEvent &event)
}
else if (id == "unassign")
{
- int i(mKeyList->getSelected());
+ const int i(mKeyList->getSelected());
if (i >= 0 && i < mActionDataSize[selectedData])
{
const SetupActionData &key = setupActionData[selectedData][i];
- int ik = key.actionId;
+ const int ik = key.actionId;
inputManager.setNewKeyIndex(ik);
refreshAssignedKey(mKeyList->getSelected());
inputManager.unassignKey();
- inputManager.setNewKeyIndex(Input::KEY_NO_VALUE);
+ inputManager.setNewKeyIndex(static_cast<int>(Input::KEY_NO_VALUE));
}
mAssignKeyButton->setEnabled(true);
}
@@ -271,11 +270,11 @@ void Setup_Input::action(const gcn::ActionEvent &event)
}
else if (id == "default")
{
- int i(mKeyList->getSelected());
+ const int i(mKeyList->getSelected());
if (i >= 0 && i < mActionDataSize[selectedData])
{
const SetupActionData &key = setupActionData[selectedData][i];
- int ik = key.actionId;
+ const int ik = key.actionId;
inputManager.makeDefault(ik);
refreshKeys();
}
@@ -300,10 +299,10 @@ void Setup_Input::action(const gcn::ActionEvent &event)
}
}
-void Setup_Input::refreshAssignedKey(int index)
+void Setup_Input::refreshAssignedKey(const int index)
{
const SetupActionData &key = setupActionData[selectedData][index];
- if (key.actionId == Input::KEY_NO_VALUE)
+ if (key.actionId == static_cast<int>(Input::KEY_NO_VALUE))
{
const std::string str = " \342\200\225\342\200\225\342\200\225"
"\342\200\225\342\200\225 ";
@@ -318,16 +317,16 @@ void Setup_Input::refreshAssignedKey(int index)
}
}
-void Setup_Input::newKeyCallback(int index)
+void Setup_Input::newKeyCallback(const int index)
{
mKeySetting = false;
- int i = keyToSetupData(index);
+ const int i = keyToSetupData(index);
if (i >= 0)
refreshAssignedKey(i);
mAssignKeyButton->setEnabled(true);
}
-int Setup_Input::keyToSetupData(int index)
+int Setup_Input::keyToSetupData(const int index) const
{
for (int i = 0; i < mActionDataSize[selectedData]; i++)
{
@@ -338,7 +337,7 @@ int Setup_Input::keyToSetupData(int index)
return -1;
}
-std::string Setup_Input::keyToString(int index)
+std::string Setup_Input::keyToString(const int index) const
{
for (int f = 0; f < setupGroups; f ++)
{
@@ -363,12 +362,13 @@ void Setup_Input::keyUnresolved()
if (mKeySetting)
{
newKeyCallback(inputManager.getNewKeyIndex());
- inputManager.setNewKeyIndex(Input::KEY_NO_VALUE);
+ inputManager.setNewKeyIndex(static_cast<int>(Input::KEY_NO_VALUE));
}
}
-void Setup_Input::fixTranslation(SetupActionData *actionDatas, int actionStart,
- int actionEnd, std::string text)
+void Setup_Input::fixTranslation(SetupActionData *const actionDatas,
+ const int actionStart, const int actionEnd,
+ const std::string &text) const
{
int k = 0;
@@ -388,15 +388,17 @@ void Setup_Input::fixTranslation(SetupActionData *actionDatas, int actionStart,
void Setup_Input::fixTranslations()
{
- fixTranslation(setupActionData1, Input::KEY_SHORTCUT_1,
- Input::KEY_SHORTCUT_20, "Item Shortcut %d");
+ fixTranslation(setupActionData1, static_cast<int>(Input::KEY_SHORTCUT_1),
+ static_cast<int>(Input::KEY_SHORTCUT_20), "Item Shortcut %d");
- fixTranslation(setupActionData3, Input::KEY_EMOTE_1,
- Input::KEY_EMOTE_48, "Emote Shortcut %d");
+ fixTranslation(setupActionData3, static_cast<int>(Input::KEY_EMOTE_1),
+ static_cast<int>(Input::KEY_EMOTE_48), "Emote Shortcut %d");
- fixTranslation(setupActionData4, Input::KEY_OUTFIT_1,
- Input::KEY_OUTFIT_48, "Outfit Shortcut %d");
+ fixTranslation(setupActionData4, static_cast<int>(Input::KEY_OUTFIT_1),
+ static_cast<int>(Input::KEY_OUTFIT_48), "Outfit Shortcut %d");
- fixTranslation(setupActionData7, Input::KEY_MOVE_TO_POINT_1,
- Input::KEY_MOVE_TO_POINT_48, "Move to point Shortcut %d");
+ fixTranslation(setupActionData7, static_cast<int>(
+ Input::KEY_MOVE_TO_POINT_1),
+ static_cast<int>(Input::KEY_MOVE_TO_POINT_48),
+ "Move to point Shortcut %d");
}
diff --git a/src/gui/setup_input.h b/src/gui/setup_input.h
index 89b102881..bed487b68 100644
--- a/src/gui/setup_input.h
+++ b/src/gui/setup_input.h
@@ -24,6 +24,8 @@
#ifndef GUI_SETUP_INPUT_H
#define GUI_SETUP_INPUT_H
+#include "keydata.h"
+
#include "gui/widgets/setuptab.h"
#include <guichan/actionlistener.hpp>
@@ -58,12 +60,12 @@ class Setup_Input : public SetupTab
/**
* Get an update on the assigned key.
*/
- void refreshAssignedKey(int index);
+ void refreshAssignedKey(const int index);
/**
* The callback function when a new key has been pressed.
*/
- void newKeyCallback(int index);
+ void newKeyCallback(const int index);
/**
* Shorthand method to update all the keys.
@@ -75,15 +77,16 @@ class Setup_Input : public SetupTab
*/
void keyUnresolved();
- int keyToSetupData(int index);
+ int keyToSetupData(const int index) const;
- std::string keyToString(int index);
+ std::string keyToString(const int index) const;
private:
void fixTranslations();
- void fixTranslation(SetupActionData *actionDatas, int actionStart,
- int actionEnd, std::string text);
+ void fixTranslation(SetupActionData *const actionDatas,
+ const int actionStart, const int actionEnd,
+ const std::string &text) const;
class KeyListModel *mKeyListModel;
gcn::ListBox *mKeyList;
diff --git a/src/gui/setup_relations.cpp b/src/gui/setup_relations.cpp
index 20ef3b3d4..45030087b 100644
--- a/src/gui/setup_relations.cpp
+++ b/src/gui/setup_relations.cpp
@@ -152,7 +152,8 @@ public:
mPlayers = player_names;
// set up widgets
- for (unsigned int r = 0, sz = player_names->size(); r < sz; ++r)
+ for (unsigned int r = 0, sz = static_cast<unsigned int>(
+ player_names->size()); r < sz; ++r)
{
std::string name = (*player_names)[r];
gcn::Widget *widget = new Label(name);
@@ -323,7 +324,7 @@ void Setup_Relations::reset()
player_relations.getPlayerIgnoreStrategy())
{
- selection = i;
+ selection = static_cast<int>(i);
break;
}
}
diff --git a/src/gui/setupactiondata.h b/src/gui/setupactiondata.h
index ee85f6ca5..1cf6dfeed 100644
--- a/src/gui/setupactiondata.h
+++ b/src/gui/setupactiondata.h
@@ -1533,7 +1533,7 @@ static SetupActionData setupActionData8[] =
}
};
-static SetupActionData *setupActionData[] =
+static SetupActionData *const setupActionData[] =
{
setupActionData0,
setupActionData7,
@@ -1546,7 +1546,7 @@ static SetupActionData *setupActionData[] =
setupActionData8
};
-static const char *pages[] =
+static const char *const pages[] =
{
N_("Basic"),
N_("Move"),
diff --git a/src/gui/statuspopup.cpp b/src/gui/statuspopup.cpp
index cc0f5c030..dae8b15fe 100644
--- a/src/gui/statuspopup.cpp
+++ b/src/gui/statuspopup.cpp
@@ -192,10 +192,11 @@ void StatusPopup::setLabelText(gcn::Label *label, const char *text, int key)
inputManager.getKeyValueString(key).c_str()));
}
-void StatusPopup::setLabelText2(gcn::Label *label, std::string text, int key)
+void StatusPopup::setLabelText2(gcn::Label *label, std::string text,
+ Input::KeyAction key)
{
label->setCaption(strprintf("%s %s", text.c_str(),
- inputManager.getKeyValueString(key).c_str()));
+ inputManager.getKeyValueString(static_cast<int>(key)).c_str()));
label->adjustSize();
}
diff --git a/src/gui/statuspopup.h b/src/gui/statuspopup.h
index 49ca7727f..0921fbb7f 100644
--- a/src/gui/statuspopup.h
+++ b/src/gui/statuspopup.h
@@ -24,6 +24,8 @@
#ifndef StatusPopup_H
#define StatusPopup_H
+#include "keydata.h"
+
#include "gui/widgets/popup.h"
#include "resources/iteminfo.h"
@@ -67,7 +69,8 @@ class StatusPopup : public Popup
void setLabelText(gcn::Label *label, const char *text, int key);
- void setLabelText2(gcn::Label *label, std::string text, int key);
+ void setLabelText2(gcn::Label *label, std::string text,
+ Input::KeyAction key);
gcn::Label *mMoveType;
gcn::Label *mCrazyMoveType;
diff --git a/src/gui/tradewindow.cpp b/src/gui/tradewindow.cpp
index b8ac3c433..82dff1dd8 100644
--- a/src/gui/tradewindow.cpp
+++ b/src/gui/tradewindow.cpp
@@ -229,7 +229,8 @@ void TradeWindow::reset()
setMoney(0);
mMoneyField->setEnabled(true);
mMoneyField->setText("");
- mMoneyLabel->setForegroundColor(Theme::getThemeColor(Theme::TEXT));
+ mMoneyLabel->setForegroundColor(Theme::getThemeColor(
+ static_cast<int>(Theme::TEXT)));
mAddButton->setEnabled(true);
mMoneyChangeButton->setEnabled(true);
mGotMoney = 0;
diff --git a/src/gui/updaterwindow.cpp b/src/gui/updaterwindow.cpp
index 49977ae4b..81fe7a9cd 100644
--- a/src/gui/updaterwindow.cpp
+++ b/src/gui/updaterwindow.cpp
@@ -263,15 +263,15 @@ void UpdaterWindow::action(const gcn::ActionEvent &event)
void UpdaterWindow::keyPressed(gcn::KeyEvent &keyEvent)
{
- int actionId = static_cast<KeyEvent*>(&keyEvent)->getActionId();
+ const int actionId = static_cast<KeyEvent*>(&keyEvent)->getActionId();
- if (actionId == Input::KEY_GUI_CANCEL)
+ if (actionId == static_cast<int>(Input::KEY_GUI_CANCEL))
{
action(gcn::ActionEvent(nullptr, mCancelButton->getActionEventId()));
Client::setState(STATE_LOGIN);
}
- else if (actionId == Input::KEY_GUI_SELECT
- || actionId == Input::KEY_GUI_SELECT2)
+ else if (actionId == static_cast<int>(Input::KEY_GUI_SELECT)
+ || actionId == static_cast<int>(Input::KEY_GUI_SELECT2))
{
if (mDownloadStatus == UPDATE_COMPLETE ||
mDownloadStatus == UPDATE_ERROR)
@@ -534,7 +534,7 @@ void UpdaterWindow::loadUpdates()
}
std::string fixPath = mUpdatesDir + "/fix";
- const unsigned sz = mUpdateFiles.size();
+ const unsigned sz = static_cast<unsigned>(mUpdateFiles.size());
for (mUpdateIndex = 0; mUpdateIndex < sz; mUpdateIndex++)
{
UpdaterWindow::addUpdateFile(resman, mUpdatesDir, fixPath,
@@ -559,8 +559,8 @@ void UpdaterWindow::loadLocalUpdates(std::string dir)
}
std::string fixPath = dir + "/fix";
- for (unsigned int updateIndex = 0, sz = updateFiles.size();
- updateIndex < sz; updateIndex ++)
+ for (unsigned int updateIndex = 0, sz = static_cast<unsigned int>(
+ updateFiles.size()); updateIndex < sz; updateIndex ++)
{
UpdaterWindow::addUpdateFile(resman, dir, fixPath,
updateFiles[updateIndex].name, false);
@@ -575,8 +575,8 @@ void UpdaterWindow::loadManaPlusUpdates(std::string dir,
std::vector<updateFile> updateFiles
= loadXMLFile(fixPath + "/" + xmlUpdateFile);
- for (unsigned int updateIndex = 0, sz = updateFiles.size();
- updateIndex < sz; updateIndex ++)
+ for (unsigned int updateIndex = 0, sz = static_cast<unsigned int>(
+ updateFiles.size()); updateIndex < sz; updateIndex ++)
{
std::string name = updateFiles[updateIndex].name;
if (strStartWith(name, "manaplus_"))
diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp
index 194ad7310..6103c8b86 100644
--- a/src/gui/viewport.cpp
+++ b/src/gui/viewport.cpp
@@ -499,18 +499,20 @@ void Viewport::mousePressed(gcn::MouseEvent &event)
}
}
else if (player_node->withinAttackRange(mHoverBeing) ||
- inputManager.isActionActive(Input::KEY_ATTACK))
+ inputManager.isActionActive(static_cast<int>(
+ Input::KEY_ATTACK)))
{
validateSpeed();
if (player_node != mHoverBeing)
{
player_node->attack(mHoverBeing,
!inputManager.isActionActive(
- Input::KEY_STOP_ATTACK));
+ static_cast<int>(Input::KEY_STOP_ATTACK)));
return;
}
}
- else if (!inputManager.isActionActive(Input::KEY_ATTACK))
+ else if (!inputManager.isActionActive(static_cast<int>(
+ Input::KEY_ATTACK)))
{
validateSpeed();
if (player_node != mHoverBeing)
@@ -528,7 +530,8 @@ void Viewport::mousePressed(gcn::MouseEvent &event)
player_node->pickUp(mHoverItem);
}
// Just walk around
- else if (!inputManager.isActionActive(Input::KEY_ATTACK))
+ else if (!inputManager.isActionActive(static_cast<int>(
+ Input::KEY_ATTACK)))
{
validateSpeed();
player_node->stopAttack();
@@ -929,8 +932,9 @@ void Viewport::returnCamera()
void Viewport::validateSpeed()
{
- if (!inputManager.isActionActive(Input::KEY_TARGET_ATTACK)
- && !inputManager.isActionActive(Input::KEY_ATTACK))
+ if (!inputManager.isActionActive(static_cast<int>(
+ Input::KEY_TARGET_ATTACK)) && !inputManager.isActionActive(
+ static_cast<int>(Input::KEY_ATTACK)))
{
if (Game::instance())
Game::instance()->setValidSpeed();
diff --git a/src/gui/widgets/browserbox.cpp b/src/gui/widgets/browserbox.cpp
index 2c8f64a02..ea5210eb8 100644
--- a/src/gui/widgets/browserbox.cpp
+++ b/src/gui/widgets/browserbox.cpp
@@ -228,7 +228,8 @@ void BrowserBox::addRow(const std::string &row, bool atTop)
i != i_end; ++ i)
{
std::string tempRow = *i;
- for (unsigned int j = 0, sz = tempRow.size(); j < sz; j++)
+ for (unsigned int j = 0, sz = static_cast<unsigned int>(
+ tempRow.size()); j < sz; j++)
{
std::string character = tempRow.substr(j, 1);
x += font->getWidth(character);
diff --git a/src/gui/widgets/emoteshortcutcontainer.cpp b/src/gui/widgets/emoteshortcutcontainer.cpp
index 2347edd0c..a1b496dc5 100644
--- a/src/gui/widgets/emoteshortcutcontainer.cpp
+++ b/src/gui/widgets/emoteshortcutcontainer.cpp
@@ -131,7 +131,7 @@ void EmoteShortcutContainer::draw(gcn::Graphics *graphics)
graphics->setColor(getForegroundColor());
g->drawText(key, emoteX + 2, emoteY + 2, gcn::Graphics::LEFT);
}
- unsigned sz = mEmoteImg.size();
+ unsigned sz = static_cast<unsigned>(mEmoteImg.size());
for (unsigned i = 0; i < mMaxItems; i++)
{
if (i < sz && mEmoteImg[i] && mEmoteImg[i]->sprite)
diff --git a/src/gui/worldselectdialog.cpp b/src/gui/worldselectdialog.cpp
index 13f2694b0..d5bb0ae40 100644
--- a/src/gui/worldselectdialog.cpp
+++ b/src/gui/worldselectdialog.cpp
@@ -141,15 +141,16 @@ void WorldSelectDialog::action(const gcn::ActionEvent &event)
void WorldSelectDialog::keyPressed(gcn::KeyEvent &keyEvent)
{
- int actionId = static_cast<KeyEvent*>(&keyEvent)->getActionId();
+ const int actionId = static_cast<KeyEvent*>(
+ &keyEvent)->getActionId();
- if (actionId == Input::KEY_GUI_CANCEL)
+ if (actionId == static_cast<int>(Input::KEY_GUI_CANCEL))
{
action(gcn::ActionEvent(nullptr,
mChangeLoginButton->getActionEventId()));
}
- else if (actionId == Input::KEY_GUI_SELECT
- || actionId == Input::KEY_GUI_SELECT2)
+ else if (actionId == static_cast<int>(Input::KEY_GUI_SELECT)
+ || actionId == static_cast<int>(Input::KEY_GUI_SELECT2))
{
action(gcn::ActionEvent(nullptr, mChooseWorld->getActionEventId()));
}