From b0cddefee60e56525fe4da0404f18af71c14acaf Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Thu, 29 Oct 2015 00:41:08 +0300 Subject: Ignore npc dialog skin if skin not exists. --- src/gui/windows/npcdialog.cpp | 34 ++++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 12 deletions(-) (limited to 'src/gui/windows/npcdialog.cpp') diff --git a/src/gui/windows/npcdialog.cpp b/src/gui/windows/npcdialog.cpp index 21c8fd577..51edbaf3b 100644 --- a/src/gui/windows/npcdialog.cpp +++ b/src/gui/windows/npcdialog.cpp @@ -132,6 +132,7 @@ NpcDialog::NpcDialog(const BeingId npcId) : mSkinName(), mPlayerBox(new PlayerBox(nullptr)), mAvatarBeing(nullptr), + mDialogInfo(nullptr), mLastNextTime(0), mCameraMode(-1), mCameraX(0), @@ -321,7 +322,7 @@ void NpcDialog::action(const ActionEvent &event) { case NPC_INPUT_LIST: { - if (!mSkinName.empty()) + if (mDialogInfo) return; if (gui) gui->resetClickCount(); @@ -952,7 +953,7 @@ void NpcDialog::buildLayout() switch (mInputState) { case NPC_INPUT_LIST: - if (mSkinName.empty()) + if (!mDialogInfo) placeMenuControls(); else placeSkinControls(); @@ -1141,7 +1142,21 @@ void NpcDialog::copyToClipboard(const BeingId npcId, void NpcDialog::setSkin(const std::string &skin) { + if (skin.empty()) + { + mSkinName = skin; + mDialogInfo = nullptr; + return; + } + const NpcDialogInfo *const dialog = NpcDialogDB::getDialog(skin); + if (!dialog) + { + logger->log("Error: creating controls for not existing npc dialog %s", + skin.c_str()); + return; + } mSkinName = skin; + mDialogInfo = dialog; } void NpcDialog::deleteSkinControls() @@ -1153,18 +1168,13 @@ void NpcDialog::createSkinControls() { deleteSkinControls(); - const NpcDialogInfo *const dialog = NpcDialogDB::getDialog(mSkinName); - if (!dialog) - { - logger->log("Error: creating controls for not existing npc dialog %s", - mSkinName.c_str()); + if (!mDialogInfo) return; - } - mHideText = dialog->hideText; + mHideText = mDialogInfo->hideText; FOR_EACH (std::vector::const_iterator, it, - dialog->menu.images) + mDialogInfo->menu.images) { const NpcImageInfo *const info = *it; Image *const image = Theme::getImageFromTheme(info->name); @@ -1177,7 +1187,7 @@ void NpcDialog::createSkinControls() } FOR_EACH (std::vector::const_iterator, it, - dialog->menu.texts) + mDialogInfo->menu.texts) { const NpcTextInfo *const info = *it; BrowserBox *box = new BrowserBox(this, @@ -1204,7 +1214,7 @@ void NpcDialog::createSkinControls() } FOR_EACH (std::vector::const_iterator, it, - dialog->menu.buttons) + mDialogInfo->menu.buttons) { const NpcButtonInfo *const info = *it; Button *const button = new Button(this); -- cgit v1.2.3-70-g09d2