2011-01-02 01:48:38 +02:00
|
|
|
/*
|
2011-08-09 03:07:41 +03:00
|
|
|
* The ManaPlus Client
|
2011-01-02 01:48:38 +02:00
|
|
|
* Copyright (C) 2009 The Mana World Development Team
|
|
|
|
|
* Copyright (C) 2009-2010 Andrei Karas
|
2024-02-09 13:36:22 +00:00
|
|
|
* Copyright (C) 2011-2020 The ManaPlus Developers
|
|
|
|
|
* Copyright (C) 2020-2023 The ManaVerse Developers
|
2011-01-02 01:48:38 +02:00
|
|
|
*
|
2011-08-09 03:07:41 +03:00
|
|
|
* This file is part of The ManaPlus Client.
|
2011-01-02 01:48:38 +02:00
|
|
|
*
|
|
|
|
|
* 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
|
2012-02-23 02:54:43 +03:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2011-01-02 01:48:38 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "textcommand.h"
|
|
|
|
|
|
2012-05-24 01:20:43 +03:00
|
|
|
#include "configuration.h"
|
|
|
|
|
|
2011-01-02 01:48:38 +02:00
|
|
|
#include "gui/theme.h"
|
|
|
|
|
|
|
|
|
|
#include "resources/iteminfo.h"
|
|
|
|
|
|
2013-09-30 20:36:56 +03:00
|
|
|
#include "resources/db/itemdb.h"
|
|
|
|
|
|
2016-06-07 15:41:00 +03:00
|
|
|
#include "resources/image/image.h"
|
|
|
|
|
|
2016-05-25 14:13:51 +03:00
|
|
|
#include "resources/loaders/imageloader.h"
|
2016-05-24 23:09:33 +03:00
|
|
|
|
2011-05-24 00:38:44 +03:00
|
|
|
#include "debug.h"
|
|
|
|
|
|
2015-11-17 20:16:14 +03:00
|
|
|
#ifdef TMWA_SUPPORT
|
2016-02-07 01:53:51 +03:00
|
|
|
TextCommand::TextCommand(const int id,
|
2015-11-16 20:23:30 +03:00
|
|
|
const std::string &symbol,
|
2012-09-04 19:11:53 +03:00
|
|
|
const std::string &command,
|
|
|
|
|
const std::string &comment,
|
2015-11-16 20:23:30 +03:00
|
|
|
const CommandTargetT type,
|
|
|
|
|
const std::string &icon,
|
|
|
|
|
const unsigned int basicLvl,
|
|
|
|
|
const MagicSchoolT school,
|
|
|
|
|
const unsigned int schoolLvl,
|
2016-02-07 01:53:51 +03:00
|
|
|
const unsigned int mana) :
|
2011-09-10 15:48:22 +03:00
|
|
|
mCommand(command),
|
2011-09-19 19:33:14 +03:00
|
|
|
mComment(comment),
|
2011-09-10 15:48:22 +03:00
|
|
|
mSymbol(symbol),
|
|
|
|
|
mTargetType(type),
|
|
|
|
|
mIcon(icon),
|
|
|
|
|
mId(id),
|
|
|
|
|
mMana(mana),
|
|
|
|
|
mSchool(school),
|
|
|
|
|
mBaseLvl(basicLvl),
|
|
|
|
|
mSchoolLvl(schoolLvl),
|
2015-11-16 20:39:21 +03:00
|
|
|
mCommandType(TextCommandType::Magic),
|
2011-11-08 00:44:17 +03:00
|
|
|
mImage(nullptr)
|
2011-01-02 01:48:38 +02:00
|
|
|
{
|
|
|
|
|
loadImage();
|
|
|
|
|
}
|
2016-09-23 22:01:44 +03:00
|
|
|
#endif // TMWA_SUPPORT
|
2011-01-02 01:48:38 +02:00
|
|
|
|
2016-02-07 01:53:51 +03:00
|
|
|
TextCommand::TextCommand(const int id,
|
2015-11-17 20:16:14 +03:00
|
|
|
const std::string &symbol,
|
2012-09-04 19:11:53 +03:00
|
|
|
const std::string &command,
|
|
|
|
|
const std::string &comment,
|
2015-11-17 20:16:14 +03:00
|
|
|
const CommandTargetT type,
|
|
|
|
|
const std::string &icon) :
|
2011-09-10 15:48:22 +03:00
|
|
|
mCommand(command),
|
2011-09-19 19:33:14 +03:00
|
|
|
mComment(comment),
|
2011-09-10 15:48:22 +03:00
|
|
|
mSymbol(symbol),
|
|
|
|
|
mTargetType(type),
|
|
|
|
|
mIcon(icon),
|
|
|
|
|
mId(id),
|
2015-11-17 20:16:14 +03:00
|
|
|
#ifdef TMWA_SUPPORT
|
2016-02-07 01:53:51 +03:00
|
|
|
mMana(0U),
|
2015-11-16 20:23:30 +03:00
|
|
|
mSchool(MagicSchool::SkillMagic),
|
2011-09-10 15:48:22 +03:00
|
|
|
mBaseLvl(0),
|
|
|
|
|
mSchoolLvl(0),
|
2015-11-16 20:39:21 +03:00
|
|
|
mCommandType(TextCommandType::Text),
|
2016-09-23 22:01:44 +03:00
|
|
|
#endif // TMWA_SUPPORT
|
2011-11-08 00:44:17 +03:00
|
|
|
mImage(nullptr)
|
2011-01-02 01:48:38 +02:00
|
|
|
{
|
|
|
|
|
loadImage();
|
|
|
|
|
}
|
|
|
|
|
|
2016-02-07 01:53:51 +03:00
|
|
|
TextCommand::TextCommand(const int id) :
|
2011-09-10 15:48:22 +03:00
|
|
|
mCommand(""),
|
2011-09-19 19:33:14 +03:00
|
|
|
mComment(""),
|
2011-09-10 15:48:22 +03:00
|
|
|
mSymbol(""),
|
2015-11-16 20:02:04 +03:00
|
|
|
mTargetType(CommandTarget::NoTarget),
|
2011-09-10 15:48:22 +03:00
|
|
|
mIcon(""),
|
|
|
|
|
mId(id),
|
2015-11-17 20:16:14 +03:00
|
|
|
#ifdef TMWA_SUPPORT
|
2016-02-07 01:53:51 +03:00
|
|
|
mMana(0U),
|
2015-11-16 20:23:30 +03:00
|
|
|
mSchool(MagicSchool::SkillMagic),
|
2011-09-10 15:48:22 +03:00
|
|
|
mBaseLvl(0),
|
|
|
|
|
mSchoolLvl(0),
|
2015-11-16 20:39:21 +03:00
|
|
|
mCommandType(TextCommandType::Text),
|
2016-09-23 22:01:44 +03:00
|
|
|
#endif // TMWA_SUPPORT
|
2011-11-08 00:44:17 +03:00
|
|
|
mImage(nullptr)
|
2011-01-02 01:48:38 +02:00
|
|
|
{
|
|
|
|
|
loadImage();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TextCommand::~TextCommand()
|
|
|
|
|
{
|
2017-06-06 23:34:34 +03:00
|
|
|
if (mImage != nullptr)
|
2011-01-02 01:48:38 +02:00
|
|
|
{
|
|
|
|
|
mImage->decRef();
|
2011-11-08 00:44:17 +03:00
|
|
|
mImage = nullptr;
|
2011-01-02 01:48:38 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TextCommand::loadImage()
|
|
|
|
|
{
|
2017-06-06 23:34:34 +03:00
|
|
|
if (mImage != nullptr)
|
2011-01-02 01:48:38 +02:00
|
|
|
{
|
|
|
|
|
mImage->decRef();
|
2011-11-08 00:44:17 +03:00
|
|
|
mImage = nullptr;
|
2011-01-02 01:48:38 +02:00
|
|
|
}
|
|
|
|
|
|
2017-10-10 19:00:20 +03:00
|
|
|
if (mIcon.empty() ||
|
|
|
|
|
!ItemDB::exists(mIcon))
|
|
|
|
|
{
|
2011-01-02 01:48:38 +02:00
|
|
|
return;
|
2017-10-10 19:00:20 +03:00
|
|
|
}
|
2011-01-02 01:48:38 +02:00
|
|
|
|
2017-10-10 19:00:20 +03:00
|
|
|
const ItemInfo &info = ItemDB::get(mIcon);
|
2017-10-10 21:03:00 +03:00
|
|
|
const SpriteDisplay &display = info.getDisplay();
|
2017-04-02 06:23:19 +03:00
|
|
|
mImage = Loader::getImage(pathJoin(paths.getStringValue("itemIcons"),
|
2016-05-25 19:32:59 +03:00
|
|
|
display.image));
|
2011-01-02 01:48:38 +02:00
|
|
|
|
2017-06-06 23:34:34 +03:00
|
|
|
if (mImage == nullptr)
|
2011-01-02 01:48:38 +02:00
|
|
|
mImage = Theme::getImageFromTheme("unknown-item.png");
|
2011-09-14 02:11:55 +03:00
|
|
|
}
|