mirror of
https://github.com/edubart/otclient.git
synced 2025-10-20 06:23:26 +02:00
info window
This commit is contained in:
@@ -80,18 +80,16 @@ void BorderedImage::setTexCoords(const Rect& left,
|
||||
|
||||
void BorderedImage::draw(const Rect& screenCoords)
|
||||
{
|
||||
// check minumim size
|
||||
if(screenCoords.size() <= m_cornersSize)
|
||||
return;
|
||||
|
||||
Rect rectCoords;
|
||||
Size centerSize = screenCoords.size() - m_cornersSize;
|
||||
|
||||
// first the center
|
||||
rectCoords = Rect(screenCoords.left() + m_leftBorderTexCoords.width(),
|
||||
screenCoords.top() + m_topBorderTexCoords.height(),
|
||||
centerSize);
|
||||
g_graphics.drawRepeatedTexturedRect(rectCoords, m_texture, m_centerTexCoords);
|
||||
if(centerSize.area() > 0) {
|
||||
rectCoords = Rect(screenCoords.left() + m_leftBorderTexCoords.width(),
|
||||
screenCoords.top() + m_topBorderTexCoords.height(),
|
||||
centerSize);
|
||||
g_graphics.drawRepeatedTexturedRect(rectCoords, m_texture, m_centerTexCoords);
|
||||
}
|
||||
|
||||
// top left corner
|
||||
rectCoords = Rect(screenCoords.topLeft(),
|
||||
|
@@ -223,7 +223,7 @@ const std::vector<Point>& Font::calculateGlyphsPositions(const std::string& text
|
||||
return glyphsPositions;
|
||||
}
|
||||
|
||||
// resize glyphsPositions vector, if needed
|
||||
// resize glyphsPositions vector when needed
|
||||
if(textLength > (int)glyphsPositions.size())
|
||||
glyphsPositions.resize(textLength);
|
||||
|
||||
@@ -250,9 +250,6 @@ const std::vector<Point>& Font::calculateGlyphsPositions(const std::string& text
|
||||
for(i = 0; i < textLength; ++i) {
|
||||
glyph = (uchar)text[i];
|
||||
|
||||
// store current glyph topLeft
|
||||
glyphsPositions[i] = virtualPos;
|
||||
|
||||
// new line or first glyph
|
||||
if(glyph == (uchar)'\n' || i == 0) {
|
||||
if(glyph == (uchar)'\n') {
|
||||
@@ -270,6 +267,9 @@ const std::vector<Point>& Font::calculateGlyphsPositions(const std::string& text
|
||||
}
|
||||
}
|
||||
|
||||
// store current glyph topLeft
|
||||
glyphsPositions[i] = virtualPos;
|
||||
|
||||
// render only if the glyph is valid
|
||||
if(glyph >= 32 && glyph != (uchar)'\n') {
|
||||
virtualPos.x += m_glyphsSize[glyph].width() + m_glyphSpacing.width();
|
||||
@@ -278,7 +278,7 @@ const std::vector<Point>& Font::calculateGlyphsPositions(const std::string& text
|
||||
|
||||
if(textBoxSize) {
|
||||
textBoxSize->setWidth(maxLineWidth);
|
||||
textBoxSize->setHeight(virtualPos.y + m_glyphHeight);
|
||||
textBoxSize->setHeight(virtualPos.y + m_glyphHeight + m_glyphSpacing.height());
|
||||
}
|
||||
|
||||
return glyphsPositions;
|
||||
|
@@ -139,7 +139,7 @@ void Graphics::disableDrawing()
|
||||
|
||||
void Graphics::drawTexturedRect(const Rect& screenCoords, const TexturePtr& texture, const Rect& textureCoords, const Color& color)
|
||||
{
|
||||
if(screenCoords.isEmpty())
|
||||
if(screenCoords.isEmpty() || textureCoords.isEmpty())
|
||||
return;
|
||||
|
||||
// rect correction for opengl
|
||||
@@ -170,7 +170,7 @@ void Graphics::drawTexturedRect(const Rect& screenCoords, const TexturePtr& text
|
||||
|
||||
void Graphics::drawRepeatedTexturedRect(const Rect& screenCoords, const TexturePtr& texture, const Rect& textureCoords, const Color& color)
|
||||
{
|
||||
if(screenCoords.isEmpty())
|
||||
if(screenCoords.isEmpty() || textureCoords.isEmpty())
|
||||
return;
|
||||
|
||||
// render many repeated texture rects
|
||||
|
@@ -293,7 +293,7 @@ void TextArea::appendCharacter(char c)
|
||||
|
||||
void TextArea::removeCharacter(bool right)
|
||||
{
|
||||
if(m_cursorPos >= 0) {
|
||||
if(m_cursorPos >= 0 && m_text.length() > 0) {
|
||||
if(right && (uint)m_cursorPos < m_text.length())
|
||||
m_text.erase(m_text.begin() + m_cursorPos);
|
||||
else if((uint)m_cursorPos == m_text.length()) {
|
||||
|
Reference in New Issue
Block a user