1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2010-2015 Winch Gate Property Limited
4 // This source file has been modified by the following contributors:
5 // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) <dfighter1985@gmail.com>
6 // Copyright (C) 2013-2020 Jan BOON (Kaetemi) <jan.boon@kaetemi.be>
8 // This program is free software: you can redistribute it and/or modify
9 // it under the terms of the GNU Affero General Public License as
10 // published by the Free Software Foundation, either version 3 of the
11 // License, or (at your option) any later version.
13 // This program is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 // GNU Affero General Public License for more details.
18 // You should have received a copy of the GNU Affero General Public License
19 // along with this program. If not, see <http://www.gnu.org/licenses/>.
22 #include "action_handler_misc.h"
23 #include "interface_manager.h"
24 #include "nel/gui/ctrl_button.h"
25 #include "nel/gui/group_container.h"
26 #include "nel/gui/group_editbox.h"
27 #include "people_interraction.h"
28 #include "nel/misc/algo.h"
29 #include "nel/gui/interface_expr.h"
30 #include "nel/gui/interface_link.h"
31 #include "../client_chat_manager.h"
32 #include "../motion/user_controls.h"
33 #include "../entity_cl.h"
34 #include "../client_cfg.h"
35 #include "../fog_map.h"
36 #include "../sky_render.h"
37 #include "../continent_manager.h"
38 #include "../main_loop.h"
42 using namespace NLMISC
;
49 extern CClientChatManager ChatMngr
;
50 extern UScene
*SceneRoot
;
51 extern UScene
*SkyScene
;
53 extern CFogState MainFogState
;
54 extern CFogState RootFogState
;
55 extern CLightCycleManager LightCycleManager
;
56 extern UCamera MainCam
;
57 extern CContinentManager ContinentMngr
;
58 extern NLMISC::CLog g_log
;
63 //static CCDBNodeLeaf *MenuColorWidgetValue = NULL; // db entry for the color menu widget (Red)
66 static const string
ScreenshotsDirectory("screenshots/"); // don't forget the final /
68 void preRenderNewSky ();
70 // ***************************************************************************
71 class CAHCommand
: public IActionHandler
75 virtual void execute (CCtrlBase
* /* pCaller */, const string
&Params
)
77 ICommand::execute(Params
, g_log
);
80 REGISTER_ACTION_HANDLER (CAHCommand
, "command");
82 // ***************************************************************************
83 // ***************************************************************************
84 // class CActionHandlerShowOne
85 // ***************************************************************************
86 // ***************************************************************************
89 // ***************************************************************************
90 REGISTER_ACTION_HANDLER (CActionHandlerShowOne
, "show_one");
92 // ***************************************************************************
93 void CActionHandlerShowOne::execute (CCtrlBase
* /* pCaller */, const std::string
¶ms
)
95 CInterfaceManager
*mngr
= CInterfaceManager::getInstance();
96 string wndListValue
= getParam(params
, "list");
97 string wndShow
= getParam(params
, "show");
100 vector
<string
> wndList
;
101 splitString(wndListValue
, ",", wndList
);
103 // hide all window from the list.
104 for(uint i
=0;i
<wndList
.size();i
++)
106 CInterfaceElement
*wnd
= CWidgetManager::getInstance()->getElementFromId(wndList
[i
]);
108 wnd
->setActive(false);
111 // show the one needed
112 CInterfaceElement
*wnd
= CWidgetManager::getInstance()->getElementFromId(wndShow
);
114 wnd
->setActive(true);
118 // ***************************************************************************
119 REGISTER_ACTION_HANDLER (CActionHandlerActive
, "set_active");
120 // ***************************************************************************
121 void CActionHandlerActive::execute (CCtrlBase
* /* pCaller */, const std::string
¶ms
)
123 std::string active
= getParam(params
, "active");
124 std::string target
= getParam(params
, "target");
125 CInterfaceExprValue activeValue
;
126 if (CInterfaceExpr::eval(active
, activeValue
, NULL
))
128 if (!activeValue
.toBool())
130 nlwarning("<CActionHandlerActive::execute> The 'active' param must be convertible to a boolean");
133 CInterfaceManager
*mngr
= CInterfaceManager::getInstance();
134 CInterfaceElement
*wnd
= CWidgetManager::getInstance()->getElementFromId(target
);
137 nlwarning("<CActionHandlerActive::execute> Can't get window %s", target
.c_str());
140 wnd
->setActive(activeValue
.getBool());
144 nlwarning("<CActionHandlerActive::execute> can't parse the 'active' param");
149 // ***************************************************************************
150 REGISTER_ACTION_HANDLER (CActionHandlerSetOpen
, "set_open");
151 // ***************************************************************************
152 void CActionHandlerSetOpen::execute (CCtrlBase
* /* pCaller */, const std::string
¶ms
)
154 std::string open
= getParam(params
, "open");
155 std::string target
= getParam(params
, "target");
156 CInterfaceExprValue activeValue
;
157 if (CInterfaceExpr::eval(open
, activeValue
, NULL
))
159 if (!activeValue
.toBool())
161 nlwarning("<CActionHandlerActive::execute> The 'active' param must be co,vertible to a boolean");
164 CInterfaceManager
*mngr
= CInterfaceManager::getInstance();
165 CGroupContainer
*wnd
= dynamic_cast<CGroupContainer
*>(CWidgetManager::getInstance()->getElementFromId(target
));
168 nlwarning("<CActionHandlerActive::execute> Can't get window %s", target
.c_str());
171 wnd
->setOpen(activeValue
.getBool());
175 nlwarning("<CActionHandlerActive::execute> can't parse the 'active' param");
180 // ***************************************************************************
181 // ***************************************************************************
182 // CActionHandlerHideClose
183 // ***************************************************************************
184 // ***************************************************************************
186 // ***************************************************************************
187 REGISTER_ACTION_HANDLER (CActionHandlerHideClose
, "hide_close");
189 // ***************************************************************************
190 void CActionHandlerHideClose::execute (CCtrlBase
* /* pCaller */, const std::string
¶ms
)
192 CInterfaceManager
*mngr
= CInterfaceManager::getInstance();
193 string hideValue
= getParam(params
, "hide");
194 string closeValue
= getParam(params
, "close");
197 vector
<string
> hideList
;
198 splitString(hideValue
, ",", hideList
);
199 vector
<string
> closeList
;
200 splitString(closeValue
, ",", closeList
);
202 // hide all window from the hide list.
204 for(i
=0;i
<hideList
.size();i
++)
206 CInterfaceElement
*wnd
= CWidgetManager::getInstance()->getElementFromId(hideList
[i
]);
208 wnd
->setActive(false);
211 // close all containers from the hide list.
212 for(i
=0;i
<closeList
.size();i
++)
214 // get a container if possible
215 CInterfaceElement
*wnd
= CWidgetManager::getInstance()->getElementFromId(closeList
[i
]);
216 CGroupContainer
*pIC
= dynamic_cast<CGroupContainer
*>(wnd
);
224 // ***************************************************************************
225 // ***************************************************************************
227 // ***************************************************************************
228 // ***************************************************************************
231 // ***************************************************************************
232 REGISTER_ACTION_HANDLER (CActionHandlerEnterModal
, "enter_modal");
233 REGISTER_ACTION_HANDLER (CActionHandlerPushModal
, "push_modal");
234 REGISTER_ACTION_HANDLER (CActionHandlerLeaveModal
, "leave_modal");
236 // ***************************************************************************
237 void CActionHandlerEnterModal::execute(CCtrlBase
*pCaller
, const std::string
¶ms
)
239 CInterfaceManager
*pIM
= CInterfaceManager::getInstance();
241 // get the group from param
242 string groupName
= getParam(params
, "group");
243 CInterfaceGroup
*group
= dynamic_cast<CInterfaceGroup
*>( CWidgetManager::getInstance()->getElementFromId(groupName
) );
246 UserControls
.stopFreeLook();
249 CWidgetManager::getInstance()->enableModalWindow(pCaller
, group
);
253 nlwarning("<CActionHandlerEnterModal::execute> Couldn't find group %s", groupName
.c_str());
257 // ***************************************************************************
258 void CActionHandlerPushModal::execute(CCtrlBase
*pCaller
, const std::string
¶ms
)
260 CInterfaceManager
*mngr
= CInterfaceManager::getInstance();
262 // get the group from param
263 string groupName
= getParam(params
, "group");
264 CInterfaceGroup
*group
= dynamic_cast<CInterfaceGroup
*>( CWidgetManager::getInstance()->getElementFromId(groupName
) );
268 CWidgetManager::getInstance()->pushModalWindow(pCaller
, group
);
272 nlwarning("<CActionHandlerPushModal::execute> Couldn't find group %s", groupName
.c_str());
277 // ***************************************************************************
278 void CActionHandlerLeaveModal::execute(CCtrlBase
* /* pCaller */, const std::string
&/* params */)
280 CInterfaceManager
*mngr
= CInterfaceManager::getInstance();
283 CWidgetManager::getInstance()->popModalWindow();
287 // ***************************************************************************
289 // ***************************************************************************
290 class CActionHandlerProc
: public IActionHandler
293 virtual void execute (CCtrlBase
*pCaller
, const std::string
¶ms
)
295 // split the parameters
296 vector
<string
> paramList
;
297 splitString(params
, "|", paramList
);
298 if(paramList
.empty())
301 // execute the procedure
302 CWidgetManager::getInstance()->runProcedure(paramList
[0], pCaller
, paramList
);
305 REGISTER_ACTION_HANDLER (CActionHandlerProc
, "proc");
308 /** Confirm that a group container can be deactivated
310 class CActionHandlerConfirmCanDeactivate
: public IActionHandler
313 virtual void execute (CCtrlBase
* /* pCaller */, const std::string
&/* params */)
315 CGroupContainer::validateCanDeactivate(true);
318 REGISTER_ACTION_HANDLER (CActionHandlerConfirmCanDeactivate
, "confirm_can_deactivate");
320 /** Cancel a group container deactivation
322 class CActionHandlerCancelCanDeactivate
: public IActionHandler
325 virtual void execute (CCtrlBase
* /* pCaller */, const std::string
&/* params */)
327 CGroupContainer::validateCanDeactivate(false);
330 REGISTER_ACTION_HANDLER (CActionHandlerCancelCanDeactivate
, "cancel_can_deactivate");
336 // ***************************************************************************
337 // ***************************************************************************
339 // ***************************************************************************
340 // ***************************************************************************
343 // ***************************************************************************
344 class CActionHandlerEditBoxNumber
: public IActionHandler
347 virtual void execute (CCtrlBase
*pCaller
, const std::string
¶ms
)
349 CGroupEditBox
*pEditBox
= dynamic_cast<CGroupEditBox
*>(pCaller
);
355 // get the dblink dest
356 string dblink
= getParam(params
, "value");
361 sint64 val
= pEditBox
->getInputStringAsInt64();
364 // see if a max value has been set
365 valueStr
= getParam(params
, "max_value");
366 if (!valueStr
.empty())
368 CInterfaceExprValue maxValue
;
369 if (!CInterfaceExpr::eval(valueStr
, maxValue
) || !maxValue
.toInteger())
371 nlwarning("<CActionHandlerEditBoxNumber::execute> Can't eval maxValue, or can't convert to integer : %s", valueStr
.c_str());
374 val
= std::min(maxValue
.getInteger(), val
);
376 // see if a min value has been set
377 valueStr
= getParam(params
, "min_value");
378 if (!valueStr
.empty())
380 CInterfaceExprValue minValue
;
381 if (!CInterfaceExpr::eval(valueStr
, minValue
) || !minValue
.toInteger())
383 nlwarning("<CActionHandlerEditBoxNumber::execute> Can't eval minValue, or can't convert to integer : %s", valueStr
.c_str());
386 val
= std::max(minValue
.getInteger(), val
);
388 // set in the database
389 CInterfaceProperty prop
;
390 prop
.link(dblink
.c_str());
392 string updateText
= getParam(params
, "update_text");
393 bool mustUpdate
= updateText
.empty() ? true : CInterfaceElement::convertBool(updateText
.c_str());
397 // replace the editbox string
398 pEditBox
->setInputStringAsInt64(val
);
399 pEditBox
->setSelectionAll();
403 REGISTER_ACTION_HANDLER (CActionHandlerEditBoxNumber
, "editbox_number");
405 // ***************************************************************************
406 // Dynamic creation of interface links
407 // ***************************************************************************
408 /** Add a link to an interface element
410 class CActionHandlerAddLink
: public IActionHandler
412 virtual void execute (CCtrlBase
*pCaller
, const std::string
¶ms
)
414 std::string expr
= getParam(params
, "expr");
415 std::string targets
= getParam(params
, "target");
416 std::string id
= getParam(params
, "id");
417 std::string ah
= getParam(params
, "action");
418 std::string ahparam
= getParam(params
, "params");
419 std::string ahcond
= getParam(params
, "cond");
422 nlwarning("<CActionHandlerAddLink> Must specify a link's id");
425 CInterfaceGroup
*parentGroup
= dynamic_cast<CInterfaceGroup
*>(pCaller
);
428 if (pCaller
) parentGroup
= pCaller
->getParent();
431 std::vector
<CInterfaceLink::CTargetInfo
> targetsVect
;
432 std::vector
<CInterfaceLink::CCDBTargetInfo
> cdbTargetsVect
;
433 bool result
= CInterfaceLink::splitLinkTargetsExt(targets
, parentGroup
, targetsVect
, cdbTargetsVect
);
436 nlwarning("<CActionHandlerAddLink> Couldn't parse all links");
439 CInterfaceLink
*il
= new CInterfaceLink
;
440 il
->init(targetsVect
, cdbTargetsVect
, expr
, ah
, ahparam
, ahcond
, parentGroup
);
441 CInterfaceManager
*im
= CInterfaceManager::getInstance();
442 CWidgetManager::getInstance()->getParser()->addLink(il
, id
);
446 REGISTER_ACTION_HANDLER (CActionHandlerAddLink
, "add_link");
448 /** Remove a link from an interface element
450 class CActionHandlerRemoveLink
: public IActionHandler
452 virtual void execute (CCtrlBase
* /* pCaller */, const std::string
¶ms
)
454 std::string id
= getParam(params
, "id");
457 nlwarning("<CActionHandlerRemoveLink> Must specify a link's id");
460 CInterfaceManager
*im
= CInterfaceManager::getInstance();
461 CWidgetManager::getInstance()->getParser()->removeLink(id
);
464 REGISTER_ACTION_HANDLER (CActionHandlerRemoveLink
, "remove_link");
466 // ***************************************************************************
467 REGISTER_ACTION_HANDLER (CActionHandlerEvalExpr
, "eval_expr");
468 // ***************************************************************************
469 void CActionHandlerEvalExpr::execute(CCtrlBase
* /* pCaller */, const std::string
¶ms
)
471 std::string expr
= getParam(params
, "expr");
474 nlwarning("<CActionHandlerEvalExpr::execute> 'expr' parameter not found or empty.");
477 CInterfaceExprValue dummyResult
; // result not used
478 if (!CInterfaceExpr::eval(expr
, dummyResult
))
480 nlwarning("<CActionHandlerEvalExpr::execute> Couldn't eval expression");
485 // ***************************************************************************
486 CInterfaceGroup
*createMenuColorWidget(const string
&colDbEntry
,
487 const string
&toolTipTextID
,
488 const string
&ccdTitle
)
490 CInterfaceManager
*im
= CInterfaceManager::getInstance();
491 pair
<string
, string
> params
[3] =
493 make_pair(string("col_db_entry"), colDbEntry
),
494 make_pair(string("tooltip"), toolTipTextID
),
495 make_pair(string("ccd_title"), ccdTitle
),
497 return CWidgetManager::getInstance()->getParser()->createGroupInstance("menu_color_widget", "", params
, 3);
500 // ***************************************************************************
508 // *********************************************************
509 CCameraBackup
setupCameraForScreenshot(UScene
&scene
, uint left
, uint right
, uint top
, uint bottom
, uint screenShotWidth
, uint screenShotHeight
)
512 cb
.Frustum
= scene
.getCam().getFrustum();
513 cb
.Viewport
= scene
.getViewport();
515 CFrustum frustumPart
;
516 frustumPart
.Left
= cb
.Frustum
.Left
+(cb
.Frustum
.Right
-cb
.Frustum
.Left
)*((float)left
/(float)screenShotWidth
);
517 frustumPart
.Right
= cb
.Frustum
.Left
+(cb
.Frustum
.Right
-cb
.Frustum
.Left
)*((float)right
/(float)screenShotWidth
);
518 frustumPart
.Top
= cb
.Frustum
.Top
+(cb
.Frustum
.Bottom
-cb
.Frustum
.Top
)*((float)top
/(float)screenShotHeight
);
519 frustumPart
.Bottom
= cb
.Frustum
.Top
+(cb
.Frustum
.Bottom
-cb
.Frustum
.Top
)*((float)bottom
/(float)screenShotHeight
);
520 frustumPart
.Near
= cb
.Frustum
.Near
;
521 frustumPart
.Far
= cb
.Frustum
.Far
;
522 frustumPart
.Perspective
= cb
.Frustum
.Perspective
;
526 NL3D::UDriver
*Driver
= CViewRenderer::getInstance()->getDriver();
527 viewport
.init (0, 0, (float)(right
-left
)/Driver
->getWindowWidth(), (float)(bottom
-top
)/Driver
->getWindowHeight());
530 scene
.getCam().setFrustum (frustumPart
);
531 scene
.setViewport (viewport
);
537 // *********************************************************
538 static void restoreCamera(UScene
&scene
, const CCameraBackup
&backup
)
540 scene
.getCam().setFrustum (backup
.Frustum
);
541 scene
.setViewport(backup
.Viewport
);
544 // ***************************************************************************
545 void renderSceneScreenShot (uint left
, uint right
, uint top
, uint bottom
, uint screenShotWidth
, uint screenShotHeight
)
547 CCameraBackup cbScene
= setupCameraForScreenshot(*Scene
, left
, right
, top
, bottom
, screenShotWidth
, screenShotHeight
);
548 CCameraBackup cbCanopy
= setupCameraForScreenshot(*SceneRoot
, left
, right
, top
, bottom
, screenShotWidth
, screenShotHeight
);
550 // sky setup are copied from main scene before rendering so no setup done here
551 renderScene(ClientCfg
.ScreenShotFullDetail
, ClientCfg
.Bloom
);
552 restoreCamera(*Scene
, cbScene
);
553 restoreCamera(*SceneRoot
, cbCanopy
);
557 // ***************************************************************************
559 void getBuffer (CBitmap
&btm
)
561 NL3D::UDriver
*Driver
= CViewRenderer::getInstance()->getDriver();
563 if (ClientCfg
.ScreenShotWidth
&& ClientCfg
.ScreenShotHeight
)
567 btm
.resize (ClientCfg
.ScreenShotWidth
, ClientCfg
.ScreenShotHeight
, CBitmap::RGBA
);
570 uint bottom
= std::min (Driver
->getWindowHeight (), ClientCfg
.ScreenShotHeight
);
571 for (top
=0; top
<ClientCfg
.ScreenShotHeight
; top
+=Driver
->getWindowHeight ())
574 uint right
= std::min (Driver
->getWindowWidth (), ClientCfg
.ScreenShotWidth
);
575 for (left
=0; left
<ClientCfg
.ScreenShotWidth
; left
+=Driver
->getWindowWidth ())
577 Driver
->clearBuffers (CRGBA::Black
);
578 renderSceneScreenShot (left
, right
, top
, bottom
, ClientCfg
.ScreenShotWidth
, ClientCfg
.ScreenShotHeight
);
580 Driver
->getBuffer (temp
);
581 Driver
->swapBuffers ();
582 btm
.blit (temp
, 0, Driver
->getWindowHeight ()-(bottom
-top
), right
-left
, bottom
-top
, left
, top
);
585 right
= std::min (right
+Driver
->getWindowWidth (), ClientCfg
.ScreenShotWidth
);
589 bottom
= std::min (bottom
+Driver
->getWindowHeight (), ClientCfg
.ScreenShotHeight
);
594 Driver
->getBuffer(btm
);
598 void displayScreenShotSavedInfo(const string
&filename
)
600 CInterfaceManager
*pIM
= CInterfaceManager::getInstance();
601 string msg
= "'" + filename
+ "' " + CI18N::get("uiScreenshotSaved");
602 pIM
->displaySystemInfo(msg
);
605 void initScreenshot()
607 if (!CFile::isExists(ScreenshotsDirectory
)) CFile::createDirectory(ScreenshotsDirectory
);
610 bool screenshotZBuffer(const std::string
&filename
)
612 std::string::size_type pos
= filename
.find(".");
614 if (pos
== std::string::npos
)
617 std::string filename_z
= filename
.substr(0, pos
) + "_z" + filename
.substr(pos
);
618 std::string ext
= filename
.substr(pos
+1);
620 std::vector
<float> z
;
621 NL3D::UDriver
*Driver
= CViewRenderer::getInstance()->getDriver();
623 Driver
->getZBuffer(z
);
625 float min
= std::numeric_limits
<float>::max();
626 float max
= std::numeric_limits
<float>::min();
628 // get min and max values
629 for(uint i
= 0; i
< z
.size(); ++i
)
636 else if (value
< min
)
645 zi
.resize(Driver
->getWindowWidth(), Driver
->getWindowHeight());
646 CRGBA
*dest
= (CRGBA
*) &zi
.getPixels()[0];
648 for(uint k
= 0; k
< z
.size(); ++k
)
651 uint8 i
= (uint8
) ((z
[k
] - min
) * 255.f
/ max
);
652 dest
->set(i
, i
, i
, i
);
673 static std::string
findNewScreenShotFileName(std::string filename
)
675 static char cstime
[25];
678 struct tm
*tms
= localtime(&dtime
);
681 strftime(cstime
, 25, "%Y-%m-%d", tms
);
683 std::string::size_type pos
= filename
.find_last_of('.');
685 // fallback if no extension is given
686 if (pos
== std::string::npos
)
687 filename
= filename
+ "_" + cstime
+ "_";
689 filename
= filename
.substr(0, pos
) + "_" + cstime
+ "_" + filename
.substr(pos
);
692 // screenshot_YYYY-MM-DD_000.jpg
693 return CFile::findNewFile(filename
);
701 string filename
= findNewScreenShotFileName(ScreenshotsDirectory
+"screenshot.tga");
704 if (!btm
.writeTGA(fs
, 24, false))
707 CFile::deleteFile(filename
);
711 if (ClientCfg
.ScreenShotZBuffer
)
712 screenshotZBuffer(filename
);
714 nlinfo("Screenshot '%s' saved in tga format (%ux%u)", filename
.c_str(), ClientCfg
.ScreenShotWidth
, ClientCfg
.ScreenShotHeight
);
715 displayScreenShotSavedInfo(filename
);
723 string filename
= findNewScreenShotFileName(ScreenshotsDirectory
+"screenshot.png");
726 if (!btm
.writePNG(fs
, 24))
729 CFile::deleteFile(filename
);
733 if (ClientCfg
.ScreenShotZBuffer
)
734 screenshotZBuffer(filename
);
736 nlinfo("Screenshot '%s' saved in png format (%ux%u)", filename
.c_str(), ClientCfg
.ScreenShotWidth
, ClientCfg
.ScreenShotHeight
);
737 displayScreenShotSavedInfo(filename
);
745 string filename
= findNewScreenShotFileName(ScreenshotsDirectory
+"screenshot.jpg");
748 if (!btm
.writeJPG(fs
))
751 CFile::deleteFile(filename
);
755 if (ClientCfg
.ScreenShotZBuffer
)
756 screenshotZBuffer(filename
);
758 nlinfo("Screenshot '%s' saved in jpg format (%ux%u)", filename
.c_str(), ClientCfg
.ScreenShotWidth
, ClientCfg
.ScreenShotHeight
);
759 displayScreenShotSavedInfo(filename
);
762 // ***************************************************************************
764 class CAHScreenShot
: public IActionHandler
766 void execute(CCtrlBase
* /* pCaller */, const std::string
&/* params */)
768 // if custom screenshot size is asked, then do it right now
769 if (ClientCfg
.ScreenShotWidth
&& ClientCfg
.ScreenShotHeight
)
771 // Custom screen shot ?
776 // post screenshot request
777 ScreenshotRequest
= ScreenshotRequestTGA
;
782 // ***************************************************************************
783 REGISTER_ACTION_HANDLER (CAHScreenShot
, "screen_shot");
785 // ***************************************************************************
786 class CAHScreenShotJPG
: public IActionHandler
788 void execute(CCtrlBase
* /* pCaller */, const std::string
&/* params */)
790 // if custom screenshot size is asked, then do it right now
791 if (ClientCfg
.ScreenShotWidth
&& ClientCfg
.ScreenShotHeight
)
797 // post screenshot request
798 ScreenshotRequest
= ScreenshotRequestJPG
;
802 // ***************************************************************************
803 REGISTER_ACTION_HANDLER (CAHScreenShotJPG
, "screen_shot_jpg");
805 // ***************************************************************************
806 class CAHScreenShotPNG
: public IActionHandler
808 void execute(CCtrlBase
* /* pCaller */, const std::string
&/* params */)
810 // if custom screenshot size is asked, then do it right now
811 if (ClientCfg
.ScreenShotWidth
&& ClientCfg
.ScreenShotHeight
)
817 // post screenshot request
818 ScreenshotRequest
= ScreenshotRequestPNG
;
822 // ***************************************************************************
823 REGISTER_ACTION_HANDLER (CAHScreenShotPNG
, "screen_shot_png");
826 // ***************************************************************************
827 // Reply to the last people who talked in the chat -> this change the target of the main chat to the name of the last teller
828 class CAHReplyTeller
: public IActionHandler
830 void execute(CCtrlBase
* /* pCaller */, const std::string
&/* params */)
832 if (!PeopleInterraction
.LastSenderName
.empty())
834 CChatWindow
*w
= PeopleInterraction
.ChatGroup
.Window
;
837 w
->setKeyboardFocus();
839 PeopleInterraction
.ChatGroup
.Filter
.setTargetPlayer(CEntityCL::removeTitleAndShardFromName(PeopleInterraction
.LastSenderName
));
840 CGroupEditBox
*eb
= w
->getEditBox();
850 REGISTER_ACTION_HANDLER (CAHReplyTeller
, "reply_teller")
852 // ***************************************************************************
853 // Reply to the last people who talked in the chat only once (display '/tell name' in the last activated chat window)
854 class CAHReplyTellerOnce
: public IActionHandler
856 void execute(CCtrlBase
* /* pCaller */, const std::string
&/* params */)
858 // display a /tell command in the main chat
859 if (!PeopleInterraction
.LastSenderName
.empty())
861 CChatWindow
*w
= PeopleInterraction
.ChatGroup
.Window
;
864 w
->setKeyboardFocus();
866 w
->setCommand("tell " + CEntityCL::removeTitleAndShardFromName(PeopleInterraction
.LastSenderName
) + " ", false);
867 CGroupEditBox
*eb
= w
->getEditBox();
876 REGISTER_ACTION_HANDLER (CAHReplyTellerOnce
, "reply_teller_once")
878 // ***************************************************************************
879 /** Cycle through the last people on which a 'tell' has been done.
880 * Focus must be in a window with a target (main chat or user chat), otherwise the main chat is used
882 class CAHCycleTell
: public IActionHandler
884 void execute(CCtrlBase
* /* pCaller */, const std::string
&/* params */)
886 CInterfaceManager
*im
= CInterfaceManager::getInstance();
887 if (!im
->isInGame()) return;
888 const string
*lastTellPeople
= ChatMngr
.cycleLastTell();
889 if (!lastTellPeople
) return;
890 // just popup the main chat
891 //CChatWindow *w = PeopleInterraction.MainChat.Window;
892 CChatWindow
*w
= PeopleInterraction
.ChatGroup
.Window
;
895 w
->setKeyboardFocus();
897 //PeopleInterraction.MainChat.Filter.setTargetPlayer(*lastTellPeople);
898 PeopleInterraction
.ChatGroup
.Filter
.setTargetPlayer(*lastTellPeople
);
902 REGISTER_ACTION_HANDLER (CAHCycleTell
, "cycle_tell")
907 // temp for test : set last sender name
908 NLMISC_COMMAND(slsn
, "Temp : set the name of the last sender.", "<name>")
910 if (args
.size() != 1) return false;
911 PeopleInterraction
.LastSenderName
= args
[0];
915 // ***************************************************************************
916 bool CStringPostProcessRemoveName::cbIDStringReceived(string
&inOut
)
918 // extract the replacement id
919 string strNewTitle
= CEntityCL::getTitleFromName(inOut
);
921 // retrieve the translated string
922 if (!strNewTitle
.empty())
924 inOut
= STRING_MANAGER::CStringManagerClient::getTitleLocalizedName(strNewTitle
, Woman
);
926 // Sometimes translation contains another title
927 string::size_type pos
= inOut
.find('$');
928 if (pos
!= string::npos
)
930 inOut
= STRING_MANAGER::CStringManagerClient::getTitleLocalizedName(CEntityCL::getTitleFromName(inOut
), Woman
);
940 // ***************************************************************************
941 bool CStringPostProcessRemoveTitle::cbIDStringReceived(string
&inOut
)
943 inOut
= CEntityCL::removeTitleAndShardFromName(inOut
);
947 // ***************************************************************************
948 bool CStringPostProcessNPCRemoveTitle::cbIDStringReceived(string
&inOut
)
950 string sOut
= CEntityCL::removeTitleAndShardFromName(inOut
);
953 CStringPostProcessRemoveName SPPRM
;
954 SPPRM
.cbIDStringReceived(inOut
);
965 // ***************************************************************************
966 class CAHAnimStart
: public IActionHandler
969 virtual void execute (CCtrlBase
* /* pCaller */, const std::string
&Params
)
971 string sAnim
= getParam(Params
, "anim");
972 CWidgetManager::getInstance()->startAnim(sAnim
);
975 REGISTER_ACTION_HANDLER (CAHAnimStart
, "anim_start");
977 // ***************************************************************************
978 class CAHAnimStop
: public IActionHandler
981 virtual void execute (CCtrlBase
* /* pCaller */, const std::string
&Params
)
983 string sAnim
= getParam(Params
, "anim");
984 CWidgetManager::getInstance()->stopAnim(sAnim
);
987 REGISTER_ACTION_HANDLER (CAHAnimStop
, "anim_stop");