forked from teamnwah/openmw-tes3coop
Use utf8 lowercase function for journal index to avoid code duplication
This commit is contained in:
parent
b5374029e5
commit
afae398b5c
4 changed files with 9 additions and 24 deletions
|
@ -244,7 +244,7 @@ BookTypesetter::Ptr JournalBooks::createLatinJournalIndex ()
|
||||||
const MWGui::TextColours& textColours = MWBase::Environment::get().getWindowManager()->getTextColours();
|
const MWGui::TextColours& textColours = MWBase::Environment::get().getWindowManager()->getTextColours();
|
||||||
BookTypesetter::Style* style = typesetter->createHotStyle (body, textColours.journalTopic,
|
BookTypesetter::Style* style = typesetter->createHotStyle (body, textColours.journalTopic,
|
||||||
textColours.journalTopicOver,
|
textColours.journalTopicOver,
|
||||||
textColours.journalTopicPressed, (uint32_t) ch);
|
textColours.journalTopicPressed, (Utf8Stream::UnicodeChar) ch);
|
||||||
|
|
||||||
if (i == 13)
|
if (i == 13)
|
||||||
typesetter->sectionBreak ();
|
typesetter->sectionBreak ();
|
||||||
|
@ -274,7 +274,7 @@ BookTypesetter::Ptr JournalBooks::createCyrillicJournalIndex ()
|
||||||
sprintf(buffer, "( %c%c )", ch[0], ch[1]);
|
sprintf(buffer, "( %c%c )", ch[0], ch[1]);
|
||||||
|
|
||||||
Utf8Stream stream ((char*) ch);
|
Utf8Stream stream ((char*) ch);
|
||||||
uint32_t first = stream.peek();
|
Utf8Stream::UnicodeChar first = stream.peek();
|
||||||
|
|
||||||
const MWGui::TextColours& textColours = MWBase::Environment::get().getWindowManager()->getTextColours();
|
const MWGui::TextColours& textColours = MWBase::Environment::get().getWindowManager()->getTextColours();
|
||||||
BookTypesetter::Style* style = typesetter->createHotStyle (body, textColours.journalTopic,
|
BookTypesetter::Style* style = typesetter->createHotStyle (body, textColours.journalTopic,
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
|
|
||||||
#include <components/translation/translation.hpp>
|
#include <components/translation/translation.hpp>
|
||||||
#include <components/misc/stringops.hpp>
|
#include <components/misc/stringops.hpp>
|
||||||
#include <components/misc/utf8stream.hpp>
|
|
||||||
|
|
||||||
#include "../mwbase/world.hpp"
|
#include "../mwbase/world.hpp"
|
||||||
#include "../mwbase/journal.hpp"
|
#include "../mwbase/journal.hpp"
|
||||||
|
@ -307,39 +306,22 @@ struct JournalViewModelImpl : JournalViewModel
|
||||||
visitor (toUtf8Span (topic.getName()));
|
visitor (toUtf8Span (topic.getName()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void visitTopicNamesStartingWith (uint32_t character, std::function < void (const std::string&) > visitor) const
|
void visitTopicNamesStartingWith (Utf8Stream::UnicodeChar character, std::function < void (const std::string&) > visitor) const
|
||||||
{
|
{
|
||||||
MWBase::Journal * journal = MWBase::Environment::get().getJournal();
|
MWBase::Journal * journal = MWBase::Environment::get().getJournal();
|
||||||
|
|
||||||
for (MWBase::Journal::TTopicIter i = journal->topicBegin (); i != journal->topicEnd (); ++i)
|
for (MWBase::Journal::TTopicIter i = journal->topicBegin (); i != journal->topicEnd (); ++i)
|
||||||
{
|
{
|
||||||
Utf8Stream stream (i->first.c_str());
|
Utf8Stream stream (i->first.c_str());
|
||||||
uint32_t first = toUpper(stream.peek());
|
Utf8Stream::UnicodeChar first = Misc::StringUtils::toLowerUtf8(stream.peek());
|
||||||
|
|
||||||
if (first != character)
|
if (first != Misc::StringUtils::toLowerUtf8(character))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
visitor (i->second.getName());
|
visitor (i->second.getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint32_t toUpper(uint32_t ch)
|
|
||||||
{
|
|
||||||
// Russian alphabet
|
|
||||||
if (ch >= 0x0430 && ch < 0x0450)
|
|
||||||
ch -= 0x20;
|
|
||||||
|
|
||||||
// Cyrillic IO character
|
|
||||||
if (ch == 0x0451)
|
|
||||||
ch -= 0x50;
|
|
||||||
|
|
||||||
// Latin alphabet
|
|
||||||
if (ch >= 0x61 && ch < 0x80)
|
|
||||||
ch -= 0x20;
|
|
||||||
|
|
||||||
return ch;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct TopicEntryImpl : BaseEntry <MWDialogue::Topic::TEntryIter, TopicEntry>
|
struct TopicEntryImpl : BaseEntry <MWDialogue::Topic::TEntryIter, TopicEntry>
|
||||||
{
|
{
|
||||||
MWDialogue::Topic const & mTopic;
|
MWDialogue::Topic const & mTopic;
|
||||||
|
|
|
@ -6,6 +6,8 @@
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#include <components/misc/utf8stream.hpp>
|
||||||
|
|
||||||
namespace MWGui
|
namespace MWGui
|
||||||
{
|
{
|
||||||
/// View-Model for the journal GUI
|
/// View-Model for the journal GUI
|
||||||
|
@ -76,7 +78,7 @@ namespace MWGui
|
||||||
virtual void visitTopicName (TopicId topicId, std::function <void (Utf8Span)> visitor) const = 0;
|
virtual void visitTopicName (TopicId topicId, std::function <void (Utf8Span)> visitor) const = 0;
|
||||||
|
|
||||||
/// walks over the topics whose names start with the character
|
/// walks over the topics whose names start with the character
|
||||||
virtual void visitTopicNamesStartingWith (uint32_t character, std::function < void (const std::string&) > visitor) const = 0;
|
virtual void visitTopicNamesStartingWith (Utf8Stream::UnicodeChar character, std::function < void (const std::string&) > visitor) const = 0;
|
||||||
|
|
||||||
/// walks over the topic entries for the topic specified by its identifier
|
/// walks over the topic entries for the topic specified by its identifier
|
||||||
virtual void visitTopicEntries (TopicId topicId, std::function <void (TopicEntry const &)> visitor) const = 0;
|
virtual void visitTopicEntries (TopicId topicId, std::function <void (TopicEntry const &)> visitor) const = 0;
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#ifndef MISC_UTF8ITER_HPP
|
#ifndef MISC_UTF8ITER_HPP
|
||||||
#define MISC_UTF8ITER_HPP
|
#define MISC_UTF8ITER_HPP
|
||||||
|
|
||||||
|
#include <cstring>
|
||||||
#include <tuple>
|
#include <tuple>
|
||||||
|
|
||||||
class Utf8Stream
|
class Utf8Stream
|
||||||
|
|
Loading…
Reference in a new issue