2013-04-07 21:25:35 +00:00
|
|
|
#include "birthsigncheck.hpp"
|
|
|
|
|
|
|
|
#include <sstream>
|
|
|
|
#include <map>
|
|
|
|
|
|
|
|
#include <components/esm/loadbsgn.hpp>
|
2018-08-24 14:37:07 +00:00
|
|
|
#include <components/misc/resourcehelpers.hpp>
|
2013-04-07 21:25:35 +00:00
|
|
|
|
2018-06-19 22:20:03 +00:00
|
|
|
#include "../prefs/state.hpp"
|
|
|
|
|
2018-08-24 14:37:07 +00:00
|
|
|
#include "../world/data.hpp"
|
2013-04-07 21:25:35 +00:00
|
|
|
#include "../world/universalid.hpp"
|
|
|
|
|
2018-08-24 14:37:07 +00:00
|
|
|
namespace
|
|
|
|
{
|
|
|
|
void addMessage(CSMDoc::Messages &messages, const CSMWorld::UniversalId &id, const std::string& text)
|
|
|
|
{
|
|
|
|
if (!text.empty())
|
|
|
|
{
|
|
|
|
messages.push_back(std::make_pair(id, text));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
std::string CSMTools::BirthsignCheckStage::checkTexture(const std::string &texture) const
|
|
|
|
{
|
|
|
|
if (texture.empty()) return "Texture is missing";
|
|
|
|
if (mTextures.searchId(texture) != -1) return std::string();
|
|
|
|
|
|
|
|
std::string ddsTexture = texture;
|
|
|
|
if (Misc::ResourceHelpers::changeExtensionToDds(ddsTexture) && mTextures.searchId(ddsTexture) != -1) return std::string();
|
|
|
|
|
|
|
|
return "Texture '" + texture + "' does not exist";
|
|
|
|
}
|
|
|
|
|
|
|
|
CSMTools::BirthsignCheckStage::BirthsignCheckStage (const CSMWorld::IdCollection<ESM::BirthSign>& birthsigns,
|
|
|
|
const CSMWorld::Resources &textures)
|
|
|
|
: mBirthsigns(birthsigns),
|
|
|
|
mTextures(textures)
|
2018-06-19 22:20:03 +00:00
|
|
|
{
|
2018-06-20 09:29:38 +00:00
|
|
|
mIgnoreBaseRecords = false;
|
2018-06-19 22:20:03 +00:00
|
|
|
}
|
2013-04-07 21:25:35 +00:00
|
|
|
|
|
|
|
int CSMTools::BirthsignCheckStage::setup()
|
|
|
|
{
|
2018-06-19 22:20:03 +00:00
|
|
|
mIgnoreBaseRecords = CSMPrefs::get()["Reports"]["ignore-base-records"].isTrue();
|
|
|
|
|
2013-04-07 21:25:35 +00:00
|
|
|
return mBirthsigns.getSize();
|
|
|
|
}
|
|
|
|
|
2014-12-07 17:57:47 +00:00
|
|
|
void CSMTools::BirthsignCheckStage::perform (int stage, CSMDoc::Messages& messages)
|
2013-04-07 21:25:35 +00:00
|
|
|
{
|
2013-09-27 08:08:09 +00:00
|
|
|
const CSMWorld::Record<ESM::BirthSign>& record = mBirthsigns.getRecord (stage);
|
|
|
|
|
2018-06-19 22:20:03 +00:00
|
|
|
// Skip "Base" records (setting!) and "Deleted" records
|
2018-06-20 09:29:38 +00:00
|
|
|
if ((mIgnoreBaseRecords && record.mState == CSMWorld::RecordBase::State_BaseOnly) || record.isDeleted())
|
2013-09-27 08:08:09 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
const ESM::BirthSign& birthsign = record.get();
|
2013-04-07 21:25:35 +00:00
|
|
|
|
|
|
|
CSMWorld::UniversalId id (CSMWorld::UniversalId::Type_Birthsign, birthsign.mId);
|
|
|
|
|
|
|
|
if (birthsign.mName.empty())
|
2018-08-24 14:37:07 +00:00
|
|
|
addMessage(messages, id, "Name is missing");
|
2013-04-07 21:25:35 +00:00
|
|
|
|
|
|
|
if (birthsign.mDescription.empty())
|
2018-08-24 14:37:07 +00:00
|
|
|
addMessage(messages, id, "Description is missing");
|
2013-04-07 21:25:35 +00:00
|
|
|
|
2018-08-24 14:37:07 +00:00
|
|
|
addMessage(messages, id, checkTexture(birthsign.mTexture));
|
2013-04-07 21:25:35 +00:00
|
|
|
|
|
|
|
/// \todo check data members that can't be edited in the table view
|
2015-03-11 14:54:45 +00:00
|
|
|
}
|