diff options
author | Andrei Karas <akaras@inbox.ru> | 2015-10-29 00:41:08 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2015-10-29 00:41:08 +0300 |
commit | b0cddefee60e56525fe4da0404f18af71c14acaf (patch) | |
tree | bc7ddd1d5062320dd9d0e1c63d03a78edbfe8f1f /src/gui/windows/npcdialog.cpp | |
parent | 9b4d3bb164034b1e8a5b7c43572a6649560c0e4a (diff) | |
download | mv-b0cddefee60e56525fe4da0404f18af71c14acaf.tar.gz mv-b0cddefee60e56525fe4da0404f18af71c14acaf.tar.bz2 mv-b0cddefee60e56525fe4da0404f18af71c14acaf.tar.xz mv-b0cddefee60e56525fe4da0404f18af71c14acaf.zip |
Ignore npc dialog skin if skin not exists.
Diffstat (limited to 'src/gui/windows/npcdialog.cpp')
-rw-r--r-- | src/gui/windows/npcdialog.cpp | 34 |
1 files changed, 22 insertions, 12 deletions
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<NpcImageInfo*>::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<NpcTextInfo*>::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<NpcButtonInfo*>::const_iterator, it, - dialog->menu.buttons) + mDialogInfo->menu.buttons) { const NpcButtonInfo *const info = *it; Button *const button = new Button(this); |