[colobot] 109/145: Fixed links in CBot listings in SatCom
Didier Raboud
odyx at moszumanska.debian.org
Mon Jul 11 12:56:23 UTC 2016
This is an automated email from the git hooks/post-receive script.
odyx pushed a commit to branch debian/master
in repository colobot.
commit 9017e5a25b37535b0fc6281effa861c9182c52e2
Author: krzys-h <krzys_h at interia.pl>
Date: Fri Jun 17 21:13:16 2016 +0200
Fixed links in CBot listings in SatCom
---
src/graphics/engine/text.cpp | 98 ++++++++++++++++++++++----------------------
src/graphics/engine/text.h | 7 ++--
src/ui/controls/edit.cpp | 13 +++---
3 files changed, 58 insertions(+), 60 deletions(-)
diff --git a/src/graphics/engine/text.cpp b/src/graphics/engine/text.cpp
index 4fcf4ac..aece13e 100644
--- a/src/graphics/engine/text.cpp
+++ b/src/graphics/engine/text.cpp
@@ -720,43 +720,42 @@ void CText::DrawString(const std::string &text, std::vector<FontMetaChar>::itera
Color c = color;
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
- }
- else if (hl == FONT_HIGHLIGHT_TYPE)
- {
- c = Color(0.31f, 0.443f, 0.196f, 1.0f); // #4F7132
- }
- else if (hl == FONT_HIGHLIGHT_CONST)
- {
- c = Color(0.882f, 0.176f, 0.176f, 1.0f); // #E12D2D
- }
- else if (hl == FONT_HIGHLIGHT_THIS)
- {
- c = Color(0.545f, 0.329f, 0.608f, 1.0f); // #8B549B
- }
- else if (hl == FONT_HIGHLIGHT_COMMENT)
- {
- c = Color(0.251f, 0.271f, 0.306f, 1.0f); // #40454E
- }
- else if (hl == FONT_HIGHLIGHT_KEYWORD)
- {
- c = Color(0.239f, 0.431f, 0.588f, 1.0f); // #3D6E96
- }
- else if (hl == FONT_HIGHLIGHT_STRING)
- {
- c = Color(0.239f, 0.384f, 0.341f, 1.0f); // #3D6257
- }
- else
- {
- Math::IntPoint charSize;
- charSize.x = GetCharWidthInt(ch, font, size, offset);
- charSize.y = GetHeightInt(font, size);
- DrawHighlight(hl, pos, charSize);
- }
+ c = Color(0.490f, 0.380f, 0.165f, 1.0f); // #7D612A
+ }
+ else if (hl == FONT_HIGHLIGHT_TYPE)
+ {
+ c = Color(0.31f, 0.443f, 0.196f, 1.0f); // #4F7132
+ }
+ else if (hl == FONT_HIGHLIGHT_CONST)
+ {
+ c = Color(0.882f, 0.176f, 0.176f, 1.0f); // #E12D2D
+ }
+ else if (hl == FONT_HIGHLIGHT_THIS)
+ {
+ c = Color(0.545f, 0.329f, 0.608f, 1.0f); // #8B549B
+ }
+ else if (hl == FONT_HIGHLIGHT_COMMENT)
+ {
+ c = Color(0.251f, 0.271f, 0.306f, 1.0f); // #40454E
+ }
+ else if (hl == FONT_HIGHLIGHT_KEYWORD)
+ {
+ c = Color(0.239f, 0.431f, 0.588f, 1.0f); // #3D6E96
+ }
+ else if (hl == FONT_HIGHLIGHT_STRING)
+ {
+ c = Color(0.239f, 0.384f, 0.341f, 1.0f); // #3D6257
+ }
+
+ // draw highlight background or link underline
+ if (font != FONT_BUTTON)
+ {
+ Math::IntPoint charSize;
+ charSize.x = GetCharWidthInt(ch, font, size, offset);
+ charSize.y = GetHeightInt(font, size);
+ DrawHighlight(format[fmtIndex], pos, charSize);
}
DrawCharAndAdjustPos(ch, font, size, pos, c);
@@ -854,26 +853,25 @@ 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
Color grad[4];
// 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);
- break;
-
- case FONT_HIGHLIGHT_KEY:
- grad[0] = grad[1] = grad[2] = grad[3] =
- Color(192.0f / 256.0f, 192.0f / 256.0f, 192.0f / 256.0f, 0.5f);
- break;
-
- default:
- return;
+ grad[0] = grad[1] = grad[2] = grad[3] = Color(0.0f, 0.0f, 1.0f, 0.5f);
+ }
+ else if ((hl & FONT_MASK_HIGHLIGHT) == FONT_HIGHLIGHT_KEY)
+ {
+ grad[0] = grad[1] = grad[2] = grad[3] =
+ Color(192.0f / 256.0f, 192.0f / 256.0f, 192.0f / 256.0f, 0.5f);
+ }
+ else
+ {
+ return;
}
Math::IntPoint vsize = m_engine->GetWindowSize();
@@ -889,7 +887,7 @@ void CText::DrawHighlight(FontHighlight hl, Math::IntPoint pos, Math::IntPoint s
p2.x = pos.x + size.x;
p2.y = pos.y;
- if (hl == FONT_HIGHLIGHT_LINK)
+ if ((hl & FONT_MASK_LINK) != 0)
{
p1.y = pos.y - h; // just emphasized
}
diff --git a/src/graphics/engine/text.h b/src/graphics/engine/text.h
index 909dada..f6414c0 100644
--- a/src/graphics/engine/text.h
+++ b/src/graphics/engine/text.h
@@ -118,7 +118,6 @@ enum FontTitle
enum FontHighlight
{
FONT_HIGHLIGHT_NONE = 0x00 << 6,
- FONT_HIGHLIGHT_LINK = 0x01 << 6, //!< link underline
FONT_HIGHLIGHT_TABLE = 0x02 << 6, //!< code background in SatCom
FONT_HIGHLIGHT_KEY = 0x03 << 6, //!< background for keys in documentation in SatCom
FONT_HIGHLIGHT_TOKEN = 0x04 << 6, //!< keywords in CBot scripts
@@ -142,8 +141,10 @@ enum FontMask
FONT_MASK_TITLE = 0x030,
//! Mask for FontHighlight
FONT_MASK_HIGHLIGHT = 0x3c0,
+ //! Mask for links
+ FONT_MASK_LINK = 0x400,
//! 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);
void DrawString(const std::string &text, FontType font,
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 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);
diff --git a/src/ui/controls/edit.cpp b/src/ui/controls/edit.cpp
index c46d5b0..c50f979 100644
--- a/src/ui/controls/edit.cpp
+++ b/src/ui/controls/edit.cpp
@@ -564,7 +564,7 @@ bool CEdit::IsLinkPos(Math::Point pos)
if ( i == -1 ) 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;
}
@@ -637,13 +637,13 @@ void CEdit::MouseRelease(Math::Point mouse)
if ( !m_bEdit )
{
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;
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
- (m_format[j+0]&Gfx::FONT_MASK_HIGHLIGHT) == Gfx::FONT_HIGHLIGHT_LINK) // TODO
+ if ( (j == 0 || (m_format[j-1]&Gfx::FONT_MASK_LINK) == 0) && // TODO check if good
+ (m_format[j+0]&Gfx::FONT_MASK_LINK) != 0) // TODO
{
rank ++;
}
@@ -1581,8 +1581,7 @@ bool CEdit::ReadText(std::string filename, int addSize)
{
if ( m_bSoluce || !bInSoluce )
{
- font &= ~Gfx::FONT_MASK_HIGHLIGHT;
- font |= Gfx::FONT_HIGHLIGHT_LINK;
+ font |= Gfx::FONT_MASK_LINK;
}
i += 3;
}
@@ -1602,7 +1601,7 @@ bool CEdit::ReadText(std::string filename, int addSize)
link.name = GetNameParam(buffer.data()+i+3, 0);
link.marker = GetNameParam(buffer.data()+i+3, 1);
m_link.push_back(link);
- font &= ~Gfx::FONT_MASK_HIGHLIGHT;
+ font &= ~Gfx::FONT_MASK_LINK;
}
i += strchr(buffer.data()+i, ';')-(buffer.data()+i)+1;
}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/colobot.git
More information about the Pkg-games-commits
mailing list