diff options
author | Andrei Karas <akaras@inbox.ru> | 2012-08-24 22:48:35 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2012-08-24 22:48:35 +0300 |
commit | b474de4a54c9b1d4d863971e40b807588d554436 (patch) | |
tree | 761e71f86ea232d1688ee2838bd2294c59dea947 /src/gui | |
parent | a316d537dce50f4b4e1e10f5c26a7851baddbd8b (diff) | |
download | manaverse-b474de4a54c9b1d4d863971e40b807588d554436.tar.gz manaverse-b474de4a54c9b1d4d863971e40b807588d554436.tar.bz2 manaverse-b474de4a54c9b1d4d863971e40b807588d554436.tar.xz manaverse-b474de4a54c9b1d4d863971e40b807588d554436.zip |
replace defines to consts.
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/chatwindow.cpp | 3 | ||||
-rw-r--r-- | src/gui/chatwindow.h | 2 | ||||
-rw-r--r-- | src/gui/outfitwindow.cpp | 36 | ||||
-rw-r--r-- | src/gui/outfitwindow.h | 4 | ||||
-rw-r--r-- | src/gui/sdlfont.cpp | 2 | ||||
-rw-r--r-- | src/gui/sdlfont.h | 2 | ||||
-rw-r--r-- | src/gui/setup_relations.cpp | 18 | ||||
-rw-r--r-- | src/gui/skilldialog.cpp | 3 | ||||
-rw-r--r-- | src/gui/skilldialog.h | 2 | ||||
-rw-r--r-- | src/gui/specialswindow.cpp | 4 | ||||
-rw-r--r-- | src/gui/widgets/chattab.cpp | 2 | ||||
-rw-r--r-- | src/gui/widgets/itemcontainer.cpp | 2 | ||||
-rw-r--r-- | src/gui/widgets/spellshortcutcontainer.cpp | 8 |
13 files changed, 46 insertions, 42 deletions
diff --git a/src/gui/chatwindow.cpp b/src/gui/chatwindow.cpp index b0318a9aa..c69e7b8a2 100644 --- a/src/gui/chatwindow.cpp +++ b/src/gui/chatwindow.cpp @@ -150,8 +150,7 @@ public: } }; -#define ACTION_COLOR_PICKER "color picker" - +static const char *ACTION_COLOR_PICKER = "color picker"; ChatWindow::ChatWindow(): Window(_("Chat"), false, nullptr, "chat.xml"), diff --git a/src/gui/chatwindow.h b/src/gui/chatwindow.h index ddc9574f2..0638d4e7a 100644 --- a/src/gui/chatwindow.h +++ b/src/gui/chatwindow.h @@ -56,7 +56,7 @@ namespace gcn class DropDown; } -#define DEFAULT_CHAT_WINDOW_SCROLL 7 // 1 means `1/8th of the window size'. +const int DEFAULT_CHAT_WINDOW_SCROLL = 7; enum Own { diff --git a/src/gui/outfitwindow.cpp b/src/gui/outfitwindow.cpp index 7ce62aa4e..93257c6c3 100644 --- a/src/gui/outfitwindow.cpp +++ b/src/gui/outfitwindow.cpp @@ -133,7 +133,7 @@ void OutfitWindow::load(bool oldConfig) memset(mItems, -1, sizeof(mItems)); memset(mItemColors, 1, sizeof(mItemColors)); - for (int o = 0; o < OUTFITS_COUNT; o++) + for (unsigned o = 0; o < OUTFITS_COUNT; o++) { std::string outfit = cfg->getValue("Outfit" + toString(o), "-1"); std::string buf; @@ -169,8 +169,8 @@ void OutfitWindow::load(bool oldConfig) true); } mAwayOutfit = cfg->getValue("OutfitAwayIndex", OUTFITS_COUNT - 1); - if (mAwayOutfit >= OUTFITS_COUNT) - mAwayOutfit = OUTFITS_COUNT - 1; + if (mAwayOutfit >= static_cast<int>(OUTFITS_COUNT)) + mAwayOutfit = static_cast<int>(OUTFITS_COUNT) - 1; if (mAwayOutfitCheck) mAwayOutfitCheck->setSelected(mAwayOutfit == mCurrentOutfit); @@ -180,10 +180,10 @@ void OutfitWindow::save() { std::string outfitStr; std::string outfitColorsStr; - for (int o = 0; o < OUTFITS_COUNT; o++) + for (unsigned o = 0; o < OUTFITS_COUNT; o++) { bool good = false; - for (int i = 0; i < OUTFIT_ITEM_COUNT; i++) + for (unsigned i = 0; i < OUTFIT_ITEM_COUNT; i++) { int res = mItems[o][i] ? mItems[o][i] : -1; if (res != -1) @@ -235,7 +235,7 @@ void OutfitWindow::action(const gcn::ActionEvent &event) } else if (eventId == "unequip") { - if (mCurrentOutfit < OUTFITS_COUNT) + if (mCurrentOutfit < static_cast<int>(OUTFITS_COUNT)) mItemsUnequip[mCurrentOutfit] = mUnequipCheck->isSelected(); } else if (eventId == "equip") @@ -257,10 +257,10 @@ void OutfitWindow::wearOutfit(int outfit, bool unwearEmpty, bool select) bool isEmpty = true; Item *item; - if (outfit < 0 || outfit > OUTFITS_COUNT) + if (outfit < 0 || outfit > static_cast<int>(OUTFITS_COUNT)) return; - for (int i = 0; i < OUTFIT_ITEM_COUNT; i++) + for (unsigned i = 0; i < OUTFIT_ITEM_COUNT; i++) { item = PlayerInfo::getInventory()->findItem( mItems[outfit][i], mItemColors[outfit][i]); @@ -274,7 +274,7 @@ void OutfitWindow::wearOutfit(int outfit, bool unwearEmpty, bool select) } } - if ((!isEmpty || unwearEmpty) && outfit < OUTFITS_COUNT + if ((!isEmpty || unwearEmpty) && outfit < static_cast<int>(OUTFITS_COUNT) && mItemsUnequip[outfit]) { unequipNotInOutfit(outfit); @@ -293,13 +293,13 @@ void OutfitWindow::copyOutfit(int outfit) void OutfitWindow::copyOutfit(int src, int dst) { - if (src < 0 || src > OUTFITS_COUNT - || dst < 0 || dst > OUTFITS_COUNT) + if (src < 0 || src > static_cast<int>(OUTFITS_COUNT) + || dst < 0 || dst > static_cast<int>(OUTFITS_COUNT)) { return; } - for (int i = 0; i < OUTFIT_ITEM_COUNT; i++) + for (unsigned int i = 0; i < OUTFIT_ITEM_COUNT; i++) mItems[dst][i] = mItems[src][i]; } @@ -308,7 +308,7 @@ void OutfitWindow::draw(gcn::Graphics *graphics) Window::draw(graphics); Graphics *g = static_cast<Graphics*>(graphics); - for (int i = 0; i < OUTFIT_ITEM_COUNT; i++) + for (unsigned int i = 0; i < OUTFIT_ITEM_COUNT; i++) { const int itemX = 10 + ((i % mGridWidth) * mBoxWidth); const int itemY = 25 + ((i / mGridWidth) * mBoxHeight); @@ -476,7 +476,7 @@ int OutfitWindow::getIndexFromGrid(int pointX, int pointY) const return -1; const int index = (((pointY - 25) / mBoxHeight) * mGridWidth) + (pointX - 10) / mBoxWidth; - if (index >= OUTFIT_ITEM_COUNT || index < 0) + if (index >= static_cast<int>(OUTFIT_ITEM_COUNT) || index < 0) return -1; return index; } @@ -519,7 +519,7 @@ std::string OutfitWindow::keyName(int number) void OutfitWindow::next() { - if (mCurrentOutfit < (OUTFITS_COUNT - 1)) + if (mCurrentOutfit < (static_cast<int>(OUTFITS_COUNT) - 1)) mCurrentOutfit++; else mCurrentOutfit = 0; @@ -547,7 +547,7 @@ void OutfitWindow::showCurrentOutfit() void OutfitWindow::wearNextOutfit(bool all) { next(); - if (!all && mCurrentOutfit < OUTFITS_COUNT) + if (!all && mCurrentOutfit < static_cast<int>(OUTFITS_COUNT)) { bool fromStart = false; while (!mItemsUnequip[mCurrentOutfit]) @@ -568,7 +568,7 @@ void OutfitWindow::wearNextOutfit(bool all) void OutfitWindow::wearPreviousOutfit(bool all) { previous(); - if (!all && mCurrentOutfit < OUTFITS_COUNT) + if (!all && mCurrentOutfit < static_cast<int>(OUTFITS_COUNT)) { bool fromStart = false; while (!mItemsUnequip[mCurrentOutfit]) @@ -606,7 +606,7 @@ void OutfitWindow::copyFromEquiped(int dst) { mItems[dst][outfitCell] = item->getId(); mItemColors[dst][outfitCell++] = item->getColor(); - if (outfitCell >= OUTFIT_ITEM_COUNT) + if (outfitCell >= static_cast<int>(OUTFIT_ITEM_COUNT)) break; } } diff --git a/src/gui/outfitwindow.h b/src/gui/outfitwindow.h index 21b78addf..9aae112e3 100644 --- a/src/gui/outfitwindow.h +++ b/src/gui/outfitwindow.h @@ -34,8 +34,8 @@ #define A_PURE #endif -#define OUTFITS_COUNT 100 -#define OUTFIT_ITEM_COUNT 16 +const unsigned int OUTFITS_COUNT = 100; +const unsigned int OUTFIT_ITEM_COUNT = 16; class Button; class CheckBox; diff --git a/src/gui/sdlfont.cpp b/src/gui/sdlfont.cpp index 45119fcec..dc24e0e35 100644 --- a/src/gui/sdlfont.cpp +++ b/src/gui/sdlfont.cpp @@ -334,7 +334,7 @@ int SDLFont::getHeight() const void SDLFont::doClean() { - for (int f = 0; f < CACHES_NUMBER; f ++) + for (unsigned int f = 0; f < CACHES_NUMBER; f ++) { std::list<SDLTextChunk> *cache = &mCache[f]; const size_t size = cache->size(); diff --git a/src/gui/sdlfont.h b/src/gui/sdlfont.h index c2cf1025f..a7bea343f 100644 --- a/src/gui/sdlfont.h +++ b/src/gui/sdlfont.h @@ -35,7 +35,7 @@ #include <list> #include <string> -#define CACHES_NUMBER 256 +const unsigned int CACHES_NUMBER = 256; class SDLTextChunk; diff --git a/src/gui/setup_relations.cpp b/src/gui/setup_relations.cpp index c0558f56f..635adebe2 100644 --- a/src/gui/setup_relations.cpp +++ b/src/gui/setup_relations.cpp @@ -40,16 +40,16 @@ #include "utils/dtor.h" #include "utils/gettext.h" -#define COLUMNS_NR 2 // name plus listbox -#define NAME_COLUMN 0 -#define RELATION_CHOICE_COLUMN 1 +static const int COLUMNS_NR = 2; // name plus listbox +static const int NAME_COLUMN = 0; +static const unsigned int RELATION_CHOICE_COLUMN = 1; -#define ROW_HEIGHT 12 +static const unsigned int ROW_HEIGHT = 12; // The following column widths really shouldn't be hardcoded // but should scale with the size of the widget... except // that, right now, the widget doesn't exactly scale either. -#define NAME_COLUMN_WIDTH 230 -#define RELATION_CHOICE_COLUMN_WIDTH 80 +static const unsigned int NAME_COLUMN_WIDTH = 230; +static const unsigned int RELATION_CHOICE_COLUMN_WIDTH = 80; #define WIDGET_AT(row, column) (((row) * COLUMNS_NR) + column) @@ -227,9 +227,9 @@ public: } }; -#define ACTION_DELETE "delete" -#define ACTION_TABLE "table" -#define ACTION_STRATEGY "strategy" +static const std::string ACTION_DELETE = "delete"; +static const std::string ACTION_TABLE = "table"; +static const std::string ACTION_STRATEGY = "strategy"; Setup_Relations::Setup_Relations(): mPlayerTableTitleModel(new StaticTableModel(1, COLUMNS_NR)), diff --git a/src/gui/skilldialog.cpp b/src/gui/skilldialog.cpp index 723cdc5e1..6195b92fc 100644 --- a/src/gui/skilldialog.cpp +++ b/src/gui/skilldialog.cpp @@ -273,7 +273,8 @@ void SkillDialog::action(const gcn::ActionEvent &event) mUseButton->setEnabled(info->range > 0); int num = itemShortcutWindow->getTabIndex(); - if (num >= 0 && num < SHORTCUT_TABS && itemShortcut[num]) + if (num >= 0 && num < static_cast<int>(SHORTCUT_TABS) + && itemShortcut[num]) { itemShortcut[num]->setItemSelected( info->id + SKILL_MIN_ID); diff --git a/src/gui/skilldialog.h b/src/gui/skilldialog.h index b0f837ccf..d5c332740 100644 --- a/src/gui/skilldialog.h +++ b/src/gui/skilldialog.h @@ -31,7 +31,7 @@ #include <map> #include <vector> -#define SKILL_MIN_ID 200000 +const int SKILL_MIN_ID = 200000; class Button; class Label; diff --git a/src/gui/specialswindow.cpp b/src/gui/specialswindow.cpp index b9c6b2530..d96ef7c85 100644 --- a/src/gui/specialswindow.cpp +++ b/src/gui/specialswindow.cpp @@ -50,8 +50,8 @@ #include "debug.h" -#define SPECIALS_WIDTH 200 -#define SPECIALS_HEIGHT 32 +static const unsigned int SPECIALS_WIDTH = 200; +static const unsigned int SPECIALS_HEIGHT = 32; class SpecialEntry : public Container { diff --git a/src/gui/widgets/chattab.cpp b/src/gui/widgets/chattab.cpp index 102fc9546..0c1bab71a 100644 --- a/src/gui/widgets/chattab.cpp +++ b/src/gui/widgets/chattab.cpp @@ -48,7 +48,7 @@ #include "debug.h" -#define MAX_WORD_SIZE 50 +static const unsigned int MAX_WORD_SIZE = 50; ChatTab::ChatTab(const std::string &name) : Tab(), diff --git a/src/gui/widgets/itemcontainer.cpp b/src/gui/widgets/itemcontainer.cpp index bff17cfa2..ba359118f 100644 --- a/src/gui/widgets/itemcontainer.cpp +++ b/src/gui/widgets/itemcontainer.cpp @@ -364,7 +364,7 @@ void ItemContainer::mousePressed(gcn::MouseEvent &event) mSelectionStatus = SEL_SELECTING; int num = itemShortcutWindow->getTabIndex(); - if (num >= 0 && num < SHORTCUT_TABS) + if (num >= 0 && num < static_cast<int>(SHORTCUT_TABS)) { if (itemShortcut[num]) itemShortcut[num]->setItemSelected(item); diff --git a/src/gui/widgets/spellshortcutcontainer.cpp b/src/gui/widgets/spellshortcutcontainer.cpp index a057eceb4..5236daec4 100644 --- a/src/gui/widgets/spellshortcutcontainer.cpp +++ b/src/gui/widgets/spellshortcutcontainer.cpp @@ -233,7 +233,8 @@ void SpellShortcutContainer::mouseReleased(gcn::MouseEvent &event) if (spell && !spell->isEmpty()) { int num = itemShortcutWindow->getTabIndex(); - if (num >= 0 && num < SHORTCUT_TABS && itemShortcut[num]) + if (num >= 0 && num < static_cast<int>(SHORTCUT_TABS) + && itemShortcut[num]) { itemShortcut[num]->setItemSelected( spell->getId() + SPELL_MIN_ID); @@ -244,8 +245,11 @@ void SpellShortcutContainer::mouseReleased(gcn::MouseEvent &event) else { int num = itemShortcutWindow->getTabIndex(); - if (num >= 0 && num < SHORTCUT_TABS && itemShortcut[num]) + if (num >= 0 && num < static_cast<int>(SHORTCUT_TABS) + && itemShortcut[num]) + { itemShortcut[num]->setItemSelected(-1); + } spellShortcut->setItemSelected(-1); } } |