2013-04-07 21:25:35 +00:00
|
|
|
#include "birthsigncheck.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"
|
|
|
|
|
2013-04-07 21:25:35 +00:00
|
|
|
#include "../world/universalid.hpp"
|
|
|
|
|
2018-08-24 14:37:07 +00:00
|
|
|
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 23:48:58 +00:00
|
|
|
messages.add(id, "Name is missing", "", CSMDoc::Message::Severity_Error);
|
2013-04-07 21:25:35 +00:00
|
|
|
|
|
|
|
if (birthsign.mDescription.empty())
|
2018-08-24 23:48:58 +00:00
|
|
|
messages.add(id, "Description is missing", "", CSMDoc::Message::Severity_Warning);
|
2013-04-07 21:25:35 +00:00
|
|
|
|
2018-08-24 23:48:58 +00:00
|
|
|
if (birthsign.mTexture.empty())
|
|
|
|
messages.add(id, "Image is missing", "", CSMDoc::Message::Severity_Error);
|
2018-09-14 18:42:11 +00:00
|
|
|
else if (mTextures.searchId(birthsign.mTexture) == -1)
|
2018-08-24 23:48:58 +00:00
|
|
|
{
|
2018-08-26 18:40:07 +00:00
|
|
|
std::string ddsTexture = birthsign.mTexture;
|
|
|
|
if (!(Misc::ResourceHelpers::changeExtensionToDds(ddsTexture) && mTextures.searchId(ddsTexture) != -1))
|
|
|
|
messages.add(id, "Image '" + birthsign.mTexture + "' does not exist", "", CSMDoc::Message::Severity_Error);
|
2018-08-24 23:48:58 +00:00
|
|
|
}
|
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
|
|
|
}
|