menu open or use for backpacks
This commit is contained in:
parent
7fc4ebd89e
commit
7c28297397
|
@ -64,9 +64,24 @@ function Inventory.onSoulChange(soul)
|
||||||
end
|
end
|
||||||
|
|
||||||
function Inventory.onInventoryItemMousePress(itemWidget, mousePos, mouseButton)
|
function Inventory.onInventoryItemMousePress(itemWidget, mousePos, mouseButton)
|
||||||
|
if mouseButton ~= MouseRightButton then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local item = itemWidget:getItem()
|
||||||
|
if not item then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
local menu = UIPopupMenu.create()
|
local menu = UIPopupMenu.create()
|
||||||
menu:addOption('Look', function() print('look') end)
|
menu:addOption('Look', function() print('look') end)
|
||||||
menu:addOption('Use', function() print('use') end)
|
|
||||||
|
if item:isContainer() then
|
||||||
|
menu:addOption('Open', function() print('open') end)
|
||||||
|
else
|
||||||
|
menu:addOption('Use', function() print('use') end)
|
||||||
|
end
|
||||||
|
|
||||||
menu:display(mousePos)
|
menu:display(mousePos)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,7 @@ Thing::Thing() : m_id(0)
|
||||||
m_yPattern = 0;
|
m_yPattern = 0;
|
||||||
m_zPattern = 0;
|
m_zPattern = 0;
|
||||||
m_animation = 0;
|
m_animation = 0;
|
||||||
m_type = g_thingsType.getEmptyThingType();
|
m_type = getType();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Thing::internalDraw(const Point& p, int layer)
|
void Thing::internalDraw(const Point& p, int layer)
|
||||||
|
@ -77,3 +77,8 @@ ThingType *Thing::getType()
|
||||||
{
|
{
|
||||||
return g_thingsType.getEmptyThingType();
|
return g_thingsType.getEmptyThingType();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Thing::isContainer()
|
||||||
|
{
|
||||||
|
return m_type->properties[ThingType::IsContainer];
|
||||||
|
}
|
||||||
|
|
|
@ -66,6 +66,8 @@ public:
|
||||||
virtual AnimatedTextPtr asAnimatedText() { return nullptr; }
|
virtual AnimatedTextPtr asAnimatedText() { return nullptr; }
|
||||||
virtual StaticTextPtr asStaticText() { return nullptr; }
|
virtual StaticTextPtr asStaticText() { return nullptr; }
|
||||||
|
|
||||||
|
bool isContainer();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void internalDraw(const Point& p, int layer);
|
void internalDraw(const Point& p, int layer);
|
||||||
|
|
||||||
|
|
|
@ -35,14 +35,16 @@ void OTClient::registerLuaFunctions()
|
||||||
g_lua.registerClass<ProtocolGame, Protocol>();
|
g_lua.registerClass<ProtocolGame, Protocol>();
|
||||||
|
|
||||||
g_lua.registerClass<Thing>();
|
g_lua.registerClass<Thing>();
|
||||||
|
g_lua.bindClassMemberFunction<Thing>("getType", &Thing::getType);
|
||||||
|
g_lua.bindClassMemberFunction<Thing>("isContainer", &Thing::isContainer);
|
||||||
|
|
||||||
g_lua.registerClass<Creature>();
|
g_lua.registerClass<Creature, Thing>();
|
||||||
g_lua.bindClassMemberFunction("setOutfit", &Creature::setOutfit);
|
g_lua.bindClassMemberFunction("setOutfit", &Creature::setOutfit);
|
||||||
g_lua.bindClassMemberFunction("getOutfit", &Creature::getOutfit);
|
g_lua.bindClassMemberFunction("getOutfit", &Creature::getOutfit);
|
||||||
|
|
||||||
g_lua.registerClass<Player, Creature>();
|
g_lua.registerClass<Player, Creature>();
|
||||||
g_lua.registerClass<LocalPlayer, Player>();
|
g_lua.registerClass<LocalPlayer, Player>();
|
||||||
g_lua.registerClass<Item>();
|
g_lua.registerClass<Item, Thing>();
|
||||||
g_lua.registerClass<Tile>();
|
g_lua.registerClass<Tile>();
|
||||||
g_lua.registerClass<Map>();
|
g_lua.registerClass<Map>();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue