diff options
author | Andrei Karas <akaras@inbox.ru> | 2015-10-30 17:47:23 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2015-10-30 18:19:54 +0300 |
commit | bd429077f8985c5ee45a53009d02e2f495b4ad90 (patch) | |
tree | aeaaaba43b24de34af6f332ac200b976b7056371 /src | |
parent | b0388c5ad0a49f65becdee1120d4df476410dd01 (diff) | |
download | plus-bd429077f8985c5ee45a53009d02e2f495b4ad90.tar.gz plus-bd429077f8985c5ee45a53009d02e2f495b4ad90.tar.bz2 plus-bd429077f8985c5ee45a53009d02e2f495b4ad90.tar.xz plus-bd429077f8985c5ee45a53009d02e2f495b4ad90.zip |
Add strong typed bool enum ShowEmptyRows and use it in itemcontainer.
Diffstat (limited to 'src')
-rw-r--r-- | src/CMakeLists.txt | 1 | ||||
-rw-r--r-- | src/Makefile.am | 1 | ||||
-rw-r--r-- | src/enums/simpletypes/showemptyrows.h | 28 | ||||
-rw-r--r-- | src/gui/widgets/itemcontainer.cpp | 11 | ||||
-rw-r--r-- | src/gui/widgets/itemcontainer.h | 3 | ||||
-rw-r--r-- | src/gui/windows/npcdialog.cpp | 2 |
6 files changed, 42 insertions, 4 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 1a1f51580..cf0a7a6d0 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1123,6 +1123,7 @@ SET(SRCS enums/simpletypes/protected.h enums/simpletypes/sfx.h enums/simpletypes/showcenter.h + enums/simpletypes/showemptyrows.h enums/simpletypes/skiperror.h enums/simpletypes/speech.h enums/simpletypes/trading.h diff --git a/src/Makefile.am b/src/Makefile.am index 65c1bbfc7..8f54837ad 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -586,6 +586,7 @@ SRC += events/actionevent.h \ enums/simpletypes/protected.h \ enums/simpletypes/sfx.h \ enums/simpletypes/showcenter.h \ + enums/simpletypes/showemptyrows.h \ enums/simpletypes/skiperror.h \ enums/simpletypes/speech.h \ enums/simpletypes/trading.h \ diff --git a/src/enums/simpletypes/showemptyrows.h b/src/enums/simpletypes/showemptyrows.h new file mode 100644 index 000000000..4656682ef --- /dev/null +++ b/src/enums/simpletypes/showemptyrows.h @@ -0,0 +1,28 @@ +/* + * The ManaPlus Client + * Copyright (C) 2015 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#ifndef ENUMS_SIMPLETYPES_SHOWEMPTYROWS_H +#define ENUMS_SIMPLETYPES_SHOWEMPTYROWS_H + +#include "enums/simpletypes/booldefines.h" + +defBoolEnum(ShowEmptyRows); + +#endif // ENUMS_SIMPLETYPES_SHOWEMPTYROWS_H diff --git a/src/gui/widgets/itemcontainer.cpp b/src/gui/widgets/itemcontainer.cpp index d9d2b5f4b..5ae542357 100644 --- a/src/gui/widgets/itemcontainer.cpp +++ b/src/gui/widgets/itemcontainer.cpp @@ -159,6 +159,7 @@ namespace ItemContainer::ItemContainer(const Widget2 *const widget, Inventory *const inventory, + const ShowEmptyRows showEmptyRows, const ForceQuantity forceQuantity) : Widget(widget), KeyListener(), @@ -192,6 +193,7 @@ ItemContainer::ItemContainer(const Widget2 *const widget, mPaddingItemY(mSkin ? mSkin->getOption("paddingItemY", 0) : 0), mSelectionStatus(SEL_NONE), mForceQuantity(forceQuantity), + mShowEmptyRows(showEmptyRows), mDescItems(false), mRedraw(true) { @@ -262,7 +264,8 @@ void ItemContainer::draw(Graphics *graphics) mVertexes->clear(); const unsigned int invSize = mInventory->getSize(); - const int maxRows = invSize / mGridColumns; + const int maxRows = mShowEmptyRows == ShowEmptyRows_true ? + invSize / mGridColumns : mGridRows; for (int j = 0; j < maxRows; j++) { const int intY0 = j * mBoxHeight; @@ -385,7 +388,8 @@ void ItemContainer::safeDraw(Graphics *graphics) if (mCellBackgroundImg) { const unsigned int invSize = mInventory->getSize(); - const int maxRows = invSize / mGridColumns; + const int maxRows = mShowEmptyRows == ShowEmptyRows_true ? + invSize / mGridColumns : mGridRows; for (int j = 0; j < maxRows; j++) { const int intY0 = j * mBoxHeight; @@ -865,7 +869,8 @@ void ItemContainer::adjustHeight() ++mGridRows; const unsigned int invSize = mInventory->getSize(); - const int maxRows = invSize / mGridColumns; + const int maxRows = mShowEmptyRows == ShowEmptyRows_true ? + invSize / mGridColumns : mGridRows; setHeight(maxRows * mBoxHeight); updateMatrix(); diff --git a/src/gui/widgets/itemcontainer.h b/src/gui/widgets/itemcontainer.h index a8d7c794e..42aeb2684 100644 --- a/src/gui/widgets/itemcontainer.h +++ b/src/gui/widgets/itemcontainer.h @@ -28,6 +28,7 @@ #include "listeners/widgetlistener.h" #include "enums/simpletypes/forcequantity.h" +#include "enums/simpletypes/showemptyrows.h" #include "gui/widgets/widget.h" @@ -59,6 +60,7 @@ class ItemContainer final : public Widget, */ ItemContainer(const Widget2 *const widget, Inventory *const inventory, + const ShowEmptyRows showEmptyRows = ShowEmptyRows_false, const ForceQuantity forceQuantity = ForceQuantity_false); A_DELETE_COPY(ItemContainer) @@ -207,6 +209,7 @@ class ItemContainer final : public Widget, int mPaddingItemY; SelectionState mSelectionStatus; ForceQuantity mForceQuantity; + ShowEmptyRows mShowEmptyRows; bool mDescItems; bool mRedraw; }; diff --git a/src/gui/windows/npcdialog.cpp b/src/gui/windows/npcdialog.cpp index f601c6405..e94904a08 100644 --- a/src/gui/windows/npcdialog.cpp +++ b/src/gui/windows/npcdialog.cpp @@ -123,7 +123,7 @@ NpcDialog::NpcDialog(const BeingId npcId) : // TRANSLATORS: npc dialog button mResetButton(new Button(this, _("Reset"), "reset", this)), mInventory(new Inventory(InventoryType::NPC, 1)), - mItemContainer(new ItemContainer(this, mInventory)), + mItemContainer(new ItemContainer(this, mInventory, ShowEmptyRows_true)), mItemScrollArea(new ScrollArea(this, mItemContainer, getOptionBool("showitemsbackground"), "npc_listbackground.xml")), mInputState(NPC_INPUT_NONE), |