diff options
author | Andrei Karas <akaras@inbox.ru> | 2015-10-28 21:02:57 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2015-10-28 22:52:27 +0300 |
commit | ed17aa400a745a81940020e024a3944671a47281 (patch) | |
tree | eac1fe8c0a1e4f1cac2fce2614c002dd449141dd /src/resources | |
parent | 519c7cfaccac61beaa84751b7dfeed1c50600bed (diff) | |
download | plus-ed17aa400a745a81940020e024a3944671a47281.tar.gz plus-ed17aa400a745a81940020e024a3944671a47281.tar.bz2 plus-ed17aa400a745a81940020e024a3944671a47281.tar.xz plus-ed17aa400a745a81940020e024a3944671a47281.zip |
Add text object to skined npc menus.
Diffstat (limited to 'src/resources')
-rw-r--r-- | src/resources/db/npcdialogdb.cpp | 22 | ||||
-rw-r--r-- | src/resources/npcdialoginfo.h | 2 | ||||
-rw-r--r-- | src/resources/npctextinfo.h | 46 |
3 files changed, 70 insertions, 0 deletions
diff --git a/src/resources/db/npcdialogdb.cpp b/src/resources/db/npcdialogdb.cpp index 86bc712f2..22dbb9b79 100644 --- a/src/resources/db/npcdialogdb.cpp +++ b/src/resources/db/npcdialogdb.cpp @@ -96,6 +96,26 @@ static void loadNpcDialog(NpcDialogInfo *const dialog, childNode, "y", 0, 0, 10000); dialog->images.push_back(imageInfo); } + else if (xmlNameEqual(childNode, "text")) + { + const std::string text = XML::getProperty(childNode, "text", ""); + if (text.empty()) + { + logger->log("Error: no text attribute found in text tag."); + continue; + } + NpcTextInfo *const textInfo = new NpcTextInfo; + textInfo->text = text; + textInfo->x = XML::getIntProperty( + childNode, "x", 0, 0, 10000); + textInfo->y = XML::getIntProperty( + childNode, "y", 0, 0, 10000); + textInfo->width = XML::getIntProperty( + childNode, "width", 20, 10, 10000); + textInfo->height = XML::getIntProperty( + childNode, "height", 20, 10, 10000); + dialog->texts.push_back(textInfo); + } } } @@ -149,6 +169,7 @@ void NpcDialogDB::deleteDialog(const std::string &name) NpcDialogInfo *dialog = (*it).second; delete_all(dialog->buttons); delete_all(dialog->images); + delete_all(dialog->texts); mDialogs.erase(it); delete dialog; } @@ -162,6 +183,7 @@ void NpcDialogDB::unload() NpcDialogInfo *dialog = (*it).second; delete_all(dialog->buttons); delete_all(dialog->images); + delete_all(dialog->texts); delete dialog; } mDialogs.clear(); diff --git a/src/resources/npcdialoginfo.h b/src/resources/npcdialoginfo.h index aa73d2c01..e6fe6e331 100644 --- a/src/resources/npcdialoginfo.h +++ b/src/resources/npcdialoginfo.h @@ -23,6 +23,7 @@ #include "resources/npcbuttoninfo.h" #include "resources/npcimageinfo.h" +#include "resources/npctextinfo.h" #include "utils/stringvector.h" @@ -40,6 +41,7 @@ struct NpcDialogInfo final std::vector<NpcButtonInfo*> buttons; std::vector<NpcImageInfo*> images; + std::vector<NpcTextInfo*> texts; std::string name; bool hideText; }; diff --git a/src/resources/npctextinfo.h b/src/resources/npctextinfo.h new file mode 100644 index 000000000..78b9fbf1d --- /dev/null +++ b/src/resources/npctextinfo.h @@ -0,0 +1,46 @@ +/* + * 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_NPCTEXTINFO_H +#define RESOURCES_NPCTEXTINFO_H + +#include <string> + +#include "localconsts.h" + +struct NpcTextInfo final +{ + NpcTextInfo() : + text(), + x(0), + y(0), + width(32), + height(32) + { + } + + std::string text; + int x; + int y; + int width; + int height; +}; + +#endif // RESOURCES_NPCTEXTINFO_H |