summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui')
-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
4 files changed, 61 insertions, 17 deletions
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