mirror of
https://github.com/OpenMW/openmw.git
synced 2025-03-02 20:39:42 +00:00
Use string_view in journalbooks
This commit is contained in:
parent
3a9a60a453
commit
66e5fbb286
5 changed files with 24 additions and 18 deletions
|
@ -167,7 +167,7 @@ namespace MWGui
|
|||
{
|
||||
const MyGUI::Colour& headerColour = windowManager->getTextColours().header;
|
||||
BookTypesetter::Style* title = typesetter->createStyle({}, headerColour, false);
|
||||
typesetter->write(title, to_utf8_span(mTitle.c_str()));
|
||||
typesetter->write(title, to_utf8_span(mTitle));
|
||||
typesetter->sectionBreak();
|
||||
}
|
||||
|
||||
|
@ -206,7 +206,7 @@ namespace MWGui
|
|||
break;
|
||||
}
|
||||
|
||||
typesetter->addContent(to_utf8_span(text.c_str()));
|
||||
typesetter->addContent(to_utf8_span(text));
|
||||
|
||||
if (hyperLinks.size()
|
||||
&& MWBase::Environment::get().getWindowManager()->getTranslationDataStorage().hasTranslation())
|
||||
|
@ -271,7 +271,7 @@ namespace MWGui
|
|||
const MyGUI::Colour& textColour = MWBase::Environment::get().getWindowManager()->getTextColours().notify;
|
||||
BookTypesetter::Style* title = typesetter->createStyle("", textColour, false);
|
||||
typesetter->sectionBreak(9);
|
||||
typesetter->write(title, to_utf8_span(mText.c_str()));
|
||||
typesetter->write(title, to_utf8_span(mText));
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------------------------------
|
||||
|
@ -628,7 +628,7 @@ namespace MWGui
|
|||
typesetter->lineBreak();
|
||||
BookTypesetter::Style* questionStyle = typesetter->createHotStyle(
|
||||
body, textColours.answer, textColours.answerOver, textColours.answerPressed, interactiveId);
|
||||
typesetter->write(questionStyle, to_utf8_span(choice.first.c_str()));
|
||||
typesetter->write(questionStyle, to_utf8_span(choice.first));
|
||||
}
|
||||
|
||||
mGoodbye = MWBase::Environment::get().getDialogueManager()->isGoodbye();
|
||||
|
@ -647,7 +647,7 @@ namespace MWGui
|
|||
BookTypesetter::Style* questionStyle = typesetter->createHotStyle(
|
||||
body, textColours.answer, textColours.answerOver, textColours.answerPressed, interactiveId);
|
||||
typesetter->lineBreak();
|
||||
typesetter->write(questionStyle, to_utf8_span(goodbye.c_str()));
|
||||
typesetter->write(questionStyle, to_utf8_span(goodbye));
|
||||
}
|
||||
|
||||
TypesetBook::Ptr book = typesetter->complete();
|
||||
|
|
|
@ -146,13 +146,13 @@ namespace
|
|||
namespace MWGui
|
||||
{
|
||||
|
||||
MWGui::BookTypesetter::Utf8Span to_utf8_span(char const* text)
|
||||
MWGui::BookTypesetter::Utf8Span to_utf8_span(std::string_view text)
|
||||
{
|
||||
typedef MWGui::BookTypesetter::Utf8Point point;
|
||||
|
||||
point begin = reinterpret_cast<point>(text);
|
||||
point begin = reinterpret_cast<point>(text.data());
|
||||
|
||||
return MWGui::BookTypesetter::Utf8Span(begin, begin + strlen(text));
|
||||
return MWGui::BookTypesetter::Utf8Span(begin, begin + text.length());
|
||||
}
|
||||
|
||||
typedef TypesetBook::Ptr book;
|
||||
|
@ -207,7 +207,7 @@ namespace MWGui
|
|||
return typesetter->complete();
|
||||
}
|
||||
|
||||
book JournalBooks::createQuestBook(const std::string& questName)
|
||||
book JournalBooks::createQuestBook(std::string_view questName)
|
||||
{
|
||||
BookTypesetter::Ptr typesetter = createTypesetter();
|
||||
|
||||
|
@ -215,7 +215,7 @@ namespace MWGui
|
|||
BookTypesetter::Style* body = typesetter->createStyle("", MyGUI::Colour::Black);
|
||||
|
||||
AddQuestName addName(typesetter, header);
|
||||
addName(to_utf8_span(questName.c_str()));
|
||||
addName(to_utf8_span(questName));
|
||||
|
||||
mModel->visitJournalEntries(questName, AddJournalEntry(typesetter, body, header, false));
|
||||
|
||||
|
@ -241,12 +241,14 @@ namespace MWGui
|
|||
mIndexPagesCount = 2;
|
||||
|
||||
char ch = 'A';
|
||||
std::string buffer;
|
||||
|
||||
BookTypesetter::Style* body = typesetter->createStyle("", MyGUI::Colour::Black);
|
||||
for (int i = 0; i < 26; ++i)
|
||||
{
|
||||
char buffer[32];
|
||||
sprintf(buffer, "( %c )", ch);
|
||||
buffer = "( ";
|
||||
buffer += ch;
|
||||
buffer += " )";
|
||||
|
||||
const MWGui::TextColours& textColours = MWBase::Environment::get().getWindowManager()->getTextColours();
|
||||
BookTypesetter::Style* style = typesetter->createHotStyle(body, textColours.journalTopic,
|
||||
|
@ -286,10 +288,14 @@ namespace MWGui
|
|||
|
||||
unsigned char ch[3] = { 0xd0, 0x90, 0x00 }; // CYRILLIC CAPITAL A is a 0xd090 in UTF-8
|
||||
|
||||
std::string buffer;
|
||||
|
||||
for (int i = 0; i < 32; ++i)
|
||||
{
|
||||
char buffer[32];
|
||||
sprintf(buffer, "( %c%c )", ch[0], ch[1]);
|
||||
buffer = "( ";
|
||||
buffer += ch[0];
|
||||
buffer += ch[1];
|
||||
buffer += " )";
|
||||
|
||||
Utf8Stream stream((char*)ch);
|
||||
Utf8Stream::UnicodeChar first = stream.peek();
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
namespace MWGui
|
||||
{
|
||||
MWGui::BookTypesetter::Utf8Span to_utf8_span(char const* text);
|
||||
MWGui::BookTypesetter::Utf8Span to_utf8_span(std::string_view text);
|
||||
|
||||
struct JournalBooks
|
||||
{
|
||||
|
@ -21,7 +21,7 @@ namespace MWGui
|
|||
Book createJournalBook();
|
||||
Book createTopicBook(uintptr_t topicId);
|
||||
Book createTopicBook(const std::string& topicId);
|
||||
Book createQuestBook(const std::string& questName);
|
||||
Book createQuestBook(std::string_view questName);
|
||||
Book createTopicIndexBook();
|
||||
|
||||
ToUTF8::FromType mEncoding;
|
||||
|
|
|
@ -264,7 +264,7 @@ namespace MWGui
|
|||
};
|
||||
|
||||
void visitJournalEntries(
|
||||
const std::string& questName, std::function<void(JournalEntry const&)> visitor) const override
|
||||
std::string_view questName, std::function<void(JournalEntry const&)> visitor) const override
|
||||
{
|
||||
MWBase::Journal* journal = MWBase::Environment::get().getJournal();
|
||||
|
||||
|
|
|
@ -78,7 +78,7 @@ namespace MWGui
|
|||
/// walks over the journal entries related to all quests with the given name
|
||||
/// If \a questName is empty, simply visits all journal entries
|
||||
virtual void visitJournalEntries(
|
||||
const std::string& questName, std::function<void(JournalEntry const&)> visitor) const = 0;
|
||||
std::string_view questName, std::function<void(JournalEntry const&)> visitor) const = 0;
|
||||
|
||||
/// provides the name of the topic specified by its id
|
||||
virtual void visitTopicName(TopicId topicId, std::function<void(Utf8Span)> visitor) const = 0;
|
||||
|
|
Loading…
Reference in a new issue