1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2010-2019 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) 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/>.
25 #include "guild_manager.h"
27 #include "interface_manager.h"
28 #include "../string_manager_client.h"
29 #include "nel/gui/action_handler.h"
30 #include "nel/gui/view_text.h"
31 #include "dbctrl_sheet.h"
32 #include "nel/gui/group_container.h"
33 #include "nel/gui/group_menu.h"
34 #include "nel/gui/group_html.h"
35 #include "../init_main_loop.h"
36 #include "inventory_manager.h"
38 #include "../connection.h"
39 #include "../entity_cl.h"
40 #include "../user_entity.h" // UserEntity
41 #include "nel/gui/view_bitmap.h"
42 #include "../sheet_manager.h"
43 #include "../net_manager.h"
44 #include "../client_sheets/building_sheet.h"
46 #include "game_share/lift_icons.h"
48 #include "../r2/editor.h"
49 #include "chat_window.h"
50 #include "people_interraction.h"
55 using namespace NLMISC
;
57 extern CPeopleInterraction PeopleInterraction
;
59 NLMISC_REGISTER_OBJECT(CViewBase
, CDBGroupListAscensor
, std::string
, "list_sheet_guild");
61 // ***************************************************************************
63 // ***************************************************************************
65 #define WIN_GUILD "ui:interface:guild"
66 #define WIN_GUILD_CHAT "ui:interface:guild_chat"
67 #define WIN_GUILD_FORUM "ui:interface:guild_forum"
68 #define VIEW_TEXT_GUILD_QUIT "ui:interface:guild:content:tab_guild_info:quit_guild"
69 #define CTRL_SHEET_GUILD_BLASON "ui:interface:guild:content:tab_guild_info:blason"
70 #define VIEW_TEXT_GUILD_MEMBER_COUNT "ui:interface:guild:content:tab_guild_info:member_count"
73 #define LIST_GUILD_MEMBERS "ui:interface:guild:content:tab_guild:list_member:guild_members"
74 #define CTRL_QUIT_GUILD "ui:interface:guild:content:tab_guild_info:quit_guild"
75 #define TEMPLATE_GUILD_MEMBER "member_template"
76 #define TEMPLATE_GUILD_MEMBER_NAME "name"
77 #define TEMPLATE_GUILD_MEMBER_GRADE "grade"
78 #define TEMPLATE_GUILD_MEMBER_SCORE "score"
79 #define TEMPLATE_GUILD_MEMBER_ENTER_DATE "enter_date"
80 #define MENU_GUILD_MEMBER "ui:interface:menu_member"
82 #define WIN_ASCENSOR "ui:interface:ascensor_teleport_list"
84 #define WIN_JOIN_PROPOSAL "ui:interface:join_guild_proposal"
85 #define VIEW_JOIN_PROPOSAL_PHRASE "ui:interface:join_guild_proposal:content:inside:phrase"
87 CGuildManager
* CGuildManager::_Instance
= NULL
;
89 // ***************************************************************************
90 CGuildManager::CGuildManager()
97 _NeedRebuildMembers
= true;
99 _NeedUpdateMembers
= false;
101 _JoinPropUpdate
= false;
102 _NewToTheGuild
= false;
105 // ***************************************************************************
106 CGuildManager::~CGuildManager()
111 static inline bool lt_member_name(const SGuildMember
&m1
, const SGuildMember
&m2
)
113 return toLower(m1
.Name
) < toLower(m2
.Name
);
116 static inline bool lt_member_grade(const SGuildMember
&m1
, const SGuildMember
&m2
)
118 return m1
.Grade
< m2
.Grade
;
121 static inline bool lt_member_online(const SGuildMember
&m1
, const SGuildMember
&m2
)
123 if (m1
.Online
== m2
.Online
)
125 return lt_member_grade(m1
, m2
);
128 // Compare online status
132 // m1 is < if m1 is online
135 case ccs_online_abroad
:
136 // m1 is < if m2 is offline
137 return (m2
.Online
== ccs_offline
);
141 // m2 is always < if m1 is offline
148 // ***************************************************************************
149 void CGuildManager::sortGuildMembers(TSortOrder order
)
151 if (_GuildMembers
.size() < 2) return;
157 sort(_GuildMembers
.begin(), _GuildMembers
.end(), lt_member_name
);
158 stable_sort(_GuildMembers
.begin(), _GuildMembers
.end(), lt_member_grade
);
161 sort(_GuildMembers
.begin(), _GuildMembers
.end(), lt_member_name
);
164 sort(_GuildMembers
.begin(), _GuildMembers
.end(), lt_member_name
);
165 stable_sort(_GuildMembers
.begin(), _GuildMembers
.end(), lt_member_online
);
170 bool CGuildManager::isProxy()
172 CInterfaceManager
*pIM
= CInterfaceManager::getInstance();
173 return NLGUI::CDBManager::getInstance()->getDbProp("SERVER:GUILD:PROXY")->getValueBool();
177 // ***************************************************************************
178 /*void CGuildManager::init (const std::vector< std::pair<uint32,uint8> > &NameGrade)
180 _GuildMembers.clear();
181 _GuildMembers.resize(NameGrade.size());
182 for (uint32 i = 0; i < NameGrade.size(); ++i)
184 _GuildMembers[i].Index = i;
185 _GuildMembers[i].NameID = NameGrade[i].first;
186 _GuildMembers[i].Grade = (EGSPD::CGuildGrade::TGuildGrade)(NameGrade[i].second&0x7f);
187 _GuildMembers[i].Online = ((NameGrade[i].second&0x80) != 0);
191 // ***************************************************************************
192 /*void CGuildManager::set (uint32 indexMember, uint32 MemberName, uint8 MemberGrade, bool bOnline)
195 for (i = 0; i < _GuildMembers.size(); ++i)
197 if (_GuildMembers[i].Index == indexMember)
201 // indexMember not found create it
202 if (i == _GuildMembers.size())
204 _GuildMembers.resize(_GuildMembers.size()+1);
205 _GuildMembers[i].Index = indexMember;
208 if ((MemberName == 0) && (MemberGrade == (uint32)EGSPD::CGuildGrade::EndGuildGrade))
211 _GuildMembers.erase(_GuildMembers.begin()+i);
216 _GuildMembers[i].NameID = MemberName;
217 _GuildMembers[i].Grade = (EGSPD::CGuildGrade::TGuildGrade)MemberGrade;
218 _GuildMembers[i].Online = bOnline;
224 // ***************************************************************************
225 bool CGuildManager::isInGuild()
227 // InGuild is set from database (if the guild name id != 0)
231 // ***************************************************************************
232 bool CGuildManager::canRecruit()
234 if (!_InGuild
) return false;
235 if ((_Grade
== EGSPD::CGuildGrade::Leader
) || (_Grade
== EGSPD::CGuildGrade::HighOfficer
) ||
236 (_Grade
== EGSPD::CGuildGrade::Officer
) /*|| (_Grade == EGSPD::CGuildGrade::Recruiter)*/)
241 // ***************************************************************************
242 bool CGuildManager::isLeaderOfTheGuild()
244 return (_Grade
== EGSPD::CGuildGrade::Leader
);
247 // ***************************************************************************
248 string
CGuildManager::getGuildName()
255 // ***************************************************************************
256 uint64
CGuildManager::getMoney()
258 CInterfaceManager
*pIM
= CInterfaceManager::getInstance();
259 return NLGUI::CDBManager::getInstance()->getDbProp("SERVER:GUILD:INVENTORY:MONEY")->getValue64();
262 // ***************************************************************************
263 uint64
CGuildManager::getXP()
265 CInterfaceManager
*pIM
= CInterfaceManager::getInstance();
266 return NLGUI::CDBManager::getInstance()->getDbProp("SERVER:GUILD:XP")->getValue64();
269 // ***************************************************************************
270 void CGuildManager::update()
272 CInterfaceManager
*pIM
= CInterfaceManager::getInstance();
273 STRING_MANAGER::CStringManagerClient
*pSMC
= STRING_MANAGER::CStringManagerClient::instance();
275 // *** Need to rebuild the guild data?
279 _NeedRebuild
= false;
281 // Rebuild transfert the database to the local structure
284 uint32 oldName
= _Guild
.NameID
;
285 _Guild
.NameID
= NLGUI::CDBManager::getInstance()->getDbProp("SERVER:GUILD:NAME")->getValue32();
287 _InGuild
= (_Guild
.NameID
!= 0);
289 closeAllInterfaces();
290 _Guild
.Icon
= NLGUI::CDBManager::getInstance()->getDbProp("SERVER:GUILD:ICON")->getValue64();
291 _Guild
.QuitGuildAvailable
= true;
294 if(_NeedRebuildMembers
)
296 _NeedUpdateMembers
= true;
297 _NeedRebuildMembers
= false;
299 _GuildMembers
.clear();
300 for (uint32 i
= 0; i
< MAX_GUILD_MEMBER
; ++i
)
302 sint32 name
= NLGUI::CDBManager::getInstance()->getDbProp("SERVER:GUILD:MEMBERS:"+toString(i
)+":NAME")->getValue32();
308 gm
.Grade
= (EGSPD::CGuildGrade::TGuildGrade
)(NLGUI::CDBManager::getInstance()->getDbProp("SERVER:GUILD:MEMBERS:"+toString(i
)+":GRADE")->getValue32());
309 gm
.Online
= (TCharConnectionState
)(NLGUI::CDBManager::getInstance()->getDbProp("SERVER:GUILD:MEMBERS:"+toString(i
)+":ONLINE")->getValue32());
310 gm
.EnterDate
= NLGUI::CDBManager::getInstance()->getDbProp("SERVER:GUILD:MEMBERS:"+toString(i
)+":ENTER_DATE")->getValue32();
311 _GuildMembers
.push_back(gm
);
316 // Does the player are newcomer ?
317 // Boris 01/09/2006 : removed : now the guild interface is open if
318 // is was active before OR if the EGS ask it to the client
320 bool playerNewToTheGuild
= _NewToTheGuild
&&(oldName
!= _Guild
.NameID
) && _InGuild
;
321 if (playerNewToTheGuild
)
324 _NewToTheGuild
= false;
325 // Don't pop the guild window in ring mode.
326 // NB nico : this test should not be necessary, as the guild infos should be filled during the init of the db
327 // However, there are situation where this db info is filled after init (should only happen at guild creation time ...)
328 // Maybe an EGS bug ?
329 if (R2::getEditor().getMode() == R2::CEditor::NotInitialized
)
331 CInterfaceElement
*pElt
;
332 // Open the guild info if we are not in the init phase
333 if (!IngameDbMngr
.initInProgress())
335 pElt
= CWidgetManager::getInstance()->getElementFromId(WIN_GUILD
);
337 pElt
->setActive(true);
340 pElt
= CWidgetManager::getInstance()->getElementFromId(WIN_GUILD_FORUM
":content:html");
343 CGroupHTML
*html
= dynamic_cast<CGroupHTML
*>(pElt
);
345 html
->browse("home");
351 // *** Need to update Names?
354 bool bAllValid
= true;
355 // Update wait until all the name of members, name of the guild and description are valid
357 if (!pSMC
->getString (_Guild
.NameID
, _Guild
.Name
)) bAllValid
= false;
359 for (uint i
= 0; i
< _GuildMembers
.size(); ++i
)
361 if (!pSMC
->getString (_GuildMembers
[i
].NameID
, _GuildMembers
[i
].Name
)) bAllValid
= false;
362 else _GuildMembers
[i
].Name
= CEntityCL::removeTitleAndShardFromName(_GuildMembers
[i
].Name
);
365 // If all is valid no more need update and if guild is opened update the interface
368 CCDBNodeLeaf
* node
= NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:CHAT:SHOW_ONLINE_OFFLINE_NOTIFICATIONS_CB", false);
369 if (node
&& node
->getValueBool())
371 // See if we need to show any online/offline messages
372 static map
<string
, SGuildMember
> CachedGuildMembers
;
373 const string
&onlineMessage
= CI18N::get("uiPlayerOnline");
374 const string
&offlineMessage
= CI18N::get("uiPlayerOffline");
376 for (uint i
= 0; i
< _GuildMembers
.size(); ++i
)
378 map
<string
, SGuildMember
>::const_iterator it
= CachedGuildMembers
.find(_GuildMembers
[i
].Name
);
379 if ( it
!= CachedGuildMembers
.end() )
381 if ( (*it
).second
.Online
== _GuildMembers
[i
].Online
)
383 // Online status not changed for this member
387 if ( (*it
).second
.Online
!= ccs_offline
&& _GuildMembers
[i
].Online
!= ccs_offline
)
389 // Not from offline, or to offline, so don't show anything
393 string msg
= (_GuildMembers
[i
].Online
!= ccs_offline
) ? onlineMessage
: offlineMessage
;
394 strFindReplace(msg
, "%s", _GuildMembers
[i
].Name
);
395 string cat
= getStringCategory(msg
, msg
);
396 map
<string
, CClientConfig::SSysInfoParam
>::const_iterator it
;
397 NLMISC::CRGBA col
= CRGBA::Yellow
;
398 it
= ClientCfg
.SystemInfoParams
.find(toLowerAscii(cat
));
399 if (it
!= ClientCfg
.SystemInfoParams
.end())
401 col
= it
->second
.Color
;
404 PeopleInterraction
.ChatInput
.Guild
.displayMessage(msg
, col
, 2, &dummy
);
409 CachedGuildMembers
.clear();
410 for (uint i
= 0; i
< _GuildMembers
.size(); ++i
)
412 CachedGuildMembers
.insert(make_pair(_GuildMembers
[i
].Name
, _GuildMembers
[i
]));
416 // Search for UserEntity to find our own grade
417 if ((UserEntity
!= NULL
) && (!_GuildMembers
.empty()))
420 _Grade
= EGSPD::CGuildGrade::Member
;
421 string sUserName
= toLower(UserEntity
->getEntityName());
422 for (i
= 0; i
< _GuildMembers
.size(); ++i
)
424 if (toLower(_GuildMembers
[i
].Name
) == sUserName
)
426 _Grade
= _GuildMembers
[i
].Grade
;
432 // set this value in the database
433 NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:USER:GUILD_GRADE")->setValue32(_Grade
);
435 // update the guild display
436 CGroupContainer
*pGuild
= dynamic_cast<CGroupContainer
*>(CWidgetManager::getInstance()->getElementFromId(WIN_GUILD
));
439 // if the guild window is visible
440 if (pGuild
->isOpen() && pGuild
->getActive())
442 // Close the modal window if the member list will change
443 if(CWidgetManager::getInstance()->getModalWindow()!=NULL
&& _NeedUpdateMembers
)
445 if (CWidgetManager::getInstance()->getModalWindow()->getId() == MENU_GUILD_MEMBER
)
446 CWidgetManager::getInstance()->disableModalWindow();
449 // Rebuild interface. Rebuild members only if needed
450 CAHManager::getInstance()->runActionHandler("guild_sheet_open", NULL
, toString("update_members=%d", (uint
)_NeedUpdateMembers
) );
456 _NeedUpdateMembers
= false;
460 // *** Join proposal handling
463 bool bAllValid
= true;
464 if (!pSMC
->getDynString (_JoinPropPhraseID
, _JoinPropPhrase
)) bAllValid
= false;
465 // If all is valid no more need update and update the interface
468 _JoinPropUpdate
= false;
469 CGroupContainer
*pJoinProp
= dynamic_cast<CGroupContainer
*>(CWidgetManager::getInstance()->getElementFromId(WIN_JOIN_PROPOSAL
));
470 if (pJoinProp
!= NULL
)
472 CViewText
*pJoinPropPhraseView
= dynamic_cast<CViewText
*>(CWidgetManager::getInstance()->getElementFromId(VIEW_JOIN_PROPOSAL_PHRASE
));
473 if (pJoinPropPhraseView
!= NULL
)
474 pJoinPropPhraseView
->setText(_JoinPropPhrase
);
476 pJoinProp
->setActive(true);
477 CWidgetManager::getInstance()->setTopWindow(pJoinProp
);
478 pJoinProp
->updateCoords();
480 pJoinProp
->enableBlink(2);
486 // ***************************************************************************
487 void CGuildManager::launchAscensor()
489 // Start the huge list exchange
492 // Increment session id
493 Ascensors
.incrementSessionID();
495 // Send request of the first page to the server specifying the session id
497 if(GenericMsgHeaderMngr
.pushNameToStream("GUILD:FIRST_ASCENSOR_PAGE", out
))
499 uint16 session
= Ascensors
.getSessionID();
502 //nlinfo("impulseCallBack : GUILD:FIRST_ASCENSOR_PAGE %d sent",session);
506 nlwarning("impulseCallBack : unknown message name : 'GUILD:FIRST_ASCENSOR_PAGE'.");
509 // Start Ascensor Interface
510 CInterfaceManager
*pIM
= CInterfaceManager::getInstance();
511 CGroupContainer
*pAC
= dynamic_cast<CGroupContainer
*>(CWidgetManager::getInstance()->getElementFromId(WIN_ASCENSOR
));
512 if (pAC
== NULL
) return;
513 pAC
->setActive(true);
514 CWidgetManager::getInstance()->setTopWindow(pAC
);
519 NLMISC_COMMAND(testAscensorPage
, "Temp : Simulate the server that fills the database for ascensor","")
521 CInterfaceManager
*im
= CInterfaceManager::getInstance();
524 NLGUI::CDBManager::getInstance()->getDbProp("LOCAL:ASCENSOR:0:NAME")->setValue32(12);
525 prop
= CGuildManager::iconMake(1, 1, false, CRGBA(255, 255, 0), CRGBA(0, 255, 0));
526 NLGUI::CDBManager::getInstance()->getDbProp("LOCAL:ASCENSOR:0:ICON")->setValue64(prop
);
528 NLGUI::CDBManager::getInstance()->getDbProp("LOCAL:ASCENSOR:1:NAME")->setValue32(12);
529 prop
= CGuildManager::iconMake(1, 2, false, CRGBA(0, 255, 255), CRGBA(255, 0, 255));
530 NLGUI::CDBManager::getInstance()->getDbProp("LOCAL:ASCENSOR:1:ICON")->setValue64(prop
);
532 NLGUI::CDBManager::getInstance()->getDbProp("LOCAL:ASCENSOR:2:NAME")->setValue32(12);
533 prop
= CGuildManager::iconMake(2, 3, false, CRGBA(255, 0, 0), CRGBA(0, 255, 0));
534 NLGUI::CDBManager::getInstance()->getDbProp("LOCAL:ASCENSOR:2:ICON")->setValue64(prop
);
536 NLGUI::CDBManager::getInstance()->getDbProp("LOCAL:ASCENSOR:3:NAME")->setValue32(12);
537 prop
= CGuildManager::iconMake(2, 4, false, CRGBA(255, 255, 0), CRGBA(0, 255, 255));
538 NLGUI::CDBManager::getInstance()->getDbProp("LOCAL:ASCENSOR:3:ICON")->setValue64(prop
);
540 NLGUI::CDBManager::getInstance()->getDbProp("LOCAL:ASCENSOR:4:NAME")->setValue32(12);
541 prop
= CGuildManager::iconMake(3, 5, false, CRGBA(255, 255, 0), CRGBA(255, 0, 255));
542 NLGUI::CDBManager::getInstance()->getDbProp("LOCAL:ASCENSOR:4:ICON")->setValue64(prop
);
544 NLGUI::CDBManager::getInstance()->getDbProp("LOCAL:ASCENSOR:5:NAME")->setValue32(12);
545 prop
= CGuildManager::iconMake(3, 6, false, CRGBA(0, 255, 255), CRGBA(255, 255, 0));
546 NLGUI::CDBManager::getInstance()->getDbProp("LOCAL:ASCENSOR:5:ICON")->setValue64(prop
);
548 NLGUI::CDBManager::getInstance()->getDbProp("LOCAL:ASCENSOR:6:NAME")->setValue32(12);
549 prop
= CGuildManager::iconMake(4, 7, false, CRGBA(0, 255, 255), CRGBA(255, 0, 255));
550 NLGUI::CDBManager::getInstance()->getDbProp("SERVER:ASCENSOR:6:ICON")->setValue64(prop
);
552 NLGUI::CDBManager::getInstance()->getDbProp("LOCAL:ASCENSOR:7:NAME")->setValue32(12);
553 prop
= CGuildManager::iconMake(4, 8, false, CRGBA(255, 0, 255), CRGBA(0, 255, 255));
554 NLGUI::CDBManager::getInstance()->getDbProp("LOCAL:ASCENSOR:7:ICON")->setValue64(prop
);
559 // ***************************************************************************
560 void CGuildManager::quitAscensor()
562 CInterfaceManager
*pIM
= CInterfaceManager::getInstance();
563 CGroupContainer
*pAC
= dynamic_cast<CGroupContainer
*>(CWidgetManager::getInstance()->getElementFromId(WIN_ASCENSOR
));
564 if (pAC
== NULL
) return;
565 pAC
->setActive(false);
568 // ***************************************************************************
569 void CGuildManager::launchJoinProposal(uint32 phraseID
)
571 _JoinPropPhraseID
= phraseID
;
572 _JoinPropUpdate
= true;
575 // ***************************************************************************
576 void CGuildManager::quitJoinProposal()
578 CInterfaceManager
*pIM
= CInterfaceManager::getInstance();
579 CGroupContainer
*pJoinProp
= dynamic_cast<CGroupContainer
*>(CWidgetManager::getInstance()->getElementFromId(WIN_JOIN_PROPOSAL
));
580 if (pJoinProp
!= NULL
)
581 pJoinProp
->setActive(false);
584 // ***************************************************************************
585 void CGuildManager::closeAllInterfaces()
587 CInterfaceManager
*pIM
= CInterfaceManager::getInstance();
588 CGroupContainer
*pGuild
= dynamic_cast<CGroupContainer
*>(CWidgetManager::getInstance()->getElementFromId(WIN_GUILD
));
590 pGuild
->setActive(false);
591 CGroupContainer
*pGuildForum
= dynamic_cast<CGroupContainer
*>(CWidgetManager::getInstance()->getElementFromId(WIN_GUILD_FORUM
));
592 if (pGuildForum
!= NULL
)
593 pGuildForum
->setActive(false);
594 CGroupContainer
*pGuildChat
= dynamic_cast<CGroupContainer
*>(CWidgetManager::getInstance()->getElementFromId(WIN_GUILD_CHAT
));
595 if (pGuildChat
!= NULL
)
596 pGuildChat
->setActive(false);
599 // ***************************************************************************
600 void CGuildManager::openGuildWindow()
602 _NewToTheGuild
= true;
603 // CInterfaceManager *pIM = CInterfaceManager::getInstance();
604 // // Open the guild window
606 // CCDBNodeLeaf *node= NLGUI::CDBManager::getInstance()->getDbProp("CLIENT:GUILD:HAVE_JOINED", false);
608 // node->setValue64(1);
610 // CInterfaceElement *pElt;
611 // pElt = CWidgetManager::getInstance()->getElementFromId(WIN_GUILD);
614 // pElt->setActive(true);
616 // // Browse the forum
617 // pElt = CWidgetManager::getInstance()->getElementFromId(WIN_GUILD_FORUM":content:html");
620 // CGroupHTML *html = dynamic_cast<CGroupHTML*>(pElt);
622 // html->browse("home");
626 // ***************************************************************************
627 void CGuildManager::initForDebug()
630 _Guild
.Name
= "TrapsGuild";
631 _Guild
.Icon
= CGuildManager::iconMake(1,1,false,CRGBA(255,0,255), CRGBA(0,255,255));
633 _Grade
= EGSPD::CGuildGrade::Officer
;
635 _GuildMembers
.clear();
637 m
.Grade
= EGSPD::CGuildGrade::Leader
;
640 _GuildMembers
.push_back(m
);
641 m
.Grade
= EGSPD::CGuildGrade::Officer
;
644 _GuildMembers
.push_back(m
);
645 m
.Grade
= EGSPD::CGuildGrade::HighOfficer
;
648 _GuildMembers
.push_back(m
);
649 m
.Grade
= EGSPD::CGuildGrade::Member
;
652 _GuildMembers
.push_back(m
);
653 m
.Grade
= EGSPD::CGuildGrade::Member
;
656 _GuildMembers
.push_back(m
);
657 // m.Grade = EGSPD::CGuildGrade::Bearer;
660 _GuildMembers
.push_back(m
);
661 // m.Grade = EGSPD::CGuildGrade::Recruiter;
664 _GuildMembers
.push_back(m
);
665 // m.Grade = EGSPD::CGuildGrade::Recruiter;
668 _GuildMembers
.push_back(m
);
669 m
.Grade
= EGSPD::CGuildGrade::Member
;
672 _GuildMembers
.push_back(m
);
673 m
.Grade
= EGSPD::CGuildGrade::Member
;
674 m
.Name
= "EricSimon";
676 _GuildMembers
.push_back(m
);
679 // ***************************************************************************
680 void CGuildManager::initDBObservers()
682 CInterfaceManager
*pIM
= CInterfaceManager::getInstance();
684 // add an observer on the whole guild
685 NLGUI::CDBManager::getInstance()->addBranchObserver( "SERVER:GUILD", &_DBObs
);
687 // add an observer on members only => need to update all
688 NLGUI::CDBManager::getInstance()->addBranchObserver("SERVER:GUILD:MEMBERS", &_DBObsMembers
);
690 // observer on ascencors
691 Ascensors
.setListType(CHugeListObs::Ascensor
);
692 NLGUI::CDBManager::getInstance()->addBranchObserver("SERVER:ASCENSOR", &Ascensors
);
695 // ***************************************************************************
696 // CDBGroupListAscensor
697 // ***************************************************************************
699 // **********************************************************************************
700 void CDBGroupListAscensor::CSheetChildAscensor::init(CDBGroupListSheetText
*pFather
, uint index
)
703 CSheetChild::init(pFather
, index
);
707 SecondSheetIdCache
= 0;
710 // **********************************************************************************
711 bool CDBGroupListAscensor::CSheetChildAscensor::isInvalidated(CDBGroupListSheetText
* /* pFather */)
713 if (Ctrl
->getSheetId() != SecondSheetIdCache
)
715 SecondSheetIdCache
= Ctrl
->getSheetId();
721 CInterfaceManager
*pIM
= CInterfaceManager::getInstance();
722 STRING_MANAGER::CStringManagerClient
*pSMC
= STRING_MANAGER::CStringManagerClient::instance();
724 uint32 nameID
= NLGUI::CDBManager::getInstance()->getDbProp("LOCAL:ASCENSOR:" + toString(Index
) + ":NAME")->getValue32();
726 if (nameID
&& pSMC
->getDynString(nameID
, name
))
730 uint64 icon
= NLGUI::CDBManager::getInstance()->getDbProp("LOCAL:ASCENSOR:" + toString(Index
) + ":ICON")->getValue64();
733 if ((icon
& UINT64_CONSTANT(0x8000000000000000)) != 0)
736 LIFT_ICONS::TLiftIcon li
= (LIFT_ICONS::TLiftIcon
)(icon
& UINT64_CONSTANT(0x7FFFFFFFFFFFFFFF));
737 string str
= toLowerAscii(LIFT_ICONS::toString(li
));
738 Ctrl
->setType(CCtrlSheetInfo::SheetType_Teleport_Location
);
739 Ctrl
->setSlot("asc_"+str
+".tga");
743 Ctrl
->setType(CCtrlSheetInfo::SheetType_GuildFlag
);
744 Ctrl
->initSheetSize();
745 Ctrl
->setSheetId(SecondSheetIdCache
);
756 // **********************************************************************************
757 bool CDBGroupListAscensor::CSheetChildAscensor::isSheetValid(CDBGroupListSheetText
* /* pFather */)
759 if (!Ctrl
) return false;
760 return Ctrl
->getSheetId() != 0;
763 // ***************************************************************************
765 // ***************************************************************************
767 // ***************************************************************************
768 void CGuildManager::CDBObs::update(ICDBNode
* /* node */)
770 CGuildManager
*pGM
= CGuildManager::getInstance();
774 void CGuildManager::CDBObsMembers::update(ICDBNode
* /* node */)
776 CGuildManager
*pGM
= CGuildManager::getInstance();
777 pGM
->rebuildBasicAndMembers();
780 // ***************************************************************************
782 // ***************************************************************************
784 // ***************************************************************************
785 class CAHGuildSheetOpen
: public IActionHandler
787 virtual void execute (CCtrlBase
* /* pCaller */, const string
&Params
)
789 CInterfaceManager
*pIM
= CInterfaceManager::getInstance();
790 CGuildManager
*pGM
= CGuildManager::getInstance();
791 bool updateMembers
= getParam(Params
, "update_members")=="1";
794 // *** Update interface with data of Guild Manager
795 const SGuild
&rGuild
= pGM
->getGuild();
797 // Freeze / unfreeze quit button
798 CCtrlBaseButton
*control
= dynamic_cast<CCtrlBaseButton
*>(CWidgetManager::getInstance()->getElementFromId(VIEW_TEXT_GUILD_QUIT
));
800 control
->setFrozen (!rGuild
.QuitGuildAvailable
|| pGM
->isProxy());
803 // *** Update Members, if necessary
806 CGuildManager::TSortOrder order
= (CGuildManager::TSortOrder
)(NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:GUILD_LIST:SORT_ORDER")->getValue32());
807 // Sort the members in Guild Manager
808 pGM
->sortGuildMembers(order
);
810 // update member count view
811 const vector
<SGuildMember
> &rGuildMembers
= pGM
->getGuildMembers();
812 CViewText
*pVT
= dynamic_cast<CViewText
*>(CWidgetManager::getInstance()->getElementFromId(VIEW_TEXT_GUILD_MEMBER_COUNT
));
814 pVT
->setText(toString(rGuildMembers
.size()));
816 // rebuild guild member list
817 CGroupList
*pParent
= dynamic_cast<CGroupList
*>(CWidgetManager::getInstance()->getElementFromId(LIST_GUILD_MEMBERS
));
818 if (pParent
== NULL
) return;
819 pParent
->clearGroups();
820 pParent
->setDynamicDisplaySize(false);
821 for (uint i
= 0; i
< rGuildMembers
.size(); i
++)
823 // create the member line
824 string templateId
= LIST_GUILD_MEMBERS
":m" + toString(i
);
825 vector
< pair
<string
, string
> > vParams
;
826 vParams
.push_back(vector
< pair
<string
, string
> >::value_type("id", templateId
));
827 CInterfaceGroup
*pLine
= NULL
;
828 pLine
= CWidgetManager::getInstance()->getParser()->createGroupInstance (TEMPLATE_GUILD_MEMBER
, LIST_GUILD_MEMBERS
, vParams
);
829 if (pLine
== NULL
) continue;
832 CViewText
*pViewName
= dynamic_cast<CViewText
*>(pLine
->getView(TEMPLATE_GUILD_MEMBER_NAME
));
833 if (pViewName
!= NULL
)
834 pViewName
->setText (rGuildMembers
[i
].Name
);
837 CViewText
*pViewGrade
= dynamic_cast<CViewText
*>(pLine
->getView(TEMPLATE_GUILD_MEMBER_GRADE
));
838 if (pViewGrade
!= NULL
)
840 if (rGuildMembers
[i
].Grade
== EGSPD::CGuildGrade::Leader
)
841 pViewGrade
->setText (CI18N::get("uiGuildLeader"));
842 else if (rGuildMembers
[i
].Grade
== EGSPD::CGuildGrade::HighOfficer
)
843 pViewGrade
->setText (CI18N::get("uiGuildHighOfficer"));
844 else if (rGuildMembers
[i
].Grade
== EGSPD::CGuildGrade::Officer
)
845 pViewGrade
->setText (CI18N::get("uiGuildOfficer"));
847 pViewGrade
->setText (CI18N::get("uiGuildMember"));
851 CViewBitmap
*onlineView
= dynamic_cast<CViewBitmap
*>(pLine
->getView("online"));
852 if (onlineView
!= NULL
)
854 CCtrlBase
*toolTip
= pLine
->getCtrl("tt_online");
856 switch(rGuildMembers
[i
].Online
)
859 onlineView
->setTexture("w_online.tga");
861 toolTip
->setDefaultContextHelp(CI18N::get("uittGuildMemberOnline"));
863 case ccs_online_abroad
:
864 onlineView
->setTexture("w_online_abroad.tga");
866 toolTip
->setDefaultContextHelp(CI18N::get("uittGuildMemberOnlineAbroad"));
869 onlineView
->setTexture("w_offline.tga");
871 toolTip
->setDefaultContextHelp(CI18N::get("uittGuildMemberOffline"));
876 CCtrlBase
*inviteButton
= pLine
->getCtrl("invite_button");
877 if (inviteButton
!= NULL
)
878 inviteButton
->setActive(rGuildMembers
[i
].Online
!= ccs_offline
&& rGuildMembers
[i
].Name
!= UserEntity
->getEntityName());
881 CViewText
*pViewEnterDate
= dynamic_cast<CViewText
*>(pLine
->getView(TEMPLATE_GUILD_MEMBER_ENTER_DATE
));
882 if (pViewEnterDate
!= NULL
)
885 rt
.updateRyzomClock(rGuildMembers
[i
].EnterDate
);
886 string str
= toString("%04d", rt
.getRyzomYear()) + " ";
887 str
+= CI18N::get("uiJenaYear") + " : ";
888 str
+= CI18N::get("uiAtysianCycle") + " ";
889 str
+= toString("%01d", rt
.getRyzomCycle()+1) +", ";
890 str
+= CI18N::get("ui"+MONTH::toString( (MONTH::EMonth
)rt
.getRyzomMonthInCurrentCycle() )) + ", ";
891 str
+= toString("%02d", rt
.getRyzomDayOfMonth()+1);
892 pViewEnterDate
->setText(str
);
896 pLine
->setParent (pParent
);
897 pParent
->addChild (pLine
);
902 REGISTER_ACTION_HANDLER (CAHGuildSheetOpen
, "guild_sheet_open");
904 // ***************************************************************************
905 static void setRights(bool lead
, bool hioff
, bool offi
, bool recr
, bool bear
, bool memb
, bool kick
)
907 CInterfaceManager
*pIM
= CInterfaceManager::getInstance();
909 pVTM
= dynamic_cast<CViewTextMenu
*>(CWidgetManager::getInstance()->getElementFromId(string(MENU_GUILD_MEMBER
":lead")));
910 if (pVTM
!= NULL
) pVTM
->setGrayed(!lead
);
911 pVTM
= dynamic_cast<CViewTextMenu
*>(CWidgetManager::getInstance()->getElementFromId(string(MENU_GUILD_MEMBER
":hiof")));
912 if (pVTM
!= NULL
) pVTM
->setGrayed(!hioff
);
913 pVTM
= dynamic_cast<CViewTextMenu
*>(CWidgetManager::getInstance()->getElementFromId(string(MENU_GUILD_MEMBER
":offi")));
914 if (pVTM
!= NULL
) pVTM
->setGrayed(!offi
);
915 pVTM
= dynamic_cast<CViewTextMenu
*>(CWidgetManager::getInstance()->getElementFromId(string(MENU_GUILD_MEMBER
":recr")));
916 if (pVTM
!= NULL
) pVTM
->setGrayed(!recr
);
917 pVTM
= dynamic_cast<CViewTextMenu
*>(CWidgetManager::getInstance()->getElementFromId(string(MENU_GUILD_MEMBER
":bear")));
918 if (pVTM
!= NULL
) pVTM
->setGrayed(!bear
);
919 pVTM
= dynamic_cast<CViewTextMenu
*>(CWidgetManager::getInstance()->getElementFromId(string(MENU_GUILD_MEMBER
":memb")));
920 if (pVTM
!= NULL
) pVTM
->setGrayed(!memb
);
921 pVTM
= dynamic_cast<CViewTextMenu
*>(CWidgetManager::getInstance()->getElementFromId(string(MENU_GUILD_MEMBER
":kick")));
922 if (pVTM
!= NULL
) pVTM
->setGrayed(!kick
);
925 // ***************************************************************************
926 class CAHGuildSheetMenuOpen
: public IActionHandler
928 virtual void execute (CCtrlBase
*pCaller
, const string
&/* Params */)
930 CInterfaceManager
*pIM
= CInterfaceManager::getInstance();
931 CGuildManager
*pGM
= CGuildManager::getInstance();
932 const vector
<SGuildMember
> &rGuildMembers
= pGM
->getGuildMembers();
934 // *** Check and retrieve the current member index (index in the member list)
935 CCtrlBase
*ctrlLaunchingModal
= CWidgetManager::getInstance()->getCtrlLaunchingModal();
936 if (pCaller
== NULL
|| ctrlLaunchingModal
== NULL
)
939 CWidgetManager::getInstance()->disableModalWindow();
942 string sId
= ctrlLaunchingModal
->getId();
943 sId
= sId
.substr(sId
.rfind('m')+1,sId
.size());
945 fromString(sId
, nLineNb
);
946 if ((nLineNb
< 0) || (nLineNb
>= (sint32
)rGuildMembers
.size()))
949 CWidgetManager::getInstance()->disableModalWindow();
952 MemberIndexSelected
= nLineNb
;
953 MemberNameSelected
= rGuildMembers
[nLineNb
].Name
;
955 // If the member is not yet received, do not allow any operation
956 if(MemberNameSelected
.empty())
959 CWidgetManager::getInstance()->disableModalWindow();
963 // *** Check with the grade of the local player which types of actions we can do on the player selected
965 // enable or disable menu entries
968 // no action allowed on proxy guild
969 setRights(false, false, false, false, false, false, false);
973 // Depending on the grade we can do things or other
975 // Grade less or equal can't do anything
976 if (pGM
->getGrade() >= rGuildMembers
[nLineNb
].Grade
)
977 setRights(false, false, false, false, false, false, false);
978 else if (pGM
->getGrade() == EGSPD::CGuildGrade::Leader
)
979 setRights(true, true, true, true, true, true, true);
980 else if (pGM
->getGrade() == EGSPD::CGuildGrade::HighOfficer
)
981 setRights(false, false, true, true, true, true, true);
982 else if (pGM
->getGrade() == EGSPD::CGuildGrade::Officer
)
983 setRights(false, false, false, false, true, true, true);
985 setRights(false, false, false, false, false, false, false);
991 static sint32 MemberIndexSelected
; // Index of the member selected when right clicked
992 static std::string MemberNameSelected
; // Name of the member selected when right clicked (for extra check)
994 REGISTER_ACTION_HANDLER (CAHGuildSheetMenuOpen
, "guild_member_menu_open");
996 sint32
CAHGuildSheetMenuOpen::MemberIndexSelected
= -1;
997 std::string
CAHGuildSheetMenuOpen::MemberNameSelected
;
1000 // ***************************************************************************
1001 // Use the control launching modal to know the text to send to the server
1002 static void sendMsgSetGrade(EGSPD::CGuildGrade::TGuildGrade Grade
)
1004 const string
&message
= "GUILD:SET_GRADE";
1005 CInterfaceManager
*pIM
= CInterfaceManager::getInstance();
1006 CGuildManager
*pGM
= CGuildManager::getInstance();
1007 const vector
<SGuildMember
> &rGuildMembers
= pGM
->getGuildMembers();
1009 // check the member selected is still valid
1010 sint32 MemberNb
= CAHGuildSheetMenuOpen::MemberIndexSelected
;
1011 if ((MemberNb
< 0) || (MemberNb
>= (sint32
)rGuildMembers
.size())) return;
1012 // double check the name (in case of some change in the guild members list)
1013 if(rGuildMembers
[MemberNb
].Name
!= CAHGuildSheetMenuOpen::MemberNameSelected
)
1016 // Ok! let's send the message!
1018 if(GenericMsgHeaderMngr
.pushNameToStream(message
, out
))
1020 uint16 u16MemberNb
= (uint16
)rGuildMembers
[MemberNb
].Index
;
1021 out
.serial(u16MemberNb
);
1022 uint8 u8Grade
= Grade
;
1023 out
.serial(u8Grade
);
1024 uint8 u8Counter
= (uint8
)NLGUI::CDBManager::getInstance()->getDbProp("SERVER:GUILD:COUNTER")->getValue8();
1025 out
.serial(u8Counter
);
1027 //nlinfo("impulseCallBack : %s %d %d %d sent", message.c_str(), u16MemberNb, u8Grade, u8Counter);
1031 nlwarning("<CHandlerAcceptExchange::execute> unknown message name '%s'", message
.c_str());
1035 // ***************************************************************************
1036 // Sort the guild member list
1037 class CAHGuildSheetSortGuildList
: public IActionHandler
1040 void execute (CCtrlBase
* /* pCaller */, const std::string
&/* sParams */)
1042 CInterfaceManager
* pIM
= CInterfaceManager::getInstance();
1043 CGuildManager::TSortOrder order
= (CGuildManager::TSortOrder
)(NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:GUILD_LIST:SORT_ORDER")->getValue32());
1045 order
= (CGuildManager::TSortOrder
)(order
+ 1);
1046 if (order
== CGuildManager::END_SORT_ORDER
)
1048 order
= CGuildManager::START_SORT_ORDER
;
1051 NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:GUILD_LIST:SORT_ORDER")->setValue32((sint32
)order
);
1052 CAHManager::getInstance()->runActionHandler("guild_sheet_open", NULL
, toString("update_members=1"));
1055 REGISTER_ACTION_HANDLER(CAHGuildSheetSortGuildList
, "sort_guild_list");
1057 // ***************************************************************************
1058 // Invoke the 'tell' command on a contact from its menu
1059 // The tell command is displayed in the 'around me' window
1060 class CAHGuildSheetTellMember
: public IActionHandler
1063 void execute (CCtrlBase
* pCaller
, const std::string
&/* sParams */)
1065 CInterfaceManager
*pIM
= CInterfaceManager::getInstance();
1066 CGuildManager
*pGM
= CGuildManager::getInstance();
1067 const vector
<SGuildMember
> &rGuildMembers
= pGM
->getGuildMembers();
1068 // *** Check and retrieve the current member index (index in the member list)
1069 CCtrlBase
*ctrlLaunchingModal
= CWidgetManager::getInstance()->getCtrlLaunchingModal();
1070 if (pCaller
== NULL
)
1075 string sId
= pCaller
->getId();
1076 sId
= sId
.substr(sId
.rfind('m')+1,sId
.size());
1078 fromString(sId
, nLineNb
);
1079 if ((nLineNb
< 0) || (nLineNb
>= (sint32
)rGuildMembers
.size()))
1084 MemberIndexSelected
= nLineNb
;
1085 MemberNameSelected
= rGuildMembers
[nLineNb
].Name
;
1087 CPeopleInterraction::displayTellInMainChat(MemberNameSelected
);
1090 // Current selection
1091 static sint32 MemberIndexSelected
; // Index of the member selected when left clicked
1092 static std::string MemberNameSelected
; // Name of the member selected when lef clicked
1094 REGISTER_ACTION_HANDLER(CAHGuildSheetTellMember
, "guild_tell_member");
1096 sint32
CAHGuildSheetTellMember::MemberIndexSelected
= -1;
1097 string
CAHGuildSheetTellMember::MemberNameSelected
;
1099 // ***************************************************************************
1100 class CAHGuildSheetSetLeader
: public IActionHandler
1102 virtual void execute (CCtrlBase
* /* pCaller */, const string
&/* Params */)
1104 CInterfaceManager
*pIM
= CInterfaceManager::getInstance();
1106 // Ask if they are sure
1107 pIM
->validMessageBox(CInterfaceManager::QuestionIconMsg
, CI18N::get("uiQSetLeader"), "guild_member_do_change_leader");
1110 REGISTER_ACTION_HANDLER (CAHGuildSheetSetLeader
, "guild_member_chg_to_leader");
1112 // ***************************************************************************
1113 class CAHGuildSheetSetLeaderConfirm
: public IActionHandler
1115 virtual void execute (CCtrlBase
* /* pCaller */, const string
&/* Params */)
1117 // Leadership change confirmed
1118 sendMsgSetGrade(EGSPD::CGuildGrade::Leader
);
1121 REGISTER_ACTION_HANDLER (CAHGuildSheetSetLeaderConfirm
, "guild_member_do_change_leader");
1125 // ***************************************************************************
1126 class CAHGuildSheetSetHighOfficer
: public IActionHandler
1128 virtual void execute (CCtrlBase
* /* pCaller */, const string
&/* Params */)
1130 sendMsgSetGrade(EGSPD::CGuildGrade::HighOfficer
);
1133 REGISTER_ACTION_HANDLER (CAHGuildSheetSetHighOfficer
, "guild_member_chg_to_high_officer");
1135 // ***************************************************************************
1136 class CAHGuildSheetSetOfficer
: public IActionHandler
1138 virtual void execute (CCtrlBase
* /* pCaller */, const string
&/* Params */)
1140 sendMsgSetGrade(EGSPD::CGuildGrade::Officer
);
1143 REGISTER_ACTION_HANDLER (CAHGuildSheetSetOfficer
, "guild_member_chg_to_officer");
1145 // ***************************************************************************
1146 class CAHGuildSheetSetRecruiter
: public IActionHandler
1148 virtual void execute (CCtrlBase
* /* pCaller */, const string
&/* Params */)
1150 //sendMsgSetGrade(EGSPD::CGuildGrade::Recruiter);
1153 REGISTER_ACTION_HANDLER (CAHGuildSheetSetRecruiter
, "guild_member_chg_to_recruiter");
1155 // ***************************************************************************
1156 class CAHGuildSheetSetBearer
: public IActionHandler
1158 virtual void execute (CCtrlBase
* /* pCaller */, const string
&/* Params */)
1160 //sendMsgSetGrade(EGSPD::CGuildGrade::Bearer);
1163 REGISTER_ACTION_HANDLER (CAHGuildSheetSetBearer
, "guild_member_chg_to_bearer");
1165 // ***************************************************************************
1166 class CAHGuildSheetSetMember
: public IActionHandler
1168 virtual void execute (CCtrlBase
* /* pCaller */, const string
&/* Params */)
1170 sendMsgSetGrade(EGSPD::CGuildGrade::Member
);
1173 REGISTER_ACTION_HANDLER (CAHGuildSheetSetMember
, "guild_member_chg_to_member");
1175 // ***************************************************************************
1176 class CAHGuildSheetKick
: public IActionHandler
1178 virtual void execute (CCtrlBase
* /* pCaller */, const string
&/* Params */)
1180 const string
&message
= "GUILD:KICK_MEMBER";
1181 CInterfaceManager
*pIM
= CInterfaceManager::getInstance();
1182 CGuildManager
*pGM
= CGuildManager::getInstance();
1183 const vector
<SGuildMember
> &rGuildMembers
= pGM
->getGuildMembers();
1185 // check the member selected is still valid
1186 sint32 MemberNb
= CAHGuildSheetMenuOpen::MemberIndexSelected
;
1187 if ((MemberNb
< 0) || (MemberNb
>= (sint32
)rGuildMembers
.size())) return;
1188 // double check the name (in case of some change in the guild members list)
1189 if(rGuildMembers
[MemberNb
].Name
!= CAHGuildSheetMenuOpen::MemberNameSelected
)
1192 // Ok! let's send the message!
1194 if(GenericMsgHeaderMngr
.pushNameToStream(message
, out
))
1196 uint16 u16MemberNb
= (uint16
)rGuildMembers
[MemberNb
].Index
;
1197 out
.serial(u16MemberNb
);
1198 uint8 u8Counter
= (uint8
)NLGUI::CDBManager::getInstance()->getDbProp("SERVER:GUILD:COUNTER")->getValue8();
1199 out
.serial(u8Counter
);
1201 //nlinfo("impulseCallBack : %s %d %d sent", message.c_str(), u16MemberNb, u8Counter);
1205 nlwarning("<CHandlerAcceptExchange::execute> unknown message name '%s'", message
.c_str());
1209 REGISTER_ACTION_HANDLER (CAHGuildSheetKick
, "guild_member_kick");
1211 // ***************************************************************************
1212 class CHandlerAscensorTeleport
: public IActionHandler
1214 virtual void execute (CCtrlBase
*pCaller
, const string
&/* Params */)
1216 CDBCtrlSheet
*ctrlSheet
= dynamic_cast<CDBCtrlSheet
*>(pCaller
);
1217 if (!ctrlSheet
) return;
1219 uint16 nTeleportLocation
= ctrlSheet
->getIndexInParent();
1221 const string msgName
= "GUILD:TELEPORT";
1223 if(GenericMsgHeaderMngr
.pushNameToStream(msgName
, out
))
1225 out
.serial( nTeleportLocation
);
1228 // Last teleport is an elevator
1229 LoadingBackground
= ElevatorBackground
;
1231 //nlinfo("impulseCallBack : GUILD:TELEPORT %d sent", nTeleportLocation);
1234 REGISTER_ACTION_HANDLER (CHandlerAscensorTeleport
, "ascensor_teleport");
1237 // ***************************************************************************
1238 class CHandlerInvGuildToBag : public IActionHandler
1240 virtual void execute (CCtrlBase *pCaller, const string &Params)
1242 CInterfaceManager *pIM = CInterfaceManager::getInstance();
1243 CDBCtrlSheet *pCSDst = dynamic_cast<CDBCtrlSheet*>(pCaller);
1244 if (!pCSDst->isSheetValid()) return;
1245 string sTmp = pCSDst->getSheet();
1247 CCDBNodeLeaf *pNL = NLGUI::CDBManager::getInstance()->getDbProp(sTmp+":SHEET",false);
1248 CCDBNodeLeaf *pNLquantity = NLGUI::CDBManager::getInstance()->getDbProp(sTmp+":QUANTITY",false);
1249 if (pNL == NULL) return;
1250 if (pNLquantity == NULL) return;
1252 sTmp = sTmp.substr(sTmp.rfind(':')+1, sTmp.size());
1254 fromString(sTmp, GuildIndex);
1256 CInventoryManager *pInv = CInventoryManager::getInstance();
1257 uint32 quantity = pNLquantity->getValue32();
1258 double totalBulk = quantity * pInv->getItemBulk(pNL->getValue32());
1260 // Only check with the bag for the moment
1262 bool bPlaceFound = false;
1263 if (pInv->isInventoryAvailable(INVENTORIES::bag))
1264 if ((pInv->getBagBulk(0) + totalBulk) <= pInv->getMaxBagBulk(0))
1269 string msg = CI18N::get("msgCantPutItemInBag");
1270 string cat = getStringCategory(msg, msg);
1271 pIM->displaySystemInfo(msg, cat);
1274 // Look for a free entry in the bag
1275 bPlaceFound = false;
1277 for (uint32 i = 0; i < MAX_BAGINV_ENTRIES; ++i)
1279 if (getInventory().getBagItem(i).getSheetID() == 0)
1281 BagIndex = (uint8)i;
1287 if (!bPlaceFound) return;
1289 uint16 Session = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:GUILD:INVENTORY:SESSION")->getValue16();
1292 const string sMsg = "GUILD:GUILD_TO_BAG";
1293 if (!GenericMsgHeaderMngr.pushNameToStream(sMsg, out))
1295 nlwarning ("don't know message name %s", sMsg.c_str());
1299 // Fill the message (temporary inventory slot)
1300 out.serial(GuildIndex);
1301 out.serial(Session);
1303 nlinfo("impulseCallBack : %s %d %d sent", sMsg.c_str(), GuildIndex, Session);
1307 REGISTER_ACTION_HANDLER (CHandlerInvGuildToBag, "inv_guild_to_bag");
1311 // ***************************************************************************
1312 class CHandlerInvBagToGuild : public IActionHandler
1314 virtual void execute (CCtrlBase *pCaller, const string &Params)
1316 CInterfaceManager *pIM = CInterfaceManager::getInstance();
1318 CDBCtrlSheet *pCS = dynamic_cast<CDBCtrlSheet*>(pCaller);
1319 string sTmp = pCS->getSheet();
1320 sTmp = sTmp.substr(sTmp.rfind(':')+1, sTmp.size());
1322 fromString(sTmp, BagIndex);
1324 uint16 Session = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:GUILD:INVENTORY:SESSION")->getValue16();
1327 const string sMsg = "GUILD:BAG_TO_GUILD";
1328 if (!GenericMsgHeaderMngr.pushNameToStream(sMsg, out))
1330 nlwarning ("don't know message name %s", sMsg.c_str());
1334 // Fill the message (temporary inventory slot)
1335 out.serial(BagIndex);
1336 out.serial(Session);
1338 nlinfo("impulseCallBack : %s %d %d sent", sMsg.c_str(), BagIndex, Session);
1342 REGISTER_ACTION_HANDLER (CHandlerInvBagToGuild, "inv_bag_to_guild");
1345 // ***************************************************************************
1346 static void sendMoneyServerMessage(const string
&sMsg
)
1348 CInterfaceManager
*pIM
= CInterfaceManager::getInstance();
1349 uint64 nMoney
= NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:CHOOSE_MONEY")->getValue64();
1350 uint16 Session
= NLGUI::CDBManager::getInstance()->getDbProp("SERVER:GUILD:INVENTORY:SESSION")->getValue16();
1352 if (!GenericMsgHeaderMngr
.pushNameToStream(sMsg
, out
))
1354 nlwarning ("don't know message name %s", sMsg
.c_str());
1358 // Fill the message (temporary inventory slot)
1360 out
.serial(Session
);
1362 //nlinfo("impulseCallBack : %s %d %d sent", sMsg.c_str(), nMoney, Session);
1366 // ***************************************************************************
1367 class CHandlerGuildInvGetMoney
: public IActionHandler
1369 virtual void execute (CCtrlBase
* /* pCaller */, const string
&/* Params */)
1371 sendMoneyServerMessage("GUILD:TAKE_MONEY");
1372 CWidgetManager::getInstance()->popModalWindow();
1375 REGISTER_ACTION_HANDLER (CHandlerGuildInvGetMoney
, "guild_inv_get_money");
1378 // ***************************************************************************
1379 class CHandlerGuildInvPutMoney
: public IActionHandler
1381 virtual void execute (CCtrlBase
* /* pCaller */, const string
&/* Params */)
1383 sendMoneyServerMessage("GUILD:PUT_MONEY");
1384 CWidgetManager::getInstance()->popModalWindow();
1387 REGISTER_ACTION_HANDLER (CHandlerGuildInvPutMoney
, "guild_inv_put_money");