mirror of
				https://github.com/OpenMW/openmw.git
				synced 2025-10-29 03:26:38 +00:00 
			
		
		
		
	Add texture check to birthsign verifier
This commit is contained in:
		
							parent
							
								
									d3aa5840ec
								
							
						
					
					
						commit
						51fdb94e34
					
				
					 3 changed files with 46 additions and 12 deletions
				
			
		|  | @ -4,13 +4,41 @@ | ||||||
| #include <map> | #include <map> | ||||||
| 
 | 
 | ||||||
| #include <components/esm/loadbsgn.hpp> | #include <components/esm/loadbsgn.hpp> | ||||||
|  | #include <components/misc/resourcehelpers.hpp> | ||||||
| 
 | 
 | ||||||
| #include "../prefs/state.hpp" | #include "../prefs/state.hpp" | ||||||
| 
 | 
 | ||||||
|  | #include "../world/data.hpp" | ||||||
|  | #include "../world/resources.hpp" | ||||||
| #include "../world/universalid.hpp" | #include "../world/universalid.hpp" | ||||||
| 
 | 
 | ||||||
| CSMTools::BirthsignCheckStage::BirthsignCheckStage (const CSMWorld::IdCollection<ESM::BirthSign>& birthsigns) | namespace | ||||||
| : mBirthsigns (birthsigns) | { | ||||||
|  |     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) | ||||||
| { | { | ||||||
|     mIgnoreBaseRecords = false; |     mIgnoreBaseRecords = false; | ||||||
| } | } | ||||||
|  | @ -34,17 +62,13 @@ void CSMTools::BirthsignCheckStage::perform (int stage, CSMDoc::Messages& messag | ||||||
| 
 | 
 | ||||||
|     CSMWorld::UniversalId id (CSMWorld::UniversalId::Type_Birthsign, birthsign.mId); |     CSMWorld::UniversalId id (CSMWorld::UniversalId::Type_Birthsign, birthsign.mId); | ||||||
| 
 | 
 | ||||||
|     // test for empty name, description and texture
 |  | ||||||
|     if (birthsign.mName.empty()) |     if (birthsign.mName.empty()) | ||||||
|         messages.push_back (std::make_pair (id, birthsign.mId + " has an empty name")); |         addMessage(messages, id, "Name is missing"); | ||||||
| 
 | 
 | ||||||
|     if (birthsign.mDescription.empty()) |     if (birthsign.mDescription.empty()) | ||||||
|         messages.push_back (std::make_pair (id, birthsign.mId + " has an empty description")); |         addMessage(messages, id, "Description is missing"); | ||||||
| 
 | 
 | ||||||
|     if (birthsign.mTexture.empty()) |     addMessage(messages, id, checkTexture(birthsign.mTexture)); | ||||||
|         messages.push_back (std::make_pair (id, birthsign.mId + " is missing a texture")); |  | ||||||
| 
 |  | ||||||
|     /// \todo test if the texture exists
 |  | ||||||
| 
 | 
 | ||||||
|     /// \todo check data members that can't be edited in the table view
 |     /// \todo check data members that can't be edited in the table view
 | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -7,17 +7,27 @@ | ||||||
| 
 | 
 | ||||||
| #include "../doc/stage.hpp" | #include "../doc/stage.hpp" | ||||||
| 
 | 
 | ||||||
|  | namespace CSMWorld | ||||||
|  | { | ||||||
|  |     class Resources; | ||||||
|  | } | ||||||
|  | 
 | ||||||
| namespace CSMTools | namespace CSMTools | ||||||
| { | { | ||||||
|     /// \brief VerifyStage: make sure that birthsign records are internally consistent
 |     /// \brief VerifyStage: make sure that birthsign records are internally consistent
 | ||||||
|     class BirthsignCheckStage : public CSMDoc::Stage |     class BirthsignCheckStage : public CSMDoc::Stage | ||||||
|     { |     { | ||||||
|             const CSMWorld::IdCollection<ESM::BirthSign>& mBirthsigns; |             const CSMWorld::IdCollection<ESM::BirthSign> &mBirthsigns; | ||||||
|  |             const CSMWorld::Resources &mTextures; | ||||||
|             bool mIgnoreBaseRecords; |             bool mIgnoreBaseRecords; | ||||||
| 
 | 
 | ||||||
|  |         private: | ||||||
|  |             std::string checkTexture(const std::string &texture) const; | ||||||
|  | 
 | ||||||
|         public: |         public: | ||||||
| 
 | 
 | ||||||
|             BirthsignCheckStage (const CSMWorld::IdCollection<ESM::BirthSign>& birthsigns); |             BirthsignCheckStage (const CSMWorld::IdCollection<ESM::BirthSign> &birthsigns, | ||||||
|  |                                  const CSMWorld::Resources &textures); | ||||||
| 
 | 
 | ||||||
|             virtual int setup(); |             virtual int setup(); | ||||||
|             ///< \return number of steps
 |             ///< \return number of steps
 | ||||||
|  |  | ||||||
|  | @ -78,7 +78,7 @@ CSMDoc::OperationHolder *CSMTools::Tools::getVerifier() | ||||||
| 
 | 
 | ||||||
|         mVerifierOperation->appendStage (new RegionCheckStage (mData.getRegions())); |         mVerifierOperation->appendStage (new RegionCheckStage (mData.getRegions())); | ||||||
| 
 | 
 | ||||||
|         mVerifierOperation->appendStage (new BirthsignCheckStage (mData.getBirthsigns())); |         mVerifierOperation->appendStage (new BirthsignCheckStage (mData.getBirthsigns(), mData.getResources (CSMWorld::UniversalId::Type_Textures))); | ||||||
| 
 | 
 | ||||||
|         mVerifierOperation->appendStage (new SpellCheckStage (mData.getSpells())); |         mVerifierOperation->appendStage (new SpellCheckStage (mData.getSpells())); | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
		Reference in a new issue