addremove vip and look improvements
This commit is contained in:
parent
f16318e80a
commit
a73908fbbe
|
@ -44,7 +44,7 @@ function Game.createThingMenu(menuPosition, lookThing, useThing, creatureThing)
|
|||
if creatureThing:asPlayer() then
|
||||
menu:addSeparator()
|
||||
menu:addOption('Message to ' .. creatureThing:getName(), function() print('message') end)
|
||||
menu:addOption('Add to VIP list', function() print('vip') end)
|
||||
menu:addOption('Add to VIP list', function() Game.addVip(creatureThing:getName()) end)
|
||||
menu:addOption('Ignore ' .. creatureThing:getName(), function() print('ignore') end)
|
||||
menu:addOption('Invite to Party', function() print('invite to party') end)
|
||||
end
|
||||
|
|
|
@ -43,5 +43,16 @@ function Game.onVipStateChange(id, online)
|
|||
label.vipOnline = online
|
||||
end
|
||||
|
||||
function VipList.onVipListLabelMousePress(widget, mousePos, mouseButton)
|
||||
if mouseButton ~= MouseRightButton then return end
|
||||
|
||||
local vipList = vipWindow:getChildById('vipList')
|
||||
|
||||
local menu = createWidget('PopupMenu')
|
||||
menu:addOption('Remove from VIP list', function() if widget then Game.removeVip(widget:getId():sub(4)) vipList:removeChild(widget) end end)
|
||||
menu:display(mousePos)
|
||||
end
|
||||
|
||||
|
||||
connect(Game, { onLogin = VipList.create,
|
||||
onLogout = VipList.destroy })
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
VipListLabel < GameLabel
|
||||
font: verdana-11px-monochrome
|
||||
margin-left: 5
|
||||
&onMousePress: VipList.onVipListLabelMousePress
|
||||
|
||||
MiniWindow
|
||||
id: vipWindow
|
||||
|
|
|
@ -235,10 +235,32 @@ void Game::talkPrivate(int channelType, const std::string& receiver, const std::
|
|||
|
||||
void Game::openOutfitWindow()
|
||||
{
|
||||
if(!m_online)
|
||||
return;
|
||||
|
||||
m_protocolGame->sendGetOutfit();
|
||||
}
|
||||
|
||||
void Game::setOutfit(const Outfit& outfit)
|
||||
{
|
||||
if(!m_online)
|
||||
return;
|
||||
|
||||
m_protocolGame->sendSetOutfit(outfit);
|
||||
}
|
||||
|
||||
void Game::addVip(const std::string& name)
|
||||
{
|
||||
if(!m_online || name.empty())
|
||||
return;
|
||||
|
||||
m_protocolGame->sendAddVip(name);
|
||||
}
|
||||
|
||||
void Game::removeVip(int playerId)
|
||||
{
|
||||
if(!m_online)
|
||||
return;
|
||||
|
||||
m_protocolGame->sendRemoveVip(playerId);
|
||||
}
|
||||
|
|
|
@ -57,6 +57,8 @@ public:
|
|||
void talkPrivate(int channelType, const std::string& receiver, const std::string& message);
|
||||
void openOutfitWindow();
|
||||
void setOutfit(const Outfit& outfit);
|
||||
void addVip(const std::string& name);
|
||||
void removeVip(int playerId);
|
||||
int getThingStackpos(const ThingPtr& thing);
|
||||
|
||||
bool isOnline() { return m_online; }
|
||||
|
|
|
@ -288,6 +288,24 @@ bool Tile::isLookPossible()
|
|||
return true;
|
||||
}
|
||||
|
||||
bool Tile::isClickable()
|
||||
{
|
||||
bool hasGround = false, hasOnBottom = false, hasIgnoreLook = false;
|
||||
for(const ThingPtr& thing : m_things) {
|
||||
ThingType *type = thing->getType();
|
||||
if(type->properties[ThingType::IsGround])
|
||||
hasGround = true;
|
||||
if(type->properties[ThingType::IsOnBottom])
|
||||
hasOnBottom = true;
|
||||
if(type->properties[ThingType::IgnoreLook])
|
||||
hasIgnoreLook = true;
|
||||
|
||||
if((hasGround || hasOnBottom) && !hasIgnoreLook)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Tile::hasCreature()
|
||||
{
|
||||
for(const ThingPtr& thing : m_things)
|
||||
|
|
|
@ -59,8 +59,7 @@ public:
|
|||
bool isLookPossible();
|
||||
bool hasCreature();
|
||||
bool isEmpty();
|
||||
|
||||
void useItem();
|
||||
bool isClickable();
|
||||
|
||||
TilePtr asTile() { return std::static_pointer_cast<Tile>(shared_from_this()); }
|
||||
|
||||
|
|
|
@ -69,6 +69,8 @@ void OTClient::registerLuaFunctions()
|
|||
g_lua.bindClassStaticFunction<Game>("attack", std::bind(&Game::attack, &g_game, _1));
|
||||
g_lua.bindClassStaticFunction<Game>("follow", std::bind(&Game::follow, &g_game, _1));
|
||||
g_lua.bindClassStaticFunction<Game>("rotate", std::bind(&Game::rotate, &g_game, _1));
|
||||
g_lua.bindClassStaticFunction<Game>("addVip", std::bind(&Game::addVip, &g_game, _1));
|
||||
g_lua.bindClassStaticFunction<Game>("removeVip", std::bind(&Game::removeVip, &g_game, _1));
|
||||
|
||||
g_lua.registerClass<UIItem, UIWidget>();
|
||||
g_lua.bindClassStaticFunction<UIItem>("create", &UIItem::create<UIItem>);
|
||||
|
|
|
@ -96,7 +96,7 @@ public:
|
|||
void sendGetOutfit();
|
||||
void sendSetOutfit(const Outfit& outfit);
|
||||
void sendAddVip(const std::string& name);
|
||||
void sendRemoveVip(int id);
|
||||
void sendRemoveVip(int playerId);
|
||||
void sendGetQuestLog();
|
||||
void sendGetQuestLine(int questId);
|
||||
|
||||
|
|
|
@ -555,11 +555,11 @@ void ProtocolGame::sendAddVip(const std::string& name)
|
|||
send(oMsg);
|
||||
}
|
||||
|
||||
void ProtocolGame::sendRemoveVip(int id)
|
||||
void ProtocolGame::sendRemoveVip(int playerId)
|
||||
{
|
||||
OutputMessage oMsg;
|
||||
oMsg.addU8(Otc::ClientRemoveBuddy);
|
||||
oMsg.addU32(id);
|
||||
oMsg.addU32(playerId);
|
||||
send(oMsg);
|
||||
}
|
||||
|
||||
|
|
|
@ -74,17 +74,19 @@ bool UIMap::onMousePress(const Point& mousePos, Fw::MouseButton button)
|
|||
// Get tile
|
||||
TilePtr tile = nullptr;
|
||||
|
||||
// We must check every floor, from top to bottom
|
||||
// We must check every floor, from top to bottom to check for a clickable tile
|
||||
int firstFloor = g_map.getFirstVisibleFloor();
|
||||
tilePos.perspectiveUp(tilePos.z - firstFloor);
|
||||
for(int i = firstFloor; i <= Map::MAX_Z; i++) {
|
||||
tile = g_map.getTile(tilePos);
|
||||
if(tile && !tile->isEmpty() && tile->getGround())
|
||||
if(tile && tile->isClickable())
|
||||
break;
|
||||
tilePos.coveredDown();
|
||||
}
|
||||
|
||||
if(!tile || tile->isEmpty())
|
||||
// todo: get creature, using walkOffset etc.
|
||||
|
||||
if(!tile || !tile->isClickable())
|
||||
return true;
|
||||
|
||||
if(button == Fw::MouseLeftButton) {
|
||||
|
|
Loading…
Reference in New Issue