Add infos into target window
[ryzomcore.git] / ryzom / client / src / outpost_manager.cpp
blobe0f72dec23b6ecee262c02eefd4c10d68c680dc1
1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2010-2019 Winch Gate Property Limited
3 //
4 // This source file has been modified by the following contributors:
5 // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) <dfighter1985@gmail.com>
6 //
7 // This program is free software: you can redistribute it and/or modify
8 // it under the terms of the GNU Affero General Public License as
9 // published by the Free Software Foundation, either version 3 of the
10 // License, or (at your option) any later version.
12 // This program is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU Affero General Public License for more details.
17 // You should have received a copy of the GNU Affero General Public License
18 // along with this program. If not, see <http://www.gnu.org/licenses/>.
21 #include "stdpch.h"
23 #include "outpost_manager.h"
24 #include "net_manager.h"
25 #include "interface_v3/interface_manager.h"
26 #include "nel/gui/group_container.h"
27 #include "nel/misc/bit_mem_stream.h"
28 #include "game_share/generic_xml_msg_mngr.h"
30 COutpostManager OutpostManager;
32 using namespace NLMISC;
35 // ***************************************************************************
36 COutpostManager::COutpostManager()
38 _EndTickForPvpJoinProposal= 0;
42 // ***************************************************************************
43 void COutpostManager::startPvpJoinProposal(OUTPOSTENUMS::TPVPType type, bool outpostInFire, bool playerGuildInConflict, bool playerGuildIsAttacker,
44 uint32 ownerGuildNameId, uint32 attackerGuildNameId, uint32 declTimer)
46 // reset counter that force player to be neutral (eg: 10 seconds)
47 _EndTickForPvpJoinProposal= NetMngr.getCurrentServerTick() + declTimer;
49 // setup TEMP DB
50 CInterfaceManager *pIM= CInterfaceManager::getInstance();
52 CCDBNodeLeaf *node= NLGUI::CDBManager::getInstance()->getDbProp("UI:TEMP:OUTPOST:PVP_PROPOSAL_PLAYER_GUILD_IN_CONFLICT");
53 if(node) node->setValueBool(playerGuildInConflict);
54 node= NLGUI::CDBManager::getInstance()->getDbProp("UI:TEMP:OUTPOST:PVP_PROPOSAL_PLAYER_GUILD_IS_ATTACKER");
55 if(node) node->setValueBool(playerGuildIsAttacker);
56 node= NLGUI::CDBManager::getInstance()->getDbProp("UI:TEMP:OUTPOST:PVP_PROPOSAL_ATTACKER");
57 if(node) node->setValue32(attackerGuildNameId);
58 node= NLGUI::CDBManager::getInstance()->getDbProp("UI:TEMP:OUTPOST:PVP_PROPOSAL_DEFENDER");
59 if(node) node->setValue32(ownerGuildNameId);
60 node= NLGUI::CDBManager::getInstance()->getDbProp("UI:TEMP:OUTPOST:PVP_PROPOSAL_TICK_END");
61 if(node) node->setValue32(_EndTickForPvpJoinProposal);
63 // open Popup
65 // Useless feature
66 CCtrlBase *ctrl = dynamic_cast<CCtrlBase *>(CWidgetManager::getInstance()->getElementFromId("ui:interface:join_pvp_outpost_proposal:content:random"));
67 if (ctrl)
68 ctrl->setActive(false);
70 ctrl = dynamic_cast<CCtrlBase *>(CWidgetManager::getInstance()->getElementFromId("ui:interface:join_pvp_outpost_proposal:content:neutral"));
71 if (ctrl)
72 ctrl->setActive(true);
74 // GvE: only attacker guild can have the option
75 ctrl = dynamic_cast<CCtrlBase *>(CWidgetManager::getInstance()->getElementFromId("ui:interface:join_pvp_outpost_proposal:content:attack"));
76 if (ctrl && (type == OUTPOSTENUMS::GVE || type == OUTPOSTENUMS::PVE || type == OUTPOSTENUMS::GVG))
77 ctrl->setActive(playerGuildIsAttacker);
79 // GvE : No defend option
80 ctrl = dynamic_cast<CCtrlBase *>(CWidgetManager::getInstance()->getElementFromId("ui:interface:join_pvp_outpost_proposal:content:defend"));
81 if (ctrl && (type == OUTPOSTENUMS::GVE || type == OUTPOSTENUMS::PVE))
82 ctrl->setActive(false);
83 if (ctrl && (type == OUTPOSTENUMS::GVG))
84 ctrl->setActive(playerGuildInConflict && !playerGuildIsAttacker);
87 CGroupContainer *pGC = dynamic_cast<CGroupContainer*>(CWidgetManager::getInstance()->getElementFromId("ui:interface:join_pvp_outpost_proposal"));
88 if (pGC)
90 pGC->setActive(true);
91 CWidgetManager::getInstance()->setTopWindow(pGC);
92 pGC->updateCoords();
93 pGC->updateCoords();
94 pGC->center();
95 pGC->enableBlink(2);
100 // ***************************************************************************
101 void COutpostManager::endPvpJoinProposal(bool bNeutral, OUTPOSTENUMS::TPVPSide pvpSide)
103 // send msg
104 string sMsg= "OUTPOST:SIDE_CHOSEN";
105 CBitMemStream out;
106 if(GenericMsgHeaderMngr.pushNameToStream(sMsg, out))
108 //nlinfo("impulseCallBack : %s %d %s sent", sMsg.c_str(), bNeutral, OUTPOSTENUMS::toString(pvpSide).c_str());
109 out.serial(bNeutral);
110 uint8 sideAsInt = (uint8)pvpSide;
111 out.serial(sideAsInt);
112 NetMngr.push(out);
114 else
116 nlwarning("command : unknown message name : '%s'.", sMsg.c_str());
119 // Abort any timer
120 _EndTickForPvpJoinProposal= 0;
123 // ***************************************************************************
124 void COutpostManager::update()
126 // *** If there is a join proposal running
127 if(_EndTickForPvpJoinProposal!=0)
129 if(_EndTickForPvpJoinProposal<NetMngr.getCurrentServerTick())
131 CInterfaceManager *pIM= CInterfaceManager::getInstance();
133 // Force the neutral choose
134 CAHManager::getInstance()->runActionHandler("outpost_pvp_join", NULL, "neutral");
136 // close the window
137 CGroupContainer *pGC = dynamic_cast<CGroupContainer*>(CWidgetManager::getInstance()->getElementFromId("ui:interface:join_pvp_outpost_proposal"));
138 if (pGC)
139 pGC->setActive(false);
141 // stop timer
142 _EndTickForPvpJoinProposal= 0;