fix move on different floors, dragqueen border on uiitem

This commit is contained in:
Henrique Santiago 2012-01-20 23:01:11 -02:00
parent 820f94a1d9
commit e3096c1648
6 changed files with 10 additions and 15 deletions

View File

@ -1,6 +1,9 @@
function UIItem:onDragEnter(mousePos)
local item = self:getItem()
if not item then return false end
self:setBorderWidth('1')
self:setBorderColor('#ffffff')
self.currentDragThing = item
setTargetCursor()
@ -10,6 +13,7 @@ end
function UIItem:onDragLeave(widget, mousePos)
self.currentDragThing = nil
restoreCursor()
self:setBorderWidth('0')
return true
end
@ -23,7 +27,6 @@ function UIItem:onDrop(widget, mousePos)
return true
end
function UIItem:onMouseRelease(mousePosition, mouseButton)
local item = self:getItem()
if not item or not self:containsPoint(mousePosition) then return false end

View File

@ -19,10 +19,11 @@ end
function UIMap:onDrop(widget, mousePos)
if not widget or not widget.currentDragThing then return false end
local pos = self:getPosition(mousePos)
local tile = self:getTile(mousePos)
if not tile then return false end
local count = 1 -- todo make a window for it
Game.move(widget.currentDragThing, pos, count)
Game.move(widget.currentDragThing, tile:getPos(), count)
return true
end

View File

@ -61,8 +61,8 @@ void UIWidget::drawSelf()
drawBackground(m_rect);
}
drawBorder(m_rect);
drawImage(m_rect);
drawBorder(m_rect);
drawIcon(m_rect);
drawText(m_rect);
}

View File

@ -239,7 +239,6 @@ void OTClient::registerLuaFunctions()
g_lua.registerClass<UIMap, UIWidget>();
g_lua.bindClassStaticFunction<UIMap>("create", []{ return UIMapPtr(new UIMap); } );
g_lua.bindClassMemberFunction<UIMap>("getTile", &UIMap::getTile);
g_lua.bindClassMemberFunction<UIMap>("getPosition", &UIMap::getPosition);
g_lua.registerClass<UIGame, UIWidget>();
g_lua.bindClassStaticFunction<UIGame>("create", []{ return UIGamePtr(new UIGame); } );

View File

@ -43,10 +43,10 @@ void UIMap::draw()
drawChildren();
}
Position UIMap::getPosition(const Point& mousePos)
TilePtr UIMap::getTile(const Point& mousePos)
{
if(!m_mapRect.contains(mousePos))
return Position();
return nullptr;
// Get tile position
Point relativeStretchMousePos = mousePos - m_mapRect.topLeft();
@ -62,13 +62,6 @@ Position UIMap::getPosition(const Point& mousePos)
PointF tilePosF = relativeMousePos / Map::NUM_TILE_PIXELS;
Position tilePos = Position(1 + (int)tilePosF.x - g_map.getCentralOffset().x, 1 + (int)tilePosF.y - g_map.getCentralOffset().y, 0) + g_map.getCentralPosition();
return tilePos;
}
TilePtr UIMap::getTile(const Point& mousePos)
{
Position tilePos = getPosition(mousePos);
if(!tilePos.isValid())
return nullptr;

View File

@ -33,7 +33,6 @@ public:
UIMap();
void draw();
Position getPosition(const Point& mousePos);
TilePtr getTile(const Point& mousePos);
protected: