Fixed links in CBot listings in SatCom
parent
b56cd11c98
commit
9017e5a25b
|
@ -720,8 +720,6 @@ void CText::DrawString(const std::string &text, std::vector<FontMetaChar>::itera
|
||||||
|
|
||||||
Color c = color;
|
Color c = color;
|
||||||
FontHighlight hl = static_cast<FontHighlight>(format[fmtIndex] & FONT_MASK_HIGHLIGHT);
|
FontHighlight hl = static_cast<FontHighlight>(format[fmtIndex] & FONT_MASK_HIGHLIGHT);
|
||||||
if (hl != FONT_HIGHLIGHT_NONE)
|
|
||||||
{
|
|
||||||
if (hl == FONT_HIGHLIGHT_TOKEN)
|
if (hl == FONT_HIGHLIGHT_TOKEN)
|
||||||
{
|
{
|
||||||
c = Color(0.490f, 0.380f, 0.165f, 1.0f); // #7D612A
|
c = Color(0.490f, 0.380f, 0.165f, 1.0f); // #7D612A
|
||||||
|
@ -750,13 +748,14 @@ void CText::DrawString(const std::string &text, std::vector<FontMetaChar>::itera
|
||||||
{
|
{
|
||||||
c = Color(0.239f, 0.384f, 0.341f, 1.0f); // #3D6257
|
c = Color(0.239f, 0.384f, 0.341f, 1.0f); // #3D6257
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
// draw highlight background or link underline
|
||||||
|
if (font != FONT_BUTTON)
|
||||||
{
|
{
|
||||||
Math::IntPoint charSize;
|
Math::IntPoint charSize;
|
||||||
charSize.x = GetCharWidthInt(ch, font, size, offset);
|
charSize.x = GetCharWidthInt(ch, font, size, offset);
|
||||||
charSize.y = GetHeightInt(font, size);
|
charSize.y = GetHeightInt(font, size);
|
||||||
DrawHighlight(hl, pos, charSize);
|
DrawHighlight(format[fmtIndex], pos, charSize);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DrawCharAndAdjustPos(ch, font, size, pos, c);
|
DrawCharAndAdjustPos(ch, font, size, pos, c);
|
||||||
|
@ -854,25 +853,24 @@ void CText::DrawString(const std::string &text, FontType font,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CText::DrawHighlight(FontHighlight hl, Math::IntPoint pos, Math::IntPoint size)
|
void CText::DrawHighlight(FontMetaChar hl, Math::IntPoint pos, Math::IntPoint size)
|
||||||
{
|
{
|
||||||
// Gradient colors
|
// Gradient colors
|
||||||
Color grad[4];
|
Color grad[4];
|
||||||
|
|
||||||
// TODO: switch to alpha factors
|
// TODO: switch to alpha factors
|
||||||
|
|
||||||
switch (hl)
|
if ((hl & FONT_MASK_LINK) != 0)
|
||||||
{
|
{
|
||||||
case FONT_HIGHLIGHT_LINK:
|
|
||||||
grad[0] = grad[1] = grad[2] = grad[3] = Color(0.0f, 0.0f, 1.0f, 0.5f);
|
grad[0] = grad[1] = grad[2] = grad[3] = Color(0.0f, 0.0f, 1.0f, 0.5f);
|
||||||
break;
|
}
|
||||||
|
else if ((hl & FONT_MASK_HIGHLIGHT) == FONT_HIGHLIGHT_KEY)
|
||||||
case FONT_HIGHLIGHT_KEY:
|
{
|
||||||
grad[0] = grad[1] = grad[2] = grad[3] =
|
grad[0] = grad[1] = grad[2] = grad[3] =
|
||||||
Color(192.0f / 256.0f, 192.0f / 256.0f, 192.0f / 256.0f, 0.5f);
|
Color(192.0f / 256.0f, 192.0f / 256.0f, 192.0f / 256.0f, 0.5f);
|
||||||
break;
|
}
|
||||||
|
else
|
||||||
default:
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -889,7 +887,7 @@ void CText::DrawHighlight(FontHighlight hl, Math::IntPoint pos, Math::IntPoint s
|
||||||
p2.x = pos.x + size.x;
|
p2.x = pos.x + size.x;
|
||||||
p2.y = pos.y;
|
p2.y = pos.y;
|
||||||
|
|
||||||
if (hl == FONT_HIGHLIGHT_LINK)
|
if ((hl & FONT_MASK_LINK) != 0)
|
||||||
{
|
{
|
||||||
p1.y = pos.y - h; // just emphasized
|
p1.y = pos.y - h; // just emphasized
|
||||||
}
|
}
|
||||||
|
|
|
@ -118,7 +118,6 @@ enum FontTitle
|
||||||
enum FontHighlight
|
enum FontHighlight
|
||||||
{
|
{
|
||||||
FONT_HIGHLIGHT_NONE = 0x00 << 6,
|
FONT_HIGHLIGHT_NONE = 0x00 << 6,
|
||||||
FONT_HIGHLIGHT_LINK = 0x01 << 6, //!< link underline
|
|
||||||
FONT_HIGHLIGHT_TABLE = 0x02 << 6, //!< code background in SatCom
|
FONT_HIGHLIGHT_TABLE = 0x02 << 6, //!< code background in SatCom
|
||||||
FONT_HIGHLIGHT_KEY = 0x03 << 6, //!< background for keys in documentation in SatCom
|
FONT_HIGHLIGHT_KEY = 0x03 << 6, //!< background for keys in documentation in SatCom
|
||||||
FONT_HIGHLIGHT_TOKEN = 0x04 << 6, //!< keywords in CBot scripts
|
FONT_HIGHLIGHT_TOKEN = 0x04 << 6, //!< keywords in CBot scripts
|
||||||
|
@ -142,8 +141,10 @@ enum FontMask
|
||||||
FONT_MASK_TITLE = 0x030,
|
FONT_MASK_TITLE = 0x030,
|
||||||
//! Mask for FontHighlight
|
//! Mask for FontHighlight
|
||||||
FONT_MASK_HIGHLIGHT = 0x3c0,
|
FONT_MASK_HIGHLIGHT = 0x3c0,
|
||||||
|
//! Mask for links
|
||||||
|
FONT_MASK_LINK = 0x400,
|
||||||
//! Mask for image bit (TODO: not used?)
|
//! Mask for image bit (TODO: not used?)
|
||||||
FONT_MASK_IMAGE = 0x400
|
FONT_MASK_IMAGE = 0x800
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -324,7 +325,7 @@ protected:
|
||||||
float size, Math::IntPoint pos, int width, int eol, Color color);
|
float size, Math::IntPoint pos, int width, int eol, Color color);
|
||||||
void DrawString(const std::string &text, FontType font,
|
void 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);
|
||||||
void DrawHighlight(FontHighlight hl, Math::IntPoint pos, Math::IntPoint size);
|
void DrawHighlight(FontMetaChar hl, Math::IntPoint pos, Math::IntPoint size);
|
||||||
void DrawCharAndAdjustPos(UTF8Char ch, FontType font, float size, Math::IntPoint &pos, Color color);
|
void DrawCharAndAdjustPos(UTF8Char ch, FontType font, float size, Math::IntPoint &pos, Color color);
|
||||||
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);
|
||||||
|
|
|
@ -564,7 +564,7 @@ bool CEdit::IsLinkPos(Math::Point pos)
|
||||||
if ( i == -1 ) return false;
|
if ( i == -1 ) return false;
|
||||||
if ( i >= m_len ) return false;
|
if ( i >= m_len ) return false;
|
||||||
|
|
||||||
if ( m_format.size() > static_cast<unsigned int>(i) && ((m_format[i] & Gfx::FONT_MASK_HIGHLIGHT) == Gfx::FONT_HIGHLIGHT_LINK)) return true; // TODO
|
if ( m_format.size() > static_cast<unsigned int>(i) && ((m_format[i] & Gfx::FONT_MASK_LINK) != 0)) return true; // TODO
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -637,13 +637,13 @@ void CEdit::MouseRelease(Math::Point mouse)
|
||||||
if ( !m_bEdit )
|
if ( !m_bEdit )
|
||||||
{
|
{
|
||||||
if ( m_format.size() > 0 && i < m_len && m_cursor1 == m_cursor2 &&
|
if ( m_format.size() > 0 && i < m_len && m_cursor1 == m_cursor2 &&
|
||||||
(m_format[i]&Gfx::FONT_MASK_HIGHLIGHT) == Gfx::FONT_HIGHLIGHT_LINK) //TODO
|
(m_format[i]&Gfx::FONT_MASK_LINK) != 0) //TODO
|
||||||
{
|
{
|
||||||
int rank = -1;
|
int rank = -1;
|
||||||
for ( int j=0 ; j<=i ; j++ )
|
for ( int j=0 ; j<=i ; j++ )
|
||||||
{
|
{
|
||||||
if ( (j == 0 || (m_format[j-1]&Gfx::FONT_MASK_HIGHLIGHT) != Gfx::FONT_HIGHLIGHT_LINK) && // TODO check if good
|
if ( (j == 0 || (m_format[j-1]&Gfx::FONT_MASK_LINK) == 0) && // TODO check if good
|
||||||
(m_format[j+0]&Gfx::FONT_MASK_HIGHLIGHT) == Gfx::FONT_HIGHLIGHT_LINK) // TODO
|
(m_format[j+0]&Gfx::FONT_MASK_LINK) != 0) // TODO
|
||||||
{
|
{
|
||||||
rank ++;
|
rank ++;
|
||||||
}
|
}
|
||||||
|
@ -1581,8 +1581,7 @@ bool CEdit::ReadText(std::string filename, int addSize)
|
||||||
{
|
{
|
||||||
if ( m_bSoluce || !bInSoluce )
|
if ( m_bSoluce || !bInSoluce )
|
||||||
{
|
{
|
||||||
font &= ~Gfx::FONT_MASK_HIGHLIGHT;
|
font |= Gfx::FONT_MASK_LINK;
|
||||||
font |= Gfx::FONT_HIGHLIGHT_LINK;
|
|
||||||
}
|
}
|
||||||
i += 3;
|
i += 3;
|
||||||
}
|
}
|
||||||
|
@ -1602,7 +1601,7 @@ bool CEdit::ReadText(std::string filename, int addSize)
|
||||||
link.name = GetNameParam(buffer.data()+i+3, 0);
|
link.name = GetNameParam(buffer.data()+i+3, 0);
|
||||||
link.marker = GetNameParam(buffer.data()+i+3, 1);
|
link.marker = GetNameParam(buffer.data()+i+3, 1);
|
||||||
m_link.push_back(link);
|
m_link.push_back(link);
|
||||||
font &= ~Gfx::FONT_MASK_HIGHLIGHT;
|
font &= ~Gfx::FONT_MASK_LINK;
|
||||||
}
|
}
|
||||||
i += strchr(buffer.data()+i, ';')-(buffer.data()+i)+1;
|
i += strchr(buffer.data()+i, ';')-(buffer.data()+i)+1;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue