一 右键点击目标头像界面,首先分析是NPC,其他玩家,玩家自己头像。然后判断状态,根据状态,发送不同的命令给lua脚本
{
CObject* pObject = (CObject*)CObjectManager::GetMe()->FindServerObject(idObj);
if(!pObject) return;
CHAR szObjId[
32]; _snprintf(szObjId, 32, "%d", pObject->GetID());// 得到鼠标位置
POINT ptMouse = CInputSystem::GetMe()->MouseGetPos();
CHAR szXPos[
32]; _snprintf(szXPos, 32, "%d", ptMouse.x);CHAR szYPos[32]; _snprintf(szYPos, 32, "%d", ptMouse.y);
std::vector< STRING > vParam;
// 根据不同物体产生不同右键事件
// 主角自身
if(g_theKernel.IsKindOf(pObject->GetClass(), GETCLASS(CObject_PlayerMySelf)))
{
if(showMyself)
{
// 如果自己已经在队伍中了
if( CUIDataPool::GetMe()->IsInTeam())
{
vParam.push_back("player_in_team");
vParam.push_back(szObjId);
vParam.push_back(szXPos);
vParam.push_back(szYPos);
CEventSystem::GetMe()->PushEvent(GE_SHOW_CONTEXMENU, vParam);
return;
}
// 自己没有组队
vParam.push_back("player");
vParam.push_back(szObjId);
vParam.push_back(szXPos);
vParam.push_back(szYPos);
CEventSystem::GetMe()->PushEvent(GE_SHOW_CONTEXMENU, vParam);
}
}
// 其他玩家
else if(g_theKernel.IsKindOf(pObject->GetClass(), GETCLASS(CObject_PlayerOther)))
{
CObject_PlayerOther* pOtherObject = (CObject_PlayerOther*)pObject;
// 是否有帮会
if( INVALID_ID != CObjectManager::GetMe()->GetMySelf()->GetCharacterData()->Get_Guild() )
{
// 根据策划的需求再进行修改: 是否判断其他玩家已经入帮了 GetCharacterData()->Get_Guild
INT tt
= CDataPool::GetMe()->Guild_GetCurPosition();// 自己是帮主或副帮主, 点击其他玩家
if( ( CDataPool::GetMe()->Guild_GetCurPosition() == GUILD_POSITION_CHIEFTAIN ) ||
( CDataPool::GetMe()->Guild_GetCurPosition() == GUILD_POSITION_ASS_CHIEFTAIN ))
{
// 自己有队伍, 对方有队伍
if( (pOtherObject->GetCharacterData()->Get_HaveTeamFlag())&&( CUIDataPool::GetMe()->IsInTeam()) )
{
vParam.push_back("guild_other_team_member");
vParam.push_back(szObjId);
vParam.push_back(szXPos);
vParam.push_back(szYPos);
CEventSystem::GetMe()->PushEvent(GE_SHOW_CONTEXMENU, vParam);
return;
}
// 其他玩家没有队伍
if((!pOtherObject->GetCharacterData()->Get_HaveTeamFlag()))
{
vParam.push_back("guild_other_not_team_member");
vParam.push_back(szObjId);
vParam.push_back(szXPos);
vParam.push_back(szYPos);
CEventSystem::GetMe()->PushEvent(GE_SHOW_CONTEXMENU, vParam);
return;
}
// 自己没队伍, 其他玩家有队伍
if((pOtherObject->GetCharacterData()->Get_HaveTeamFlag())&&( !CUIDataPool::GetMe()->IsInTeam()))
{
vParam.push_back("guild_other_team_member_me_not_teamer");
vParam.push_back(szObjId);
vParam.push_back(szXPos);
vParam.push_back(szYPos);
CEventSystem::GetMe()->PushEvent(GE_SHOW_CONTEXMENU, vParam);
return;
}
vParam.push_back(
"guild_other_player");vParam.push_back(szObjId);
vParam.push_back(szXPos);
vParam.push_back(szYPos);
CEventSystem::GetMe()->PushEvent( GE_SHOW_CONTEXMENU, vParam );
return ;
}
// 自己有帮会(帮主), 对方已加帮
// 自己有队伍, 对方有队伍
// 其他玩家没有队伍
// 自己没队伍, 其他玩家有队伍
// 自己有帮会(帮主), 对方没加帮
}
// 自己有队伍, 点击的其他玩家也有队伍
if((pOtherObject->GetCharacterData()->Get_HaveTeamFlag())&&( CUIDataPool::GetMe()->IsInTeam()))
{
vParam.push_back("other_team_member");
vParam.push_back(szObjId);
vParam.push_back(szXPos);
vParam.push_back(szYPos);
CEventSystem::GetMe()->PushEvent(GE_SHOW_CONTEXMENU, vParam);
return;
}
// 点击其他玩家没有队伍
if((!pOtherObject->GetCharacterData()->Get_HaveTeamFlag()))
{
vParam.push_back("other_not_team_member");
vParam.push_back(szObjId);
vParam.push_back(szXPos);
vParam.push_back(szYPos);
CEventSystem::GetMe()->PushEvent(GE_SHOW_CONTEXMENU, vParam);
return;
}
if((pOtherObject->GetCharacterData()->Get_HaveTeamFlag())&&( !CUIDataPool::GetMe()->IsInTeam()))
{
vParam.push_back("other_team_member_me_not_teamer");
vParam.push_back(szObjId);
vParam.push_back(szXPos);
vParam.push_back(szYPos);
CEventSystem::GetMe()->PushEvent(GE_SHOW_CONTEXMENU, vParam);
return;
}
vParam.push_back(
"other_player");vParam.push_back(szObjId);
vParam.push_back(szXPos);
vParam.push_back(szYPos);
CEventSystem::GetMe()->PushEvent(GE_SHOW_CONTEXMENU, vParam);
}
// NPC
else if(g_theKernel.IsKindOf(pObject->GetClass(), GETCLASS(CObject_PlayerNPC)))
{
//PET_GUID_t pg = CObjectManager::GetMe()->GetMySelf()->GetCharacterData()->Get_CurrentPetGUID();
// 自己的宠物
/*if(!(pg.IsNull()) && CDataPool::GetMe()->Pet_GetPet(pg) && CDataPool::GetMe()->Pet_GetPet(pg)->m_idServer == pObject->GetServerID())
{
vParam.push_back("my_pet");
vParam.push_back(szObjId);
vParam.push_back(szXPos);
vParam.push_back(szYPos);
CEventSystem::GetMe()->PushEvent(GE_SHOW_CONTEXMENU, vParam);
return;
}*/
//CObject_PlayerNPC* pNpcObject = (CObject_PlayerNPC*)pObject;
// 其他宠物
//if(pNpcObject->GetNpcType() == NPC_TYPE_PET)
//{
// if(INVALID_UID != pNpcObject->GetCharacterData()->Get_OwnerID())
// {
// // 有归属的宠物才显示菜单
// vParam.push_back("other_pet");
// vParam.push_back(szObjId);
// vParam.push_back(szXPos);
// vParam.push_back(szYPos);
// CEventSystem::GetMe()->PushEvent(GE_SHOW_CONTEXMENU, vParam);
// }
// return;
//}
vParam.push_back("npc");
vParam.push_back(szObjId);
vParam.push_back(szXPos);
vParam.push_back(szYPos);
CEventSystem::GetMe()->PushEvent(GE_SHOW_CONTEXMENU, vParam);
}
else
return;
}
二 lua判断C++传来的参数
--
-- 如果是其他队员打开的菜单.
--
if(arg0 == "Team_Member") then
this:Show();
--关心NPC
objCared = tonumber(arg1);
this:CareObject(objCared, 1, "ContexMenu");
if( Player:InTeamFollowMode() ) then
ContexMenu_TeamFollowMember:SetPopMenuPos(arg2, arg3);
ContexMenu_TeamFollowMember:Show();
else
ContexMenu_TeamMember:SetPopMenuPos(arg2, arg3);
ContexMenu_TeamMember:Show();
end
currentSelectMember = arg4;
return;
end;
--------------------------------------------------------------------------------------------------------------------------
--
-- 打开自己队伍界面
--
if(arg0 == "player") then
this:Show();
--关心NPC
objCared = tonumber(arg1);
this:CareObject(objCared, 1, "ContexMenu");
ContexMenu_Self:Show();
ContexMenu_Self:SetPopMenuPos(arg2, arg3);
end;
if(arg0 == "ModifyPKMode") then
this:Show();
--关心NPC
objCared = tonumber(arg1);
this:CareObject(objCared, 1, "ContexMenu");
ContexMenu_Self_pk:SetPopMenuPos(arg2, arg3);
ContexMenu_Self_pk:Show();
PKModeItem[currentPKMode]:SetProperty("Text", "#c00ff00"..PKModeName[currentPKMode]);
return;
end;
if(arg0 == "ModifyAlloCationMode") then
this:Show();
--关心NPC
objCared = tonumber(arg1);
this:CareObject(objCared, 1, "ContexMenu");
--[[ local pos = ContexMenuFrame:GetProperty("Position");
local pos11, pos12
= string.find( pos, "x" );local pos13, pos14 = string.find( pos, "y" );
local PosX1 = string.sub( pos, pos12 + 2, pos13 - 2 );
local PosY1 = string.sub( pos, pos14 + 2);
local width = ContexMenu_Self_In_Team:GetProperty("Width");
local Height = ContexMenu_Self_In_Team:GetProperty("Height");
local newPosX = tonumber(PosX1)+tonumber(width);
local newPosY = tonumber(PosY1)+tonumber(Height);
ContexMenu_Item_fenpei:SetPopMenuPos(newPosX, newPosY);]]--
ContexMenu_Item_fenpei:SetPopMenuPos(arg2, arg3);
ContexMenu_Item_fenpei:Show();
currentAlloCationMode = Player:GetTeamAllocationMode();
for i= 0 ,3 do
AlloCationModeItem[i]:SetProperty("Text", "#W"..AlloCationModeName[i]);
end
AxTrace(0,0,"物品是拾取模式是 "..tostring(currentAlloCationMode));
--这句的作用是队长选择分配模式时绿色显示原先的分配模式
AlloCationModeItem[currentAlloCationMode]:SetProperty("Text", "#c00ff00"..AlloCationModeName[currentAlloCationMode]);
isLeader= DataPool:GetMyTeamLeaderFlag();
if(isLeader ==1)then
for i =0 ,3 do
AlloCationModeItem[i] :SetProperty(
"Visible", "True" );end
elseif(isLeader ==0)then
for i =0 ,3 do
AlloCationModeItem[i] :SetProperty( "Visible", "False" );
end
AlloCationModeItem[currentAlloCationMode] :SetProperty( "Visible", "True" );
end;
return;
end;
--
-- 自己有队伍, 只打开摆摊按钮界面
--
if(arg0 == "player_in_team") then
this:Show();
--关心NPC
objCared = tonumber(arg1);
this:CareObject(objCared, 1, "ContexMenu");
ContexMenu_Self_In_Team:Show();
ContexMenu_Self_In_Team:SetPopMenuPos(arg2, arg3);
isLeader
currentAlloCationMode = Player:GetTeamAllocationMode();
if(isLeader ==1)then
item_fenpei:SetProperty( "Text", "物品分配模式" );
item_fenpei:SetProperty( "Clicked","True");
elseif(isLeader ==0)then
item_fenpei:SetProperty( "Text", "#G物品分配模式:"..AlloCationModeName[currentAlloCationMode] );
item_fenpei:SetProperty( "Clicked","False");
end
-- AxTrace( 0,0, "addleader = "..tostring( isLeader ) );
return;
end;
--------------------------------------------------------------------------------------------------------------------------
--
-- 自己是帮主或副帮主, 自己有队伍, 对方有队伍
if(arg0 == "guild_other_team_member") then
this:Show();
objCared = tonumber(arg1);
this:CareObject(objCared, 1, "ContexMenu");
Guild_ContexMenu_Model_Open_Other:Show();
Guild_ContexMenu_Model_Open_Other:SetPopMenuPos(arg2, arg3);
return;
end
-- 自己是帮主或副帮主, 其他玩家没有队伍
if(arg0 == "guild_other_not_team_member") then
this:Show();
objCared = tonumber(arg1);
this:CareObject(objCared, 1, "ContexMenu");
Guild_ContexMenu_Model_Open_Other_Not_teammer:Show();
Guild_ContexMenu_Model_Open_Other_Not_teammer:SetPopMenuPos(arg2, arg3);
return;
end
-- 自己是帮主或副帮主, 自己没队伍, 其他玩家有队伍
if(arg0 == "guild_other_team_member_me_not_teamer") then
this:Show();
objCared = tonumber(arg1);
this:CareObject(objCared, 1, "ContexMenu");
Guild_ContexMenu_Model_Open_Other_teammer_me_not_teammer:Show();
Guild_ContexMenu_Model_Open_Other_teammer_me_not_teammer:SetPopMenuPos(arg2, arg3);
return;
end
-- 自己是帮主或副帮主, 点击其他玩家
if(arg0 == "guild_other_player") then
this:Show();
objCared = tonumber(arg1);
this:CareObject(objCared, 1, "ContexMenu");
ContexMenu_GuildMenu:Show();
ContexMenu_GuildMenu:SetPopMenuPos(arg2, arg3);
return;
end
--
-- 点击其他队友模型, 弹出的对话框
--
if(arg0 == "other_team_member") then
this:Show();
--关心NPC
objCared = tonumber(arg1);
this:CareObject(objCared, 1, "ContexMenu");
ContexMenu_Model_Open_Other:Show();
ContexMenu_Model_Open_Other:SetPopMenuPos(arg2, arg3);
end;
--------------------------------------------------------------------------------------------------------------------------
--
-- 点击非组队玩家弹出来的界面
--
if(arg0 == "other_not_team_member") then
this:Show();
--关心NPC
objCared = tonumber(arg1);
this:CareObject(objCared, 1, "ContexMenu");
ContexMenu_Model_Open_Other_Not_teammer:Show();
ContexMenu_Model_Open_Other_Not_teammer:SetPopMenuPos(arg2, arg3);
end;
--------------------------------------------------------------------------------------------------------------------------
--
-- 非组队玩家, 点击组队玩家, 弹出的菜单
--
if(arg0 == "other_team_member_me_not_teamer") then
this:Show();
--关心NPC
objCared = tonumber(arg1);
this:CareObject(objCared, 1, "ContexMenu");
ContexMenu_Model_Open_Other_teammer_me_not_teammer:Show();
ContexMenu_Model_Open_Other_teammer_me_not_teammer:SetPopMenuPos(arg2, arg3);
end;
--------------------------------------------------------------------------------------------------------------------------
--
-- 点击聊天里的人物名, 弹出的菜单
--
if(arg0 == "chat_private") then
this:Show();
--关心NPC
objCared = tonumber(arg1);
this:CareObject(objCared, 1, "ContexMenu");
ContexMenu_ChatBoard:Show();
ContexMenu_ChatBoard:SetPopMenuPos(arg2,arg3);
ChatBoardName
ChatBoardData = arg5;
return;
end;
--------------------------------------------------------------------------------------------------------------------------
--
-- 右键点击好友或黑名单列表或仇人名单
--
if( arg0 == "friendmenu" ) then
currentSelectChannal = arg2;
currentIndex = arg3;
this:Show();
--关心NPC
objCared = tonumber(arg1);
this:CareObject(objCared, 1, "ContexMenu");
if( tonumber( arg2 ) == 6 ) then
AxTrace( 0,0, "show black list menu" );
ContexMenu_BlackListMenu:Show();
ContexMenu_BlackListMenu:SetPopMenuPos(arg4,arg5);
elseif( tonumber( arg2 )== 7 ) then
AxTrace( 0,0, "show enemy list menu" );
ContexMenu_EnemyListMenu:Show();
ContexMenu_EnemyListMenu:SetPopMenuPos(arg4,arg5);
elseif( tonumber( arg2 )== 9 ) then
AxTrace( 0,0, "show temp list menu" );
ContexMenu_TempFriendMenu:Show();
ContexMenu_TempFriendMenu:SetPopMenuPos(arg4,arg5);
else
AxTrace( 0,0, "show friend list menu" );
ContexMenu_FriendMenu:Show();
ContexMenu_FriendMenu:SetPopMenuPos(arg4,arg5);
end
return;
end --------------------------------------------------------------------------------------------------------------------------
--
-- 右键点击临时好友列表
--
if( arg0 == "groupingmenu" ) then
AxTrace( 0,0, "show groping menu" );
currentSelectChannal = arg2;
currentIndex = arg3;
this:Show();
--