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

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

View File

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

View File

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

View File

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

View File

@ -43,10 +43,10 @@ void UIMap::draw()
drawChildren(); drawChildren();
} }
Position UIMap::getPosition(const Point& mousePos) TilePtr UIMap::getTile(const Point& mousePos)
{ {
if(!m_mapRect.contains(mousePos)) if(!m_mapRect.contains(mousePos))
return Position(); return nullptr;
// Get tile position // Get tile position
Point relativeStretchMousePos = mousePos - m_mapRect.topLeft(); Point relativeStretchMousePos = mousePos - m_mapRect.topLeft();
@ -62,13 +62,6 @@ Position UIMap::getPosition(const Point& mousePos)
PointF tilePosF = relativeMousePos / Map::NUM_TILE_PIXELS; 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(); 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()) if(!tilePos.isValid())
return nullptr; return nullptr;

View File

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