mirror of
https://github.com/edubart/otclient.git
synced 2025-10-15 03:54:54 +02:00
add command completion to console
This commit is contained in:
@@ -183,9 +183,11 @@ void Graphics::drawRepeatedTexturedRect(const Rect& screenCoords,
|
||||
if(screenCoords.isEmpty() || texture->getId() == 0 || textureCoords.isEmpty())
|
||||
return;
|
||||
|
||||
bool mustStopDrawing = false;
|
||||
if(!m_drawing) {
|
||||
bindTexture(texture);
|
||||
startDrawing();
|
||||
mustStopDrawing = true;
|
||||
}
|
||||
|
||||
// render many repeated texture rects
|
||||
@@ -212,7 +214,7 @@ void Graphics::drawRepeatedTexturedRect(const Rect& screenCoords,
|
||||
}
|
||||
}
|
||||
|
||||
if(!m_drawing)
|
||||
if(mustStopDrawing)
|
||||
stopDrawing();
|
||||
}
|
||||
|
||||
|
@@ -30,6 +30,7 @@
|
||||
Image::Image()
|
||||
{
|
||||
m_fixedRatio = false;
|
||||
m_repeated = false;
|
||||
}
|
||||
|
||||
void Image::loadFromOTML(const OTMLNodePtr& imageNode)
|
||||
@@ -37,13 +38,14 @@ void Image::loadFromOTML(const OTMLNodePtr& imageNode)
|
||||
// load configs from otml node
|
||||
std::string source = imageNode->hasValue() ? imageNode->value() : imageNode->valueAt("source");
|
||||
bool smooth = imageNode->valueAt("smooth", false);
|
||||
m_textureCoords = imageNode->valueAt("coords", Rect());
|
||||
m_fixedRatio = imageNode->valueAt("fixed ratio", false);
|
||||
m_repeated = imageNode->valueAt("repeated", false);
|
||||
|
||||
// load texture
|
||||
m_texture = g_textures.getTexture(source);
|
||||
if(!m_texture)
|
||||
throw OTMLException(imageNode, "could not load image texture");
|
||||
m_textureCoords = imageNode->valueAt("coords", Rect(Point(0,0),m_texture->getSize()));
|
||||
|
||||
// enable texture bilinear filter
|
||||
if(smooth)
|
||||
@@ -65,7 +67,10 @@ void Image::draw(const Rect& screenCoords)
|
||||
|
||||
g_graphics.drawTexturedRect(screenCoords, m_texture, Rect(texCoordsOffset, texCoordsSize));
|
||||
} else {
|
||||
g_graphics.drawTexturedRect(screenCoords, m_texture, m_textureCoords);
|
||||
if(m_repeated)
|
||||
g_graphics.drawRepeatedTexturedRect(screenCoords, m_texture, m_textureCoords);
|
||||
else
|
||||
g_graphics.drawTexturedRect(screenCoords, m_texture, m_textureCoords);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -40,6 +40,7 @@ protected:
|
||||
TexturePtr m_texture;
|
||||
Rect m_textureCoords;
|
||||
bool m_fixedRatio;
|
||||
bool m_repeated;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@@ -108,6 +108,7 @@ void LuaInterface::registerFunctions()
|
||||
g_lua.bindClassMemberFunction<UILineEdit>("getText", &UILineEdit::getText);
|
||||
g_lua.bindClassMemberFunction<UILineEdit>("setText", &UILineEdit::setText);
|
||||
g_lua.bindClassMemberFunction<UILineEdit>("clearText", &UILineEdit::clearText);
|
||||
g_lua.bindClassMemberFunction<UILineEdit>("getCursorPos", &UILineEdit::getCursorPos);
|
||||
|
||||
// UIWindow
|
||||
g_lua.registerClass<UIWindow, UIWidget>();
|
||||
|
@@ -92,7 +92,7 @@ void push_luavalue(const std::string& str)
|
||||
bool luavalue_cast(int index, std::string& str)
|
||||
{
|
||||
str = g_lua.toString(index);
|
||||
if(str.empty() && !g_lua.isString(index))
|
||||
if(str.empty() && g_lua.isString(index) && !g_lua.isNil())
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
@@ -50,6 +50,7 @@ public:
|
||||
std::string getText() const { return m_text; }
|
||||
std::string getDisplayedText();
|
||||
int getTextPos(Point pos);
|
||||
int getCursorPos() const { return m_cursorPos; }
|
||||
|
||||
protected:
|
||||
virtual void onStyleApply(const OTMLNodePtr& styleNode);
|
||||
|
@@ -105,7 +105,7 @@ void UIWidget::render()
|
||||
// debug draw box
|
||||
//g_graphics.bindColor(Fw::green);
|
||||
//g_graphics.drawBoundingRect(child->getRect());
|
||||
//g_fonts.getDefaultFont()->renderText(child->getId(), child->getPosition() + Point(2, 0), Color::red);
|
||||
//g_fonts.getDefaultFont()->renderText(child->getId(), child->getPosition() + Point(2, 0), Fw::red);
|
||||
|
||||
g_graphics.setOpacity(oldOpacity);
|
||||
}
|
||||
|
Reference in New Issue
Block a user