From 8cd16a9a9ca605137276379361b0328af736c2cc Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Wed, 28 Oct 2015 18:18:13 +0300 Subject: Add support for add images into buttons in skinned npc dialogs. --- src/gui/widgets/button.h | 6 ++++++ src/gui/windows/npcdialog.cpp | 20 +++++++++++++++----- 2 files changed, 21 insertions(+), 5 deletions(-) (limited to 'src/gui') diff --git a/src/gui/widgets/button.h b/src/gui/widgets/button.h index cb96fa7e3..67ba32da8 100644 --- a/src/gui/widgets/button.h +++ b/src/gui/widgets/button.h @@ -253,6 +253,12 @@ class Button final : public Widget, void setWindow(Widget *const widget) override final; + void setImageWidth(const int width) + { mImageWidth = width; } + + void setImageHeight(const int height) + { mImageHeight = height; } + enum { BUTTON_STANDARD = 0, // 0 diff --git a/src/gui/windows/npcdialog.cpp b/src/gui/windows/npcdialog.cpp index 8e9ef526a..bb6a84eb7 100644 --- a/src/gui/windows/npcdialog.cpp +++ b/src/gui/windows/npcdialog.cpp @@ -1146,12 +1146,22 @@ void NpcDialog::createSkinControls() FOR_EACH (std::vector::const_iterator, it, dialog->buttons) { const NpcButtonInfo *const info = *it; - Button *const button = new Button(this, - info->name, - "skin_" + info->value, - this); - + Button *const button = new Button(this); + button->setCaption(info->name); + button->setActionEventId("skin_" + info->value); + button->addActionListener(this); button->setPosition(info->x, info->y); + if (!info->image.empty()) + { + button->setImageWidth(info->imageWidth); + button->setImageHeight(info->imageHeight); + button->loadImageSet(info->image); + } mSkinContainer->add(button); + logger->log("test 1"); + button->adjustSize(); + logger->log("test 2"); + button->setWidth(20); + button->setHeight(20); } } -- cgit v1.2.3-70-g09d2