summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/CMakeLists.txt1
-rw-r--r--src/Makefile.am1
-rw-r--r--src/gui/widgets/itemcontainer.cpp11
-rw-r--r--src/gui/widgets/itemcontainer.h4
-rw-r--r--src/gui/windows/npcdialog.cpp62
-rw-r--r--src/gui/windows/npcdialog.h1
-rw-r--r--src/resources/db/npcdialogdb.cpp12
-rw-r--r--src/resources/npcdialoginfo.h3
-rw-r--r--src/resources/npcinventoryinfo.h40
9 files changed, 118 insertions, 17 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index cf0a7a6d0..8eb7697a7 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -676,6 +676,7 @@ SET(SRCS
resources/npcdialoginfo.h
resources/npcdialogmenuinfo.h
resources/npcimageinfo.h
+ resources/npcinventoryinfo.h
resources/npctextinfo.h
enums/resources/notifyflags.h
enums/resources/notifytypes.h
diff --git a/src/Makefile.am b/src/Makefile.am
index 8f54837ad..25c365104 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -341,6 +341,7 @@ SRC += events/actionevent.h \
resources/npcdialoginfo.h \
resources/npcdialogmenuinfo.h \
resources/npcimageinfo.h \
+ resources/npcinventoryinfo.h \
resources/npctextinfo.h \
enums/resources/notifyflags.h \
enums/resources/notifytypes.h \
diff --git a/src/gui/widgets/itemcontainer.cpp b/src/gui/widgets/itemcontainer.cpp
index ad9f868ad..59d5c8976 100644
--- a/src/gui/widgets/itemcontainer.cpp
+++ b/src/gui/widgets/itemcontainer.cpp
@@ -901,6 +901,11 @@ void ItemContainer::mouseExited(MouseEvent &event A_UNUSED)
void ItemContainer::widgetResized(const Event &event A_UNUSED)
{
+ updateSize();
+}
+
+void ItemContainer::updateSize()
+{
mGridColumns = std::min(mMaxColumns,
std::max(1, mDimension.width / mBoxWidth));
if (mGridColumns > mMaxColumns)
@@ -1088,3 +1093,9 @@ void ItemContainer::setCellBackgroundImage(const std::string &xmlName)
mCellBackgroundImg = Theme::getImageFromThemeXml(xmlName, "");
mRedraw = true;
}
+
+void ItemContainer::setMaxColumns(const int maxColumns)
+{
+ mMaxColumns = maxColumns;
+ updateSize();
+}
diff --git a/src/gui/widgets/itemcontainer.h b/src/gui/widgets/itemcontainer.h
index 4e29cf2c5..b411e0136 100644
--- a/src/gui/widgets/itemcontainer.h
+++ b/src/gui/widgets/itemcontainer.h
@@ -140,6 +140,8 @@ class ItemContainer final : public Widget,
void setCellBackgroundImage(const std::string &xmlName);
+ void setMaxColumns(const int maxColumns);
+
private:
enum Direction
{
@@ -173,6 +175,8 @@ class ItemContainer final : public Widget,
*/
void distributeValueChangedEvent();
+ void updateSize();
+
/**
* Gets the inventory slot index based on the cursor position.
*
diff --git a/src/gui/windows/npcdialog.cpp b/src/gui/windows/npcdialog.cpp
index de74037f8..406e90c1a 100644
--- a/src/gui/windows/npcdialog.cpp
+++ b/src/gui/windows/npcdialog.cpp
@@ -139,8 +139,7 @@ NpcDialog::NpcDialog(const BeingId npcId) :
mCameraX(0),
mCameraY(0),
mShowAvatar(false),
- mLogInteraction(config.getBoolValue("logNpcInGui")),
- mHideText(false)
+ mLogInteraction(config.getBoolValue("logNpcInGui"))
{
// Basic Window Setup
setWindowName("NpcText");
@@ -816,7 +815,7 @@ void NpcDialog::placeMenuControls()
void NpcDialog::placeSkinControls()
{
createSkinControls();
- if (mHideText)
+ if (mDialogInfo && mDialogInfo->hideText)
{
if (mShowAvatar)
{
@@ -896,22 +895,54 @@ void NpcDialog::placeIntInputControls()
void NpcDialog::placeItemInputControls()
{
- if (mShowAvatar)
+ if (mDialogInfo)
{
- place(0, 0, mPlayerBox);
- place(1, 0, mScrollArea, 6, 3);
- place(0, 3, mItemScrollArea, 7, 3);
- place(1, 6, mButton3, 2);
- place(3, 6, mClearButton, 2);
- place(5, 6, mButton, 2);
+ mItemContainer->setCellBackgroundImage(mDialogInfo->inventory.cell);
+ mItemContainer->setMaxColumns(mDialogInfo->inventory.columns);
}
else
{
- place(0, 0, mScrollArea, 6, 3);
- place(0, 3, mItemScrollArea, 6, 3);
- place(0, 6, mButton3, 2);
- place(2, 6, mClearButton, 2);
- place(4, 6, mButton, 2);
+ mItemContainer->setCellBackgroundImage("inventory_cell.xml");
+ mItemContainer->setMaxColumns(10000);
+ }
+
+ if (mDialogInfo && mDialogInfo->hideText)
+ {
+ if (mShowAvatar)
+ {
+ place(0, 0, mPlayerBox);
+ place(1, 0, mItemScrollArea, 7, 3);
+ place(1, 3, mButton3, 2);
+ place(3, 3, mClearButton, 2);
+ place(5, 3, mButton, 2);
+ }
+ else
+ {
+ place(0, 0, mItemScrollArea, 6, 3);
+ place(0, 3, mButton3, 2);
+ place(2, 3, mClearButton, 2);
+ place(4, 3, mButton, 2);
+ }
+ }
+ else
+ {
+ if (mShowAvatar)
+ {
+ place(0, 0, mPlayerBox);
+ place(1, 0, mScrollArea, 6, 3);
+ place(0, 3, mItemScrollArea, 7, 3);
+ place(1, 6, mButton3, 2);
+ place(3, 6, mClearButton, 2);
+ place(5, 6, mButton, 2);
+ }
+ else
+ {
+ place(0, 0, mScrollArea, 6, 3);
+ place(0, 3, mItemScrollArea, 6, 3);
+ place(0, 6, mButton3, 2);
+ place(2, 6, mClearButton, 2);
+ place(4, 6, mButton, 2);
+ }
}
}
@@ -1153,7 +1184,6 @@ void NpcDialog::createSkinControls()
if (!mDialogInfo)
return;
- mHideText = mDialogInfo->hideText;
FOR_EACH (std::vector<NpcImageInfo*>::const_iterator,
it,
mDialogInfo->menu.images)
diff --git a/src/gui/windows/npcdialog.h b/src/gui/windows/npcdialog.h
index 997f97e8a..ffe021bc6 100644
--- a/src/gui/windows/npcdialog.h
+++ b/src/gui/windows/npcdialog.h
@@ -318,7 +318,6 @@ class NpcDialog final : public Window,
int mCameraY;
bool mShowAvatar;
bool mLogInteraction;
- bool mHideText;
};
#endif // GUI_WINDOWS_NPCDIALOG_H
diff --git a/src/resources/db/npcdialogdb.cpp b/src/resources/db/npcdialogdb.cpp
index 5d704b001..365ed018e 100644
--- a/src/resources/db/npcdialogdb.cpp
+++ b/src/resources/db/npcdialogdb.cpp
@@ -119,6 +119,14 @@ static void loadNpcDialogMenu(NpcDialogInfo *const dialog,
}
}
+static void loadNpcDialogInventory(NpcDialogInfo *const dialog,
+ XmlNodePtrConst node)
+{
+ dialog->inventory.cell = XML::getProperty(node, "cell", "");
+ dialog->inventory.columns = XML::getIntProperty(
+ node, "columns", 10000, 1, 10000);
+}
+
static void loadNpcDialog(NpcDialogInfo *const dialog,
const XmlNodePtrConst node)
{
@@ -128,6 +136,10 @@ static void loadNpcDialog(NpcDialogInfo *const dialog,
{
loadNpcDialogMenu(dialog, childNode);
}
+ else if (xmlNameEqual(childNode, "inventory"))
+ {
+ loadNpcDialogInventory(dialog, childNode);
+ }
}
}
diff --git a/src/resources/npcdialoginfo.h b/src/resources/npcdialoginfo.h
index c45ae3b6f..d27804cd5 100644
--- a/src/resources/npcdialoginfo.h
+++ b/src/resources/npcdialoginfo.h
@@ -24,6 +24,7 @@
#include "resources/npcbuttoninfo.h"
#include "resources/npcdialogmenuinfo.h"
#include "resources/npcimageinfo.h"
+#include "resources/npcinventoryinfo.h"
#include "resources/npctextinfo.h"
#include "utils/stringvector.h"
@@ -34,12 +35,14 @@ struct NpcDialogInfo final
{
NpcDialogInfo() :
menu(),
+ inventory(),
name(),
hideText(false)
{
}
NpcDialogMenuInfo menu;
+ NpcInventoryInfo inventory;
std::string name;
bool hideText;
};
diff --git a/src/resources/npcinventoryinfo.h b/src/resources/npcinventoryinfo.h
new file mode 100644
index 000000000..494499851
--- /dev/null
+++ b/src/resources/npcinventoryinfo.h
@@ -0,0 +1,40 @@
+/*
+ * The ManaPlus Client
+ * Copyright (C) 2011-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 RESOURCES_NPCINVENTORYINFO_H
+#define RESOURCES_NPCINVENTORYINFO_H
+
+#include <string>
+
+#include "localconsts.h"
+
+struct NpcInventoryInfo final
+{
+ NpcInventoryInfo() :
+ cell(),
+ columns(100000)
+ {
+ }
+
+ std::string cell;
+ int columns;
+};
+
+#endif // RESOURCES_NPCINVENTORYINFO_H