diff options
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/buydialog.cpp | 46 | ||||
-rw-r--r-- | src/gui/buydialog.h | 4 | ||||
-rw-r--r-- | src/gui/inventorywindow.cpp | 10 | ||||
-rw-r--r-- | src/gui/inventorywindow.h | 4 | ||||
-rw-r--r-- | src/gui/widgets/itemcontainer.cpp | 32 |
5 files changed, 49 insertions, 47 deletions
diff --git a/src/gui/buydialog.cpp b/src/gui/buydialog.cpp index 2fc49d240..404a126b7 100644 --- a/src/gui/buydialog.cpp +++ b/src/gui/buydialog.cpp @@ -49,7 +49,7 @@ #include "debug.h" -static const char *SORT_NAME[7] = +static const char *SORT_NAME_BUY[7] = { N_("unsorted"), N_("by price"), @@ -60,10 +60,10 @@ static const char *SORT_NAME[7] = N_("by type") }; -class SortListModel final : public gcn::ListModel +class SortListModelBuy final : public gcn::ListModel { public: - virtual ~SortListModel() + virtual ~SortListModelBuy() { } virtual int getNumberOfElements() @@ -74,11 +74,11 @@ public: if (i >= getNumberOfElements() || i < 0) return _("???"); - return gettext(SORT_NAME[i]); + return gettext(SORT_NAME_BUY[i]); } }; -static class SortItemPriceFunctor final +class SortItemPriceFunctor final { public: bool operator() (const ShopItem *const item1, @@ -93,9 +93,9 @@ static class SortItemPriceFunctor final return item1->getDisplayName() < item2->getDisplayName(); return price1 < price2; } -} itemPriceSorter; +} itemPriceBuySorter; -static class SortItemNameFunctor final +class SortItemNameFunctor final { public: bool operator() (const ShopItem *const item1, @@ -110,9 +110,9 @@ static class SortItemNameFunctor final return item1->getPrice() < item2->getPrice(); return name1 < name2; } -} itemNameSorter; +} itemNameBuySorter; -static class SortItemIdFunctor final +class SortItemIdFunctor final { public: bool operator() (const ShopItem *const item1, @@ -127,9 +127,9 @@ static class SortItemIdFunctor final return item1->getPrice() < item2->getPrice(); return id1 < id2; } -} itemIdSorter; +} itemIdBuySorter; -static class SortItemWeightFunctor final +class SortItemWeightFunctor final { public: bool operator() (const ShopItem *const item1, @@ -144,9 +144,9 @@ static class SortItemWeightFunctor final return item1->getPrice() < item2->getPrice(); return weight1 < weight2; } -} itemWeightSorter; +} itemWeightBuySorter; -static class SortItemAmountFunctor final +class SortItemAmountFunctor final { public: bool operator() (const ShopItem *const item1, @@ -161,9 +161,9 @@ static class SortItemAmountFunctor final return item1->getPrice() < item2->getPrice(); return amount1 < amount2; } -} itemAmountSorter; +} itemAmountBuySorter; -static class SortItemTypeFunctor final +class SortItemTypeFunctor final { public: bool operator() (const ShopItem *const item1, @@ -178,7 +178,7 @@ static class SortItemTypeFunctor final return item1->getPrice() < item2->getPrice(); return type1 < type2; } -} itemTypeSorter; +} itemTypeBuySorter; BuyDialog::DialogList BuyDialog::instances; @@ -198,7 +198,7 @@ BuyDialog::BuyDialog(std::string nick) : gcn::ActionListener(), gcn::SelectionListener(), mNpcId(-1), mMoney(0), mAmountItems(0), mMaxItems(0), mNick(nick), - mSortModel(new SortListModel), + mSortModel(new SortListModelBuy), mSortDropDown(new DropDown(this, mSortModel, false, false, this, "sort")) { init(); @@ -345,22 +345,22 @@ void BuyDialog::action(const gcn::ActionEvent &event) switch (mSortDropDown->getSelected()) { case 1: - std::sort(items.begin(), items.end(), itemPriceSorter); + std::sort(items.begin(), items.end(), itemPriceBuySorter); break; case 2: - std::sort(items.begin(), items.end(), itemNameSorter); + std::sort(items.begin(), items.end(), itemNameBuySorter); break; case 3: - std::sort(items.begin(), items.end(), itemIdSorter); + std::sort(items.begin(), items.end(), itemIdBuySorter); break; case 4: - std::sort(items.begin(), items.end(), itemWeightSorter); + std::sort(items.begin(), items.end(), itemWeightBuySorter); break; case 5: - std::sort(items.begin(), items.end(), itemAmountSorter); + std::sort(items.begin(), items.end(), itemAmountBuySorter); break; case 6: - std::sort(items.begin(), items.end(), itemTypeSorter); + std::sort(items.begin(), items.end(), itemTypeBuySorter); break; case 0: default: diff --git a/src/gui/buydialog.h b/src/gui/buydialog.h index 76910f247..9d6bf447c 100644 --- a/src/gui/buydialog.h +++ b/src/gui/buydialog.h @@ -32,7 +32,7 @@ class Button; class DropDown; class ShopItems; class ShopListBox; -class SortListModel; +class SortListModelBuy; class IntTextField; class Label; class ListBox; @@ -147,7 +147,7 @@ class BuyDialog final : public Window, int mAmountItems; int mMaxItems; std::string mNick; - SortListModel *mSortModel; + SortListModelBuy *mSortModel; DropDown *mSortDropDown; }; diff --git a/src/gui/inventorywindow.cpp b/src/gui/inventorywindow.cpp index 19043510a..5223e033a 100644 --- a/src/gui/inventorywindow.cpp +++ b/src/gui/inventorywindow.cpp @@ -58,7 +58,7 @@ #include "debug.h" -static const char *SORT_NAME[6] = +static const char *SORT_NAME_INVENTORY[6] = { N_("default"), N_("by name"), @@ -68,10 +68,10 @@ static const char *SORT_NAME[6] = N_("by type") }; -class SortListModel final : public gcn::ListModel +class SortListModelInv final : public gcn::ListModel { public: - virtual ~SortListModel() + virtual ~SortListModelInv() { } virtual int getNumberOfElements() @@ -82,7 +82,7 @@ public: if (i >= getNumberOfElements() || i < 0) return _("???"); - return gettext(SORT_NAME[i]); + return gettext(SORT_NAME_INVENTORY[i]); } }; @@ -107,7 +107,7 @@ InventoryWindow::InventoryWindow(Inventory *const inventory): mWeightBar(nullptr), mSlotsBar(new ProgressBar(this, 0.0f, 100, 0, Theme::PROG_INVY_SLOTS)), mFilter(nullptr), - mSortModel(new SortListModel), + mSortModel(new SortListModelInv), mSortDropDown(new DropDown(this, mSortModel, false, false, this, "sort")), mNameFilter(new TextField(this, "", true, this, "namefilter", true)), mSortDropDownCell(nullptr), diff --git a/src/gui/inventorywindow.h b/src/gui/inventorywindow.h index ad40bb5df..b6bcbd304 100644 --- a/src/gui/inventorywindow.h +++ b/src/gui/inventorywindow.h @@ -42,7 +42,7 @@ class ItemContainer; class Label; class LayoutCell; class ProgressBar; -class SortListModel; +class SortListModelInv; class TabStrip; class TextField; @@ -174,7 +174,7 @@ class InventoryWindow final : public Window, ProgressBar *mWeightBar; ProgressBar *mSlotsBar; TabStrip *mFilter; - SortListModel *mSortModel; + SortListModelInv *mSortModel; DropDown *mSortDropDown; TextField *mNameFilter; LayoutCell *mSortDropDownCell; diff --git a/src/gui/widgets/itemcontainer.cpp b/src/gui/widgets/itemcontainer.cpp index 70c938559..b677ce83a 100644 --- a/src/gui/widgets/itemcontainer.cpp +++ b/src/gui/widgets/itemcontainer.cpp @@ -62,7 +62,7 @@ class ItemIdPair final Item* mItem; }; -static class SortItemAlphaFunctor final +class SortItemAlphaFunctor final { public: bool operator() (const ItemIdPair *const pair1, @@ -74,9 +74,9 @@ static class SortItemAlphaFunctor final return (pair1->mItem->getInfo().getName() < pair2->mItem->getInfo().getName()); } -} itemAlphaSorter; +} itemAlphaInvSorter; -static class SortItemIdFunctor final +class SortItemIdFunctor final { public: bool operator() (const ItemIdPair *const pair1, @@ -87,9 +87,9 @@ static class SortItemIdFunctor final return pair1->mItem->getId() < pair2->mItem->getId(); } -} itemIdSorter; +} itemIdInvSorter; -static class SortItemWeightFunctor final +class SortItemWeightFunctor final { public: bool operator() (const ItemIdPair *const pair1, @@ -107,9 +107,9 @@ static class SortItemWeightFunctor final } return w1 < w2; } -} itemWeightSorter; +} itemWeightInvSorter; -static class SortItemAmountFunctor final +class SortItemAmountFunctor final { public: bool operator() (const ItemIdPair *const pair1, @@ -127,9 +127,9 @@ static class SortItemAmountFunctor final } return c1 < c2; } -} itemAmountSorter; +} itemAmountInvSorter; -static class SortItemTypeFunctor final +class SortItemTypeFunctor final { public: bool operator() (const ItemIdPair *const pair1, @@ -147,7 +147,7 @@ static class SortItemTypeFunctor final } return t1 < t2; } -} itemTypeSorter; +} itemTypeInvSorter; ItemContainer::ItemContainer(const Widget2 *const widget, Inventory *const inventory, @@ -554,21 +554,23 @@ void ItemContainer::updateMatrix() default: break; case 1: - std::sort(sortedItems.begin(), sortedItems.end(), itemAlphaSorter); + std::sort(sortedItems.begin(), sortedItems.end(), + itemAlphaInvSorter); break; case 2: - std::sort(sortedItems.begin(), sortedItems.end(), itemIdSorter); + std::sort(sortedItems.begin(), sortedItems.end(), itemIdInvSorter); break; case 3: std::sort(sortedItems.begin(), sortedItems.end(), - itemWeightSorter); + itemWeightInvSorter); break; case 4: std::sort(sortedItems.begin(), sortedItems.end(), - itemAmountSorter); + itemAmountInvSorter); break; case 5: - std::sort(sortedItems.begin(), sortedItems.end(), itemTypeSorter); + std::sort(sortedItems.begin(), sortedItems.end(), + itemTypeInvSorter); break; } |