fix merge

This commit is contained in:
Henrique 2011-08-21 22:12:37 -03:00
commit 24c45bde50
9 changed files with 31 additions and 19 deletions

View File

@ -3,6 +3,8 @@ Console = { }
local console
local logLocked = false
local commandEnv = createEnvironment()
local maxLines = 80
local numLines = 0
function Console.onLog(level, message, time)
-- avoid logging while reporting logs (would cause a infinite loop)
@ -28,12 +30,18 @@ end
function Console.addLine(text, color)
-- create new label
local label = UILabel.create()
label:setStyle('ConsoleLabel')
label:setText(text)
label:setForegroundColor(color)
console:insertChild(label, -1)
numLines = numLines + 1
if numLines > maxLines then
local firstLine = console:getChildByIndex(0)
firstLine:destroy()
end
end
function Console.create()

View File

@ -30,9 +30,9 @@ function EnterGame_connectToLoginServer()
mainMenu:hide()
end
local enterGameWindow = rootWidget:getChild("enterGameWindow")
local account = enterGameWindow:getChild("accountNameLineEdit"):getText()
local password = enterGameWindow:getChild("accountPasswordLineEdit"):getText()
local enterGameWindow = rootWidget:getChildById("enterGameWindow")
local account = enterGameWindow:getChildById("accountNameLineEdit"):getText()
local password = enterGameWindow:getChildById("accountPasswordLineEdit"):getText()
protocolLogin:login(account, password)
enterGameWindow:destroy()

View File

@ -42,7 +42,8 @@ void LuaInterface::registerFunctions()
g_lua.bindClassMemberFunction<UIWidget>("fill", &UIWidget::fill);
g_lua.bindClassMemberFunction<UIWidget>("centerIn", &UIWidget::centerIn);
g_lua.bindClassMemberFunction<UIWidget>("addAnchor", &UIWidget::addAnchor);
g_lua.bindClassMemberFunction<UIWidget>("getChild", &UIWidget::getChildById);
g_lua.bindClassMemberFunction<UIWidget>("getChildById", &UIWidget::getChildById);
g_lua.bindClassMemberFunction<UIWidget>("getChildByIndex", &UIWidget::getChildByIndex);
g_lua.bindClassMemberFunction<UIWidget>("insertChild", &UIWidget::insertChild);
g_lua.bindClassMemberFunction<UIWidget>("removeChild", &UIWidget::removeChild);
g_lua.bindClassMemberFunction<UIWidget>("addChild", &UIWidget::addChild);

View File

@ -16,8 +16,10 @@ void Protocol::connect(const std::string& host, uint16 port)
void Protocol::disconnect()
{
if(m_connection) {
m_connection->close();
m_connection.reset();
}
}
void Protocol::send(OutputMessage& outputMessage)

View File

@ -17,7 +17,6 @@ UIButton::UIButton(): UIWidget(UITypeButton)
UIButtonPtr UIButton::create()
{
UIButtonPtr button(new UIButton);
button->setStyle("Button");
return button;
}

View File

@ -288,12 +288,15 @@ void UILineEdit::appendCharacter(char c)
void UILineEdit::removeCharacter(bool right)
{
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()) {
if((uint)m_cursorPos >= m_text.length()) {
m_text.erase(m_text.begin() + (--m_cursorPos));
blinkCursor();
} else {
if(right)
m_text.erase(m_text.begin() + m_cursorPos);
else if(m_cursorPos > 0)
m_text.erase(m_text.begin() + --m_cursorPos);
}
blinkCursor();
update();
}
}
@ -355,7 +358,7 @@ void UILineEdit::onKeyPress(UIKeyEvent& event)
{
if(event.keyCode() == KC_DELETE) // erase right character
removeCharacter(true);
else if(event.keyCode() == KC_BACK) // erase left character
else if(event.keyCode() == KC_BACK) // erase left character {
removeCharacter(false);
else if(event.keyCode() == KC_RIGHT) // move cursor right
moveCursor(true);

View File

@ -287,8 +287,8 @@ bool UIWidget::hasFocus()
if(parent->hasFocus() && parent->getFocusedChild() == shared_from_this())
return true;
}
// root widget always has focus
else if(asUIWidget() == g_ui.getRootWidget())
// root parent always has focus
else if(asUIWidget() == getRootParent())
return true;
return false;
}
@ -350,7 +350,7 @@ UIWidgetPtr UIWidget::getChildById(const std::string& childId)
else if(childId == "parent")
return getParent();
else if(childId == "root")
return g_ui.getRootWidget();
return getRootParent();
else if(childId == "prev") {
if(UIWidgetPtr parent = getParent())
return parent->getChildBefore(asUIWidget());
@ -468,7 +468,7 @@ void UIWidget::addChild(const UIWidgetPtr& childToAdd)
updateChildrenLayout();
// always focus new children
if(childToAdd->isFocusable())
if(childToAdd->isFocusable() && childToAdd->isExplicitlyVisible() && childToAdd->isExplicitlyEnabled())
focusChild(childToAdd, ActiveFocusReason);
}

View File

@ -11,7 +11,6 @@ UIWindow::UIWindow(): UIWidget(UITypeWindow)
UIWindowPtr UIWindow::create()
{
UIWindowPtr window(new UIWindow);
window->setStyle("Window");
return window;
}

View File

@ -81,7 +81,7 @@ void Creature::drawInformation(int x, int y, bool useGray)
// name
FontPtr font = g_fonts.getFont("tibia-12px-rounded");
font->renderText(m_name, Rect(x-50, y-15, 100, 15), AlignTopCenter, fillColor);
font->renderText(m_name, Rect(x-100, y-15, 200, 15), AlignTopCenter, fillColor);
}
const ThingAttributes& Creature::getAttributes()