mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-26 18:35:20 +00:00
A Russian journal index
This commit is contained in:
parent
eac2e52841
commit
4dcaf040e6
@ -224,20 +224,22 @@ book JournalBooks::createTopicIndexBook ()
|
||||
|
||||
BookTypesetter::Style* body = typesetter->createStyle ("", MyGUI::Colour::Black);
|
||||
|
||||
for (int i = 0; i < 26; ++i)
|
||||
for (int i = 0; i < 32; ++i)
|
||||
{
|
||||
char ch = 'A' + i;
|
||||
|
||||
char buffer [32];
|
||||
|
||||
sprintf (buffer, "( %c )", ch);
|
||||
sprintf(buffer, "( %c%c )", 0xd0, 0x90 + i); // CYRILLIC CAPITAL A is a 0xd090 in UTF-8
|
||||
|
||||
const MWGui::TextColours& textColours = MWBase::Environment::get().getWindowManager()->getTextColours();
|
||||
BookTypesetter::Style* style = typesetter->createHotStyle (body, textColours.journalTopic,
|
||||
textColours.journalTopicOver,
|
||||
textColours.journalTopicPressed, ch);
|
||||
textColours.journalTopicPressed, i+1);
|
||||
|
||||
if (i == 13)
|
||||
// Words can not be started with these characters
|
||||
if (i == 26 || i == 28)
|
||||
continue;
|
||||
|
||||
if (i == 15)
|
||||
typesetter->sectionBreak ();
|
||||
|
||||
typesetter->write (style, to_utf8_span (buffer));
|
||||
|
@ -305,18 +305,36 @@ struct JournalViewModelImpl : JournalViewModel
|
||||
visitor (toUtf8Span (topic.getName()));
|
||||
}
|
||||
|
||||
void visitTopicNamesStartingWith (char character, std::function < void (const std::string&) > visitor) const
|
||||
void visitTopicNamesStartingWith (int index, std::function < void (const std::string&) > visitor) const
|
||||
{
|
||||
MWBase::Journal * journal = MWBase::Environment::get().getJournal();
|
||||
|
||||
for (MWBase::Journal::TTopicIter i = journal->topicBegin (); i != journal->topicEnd (); ++i)
|
||||
{
|
||||
if (i->first [0] != Misc::StringUtils::toLower(character))
|
||||
if (i->first.length() < 2)
|
||||
continue;
|
||||
|
||||
unsigned char byte1 = i->first[0];
|
||||
unsigned char byte2 = i->first[1];
|
||||
|
||||
// Upper case
|
||||
if (byte1 == 0xd0 && byte2 >= 0xb0 && byte2 < 0xc0)
|
||||
byte2 -= 32;
|
||||
|
||||
if (byte1 == 0xd1 && byte2 >= 0x80 && byte2 < 0x90)
|
||||
{
|
||||
byte1 -= 1;
|
||||
byte2 += 32;
|
||||
}
|
||||
|
||||
// CYRILLIC CAPITAL A is a 0xd090 in UTF-8
|
||||
// so we can use 0xd08f + index
|
||||
// (index is a position of letter in alphabet, begins from 1)
|
||||
if (byte1 != 0xd0 || byte2 != 0x8f + index)
|
||||
continue;
|
||||
|
||||
visitor (i->second.getName());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
struct TopicEntryImpl : BaseEntry <MWDialogue::Topic::TEntryIter, TopicEntry>
|
||||
|
@ -75,8 +75,8 @@ namespace MWGui
|
||||
/// provides the name of the topic specified by its id
|
||||
virtual void visitTopicName (TopicId topicId, std::function <void (Utf8Span)> visitor) const = 0;
|
||||
|
||||
/// walks over the topics whose names start with the specified character providing the topics name
|
||||
virtual void visitTopicNamesStartingWith (char character, std::function < void (const std::string&) > visitor) const = 0;
|
||||
/// walks over the topics whose names start with the character, specified by its index in the alphabet, providing the topics name
|
||||
virtual void visitTopicNamesStartingWith (int index, std::function < void (const std::string&) > visitor) const = 0;
|
||||
|
||||
/// 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;
|
||||
|
@ -431,7 +431,7 @@ namespace
|
||||
MWBase::Environment::get().getWindowManager()->playSound("book page");
|
||||
}
|
||||
|
||||
void notifyIndexLinkClicked (MWGui::TypesetBook::InteractiveId character)
|
||||
void notifyIndexLinkClicked (MWGui::TypesetBook::InteractiveId index)
|
||||
{
|
||||
setVisible (LeftTopicIndex, false);
|
||||
setVisible (RightTopicIndex, false);
|
||||
@ -444,7 +444,7 @@ namespace
|
||||
|
||||
AddNamesToList add(list);
|
||||
|
||||
mModel->visitTopicNamesStartingWith((char) character, add);
|
||||
mModel->visitTopicNamesStartingWith(index, add);
|
||||
|
||||
list->adjustSize();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user