1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2010-2018 Winch Gate Property Limited
4 // This source file has been modified by the following contributors:
5 // Copyright (C) 2012 Matt RAYKOWSKI (sfb) <matt.raykowski@gmail.com>
6 // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) <dfighter1985@gmail.com>
7 // Copyright (C) 2013-2020 Jan BOON (Kaetemi) <jan.boon@kaetemi.be>
9 // This program is free software: you can redistribute it and/or modify
10 // it under the terms of the GNU Affero General Public License as
11 // published by the Free Software Foundation, either version 3 of the
12 // License, or (at your option) any later version.
14 // This program is distributed in the hope that it will be useful,
15 // but WITHOUT ANY WARRANTY; without even the implied warranty of
16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 // GNU Affero General Public License for more details.
19 // You should have received a copy of the GNU Affero General Public License
20 // along with this program. If not, see <http://www.gnu.org/licenses/>.
30 #include "cursor_functions.h"
31 #include "user_entity.h"
33 #include "net_manager.h"
34 #include "interface_v3/interface_manager.h"
35 #include "interface_v3/interface_3d_scene.h"
36 #include "nel/gui/group_container.h"
37 #include "sheet_manager.h"
38 #include "interface_v3/inventory_manager.h"
39 #include "interface_v3/guild_manager.h"
40 #include "nel/3d/u_instance.h"
41 #include "main_loop.h"
43 #include "game_share/bot_chat_types.h"
45 #include "r2/editor.h"
51 using namespace NLMISC
;
63 CContextualCursor ContextCur
;
64 CLFECOMMON::TCLEntityId SlotUnderCursor
;
66 uint32 MissionRingId
= 0;
67 sint32 InstanceId
= 0;
68 sint32 selectedInstance
= -1;
69 string selectedInstanceURL
;
70 static NLMISC::CRefPtr
<NLMISC::CCDBNodeLeaf
> s_UserCharFade
;
76 void checkUnderCursor();
77 void contextSelect (bool rightClick
, bool dblClick
);
78 void contextAttack (bool rightClick
, bool dblClick
);
79 void contextQuarter (bool rightClick
, bool dblClick
);
80 void contextLoot (bool rightClick
, bool dblClick
);
81 void contextPickUp (bool rightClick
, bool dblClick
);
82 void contextTradeItem (bool rightClick
, bool dblClick
);
83 void contextTradePhrase (bool rightClick
, bool dblClick
);
84 void contextDynamicMission (bool rightClick
, bool dblClick
);
85 void contextStaticMission (bool rightClick
, bool dblClick
);
86 void contextTradePact (bool rightClick
, bool dblClick
);
87 void contextCreateGuild (bool rightClick
, bool dblClick
);
88 void contextNews (bool rightClick
, bool dblClick
);
89 void contextTeleport (bool rightClick
, bool dblClick
);
90 void contextFaction (bool rightClick
, bool dblClick
);
91 void contextCosmetic (bool rightClick
, bool dblClick
);
92 void contextTalk (bool rightClick
, bool dblClick
);
93 void contextExtractRM (bool rightClick
, bool dblClick
);
94 void contextMission (bool rightClick
, bool dblClick
);
95 void contextWebPage (bool rightClick
, bool dblClick
);
96 void contextWebIG (bool rightClick
, bool dblClick
);
97 void contextARKitect (bool rightClick
, bool dblClick
);
98 void contextRingMission (bool rightClick
, bool dblClick
);
99 void contextOutpost (bool rightClick
, bool dblClick
);
100 void contextBuildTotem (bool rightClick
, bool dblClick
);
101 //-----------------------------------------------
102 // initContextualCursor :
103 // Initialize Contextual Cursor.
104 //-----------------------------------------------
105 void initContextualCursor()
107 // Create states of the Contextual Cursor.
108 ContextCur
.add(false, "STAND BY", string("curs_default.tga"), 0.0f
, checkUnderCursor
, 0);
109 ContextCur
.add(false, "SELECTABLE", string("curs_pick.tga"), 0.0f
, checkUnderCursor
, contextSelect
);
110 // ContextCur.add(false, "ATTACK", string("hand_attack.TGA"), 0.0f, checkUnderCursor, contextAttack);
111 // ContextCur.add(false, "QUARTER", string("hand_harvest.TGA"), 0.0f, checkUnderCursor, contextQuarter);
112 // ContextCur.add(false, "LOOT", string("hand_loot.TGA"), 0.0f, checkUnderCursor, contextLoot);
113 // ContextCur.add(false, "PICKUP", string("hand_loot.TGA"), 0.0f, checkUnderCursor, contextPickUp);
114 // ContextCur.add(false, "TALK", string("hand_speak.TGA"), 0.0f, checkUnderCursor, contextTalk);
117 ContextCur
.add(true, "ATTACK", string("uimGcmAttack"), 0.0f
, checkUnderCursor
, contextAttack
);
118 ContextCur
.add(true, "QUARTER", string("uimGcmQuartering"), 0.0f
, checkUnderCursor
, contextQuarter
);
119 ContextCur
.add(true, "LOOT", string("uimGcmLoot"), 0.0f
, checkUnderCursor
, contextLoot
);
120 ContextCur
.add(true, "PICKUP", string("uimGcmPickUp"), 0.0f
, checkUnderCursor
, contextPickUp
);
121 ContextCur
.add(true, "TRADE ITEM", string("uimGcmTrade"), 0.0f
, checkUnderCursor
, contextTradeItem
);
122 ContextCur
.add(true, "TRADE PHRASE", string("uimGcmTradePhase"), 0.0f
, checkUnderCursor
, contextTradePhrase
);
123 ContextCur
.add(true, "DYNAMIC MISSION", string("uimGcmDynamicMission"), 0.0f
, checkUnderCursor
, contextDynamicMission
);
124 ContextCur
.add(true, "STATIC MISSION", string("uimGcmMissions"), 0.0f
, checkUnderCursor
, contextStaticMission
);
125 ContextCur
.add(true, "TRADE PACT", string("uimGcmTradePact"), 0.0f
, checkUnderCursor
, contextTradePact
);
126 ContextCur
.add(true, "CREATE GUILD", string("uimGcmCreateGuild"), 0.0f
, checkUnderCursor
, contextCreateGuild
);
127 ContextCur
.add(true, "NEWS", string("uimGcmNews"), 0.0f
, checkUnderCursor
, contextNews
);
128 ContextCur
.add(true, "TELEPORT", string("uimGcmTeleport"), 0.0f
, checkUnderCursor
, contextTeleport
);
129 ContextCur
.add(true, "FACTION", string("uimGcmFaction"), 0.0f
, checkUnderCursor
, contextFaction
);
130 ContextCur
.add(true, "COSMETIC", string("uimGcmCosmetic"), 0.0f
, checkUnderCursor
, contextCosmetic
);
131 // ContextCur.add(true, "TALK", string("uimGcmTalk"), 0.0f, checkUnderCursor, contextTalk);
132 ContextCur
.add(true, "EXTRACT_RM", string("uimGcmExtractRM"), 0.0f
, checkUnderCursor
, contextExtractRM
);
133 ContextCur
.add(true, "MISSION", string(""), 0.0f
, checkUnderCursor
, contextMission
);
134 ContextCur
.add(true, "WEB PAGE", string(""), 0.0f
, checkUnderCursor
, contextWebPage
);
135 ContextCur
.add(true, "WEBIG", string(""), 0.0f
, checkUnderCursor
, contextWebIG
);
136 ContextCur
.add(false, "ARKITECT", string("curs_create.tga"), 0.0f
, checkUnderCursor
, contextARKitect
);
137 ContextCur
.add(true, "OUTPOST", string(""), 0.0f
, checkUnderCursor
, contextOutpost
);
138 ContextCur
.add(true, "RING MISSION", string(""), 0.0f
, checkUnderCursor
, contextRingMission
);
139 ContextCur
.add(true, "BUILD_TOTEM", string("uimGcmChooseBuilding"), 0.0f
, checkUnderCursor
, contextBuildTotem
);
140 }// initContextualCursor //
142 //-----------------------------------------------
143 // releaseContextualCursor :
145 //-----------------------------------------------
146 void releaseContextualCursor()
148 ContextCur
.release();
149 }// releaseContextualCursor //
152 //-----------------------------------------------
154 //-----------------------------------------------
155 static bool testMissionOption(sint32 priorityWanted
)
157 CInterfaceManager
*pIM
= CInterfaceManager::getInstance();
160 sint32 bestPriority
= 0;
161 for(uint k
= 0; k
< NUM_MISSION_OPTIONS
; ++k
)
163 std::string nodeName
= toString("LOCAL:TARGET:CONTEXT_MENU:MISSIONS_OPTIONS:%d:PRIORITY", (int) k
);
164 CCDBNodeLeaf
*pNL
= NLGUI::CDBManager::getInstance()->getDbProp(nodeName
, false);
167 sint32 priority
= pNL
->getValue32();
168 if(priority
== priorityWanted
)
170 // Special for priority 2 (yoyo: don't know why...). fail if more than one choice
171 if(priorityWanted
!= 2 || textID
==0)
173 nodeName
= toString("LOCAL:TARGET:CONTEXT_MENU:MISSIONS_OPTIONS:%d:TITLE", (int) k
);
174 pNL
= NLGUI::CDBManager::getInstance()->getDbProp(nodeName
, false);
175 if(pNL
&& pNL
->getValue32())
177 textID
= pNL
->getValue32();
179 bestPriority
= priority
;
180 // general case: found so stop. priority==2: must check all options
181 if(priorityWanted
!=2)
185 // here means that priorityWanted==2 and textId!=0
188 // More than a choice for priorityWanted=2 mission options so nothing to show.
195 nlwarning("checkUnderCursor: entry '%s' dose not exist.", nodeName
.c_str());
197 // Get the Text for the cursor
201 bool res
= STRING_MANAGER::CStringManagerClient::instance()->getDynString(textID
, result
);
203 result
= NLMISC::CI18N::get("uiMissionOptionNotReceived");
204 if(ContextCur
.context("MISSION", 0.0, result
))
211 //-----------------------------------------------
213 //-----------------------------------------------
214 static bool testMissionRing()
216 CInterfaceManager
*pIM
= CInterfaceManager::getInstance();
218 for(uint i
=0;i
<BOTCHATTYPE::MaxR2MissionEntryDatabase
;i
++)
220 // get the ring mission title textID
221 CCDBNodeLeaf
*pNL
= NLGUI::CDBManager::getInstance()->getDbProp(toString("LOCAL:TARGET:CONTEXT_MENU:MISSION_RING:%d:TITLE", i
), false);
222 if(pNL
&& pNL
->getValue32())
224 uint32 textID
= pNL
->getValue32();
226 // if the string is not received display a temp string
227 string missionRingText
;
228 if(!STRING_MANAGER::CStringManagerClient::instance()->getDynString(textID
, missionRingText
))
229 missionRingText
= NLMISC::CI18N::get("uiMissionRingNameNotReceived");
231 // display the cursor
233 if(ContextCur
.context("RING MISSION", 0.f
, missionRingText
))
242 //-----------------------------------------------
243 // checkUnderCursor :
244 // Select the right context according to what is under the cursor.
245 //-----------------------------------------------
246 void checkUnderCursor()
248 // Get the interface instance.
249 CInterfaceManager
*IM
= CInterfaceManager::getInstance();
253 // Get the cursor instance
254 CViewPointer
*cursor
= static_cast< CViewPointer
* >( CWidgetManager::getInstance()->getPointer() );
258 // No Op if screen minimized
259 if(CViewRenderer::getInstance()->isMinimized())
262 // Get the pointer position (in pixel)
264 cursor
->getPointerPos(x
, y
);
266 // Over the interface ?
267 if (CWidgetManager::getInstance()->getWindowUnder(x
, y
) == NULL
)
269 // Is the pointer in the window ?
273 CViewRenderer
&viewRender
= *CViewRenderer::getInstance();
274 viewRender
.getScreenSize(w
, h
);
275 if(x
>=(sint32
)w
|| y
>=(sint32
)h
)
277 // Get the pointer position (in float)
279 cursX
= (float)x
/(float)w
;
280 cursY
= (float)y
/(float)h
;
282 // Get the entities under position
283 bool isPlayerUnderCursor
;
285 entity
= EntitiesMngr
.getEntityUnderPos(cursX
, cursY
, ClientCfg
.SelectionDist
, isPlayerUnderCursor
);
287 // If the mouse is over the player make the player transparent
288 CCDBNodeLeaf
*pNL
= s_UserCharFade
? &*s_UserCharFade
289 : &*(s_UserCharFade
= NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:USER_CHAR_FADE", false));
290 if ((pNL
!= NULL
) && (pNL
->getValue32() == 1) && UserEntity
->selectable())
292 // If the nearest entity is the player, hide!
293 if (isPlayerUnderCursor
)
294 UserEntity
->makeTransparent(true);
296 UserEntity
->makeTransparent(false);
299 UserEntity
->makeTransparent(false);
301 // make transparent the entity under cursor?
302 if (ClientCfg
.TransparentUnderCursor
)
304 for (uint32 i
= 1; i
< 255; ++i
)
306 CEntityCL
*pE
= EntitiesMngr
.entity(i
);
310 pE
->makeTransparent(true);
312 pE
->makeTransparent(false);
317 // If there is an entity selected -> Set as the Target.
320 // Get the distance between the user and the entity.
321 float dist
= (float)(entity
->pos() - UserEntity
->pos()).norm()-entity
->box().getRadius();
322 // Entity Slot under the cursor.
323 SlotUnderCursor
= entity
->slot();
324 uint32 availablePrograms
= (uint32
)NLGUI::CDBManager::getInstance()->getDbProp("LOCAL:TARGET:CONTEXT_MENU:PROGRAMMES")->getValue32();
325 bool entityAttackable
= (availablePrograms
&(1<<BOTCHATTYPE::Attackable
)) || entity
->properties().attackable();
326 if (ClientCfg
.R2EDEnabled
)
328 if (R2::getEditor().isDMing())
330 availablePrograms
= 0;
331 entityAttackable
= false;
334 // If the selection is not the entity under the cursor.
335 if(SlotUnderCursor
!= UserEntity
->selection())
337 // If the user is fighting, clicking automatically attacks the new target
338 if( ClientCfg
.AtkOnSelect
&& UserEntity
->isFighting() && entityAttackable
)
340 if(ContextCur
.context("ATTACK"))
343 // If the Entity is selectable -> select it.
344 else if(entity
->properties().selectable())
346 if(ContextCur
.context("SELECTABLE", dist
))
350 // Entity Under the cursor is the entity selected.
353 // Wait for the target is up to date. Do not display context cursor if the user is mounted.
354 if( (UserEntity
->selection() == UserEntity
->targetSlot()) &&
355 (! UserEntity
->isRiding()) )
358 if ( entity
->isForageSource() )
360 if( !UserEntity
->isFighting() )
362 if(ContextCur
.context("EXTRACT_RM"))
367 else if(entity
->isDead()==false)
370 // Mission Option of priority 3
371 if(testMissionOption(3))
375 if(availablePrograms
)
378 if(availablePrograms
& (1 << BOTCHATTYPE::ChooseMissionFlag
))
380 if(ContextCur
.context("STATIC MISSION"))
384 else if (availablePrograms
& (1 << BOTCHATTYPE::TradeItemFlag
))
386 if(ContextCur
.context("TRADE ITEM"))
390 else if(availablePrograms
& (1 << BOTCHATTYPE::TradePhraseFlag
))
392 if(ContextCur
.context("TRADE PHRASE"))
396 // else if(availablePrograms & (1 << BOTCHATTYPE::DynamicMissionFlag))
398 // if(ContextCur.context("DYNAMIC MISSION"))
402 else if(availablePrograms
& (1 << BOTCHATTYPE::TradePactFlag
))
404 if(ContextCur
.context("TRADE PACT"))
408 else if(availablePrograms
& (1 << BOTCHATTYPE::CreateGuildFlag
))
410 if (!CGuildManager::getInstance()->isInGuild())
411 if(ContextCur
.context("CREATE GUILD"))
415 else if(availablePrograms
& (1 << BOTCHATTYPE::NewsFlag
))
417 if(ContextCur
.context("NEWS"))
421 else if(availablePrograms
& (1 << BOTCHATTYPE::TradeTeleportFlag
))
423 if(ContextCur
.context("TELEPORT"))
427 else if(availablePrograms
& (1 << BOTCHATTYPE::TradeFactionFlag
))
429 if(ContextCur
.context("FACTION"))
433 else if(availablePrograms
& (1 << BOTCHATTYPE::TradeCosmeticFlag
))
435 if(ContextCur
.context("COSMETIC"))
439 else if(availablePrograms
& (1 << BOTCHATTYPE::WebPageFlag
))
441 // get the web page title textID
442 CCDBNodeLeaf
*pNL
= NLGUI::CDBManager::getInstance()->getDbProp("LOCAL:TARGET:CONTEXT_MENU:WEB_PAGE_TITLE", false);
443 if(pNL
&& pNL
->getValue32())
445 uint32 textID
= pNL
->getValue32();
447 // if the string is not received display a temp string
449 if(!STRING_MANAGER::CStringManagerClient::instance()->getDynString(textID
, webPageText
))
450 webPageText
= NLMISC::CI18N::get("uiWebPageNameNotReceived");
452 // display the cursor
453 if(ContextCur
.context("WEB PAGE", 0.f
, webPageText
))
458 else if(availablePrograms
& (1 << BOTCHATTYPE::OutpostFlag
))
460 // get the outpost sheet
461 CCDBNodeLeaf
*pNL
= NLGUI::CDBManager::getInstance()->getDbProp("LOCAL:TARGET:CONTEXT_MENU:OUTPOST", false);
462 if(pNL
&& pNL
->getValue32())
464 // get the outpost name
465 CSheetId
outpostSheet(pNL
->getValue32());
467 outpostName
= STRING_MANAGER::CStringManagerClient::getOutpostLocalizedName(outpostSheet
);
469 // display the cursor
470 if(ContextCur
.context("OUTPOST", 0.f
, outpostName
))
475 else if(availablePrograms
& (1 << BOTCHATTYPE::Totem
))
477 if(ContextCur
.context("BUILD_TOTEM"))
483 // test mission options of lesser priorities
484 if(testMissionOption(2))
486 if(testMissionOption(1))
490 if(testMissionRing())
494 if (entityAttackable
)
496 if(ContextCur
.context("ATTACK"))
500 if(testMissionOption(0))
506 if (!R2::getEditor().isDMing())
509 if((entity
->properties()).harvestable())
511 if(ContextCur
.context("QUARTER"))
515 else if((entity
->properties()).lootable())
517 if(ContextCur
.context("LOOT"))
521 else if((entity
->properties()).liftable())
523 if(ContextCur
.context("PICKUP"))
529 if(entity
->properties().selectable())
531 if(ContextCur
.context("SELECTABLE", dist
))
540 CShapeInstanceReference instref
= EntitiesMngr
.getShapeInstanceUnderPos(cursX
, cursY
, instance_idx
);
542 std::vector
<string
> keys
;
543 keys
.push_back("colorize");
545 if (instance_idx
!= selectedInstance
&& selectedInstance
!= -1) {
546 std::vector
<string
> values
;
547 values
.push_back("0");
548 EntitiesMngr
.setupInstance((uint32
)selectedInstance
, keys
, values
);
551 UInstance instance
= instref
.Instance
;
552 if (!instance
.empty() && !instref
.ContextURL
.empty())
555 selectedInstanceURL
= instref
.ContextURL
;
556 if (instref
.ContextText
.empty())
558 if (instance_idx
!= -1) {
559 std::vector
<string
> values
;
560 values
.push_back("#FF0000FF");
561 EntitiesMngr
.setupInstance((uint32
)instance_idx
, keys
, values
);
562 selectedInstance
= instance_idx
;
565 cursor
->setCursor("r2ed_tool_select_move_over.tga");
566 InstanceId
= instance_idx
;
567 if (ContextCur
.context("ARKITECT", 0.f
, "Edit"))
572 cursor
->setCursor("curs_pick.tga");
573 string contextText
= instref
.ContextText
;
574 if (ContextCur
.context("WEBIG", 0.f
, contextText
))
578 if (!selectedInstanceURL
.empty()) {
579 cursor
->setCursor("curs_default.tga");
580 selectedInstanceURL
.clear();
584 SlotUnderCursor
= CLFECOMMON::INVALID_SLOT
;
590 UserEntity
->makeTransparent(false);
593 ContextCur
.context("STAND BY");
594 }// checkUnderCursor //
597 //-----------------------------------------------
599 // Select what is under the cursor.
600 // \Warning Be sure the checkUnderCursor and contextSelect are done after entites removed.
601 //-----------------------------------------------
602 void contextSelect(bool /* rightClick */, bool /* dblClick */)
604 // Push a message with the entity target (in slot).
605 if(SlotUnderCursor
!= CLFECOMMON::INVALID_SLOT
)
608 UserEntity
->selection(SlotUnderCursor
);
612 //-----------------------------------------------
614 //-----------------------------------------------
615 void contextAttack(bool rightClick
, bool dblClick
)
619 if( ClientCfg
.DblClickMode
&& !dblClick
)
621 // Select the entity to target.
622 UserEntity
->selection(SlotUnderCursor
);
624 if( UserEntity
->canEngageCombat() )
626 // Move to the current selection and attack.
627 UserEntity
->moveToAttack();
631 //-----------------------------------------------
633 //-----------------------------------------------
634 void contextQuarter(bool rightClick
, bool dblClick
)
638 if( ClientCfg
.DblClickMode
&& !dblClick
)
640 UserEntity
->moveTo(SlotUnderCursor
, 3.0, CUserEntity::Quarter
);
641 }// contextQuarter //
643 //-----------------------------------------------
645 //-----------------------------------------------
646 void contextLoot(bool rightClick
, bool dblClick
)
650 if( ClientCfg
.DblClickMode
&& !dblClick
)
652 UserEntity
->moveTo(SlotUnderCursor
, 3.0, CUserEntity::Loot
);
655 //-----------------------------------------------
657 //-----------------------------------------------
658 void contextPickUp(bool rightClick
, bool dblClick
)
662 if( ClientCfg
.DblClickMode
&& !dblClick
)
664 UserEntity
->moveTo(SlotUnderCursor
, 3.0, CUserEntity::PickUp
);
667 //-----------------------------------------------
668 // contextTradeItem :
669 //-----------------------------------------------
670 void contextTradeItem(bool rightClick
, bool dblClick
)
674 if( ClientCfg
.DblClickMode
&& !dblClick
)
676 UserEntity
->moveTo(SlotUnderCursor
, 3.0, CUserEntity::TradeItem
);
677 }// contextTradeItem //
679 //-----------------------------------------------
680 // contextTradePhrase :
681 //-----------------------------------------------
682 void contextTradePhrase(bool rightClick
, bool dblClick
)
686 if( ClientCfg
.DblClickMode
&& !dblClick
)
688 UserEntity
->moveTo(SlotUnderCursor
, 3.0, CUserEntity::TradePhrase
);
689 }// contextTradePhrase //
691 //-----------------------------------------------
692 // contextDynamicMission :
693 //-----------------------------------------------
694 void contextDynamicMission(bool rightClick
, bool dblClick
)
698 if( ClientCfg
.DblClickMode
&& !dblClick
)
700 UserEntity
->moveTo(SlotUnderCursor
, 3.0, CUserEntity::DynamicMission
);
701 }// contextDynamicMission //
703 //-----------------------------------------------
704 // contextStaticMission :
705 //-----------------------------------------------
706 void contextStaticMission(bool rightClick
, bool dblClick
)
710 if( ClientCfg
.DblClickMode
&& !dblClick
)
712 UserEntity
->moveTo(SlotUnderCursor
, 3.0, CUserEntity::StaticMission
);
713 }// contextStaticMission //
715 //-----------------------------------------------
716 // contextTradePact :
717 //-----------------------------------------------
718 void contextTradePact(bool rightClick
, bool dblClick
)
722 if( ClientCfg
.DblClickMode
&& !dblClick
)
724 UserEntity
->moveTo(SlotUnderCursor
, 3.0, CUserEntity::TradePact
);
725 }// contextTradePact //
727 //-----------------------------------------------
728 // contextCreateGuild :
729 //-----------------------------------------------
730 void contextCreateGuild(bool rightClick
, bool dblClick
)
734 if( ClientCfg
.DblClickMode
&& !dblClick
)
736 UserEntity
->moveTo(SlotUnderCursor
, 3.0, CUserEntity::CreateGuild
);
737 }// contextCreateGuild //
739 //-----------------------------------------------
741 //-----------------------------------------------
742 void contextNews(bool rightClick
, bool dblClick
)
746 if( ClientCfg
.DblClickMode
&& !dblClick
)
748 UserEntity
->moveTo(SlotUnderCursor
, 3.0, CUserEntity::News
);
751 //-----------------------------------------------
753 //-----------------------------------------------
754 void contextTeleport(bool rightClick
, bool dblClick
)
758 if( ClientCfg
.DblClickMode
&& !dblClick
)
760 UserEntity
->moveTo(SlotUnderCursor
, 3.0, CUserEntity::TradeTeleport
);
761 }// contextTeleport //
763 //-----------------------------------------------
765 //-----------------------------------------------
766 void contextFaction(bool rightClick
, bool dblClick
)
770 if( ClientCfg
.DblClickMode
&& !dblClick
)
772 UserEntity
->moveTo(SlotUnderCursor
, 3.0, CUserEntity::TradeFaction
);
773 }// contextFaction //
775 //-----------------------------------------------
777 //-----------------------------------------------
778 void contextCosmetic(bool rightClick
, bool dblClick
)
782 if( ClientCfg
.DblClickMode
&& !dblClick
)
784 UserEntity
->moveTo(SlotUnderCursor
, 3.0, CUserEntity::TradeCosmetic
);
785 }// contextCosmetic //
787 //-----------------------------------------------
789 //-----------------------------------------------
790 void contextTalk(bool rightClick
, bool dblClick
)
794 if( ClientCfg
.DblClickMode
&& !dblClick
)
796 // Get the interface instace.
797 CInterfaceManager
*IM
= CInterfaceManager::getInstance();
800 // Get Entity Program
801 uint32 availablePrograms
= (uint32
)NLGUI::CDBManager::getInstance()->getDbProp("LOCAL:TARGET:CONTEXT_MENU:PROGRAMMES")->getValue32();
803 if(availablePrograms
& (1 << BOTCHATTYPE::ChooseMissionFlag
))
804 UserEntity
->moveTo(SlotUnderCursor
, 2.0, CUserEntity::StaticMission
);
806 else if (availablePrograms
& (1 << BOTCHATTYPE::TradeItemFlag
))
807 UserEntity
->moveTo(SlotUnderCursor
, 2.0, CUserEntity::TradeItem
);
809 else if(availablePrograms
& (1 << BOTCHATTYPE::TradePhraseFlag
))
810 UserEntity
->moveTo(SlotUnderCursor
, 2.0, CUserEntity::TradePhrase
);
811 // Dynamic Mission DEPRECATED
812 /* else if(availablePrograms & (1 << BOTCHATTYPE::DynamicMissionFlag))
813 UserEntity->moveTo(SlotUnderCursor, 2.0, CUserEntity::DynamicMission);*/
816 else if(availablePrograms
& (1 << BOTCHATTYPE::TradePactFlag
))
817 UserEntity
->moveTo(SlotUnderCursor
, 2.0, CUserEntity::TradePact
);
819 else if(availablePrograms
& (1 << BOTCHATTYPE::CreateGuildFlag
))
821 if (!CGuildManager::getInstance()->isInGuild())
822 UserEntity
->moveTo(SlotUnderCursor
, 2.0, CUserEntity::CreateGuild
);
825 else if(availablePrograms
& (1 << BOTCHATTYPE::NewsFlag
))
826 UserEntity
->moveTo(SlotUnderCursor
, 2.0, CUserEntity::Talk
);
828 else if(availablePrograms
& (1 << BOTCHATTYPE::TradeTeleportFlag
))
829 UserEntity
->moveTo(SlotUnderCursor
, 2.0, CUserEntity::TradeTeleport
);
831 else if(availablePrograms
& (1 << BOTCHATTYPE::TradeFactionFlag
))
832 UserEntity
->moveTo(SlotUnderCursor
, 2.0, CUserEntity::TradeFaction
);
834 else if(availablePrograms
& (1 << BOTCHATTYPE::WebPageFlag
))
835 UserEntity
->moveTo(SlotUnderCursor
, 2.0, CUserEntity::WebPage
);
837 else if(availablePrograms
& (1 << BOTCHATTYPE::OutpostFlag
))
838 UserEntity
->moveTo(SlotUnderCursor
, 2.0, CUserEntity::Outpost
);
842 //-----------------------------------------------
843 // contextExtractRM :
844 //-----------------------------------------------
845 void contextExtractRM(bool rightClick
, bool dblClick
)
849 if( ClientCfg
.DblClickMode
&& !dblClick
)
851 UserEntity
->moveToExtractionPhrase(SlotUnderCursor
, MaxExtractionDistance
, std::numeric_limits
<uint
>::max(), std::numeric_limits
<uint
>::max(), true );
854 //-----------------------------------------------
856 // Callback for dynamic missions
857 //-----------------------------------------------
858 void contextMission(bool rightClick
, bool dblClick
)
862 if( ClientCfg
.DblClickMode
&& !dblClick
)
864 UserEntity
->moveToMission(SlotUnderCursor
, 3.0, MissionId
);
865 }// contextMission //
867 //-----------------------------------------------
869 //-----------------------------------------------
870 void contextWebPage(bool rightClick
, bool dblClick
)
874 if( ClientCfg
.DblClickMode
&& !dblClick
)
876 UserEntity
->moveTo(SlotUnderCursor
, 3.0, CUserEntity::WebPage
);
877 }// contextWebPage //
879 //-----------------------------------------------
881 //-----------------------------------------------
882 void contextWebIG(bool rightClick
, bool dblClick
)
886 CInterfaceManager
*IM
= CInterfaceManager::getInstance();
887 CInterfaceElement
*pGC
= CWidgetManager::getInstance()->getElementFromId("ui:interface:bot_chat_object");
888 CInterface3DShape
*el
= dynamic_cast<CInterface3DShape
*>(CWidgetManager::getInstance()->getElementFromId("ui:interface:bot_chat_object:scene3d:object_1"));
892 //el->setName(selectedInstance.getShapeName());
895 if (selectedInstanceURL
.empty())
898 pGC
->setActive(true);
903 pGC
->setActive(false);
905 if (selectedInstanceURL
.substr(0, 5) == "@LUA ")
907 string header
= toString("doubleClick = %s\nrightClick = %s\nSelectedInstanceId = %u\n", dblClick
?"true":"false", rightClick
?"true":"false", InstanceId
);
908 CLuaManager::getInstance().executeLuaScript(header
+selectedInstanceURL
.substr(5), true);
912 CAHManager::getInstance()->runActionHandler("browse", NULL
, "name=ui:interface:webig:content:html|url="+selectedInstanceURL
);
918 //-----------------------------------------------
920 //-----------------------------------------------
921 void contextARKitect(bool rightClick
, bool dblClick
)
923 string header
= toString("doubleClick = %s\nrightClick = %s\nSelectedInstanceId = %u\n", dblClick
?"true":"false", rightClick
?"true":"false", InstanceId
);
925 CLuaManager::getInstance().executeLuaScript(header
+selectedInstanceURL
, true);
927 }// contextARKitect //
930 //-----------------------------------------------
932 //-----------------------------------------------
933 void contextOutpost(bool rightClick
, bool dblClick
)
937 if( ClientCfg
.DblClickMode
&& !dblClick
)
939 UserEntity
->moveTo(SlotUnderCursor
, 3.0, CUserEntity::Outpost
);
940 }// contextOutpost //
942 //-----------------------------------------------
943 // contextRingMission
944 //-----------------------------------------------
945 void contextRingMission(bool rightClick
, bool dblClick
)
949 if( ClientCfg
.DblClickMode
&& !dblClick
)
951 UserEntity
->moveToMissionRing(SlotUnderCursor
, 3.0, MissionRingId
);
952 }// contextRingMission //
954 //-----------------------------------------------
955 // contextBuildTotem :
956 //-----------------------------------------------
957 void contextBuildTotem(bool rightClick
, bool dblClick
)
961 if( ClientCfg
.DblClickMode
&& !dblClick
)
963 UserEntity
->moveToTotemBuildingPhrase(SlotUnderCursor
,MaxExtractionDistance
, std::numeric_limits
<uint
>::max(), std::numeric_limits
<uint
>::max(), true );
964 }// contextBuildTotem //