Move logic for determining Russian index page count to a shared place

This commit is contained in:
Andrew Lanzone 2025-07-10 08:45:51 -07:00
parent d100867bce
commit e04f0a8bd6
3 changed files with 12 additions and 15 deletions

View File

@ -156,6 +156,13 @@ namespace MWGui
return MWGui::BookTypesetter::Utf8Span(begin, begin + text.length());
}
int getCyrillicIndexPageCount()
{
// For small font size split alphabet to two columns (2x15 characers), for big font size split it to three
// colums (3x10 characters).
return Settings::gui().mFontSize < 18 ? 2 : 3;
}
typedef TypesetBook::Ptr book;
JournalBooks::JournalBooks(JournalViewModel::Ptr model, ToUTF8::FromType encoding)
@ -277,13 +284,8 @@ namespace MWGui
// for small font size split alphabet to two columns (2x15 characers), for big font size split it to three
// colums (3x10 characters).
int sectionBreak = 10;
mIndexPagesCount = 3;
if (Settings::gui().mFontSize < 18)
{
sectionBreak = 15;
mIndexPagesCount = 2;
}
mIndexPagesCount = getCyrillicIndexPageCount();
int sectionBreak = 30 / mIndexPagesCount;
unsigned char ch[3] = { 0xd0, 0x90, 0x00 }; // CYRILLIC CAPITAL A is a 0xd090 in UTF-8

View File

@ -9,6 +9,7 @@
namespace MWGui
{
MWGui::BookTypesetter::Utf8Span to_utf8_span(std::string_view text);
int getCyrillicIndexPageCount();
const MyGUI::Colour journalHeaderColour = MyGUI::Colour(0.60f, 0.00f, 0.00f);

View File

@ -221,14 +221,8 @@ namespace
// Latin = 26 (13 + 13)
mIndexRowCount = 13;
bool isRussian = (mEncoding == ToUTF8::WINDOWS_1251);
if (isRussian)
{
// This should match the logic in createCyrillicJournalIndex
if (Settings::gui().mFontSize < 18)
mIndexRowCount = 15; // Cyrillic = 30 (15 + 15)
else
mIndexRowCount = 10; // Cyrillic = 30 (10 + 10 + 10)
}
if (isRussian) // Cyrillic is either (10 + 10 + 10) or (15 + 15)
mIndexRowCount = MWGui::getCyrillicIndexPageCount();
mControllerButtons.a = "#{sSelect}";
mControllerButtons.x = "#{OMWEngine:JournalQuests}";