mirror of
				https://github.com/OpenMW/openmw.git
				synced 2025-10-25 07:56:37 +00:00 
			
		
		
		
	splitted StampedJournalEntry class off from JournalEntry
This commit is contained in:
		
							parent
							
								
									f3fecdc627
								
							
						
					
					
						commit
						65e43c448a
					
				
					 4 changed files with 51 additions and 10 deletions
				
			
		|  | @ -12,7 +12,7 @@ namespace MWDialogue | |||
| 
 | ||||
|     void Journal::addEntry (const std::string& id, int index) | ||||
|     { | ||||
|         mJournal.push_back (JournalEntry::makeFromQuest (id, index, *mEnvironment.mWorld)); | ||||
|         mJournal.push_back (StampedJournalEntry::makeFromQuest (id, index, *mEnvironment.mWorld)); | ||||
|         std::cout << "journal: " << id << " at " << index << std::endl; | ||||
|     } | ||||
| 
 | ||||
|  |  | |||
|  | @ -17,13 +17,13 @@ namespace MWDialogue | |||
|     { | ||||
|         public: | ||||
| 
 | ||||
|             typedef std::deque<JournalEntry> TEntryContainer; | ||||
|             typedef std::deque<StampedJournalEntry> TEntryContainer; | ||||
|             typedef TEntryContainer::const_iterator TEntryIter; | ||||
| 
 | ||||
|         private: | ||||
| 
 | ||||
|             MWWorld::Environment& mEnvironment; | ||||
|             std::deque<JournalEntry> mJournal; | ||||
|             TEntryContainer mJournal; | ||||
| 
 | ||||
|         public: | ||||
| 
 | ||||
|  |  | |||
|  | @ -11,8 +11,8 @@ namespace MWDialogue | |||
| { | ||||
|     JournalEntry::JournalEntry() {} | ||||
| 
 | ||||
|     JournalEntry::JournalEntry (int day, const std::string& topic, const std::string& infoId) | ||||
|     : mDay (day), mTopic (topic), mInfoId (infoId) | ||||
|     JournalEntry::JournalEntry (const std::string& topic, const std::string& infoId) | ||||
|     : mTopic (topic), mInfoId (infoId) | ||||
|     {} | ||||
| 
 | ||||
|     std::string JournalEntry::getText (const ESMS::ESMStore& store) const | ||||
|  | @ -29,6 +29,12 @@ namespace MWDialogue | |||
| 
 | ||||
|     JournalEntry JournalEntry::makeFromQuest (const std::string& topic, int index, | ||||
|         const MWWorld::World& world) | ||||
|     { | ||||
|         return JournalEntry (topic, idFromIndex (topic, index, world)); | ||||
|     } | ||||
| 
 | ||||
|     std::string JournalEntry::idFromIndex (const std::string& topic, int index, | ||||
|         const MWWorld::World& world) | ||||
|     { | ||||
|         const ESM::Dialogue *dialogue = world.getStore().dialogs.find (topic); | ||||
| 
 | ||||
|  | @ -36,10 +42,28 @@ namespace MWDialogue | |||
|             iter!=dialogue->mInfo.end(); ++iter) | ||||
|             if (iter->data.disposition==index) /// \todo cleanup info structure
 | ||||
|             { | ||||
|                 int day = world.getGlobalVariable ("dayspassed").mLong; | ||||
|                 return JournalEntry (day, topic, iter->id); | ||||
|                 iter->id; | ||||
|             } | ||||
| 
 | ||||
|         throw std::runtime_error ("unknown journal index for topic " + topic); | ||||
|     } | ||||
| 
 | ||||
|     StampedJournalEntry::StampedJournalEntry() | ||||
|     : mDay (0), mMonth (0), mDayOfMonth (0) | ||||
|     {} | ||||
| 
 | ||||
|     StampedJournalEntry::StampedJournalEntry (const std::string& topic, const std::string& infoId, | ||||
|         int day, int month, int dayOfMonth) | ||||
|     : JournalEntry (topic, infoId), mDay (day), mMonth (month), mDayOfMonth (dayOfMonth) | ||||
|     {} | ||||
| 
 | ||||
|     StampedJournalEntry StampedJournalEntry::makeFromQuest (const std::string& topic, int index, | ||||
|         const MWWorld::World& world) | ||||
|     { | ||||
|         int day = world.getGlobalVariable ("dayspassed").mLong; | ||||
|         int month = world.getGlobalVariable ("day").mLong; | ||||
|         int dayOfMonth = world.getGlobalVariable ("month").mLong; | ||||
| 
 | ||||
|         return StampedJournalEntry (topic, idFromIndex (topic, index, world), day, month, dayOfMonth); | ||||
|     } | ||||
| } | ||||
|  |  | |||
|  | @ -15,23 +15,40 @@ namespace MWWorld | |||
| 
 | ||||
| namespace MWDialogue | ||||
| { | ||||
|     /// \brief a quest or dialogue entry with a timestamp
 | ||||
|     /// \brief A quest or dialogue entry
 | ||||
|     struct JournalEntry | ||||
|     { | ||||
|         int mDay; | ||||
|         std::string mTopic; | ||||
|         std::string mInfoId; | ||||
| 
 | ||||
|         JournalEntry(); | ||||
| 
 | ||||
|         JournalEntry (int day, const std::string& topic, const std::string& infoId); | ||||
|         JournalEntry (const std::string& topic, const std::string& infoId); | ||||
| 
 | ||||
|         std::string getText (const ESMS::ESMStore& store) const; | ||||
| 
 | ||||
|         static JournalEntry makeFromQuest (const std::string& topic, int index, | ||||
|             const MWWorld::World& world); | ||||
| 
 | ||||
|         static std::string idFromIndex (const std::string& topic, int index, | ||||
|             const MWWorld::World& world); | ||||
|     }; | ||||
| 
 | ||||
|     /// \biref A quest entry with a timestamp.
 | ||||
|     struct StampedJournalEntry : public JournalEntry | ||||
|     { | ||||
|         int mDay; | ||||
|         int mMonth; | ||||
|         int mDayOfMonth; | ||||
| 
 | ||||
|         StampedJournalEntry(); | ||||
| 
 | ||||
|         StampedJournalEntry (const std::string& topic, const std::string& infoId, | ||||
|             int day, int month, int dayOfMonth); | ||||
| 
 | ||||
|         static StampedJournalEntry makeFromQuest (const std::string& topic, int index, | ||||
|             const MWWorld::World& world); | ||||
|     }; | ||||
| } | ||||
| 
 | ||||
| #endif | ||||
|  |  | |||
		Loading…
	
		Reference in a new issue