Fix crashes on SatCom in Moon missions (#1334)
parent
5112bf86df
commit
a5c7187017
|
@ -430,7 +430,7 @@ float CText::GetStringWidth(const std::string &text,
|
||||||
|
|
||||||
UTF8Char ch;
|
UTF8Char ch;
|
||||||
|
|
||||||
int len = StrUtils::Utf8CharSizeAt(text, index);
|
int len = GetCharSizeAt(font, text, index);
|
||||||
if (len >= 1)
|
if (len >= 1)
|
||||||
ch.c1 = text[index];
|
ch.c1 = text[index];
|
||||||
if (len >= 2)
|
if (len >= 2)
|
||||||
|
@ -565,7 +565,7 @@ int CText::Justify(const std::string &text, std::vector<FontMetaChar>::iterator
|
||||||
|
|
||||||
UTF8Char ch;
|
UTF8Char ch;
|
||||||
|
|
||||||
int len = StrUtils::Utf8CharSizeAt(text, index);
|
int len = GetCharSizeAt(font, text, index);
|
||||||
if (len >= 1)
|
if (len >= 1)
|
||||||
ch.c1 = text[index];
|
ch.c1 = text[index];
|
||||||
if (len >= 2)
|
if (len >= 2)
|
||||||
|
@ -606,7 +606,7 @@ int CText::Justify(const std::string &text, FontType font, float size, float wid
|
||||||
{
|
{
|
||||||
UTF8Char ch;
|
UTF8Char ch;
|
||||||
|
|
||||||
int len = StrUtils::Utf8CharSizeAt(text, index);
|
int len = GetCharSizeAt(font, text, index);
|
||||||
if (len >= 1)
|
if (len >= 1)
|
||||||
ch.c1 = text[index];
|
ch.c1 = text[index];
|
||||||
if (len >= 2)
|
if (len >= 2)
|
||||||
|
@ -648,12 +648,9 @@ int CText::Detect(const std::string &text, std::vector<FontMetaChar>::iterator f
|
||||||
if (format + fmtIndex != end)
|
if (format + fmtIndex != end)
|
||||||
font = static_cast<FontType>(*(format + fmtIndex) & FONT_MASK_FONT);
|
font = static_cast<FontType>(*(format + fmtIndex) & FONT_MASK_FONT);
|
||||||
|
|
||||||
// TODO: if (font == FONT_BUTTON)
|
|
||||||
//if (font == FONT_BUTTON) continue;
|
|
||||||
|
|
||||||
UTF8Char ch;
|
UTF8Char ch;
|
||||||
|
|
||||||
int len = StrUtils::Utf8CharSizeAt(text, index);
|
int len = GetCharSizeAt(font, text, index);
|
||||||
if (len >= 1)
|
if (len >= 1)
|
||||||
ch.c1 = text[index];
|
ch.c1 = text[index];
|
||||||
if (len >= 2)
|
if (len >= 2)
|
||||||
|
@ -686,7 +683,7 @@ int CText::Detect(const std::string &text, FontType font, float size, float offs
|
||||||
{
|
{
|
||||||
UTF8Char ch;
|
UTF8Char ch;
|
||||||
|
|
||||||
int len = StrUtils::Utf8CharSizeAt(text, index);
|
int len = GetCharSizeAt(font, text, index);
|
||||||
if (len >= 1)
|
if (len >= 1)
|
||||||
ch.c1 = text[index];
|
ch.c1 = text[index];
|
||||||
if (len >= 2)
|
if (len >= 2)
|
||||||
|
@ -898,16 +895,7 @@ void CText::StringToUTFCharList(const std::string &text, std::vector<UTF8Char> &
|
||||||
if (format + index != end)
|
if (format + index != end)
|
||||||
font = static_cast<FontType>(*(format + index) & FONT_MASK_FONT);
|
font = static_cast<FontType>(*(format + index) & FONT_MASK_FONT);
|
||||||
|
|
||||||
int len;
|
int len = GetCharSizeAt(font, text, index);
|
||||||
|
|
||||||
if(font == FONT_BUTTON)
|
|
||||||
{
|
|
||||||
len = 1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
len = StrUtils::Utf8CharSizeAt(text, index);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (len >= 1)
|
if (len >= 1)
|
||||||
ch.c1 = text[index];
|
ch.c1 = text[index];
|
||||||
|
@ -922,6 +910,20 @@ void CText::StringToUTFCharList(const std::string &text, std::vector<UTF8Char> &
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int CText::GetCharSizeAt(Gfx::FontType font, const std::string& text, unsigned int index) const
|
||||||
|
{
|
||||||
|
int len = 0;
|
||||||
|
if (font == FONT_BUTTON)
|
||||||
|
{
|
||||||
|
len = 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
len = StrUtils::Utf8CharSizeAt(text, index);
|
||||||
|
}
|
||||||
|
return len;
|
||||||
|
}
|
||||||
|
|
||||||
void CText::DrawString(const std::string &text, FontType font,
|
void CText::DrawString(const std::string &text, FontType font,
|
||||||
float size, Math::IntPoint pos, int width, int eol, Color color)
|
float size, Math::IntPoint pos, int width, int eol, Color color)
|
||||||
{
|
{
|
||||||
|
|
|
@ -337,6 +337,8 @@ protected:
|
||||||
void StringToUTFCharList(const std::string &text, std::vector<UTF8Char> &chars);
|
void StringToUTFCharList(const std::string &text, std::vector<UTF8Char> &chars);
|
||||||
void StringToUTFCharList(const std::string &text, std::vector<UTF8Char> &chars, std::vector<FontMetaChar>::iterator format, std::vector<FontMetaChar>::iterator end);
|
void StringToUTFCharList(const std::string &text, std::vector<UTF8Char> &chars, std::vector<FontMetaChar>::iterator format, std::vector<FontMetaChar>::iterator end);
|
||||||
|
|
||||||
|
int GetCharSizeAt(Gfx::FontType font, const std::string& text, unsigned int index) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
CEngine* m_engine;
|
CEngine* m_engine;
|
||||||
CDevice* m_device;
|
CDevice* m_device;
|
||||||
|
|
Loading…
Reference in New Issue