2013-01-27 12:01:37 -08:00
|
|
|
#include "journalviewmodel.hpp"
|
|
|
|
|
2013-05-04 14:15:47 +02:00
|
|
|
#include <map>
|
|
|
|
|
|
|
|
#include <MyGUI_LanguageManager.h>
|
|
|
|
|
2022-08-03 00:00:54 +02:00
|
|
|
#include <components/misc/strings/algorithm.hpp>
|
2015-01-31 23:27:34 +01:00
|
|
|
#include <components/translation/translation.hpp>
|
|
|
|
|
2013-01-27 12:01:37 -08:00
|
|
|
#include "../mwbase/environment.hpp"
|
|
|
|
#include "../mwbase/journal.hpp"
|
2013-05-06 15:14:39 +02:00
|
|
|
#include "../mwbase/windowmanager.hpp"
|
2013-01-27 12:01:37 -08:00
|
|
|
#include "../mwbase/world.hpp"
|
|
|
|
|
2014-10-18 19:51:07 +02:00
|
|
|
#include "../mwdialogue/keywordsearch.hpp"
|
2013-01-27 12:01:37 -08:00
|
|
|
|
2013-05-06 16:04:28 +02:00
|
|
|
namespace MWGui
|
2013-01-27 12:01:37 -08:00
|
|
|
{
|
|
|
|
|
2013-05-04 14:15:47 +02:00
|
|
|
struct JournalViewModelImpl;
|
2013-01-27 12:01:37 -08:00
|
|
|
|
2013-03-06 20:02:00 -08:00
|
|
|
struct JournalViewModelImpl : JournalViewModel
|
2013-01-27 12:01:37 -08:00
|
|
|
{
|
2013-02-14 21:37:33 -08:00
|
|
|
typedef MWDialogue::KeywordSearch<std::string, intptr_t> KeywordSearchT;
|
2013-01-27 12:01:37 -08:00
|
|
|
|
2013-03-06 20:02:00 -08:00
|
|
|
mutable bool mKeywordSearchLoaded;
|
2013-05-04 14:15:47 +02:00
|
|
|
mutable KeywordSearchT mKeywordSearch;
|
2013-01-27 12:01:37 -08:00
|
|
|
|
2022-08-24 20:38:52 +02:00
|
|
|
JournalViewModelImpl() { mKeywordSearchLoaded = false; }
|
2013-01-27 12:01:37 -08:00
|
|
|
|
2022-08-24 20:38:52 +02:00
|
|
|
virtual ~JournalViewModelImpl() {}
|
2013-01-27 12:01:37 -08:00
|
|
|
|
2013-05-01 10:28:59 +02:00
|
|
|
/// \todo replace this nasty BS
|
|
|
|
static Utf8Span toUtf8Span(std::string_view str)
|
2022-09-22 21:26:05 +03:00
|
|
|
{
|
2013-05-01 10:28:59 +02:00
|
|
|
if (str.size() == 0)
|
|
|
|
return Utf8Span(Utf8Point(nullptr), Utf8Point(nullptr));
|
2013-01-27 12:01:37 -08:00
|
|
|
|
2020-10-16 22:18:54 +04:00
|
|
|
Utf8Point point = reinterpret_cast<Utf8Point>(str.data());
|
2013-01-27 12:01:37 -08:00
|
|
|
|
2020-10-16 22:18:54 +04:00
|
|
|
return Utf8Span(point, point + str.size());
|
2013-01-27 12:01:37 -08:00
|
|
|
}
|
|
|
|
|
2013-02-14 21:37:33 -08:00
|
|
|
void load() override {}
|
2022-09-22 21:26:05 +03:00
|
|
|
|
2020-10-16 22:18:54 +04:00
|
|
|
void unload() override
|
2022-09-22 21:26:05 +03:00
|
|
|
{
|
2013-02-14 21:37:33 -08:00
|
|
|
mKeywordSearch.clear();
|
|
|
|
mKeywordSearchLoaded = false;
|
2022-09-22 21:26:05 +03:00
|
|
|
}
|
|
|
|
|
2013-02-14 21:37:33 -08:00
|
|
|
void ensureKeyWordSearchLoaded() const
|
2013-01-27 12:01:37 -08:00
|
|
|
{
|
2013-02-14 21:37:33 -08:00
|
|
|
if (!mKeywordSearchLoaded)
|
2022-09-22 21:26:05 +03:00
|
|
|
{
|
2013-02-09 10:44:20 -08:00
|
|
|
MWBase::Journal* journal = MWBase::Environment::get().getJournal();
|
2013-01-27 12:01:37 -08:00
|
|
|
|
2013-02-09 10:44:20 -08:00
|
|
|
for (MWBase::Journal::TTopicIter i = journal->topicBegin(); i != journal->topicEnd(); ++i)
|
Initial commit: In ESM structures, replace the string members that are RefIds to other records, to a new strong type
The strong type is actually just a string underneath, but this will help in the future to have a distinction so it's easier to search and replace when we use an integer ID
Slowly going through all the changes to make, still hundreds of errors
a lot of functions/structures use std::string or stringview to designate an ID. So it takes time
Continues slowly replacing ids. There are technically more and more compilation errors
I have good hope that there is a point where the amount of errors will dramatically go down as all the main functions use the ESM::RefId type
Continue moving forward, changes to the stores
slowly moving along
Starting to see the fruit of those changes.
still many many error, but more and more Irun into a situation where a function is sandwiched between two functions that use the RefId type.
More replacements. Things are starting to get easier
I can see more and more often the issue is that the function is awaiting a RefId, but is given a string
there is less need to go down functions and to fix a long list of them.
Still moving forward, and for the first time error count is going down!
Good pace, not sure about topics though, mId and mName are actually the same thing and are used interchangeably
Cells are back to using string for the name, haven't fixed everything yet. Many other changes
Under the bar of 400 compilation errors.
more good progress <100 compile errors!
More progress
Game settings store can use string for find, it was a bit absurd how every use of it required to create refId from string
some more progress on other fronts
Mostly game settings clean
one error opened a lot of other errors. Down to 18, but more will prbably appear
only link errors left??
Fixed link errors
OpenMW compiles, and launches, with some issues, but still!
2022-09-25 13:17:09 +02:00
|
|
|
mKeywordSearch.seed(i->first.getRefIdString(), intptr_t(&i->second));
|
2013-01-27 12:01:37 -08:00
|
|
|
|
2013-02-14 21:37:33 -08:00
|
|
|
mKeywordSearchLoaded = true;
|
2022-09-22 21:26:05 +03:00
|
|
|
}
|
2013-01-27 12:01:37 -08:00
|
|
|
}
|
|
|
|
|
2020-10-16 22:18:54 +04:00
|
|
|
bool isEmpty() const override
|
2013-01-27 12:01:37 -08:00
|
|
|
{
|
2013-02-09 10:44:20 -08:00
|
|
|
MWBase::Journal* journal = MWBase::Environment::get().getJournal();
|
2013-01-27 12:01:37 -08:00
|
|
|
|
|
|
|
return journal->begin() == journal->end();
|
|
|
|
}
|
|
|
|
|
2013-05-06 16:05:56 +02:00
|
|
|
template <typename t_iterator, typename Interface>
|
|
|
|
struct BaseEntry : Interface
|
2013-01-27 12:01:37 -08:00
|
|
|
{
|
2013-02-09 10:44:20 -08:00
|
|
|
typedef t_iterator iterator_t;
|
|
|
|
|
2013-03-06 20:02:00 -08:00
|
|
|
iterator_t itr;
|
2013-05-01 10:28:59 +02:00
|
|
|
JournalViewModelImpl const* mModel;
|
2013-01-27 12:01:37 -08:00
|
|
|
|
2013-05-01 10:28:59 +02:00
|
|
|
BaseEntry(JournalViewModelImpl const* model, iterator_t itr)
|
2015-04-30 19:24:27 -05:00
|
|
|
: itr(itr)
|
|
|
|
, mModel(model)
|
|
|
|
, loaded(false)
|
2013-01-27 12:01:37 -08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-02-14 21:37:33 -08:00
|
|
|
virtual ~BaseEntry() {}
|
2013-01-27 12:01:37 -08:00
|
|
|
|
|
|
|
mutable bool loaded;
|
|
|
|
mutable std::string utf8text;
|
|
|
|
|
2013-05-06 15:14:39 +02:00
|
|
|
typedef std::pair<size_t, size_t> Range;
|
|
|
|
|
|
|
|
// hyperlinks in @link# notation
|
|
|
|
mutable std::map<Range, intptr_t> mHyperLinks;
|
|
|
|
|
2013-01-27 12:01:37 -08:00
|
|
|
virtual std::string getText() const = 0;
|
|
|
|
|
2013-02-14 21:37:33 -08:00
|
|
|
void ensureLoaded() const
|
2013-01-27 12:01:37 -08:00
|
|
|
{
|
2013-05-06 15:14:39 +02:00
|
|
|
if (!loaded)
|
|
|
|
{
|
|
|
|
mModel->ensureKeyWordSearchLoaded();
|
|
|
|
|
|
|
|
utf8text = getText();
|
|
|
|
|
2014-09-26 17:12:48 +02:00
|
|
|
size_t pos_end = 0;
|
2022-09-22 21:26:05 +03:00
|
|
|
for (;;)
|
|
|
|
{
|
2014-09-26 17:12:48 +02:00
|
|
|
size_t pos_begin = utf8text.find('@');
|
2013-05-06 15:14:39 +02:00
|
|
|
if (pos_begin != std::string::npos)
|
|
|
|
pos_end = utf8text.find('#', pos_begin);
|
2022-09-22 21:26:05 +03:00
|
|
|
|
2013-05-06 15:14:39 +02:00
|
|
|
if (pos_begin != std::string::npos && pos_end != std::string::npos)
|
2022-09-22 21:26:05 +03:00
|
|
|
{
|
2013-05-06 15:14:39 +02:00
|
|
|
std::string link = utf8text.substr(pos_begin + 1, pos_end - pos_begin - 1);
|
|
|
|
const char specialPseudoAsteriskCharacter = 127;
|
|
|
|
std::replace(link.begin(), link.end(), specialPseudoAsteriskCharacter, '*');
|
|
|
|
std::string topicName = MWBase::Environment::get()
|
|
|
|
.getWindowManager()
|
|
|
|
->getTranslationDataStorage()
|
|
|
|
.topicStandardForm(link);
|
2022-09-22 21:26:05 +03:00
|
|
|
|
2013-05-06 15:14:39 +02:00
|
|
|
std::string displayName = link;
|
|
|
|
while (displayName[displayName.size() - 1] == '*')
|
|
|
|
displayName.erase(displayName.size() - 1, 1);
|
2022-09-22 21:26:05 +03:00
|
|
|
|
2013-05-06 15:14:39 +02:00
|
|
|
utf8text.replace(pos_begin, pos_end + 1 - pos_begin, displayName);
|
2022-09-22 21:26:05 +03:00
|
|
|
|
2021-04-19 15:51:00 +04:00
|
|
|
intptr_t value = 0;
|
2013-05-06 15:14:39 +02:00
|
|
|
if (mModel->mKeywordSearch.containsKeyword(topicName, value))
|
|
|
|
mHyperLinks[std::make_pair(pos_begin, pos_begin + displayName.size())] = value;
|
2022-09-22 21:26:05 +03:00
|
|
|
}
|
|
|
|
else
|
|
|
|
break;
|
2013-05-06 15:14:39 +02:00
|
|
|
}
|
|
|
|
|
2013-01-27 12:01:37 -08:00
|
|
|
loaded = true;
|
2022-09-22 21:26:05 +03:00
|
|
|
}
|
2013-01-27 12:01:37 -08:00
|
|
|
}
|
|
|
|
|
2013-02-14 21:37:33 -08:00
|
|
|
Utf8Span body() const override
|
2022-09-22 21:26:05 +03:00
|
|
|
{
|
2013-02-14 21:37:33 -08:00
|
|
|
ensureLoaded();
|
2013-01-27 12:01:37 -08:00
|
|
|
|
2020-10-16 22:18:54 +04:00
|
|
|
return toUtf8Span(utf8text);
|
2022-09-22 21:26:05 +03:00
|
|
|
}
|
2013-01-27 12:01:37 -08:00
|
|
|
|
2013-05-06 15:14:39 +02:00
|
|
|
void visitSpans(std::function<void(TopicId, size_t, size_t)> visitor) const override
|
|
|
|
{
|
2013-02-14 21:37:33 -08:00
|
|
|
ensureLoaded();
|
2013-05-06 15:14:39 +02:00
|
|
|
mModel->ensureKeyWordSearchLoaded();
|
2022-09-22 21:26:05 +03:00
|
|
|
|
2013-05-06 15:14:39 +02:00
|
|
|
if (mHyperLinks.size()
|
|
|
|
&& MWBase::Environment::get().getWindowManager()->getTranslationDataStorage().hasTranslation())
|
|
|
|
{
|
|
|
|
size_t formatted = 0; // points to the first character that is not laid out yet
|
|
|
|
for (std::map<Range, intptr_t>::const_iterator it = mHyperLinks.begin(); it != mHyperLinks.end();
|
2022-09-22 21:26:05 +03:00
|
|
|
++it)
|
|
|
|
{
|
2013-05-06 15:14:39 +02:00
|
|
|
intptr_t topicId = it->second;
|
|
|
|
if (formatted < it->first.first)
|
|
|
|
visitor(0, formatted, it->first.first);
|
|
|
|
visitor(topicId, it->first.first, it->first.second);
|
|
|
|
formatted = it->first.second;
|
2022-09-22 21:26:05 +03:00
|
|
|
}
|
2013-05-06 15:14:39 +02:00
|
|
|
if (formatted < utf8text.size())
|
|
|
|
visitor(0, formatted, utf8text.size());
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-01-09 04:19:38 +01:00
|
|
|
std::vector<KeywordSearchT::Match> matches;
|
2013-05-06 15:14:39 +02:00
|
|
|
mModel->mKeywordSearch.highlightKeywords(utf8text.begin(), utf8text.end(), matches);
|
2013-01-27 12:01:37 -08:00
|
|
|
|
2013-05-06 15:14:39 +02:00
|
|
|
std::string::const_iterator i = utf8text.begin();
|
|
|
|
for (std::vector<KeywordSearchT::Match>::const_iterator it = matches.begin(); it != matches.end();
|
2022-09-22 21:26:05 +03:00
|
|
|
++it)
|
|
|
|
{
|
2015-01-09 04:19:38 +01:00
|
|
|
const KeywordSearchT::Match& match = *it;
|
2013-01-27 12:01:37 -08:00
|
|
|
|
2013-05-06 15:14:39 +02:00
|
|
|
if (i != match.mBeg)
|
|
|
|
visitor(0, i - utf8text.begin(), match.mBeg - utf8text.begin());
|
2013-01-27 12:01:37 -08:00
|
|
|
|
|
|
|
visitor(match.mValue, match.mBeg - utf8text.begin(), match.mEnd - utf8text.begin());
|
|
|
|
|
2013-02-09 10:44:20 -08:00
|
|
|
i = match.mEnd;
|
2022-09-22 21:26:05 +03:00
|
|
|
}
|
2013-01-27 12:01:37 -08:00
|
|
|
|
2013-05-06 15:14:39 +02:00
|
|
|
if (i != utf8text.end())
|
2022-08-24 20:38:52 +02:00
|
|
|
visitor(0, i - utf8text.begin(), utf8text.size());
|
2022-09-22 21:26:05 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
2014-06-03 00:16:32 +02:00
|
|
|
|
2014-10-02 19:26:37 +02:00
|
|
|
void visitQuestNames(bool active_only, std::function<void(std::string_view, bool)> visitor) const override
|
2013-01-27 12:01:37 -08:00
|
|
|
{
|
2014-10-02 19:26:37 +02:00
|
|
|
MWBase::Journal* journal = MWBase::Environment::get().getJournal();
|
2022-09-22 21:26:05 +03:00
|
|
|
|
2014-10-02 19:26:37 +02:00
|
|
|
std::set<std::string, std::less<>> visitedQuests;
|
|
|
|
|
|
|
|
// Note that for purposes of the journal GUI, quests are identified by the name, not the ID, so several
|
|
|
|
// different quest IDs can end up in the same quest log. A quest log should be considered finished
|
|
|
|
// when any quest ID in that log is finished.
|
|
|
|
for (MWBase::Journal::TQuestIter i = journal->questBegin(); i != journal->questEnd(); ++i)
|
|
|
|
{
|
|
|
|
const MWDialogue::Quest& quest = i->second;
|
|
|
|
|
|
|
|
bool isFinished = false;
|
|
|
|
for (MWBase::Journal::TQuestIter j = journal->questBegin(); j != journal->questEnd(); ++j)
|
2022-09-22 21:26:05 +03:00
|
|
|
{
|
2014-10-02 19:26:37 +02:00
|
|
|
if (quest.getName() == j->second.getName() && j->second.isFinished())
|
2013-01-27 12:01:37 -08:00
|
|
|
isFinished = true;
|
2022-09-22 21:26:05 +03:00
|
|
|
}
|
2013-01-27 12:01:37 -08:00
|
|
|
|
2014-06-03 00:16:32 +02:00
|
|
|
if (active_only && isFinished)
|
|
|
|
continue;
|
|
|
|
|
2014-01-23 12:54:37 +01:00
|
|
|
// Unfortunately Morrowind.esm has no quest names, since the quest book was added with tribunal.
|
2014-02-16 13:12:31 +01:00
|
|
|
// Note that even with Tribunal, some quests still don't have quest names. I'm assuming those are not
|
2015-02-13 16:51:34 +01:00
|
|
|
// supposed to appear in the quest book.
|
|
|
|
if (!quest.getName().empty())
|
2022-09-22 21:26:05 +03:00
|
|
|
{
|
2014-06-03 00:16:32 +02:00
|
|
|
// Don't list the same quest name twice
|
|
|
|
if (visitedQuests.find(quest.getName()) != visitedQuests.end())
|
|
|
|
continue;
|
2022-09-22 21:26:05 +03:00
|
|
|
|
2015-02-13 16:51:34 +01:00
|
|
|
visitor(quest.getName(), isFinished);
|
2014-06-03 00:16:32 +02:00
|
|
|
|
2022-08-24 20:38:52 +02:00
|
|
|
visitedQuests.emplace(quest.getName());
|
2022-09-22 21:26:05 +03:00
|
|
|
}
|
2014-06-03 00:16:32 +02:00
|
|
|
}
|
2013-01-27 12:01:37 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
template <typename iterator_t>
|
2013-03-06 20:02:00 -08:00
|
|
|
struct JournalEntryImpl : BaseEntry<iterator_t, JournalEntry>
|
2013-01-27 12:01:37 -08:00
|
|
|
{
|
2013-03-06 20:02:00 -08:00
|
|
|
using BaseEntry<iterator_t, JournalEntry>::itr;
|
2013-01-27 12:01:37 -08:00
|
|
|
|
|
|
|
mutable std::string timestamp_buffer;
|
|
|
|
|
2013-05-04 14:15:47 +02:00
|
|
|
JournalEntryImpl(JournalViewModelImpl const* model, iterator_t itr)
|
|
|
|
: BaseEntry<iterator_t, JournalEntry>(model, itr)
|
2013-01-27 12:01:37 -08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2020-10-16 22:18:54 +04:00
|
|
|
std::string getText() const override { return itr->getText(); }
|
2013-01-27 12:01:37 -08:00
|
|
|
|
2020-10-16 22:18:54 +04:00
|
|
|
Utf8Span timestamp() const override
|
2013-01-27 12:01:37 -08:00
|
|
|
{
|
|
|
|
if (timestamp_buffer.empty())
|
2022-09-22 21:26:05 +03:00
|
|
|
{
|
2013-11-26 12:47:30 +01:00
|
|
|
std::string dayStr = MyGUI::LanguageManager::getInstance().replaceTags("#{sDay}");
|
2013-01-27 12:01:37 -08:00
|
|
|
|
2014-07-21 01:17:01 +02:00
|
|
|
std::ostringstream os;
|
2013-01-27 12:01:37 -08:00
|
|
|
|
|
|
|
os << itr->mDayOfMonth << ' ' << MWBase::Environment::get().getWorld()->getMonthName(itr->mMonth)
|
|
|
|
<< " (" << dayStr << " " << (itr->mDay) << ')';
|
|
|
|
|
2013-02-14 21:37:33 -08:00
|
|
|
timestamp_buffer = os.str();
|
2013-01-27 12:01:37 -08:00
|
|
|
}
|
|
|
|
|
2020-10-16 22:18:54 +04:00
|
|
|
return toUtf8Span(timestamp_buffer);
|
2022-09-22 21:26:05 +03:00
|
|
|
}
|
2013-02-09 10:44:20 -08:00
|
|
|
};
|
2013-01-27 12:01:37 -08:00
|
|
|
|
2020-10-16 22:18:54 +04:00
|
|
|
void visitJournalEntries(
|
2023-01-29 21:31:21 +01:00
|
|
|
std::string_view questName, std::function<void(JournalEntry const&)> visitor) const override
|
2013-01-27 12:01:37 -08:00
|
|
|
{
|
2014-06-03 00:16:32 +02:00
|
|
|
MWBase::Journal* journal = MWBase::Environment::get().getJournal();
|
2013-01-27 12:01:37 -08:00
|
|
|
|
2013-02-09 10:44:20 -08:00
|
|
|
if (!questName.empty())
|
2013-01-27 12:01:37 -08:00
|
|
|
{
|
2014-06-03 00:16:32 +02:00
|
|
|
std::vector<MWDialogue::Quest const*> quests;
|
|
|
|
for (MWBase::Journal::TQuestIter questIt = journal->questBegin(); questIt != journal->questEnd();
|
|
|
|
++questIt)
|
2022-09-22 21:26:05 +03:00
|
|
|
{
|
2014-06-03 00:16:32 +02:00
|
|
|
if (Misc::StringUtils::ciEqual(questIt->second.getName(), questName))
|
|
|
|
quests.push_back(&questIt->second);
|
2022-09-22 21:26:05 +03:00
|
|
|
}
|
|
|
|
|
2014-06-03 00:16:32 +02:00
|
|
|
for (MWBase::Journal::TEntryIter i = journal->begin(); i != journal->end(); ++i)
|
2013-01-27 12:01:37 -08:00
|
|
|
{
|
2014-06-03 00:16:32 +02:00
|
|
|
for (std::vector<MWDialogue::Quest const*>::iterator questIt = quests.begin();
|
|
|
|
questIt != quests.end(); ++questIt)
|
|
|
|
{
|
|
|
|
MWDialogue::Quest const* quest = *questIt;
|
2013-02-09 10:44:20 -08:00
|
|
|
for (MWDialogue::Topic::TEntryIter j = quest->begin(); j != quest->end(); ++j)
|
2022-09-22 21:26:05 +03:00
|
|
|
{
|
2014-06-03 00:16:32 +02:00
|
|
|
if (i->mInfoId == j->mInfoId)
|
|
|
|
visitor(JournalEntryImpl<MWBase::Journal::TEntryIter>(this, i));
|
2022-09-22 21:26:05 +03:00
|
|
|
}
|
2014-06-03 00:16:32 +02:00
|
|
|
}
|
2013-01-27 12:01:37 -08:00
|
|
|
}
|
|
|
|
}
|
2022-09-22 21:26:05 +03:00
|
|
|
else
|
|
|
|
{
|
2013-02-09 10:44:20 -08:00
|
|
|
for (MWBase::Journal::TEntryIter i = journal->begin(); i != journal->end(); ++i)
|
2013-03-06 20:02:00 -08:00
|
|
|
visitor(JournalEntryImpl<MWBase::Journal::TEntryIter>(this, i));
|
2022-09-22 21:26:05 +03:00
|
|
|
}
|
2013-01-27 12:01:37 -08:00
|
|
|
}
|
2022-09-22 21:26:05 +03:00
|
|
|
|
2013-01-27 12:01:37 -08:00
|
|
|
void visitTopicName(TopicId topicId, std::function<void(Utf8Span)> visitor) const override
|
|
|
|
{
|
2013-02-09 10:44:20 -08:00
|
|
|
MWDialogue::Topic const& topic = *reinterpret_cast<MWDialogue::Topic const*>(topicId);
|
2013-03-06 20:02:00 -08:00
|
|
|
visitor(toUtf8Span(topic.getName()));
|
2013-01-27 12:01:37 -08:00
|
|
|
}
|
|
|
|
|
2013-02-09 10:44:20 -08:00
|
|
|
void visitTopicNamesStartingWith(
|
|
|
|
Utf8Stream::UnicodeChar character, std::function<void(std::string_view)> visitor) const override
|
2013-01-27 12:01:37 -08:00
|
|
|
{
|
2021-11-05 09:53:52 +00:00
|
|
|
MWBase::Journal* journal = MWBase::Environment::get().getJournal();
|
2017-08-04 20:21:13 +04:00
|
|
|
|
2013-02-09 10:44:20 -08:00
|
|
|
for (MWBase::Journal::TTopicIter i = journal->topicBegin(); i != journal->topicEnd(); ++i)
|
2022-09-22 21:26:05 +03:00
|
|
|
{
|
Initial commit: In ESM structures, replace the string members that are RefIds to other records, to a new strong type
The strong type is actually just a string underneath, but this will help in the future to have a distinction so it's easier to search and replace when we use an integer ID
Slowly going through all the changes to make, still hundreds of errors
a lot of functions/structures use std::string or stringview to designate an ID. So it takes time
Continues slowly replacing ids. There are technically more and more compilation errors
I have good hope that there is a point where the amount of errors will dramatically go down as all the main functions use the ESM::RefId type
Continue moving forward, changes to the stores
slowly moving along
Starting to see the fruit of those changes.
still many many error, but more and more Irun into a situation where a function is sandwiched between two functions that use the RefId type.
More replacements. Things are starting to get easier
I can see more and more often the issue is that the function is awaiting a RefId, but is given a string
there is less need to go down functions and to fix a long list of them.
Still moving forward, and for the first time error count is going down!
Good pace, not sure about topics though, mId and mName are actually the same thing and are used interchangeably
Cells are back to using string for the name, haven't fixed everything yet. Many other changes
Under the bar of 400 compilation errors.
more good progress <100 compile errors!
More progress
Game settings store can use string for find, it was a bit absurd how every use of it required to create refId from string
some more progress on other fronts
Mostly game settings clean
one error opened a lot of other errors. Down to 18, but more will prbably appear
only link errors left??
Fixed link errors
OpenMW compiles, and launches, with some issues, but still!
2022-09-25 13:17:09 +02:00
|
|
|
Utf8Stream stream(i->first.getRefIdString().c_str());
|
2021-11-05 09:53:52 +00:00
|
|
|
Utf8Stream::UnicodeChar first = Utf8Stream::toLowerUtf8(stream.peek());
|
2022-09-22 21:26:05 +03:00
|
|
|
|
2021-11-05 09:53:52 +00:00
|
|
|
if (first != Utf8Stream::toLowerUtf8(character))
|
2017-11-21 12:31:23 +04:00
|
|
|
continue;
|
2013-01-27 12:01:37 -08:00
|
|
|
|
2017-11-21 12:31:23 +04:00
|
|
|
visitor(i->second.getName());
|
2022-09-22 21:26:05 +03:00
|
|
|
}
|
2013-01-27 12:01:37 -08:00
|
|
|
}
|
|
|
|
|
2013-03-06 20:02:00 -08:00
|
|
|
struct TopicEntryImpl : BaseEntry<MWDialogue::Topic::TEntryIter, TopicEntry>
|
2013-01-27 12:01:37 -08:00
|
|
|
{
|
2013-05-01 10:28:59 +02:00
|
|
|
MWDialogue::Topic const& mTopic;
|
2022-09-22 21:26:05 +03:00
|
|
|
|
2013-05-01 10:28:59 +02:00
|
|
|
TopicEntryImpl(JournalViewModelImpl const* model, MWDialogue::Topic const& topic, iterator_t itr)
|
|
|
|
: BaseEntry(model, itr)
|
|
|
|
, mTopic(topic)
|
2022-09-22 21:26:05 +03:00
|
|
|
{
|
|
|
|
}
|
2013-01-27 12:01:37 -08:00
|
|
|
|
2013-05-01 10:28:59 +02:00
|
|
|
std::string getText() const override { return itr->getText(); }
|
2013-01-27 12:01:37 -08:00
|
|
|
|
2020-10-16 22:18:54 +04:00
|
|
|
Utf8Span source() const override { return toUtf8Span(itr->mActorName); }
|
2013-02-09 10:44:20 -08:00
|
|
|
};
|
2013-01-27 12:01:37 -08:00
|
|
|
|
2020-10-16 22:18:54 +04:00
|
|
|
void visitTopicEntries(TopicId topicId, std::function<void(TopicEntry const&)> visitor) const override
|
2013-02-09 10:44:20 -08:00
|
|
|
{
|
2014-01-25 23:53:50 +01:00
|
|
|
typedef MWDialogue::Topic::TEntryIter iterator_t;
|
2022-09-22 21:26:05 +03:00
|
|
|
|
2014-01-25 23:53:50 +01:00
|
|
|
MWDialogue::Topic const& topic = *reinterpret_cast<MWDialogue::Topic const*>(topicId);
|
2013-01-27 12:01:37 -08:00
|
|
|
|
2013-05-01 10:28:59 +02:00
|
|
|
for (iterator_t i = topic.begin(); i != topic.end(); ++i)
|
|
|
|
visitor(TopicEntryImpl(this, topic, i));
|
2022-09-22 21:26:05 +03:00
|
|
|
}
|
2013-02-09 10:44:20 -08:00
|
|
|
};
|
2013-01-27 12:01:37 -08:00
|
|
|
|
2020-10-16 22:18:54 +04:00
|
|
|
JournalViewModel::Ptr JournalViewModel::create()
|
2013-02-09 10:44:20 -08:00
|
|
|
{
|
2013-05-01 10:28:59 +02:00
|
|
|
return std::make_shared<JournalViewModelImpl>();
|
2013-01-27 12:01:37 -08:00
|
|
|
}
|
2013-05-06 16:04:28 +02:00
|
|
|
|
|
|
|
}
|