From 4544a5ffdaf7452ccf1c0696185eefb7e5abf4c0 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Mon, 13 Feb 2012 02:30:26 +0100 Subject: [PATCH] Moved an action handler, from the view manager's source to the game action handlers' source. --- .../src/interface_v3/action_handler_game.cpp | 121 +++++++++++++++++ .../src/interface_v3/interface_manager.cpp | 124 ------------------ 2 files changed, 121 insertions(+), 124 deletions(-) diff --git a/code/ryzom/client/src/interface_v3/action_handler_game.cpp b/code/ryzom/client/src/interface_v3/action_handler_game.cpp index 22d65d138..ec0931b73 100644 --- a/code/ryzom/client/src/interface_v3/action_handler_game.cpp +++ b/code/ryzom/client/src/interface_v3/action_handler_game.cpp @@ -4106,3 +4106,124 @@ public: } }; REGISTER_ACTION_HANDLER(CHandlerConfigureQuitDialogBox, "configure_quit_dialog_box"); + +// ---------------------------------------------------------------------------- +static bool isSwimming() +{ + if (UserEntity != NULL) + return (UserEntity->mode() == MBEHAV::SWIM || UserEntity->mode() == MBEHAV::MOUNT_SWIM); + else + return false; +} + +static bool isStunned() +{ + if (UserEntity != NULL) + return (UserEntity->behaviour() == MBEHAV::STUNNED); + else + return false; +} + +static bool isDead() +{ + if (UserEntity != NULL) + return (UserEntity->mode() == MBEHAV::DEATH); + else + return false; +} + +// *************************************************************************** + +class CHandlerEmote : public IActionHandler +{ +public: + void execute (CCtrlBase * /* pCaller */, const std::string &sParams) + { + // An emote is 2 things : a phrase and an animation + // Phrase is the phrase that server returns in chat system + // Behav is the animation played + // CustomPhrase is an user phrase which can replace default phrase + string sPhraseNb = getParam(sParams, "nb"); + string sBehav = getParam(sParams, "behav"); + string sCustomPhrase = getParam(sParams, "custom_phrase"); + + uint32 phraseNb; + fromString(sPhraseNb, phraseNb); + uint8 behaviour; + fromString(sBehav, behaviour); + + MBEHAV::EBehaviour behavToSend = (MBEHAV::EBehaviour)(MBEHAV::EMOTE_BEGIN + behaviour); + uint16 phraseNbToSend = (uint16)phraseNb; + + if (EAM) + { + const uint nbBehav = EAM->getNbEmots(); // Miscalled: this is the number of behaviour for all emotes + if ((behaviour >= nbBehav) || (behaviour == 255)) + behavToSend = MBEHAV::IDLE; + } + else + { + if (behaviour == 255) + behavToSend = MBEHAV::IDLE; + } + + /* Emotes forbidden when dead, emotes with behav forbidden when + * stunned or swimming */ + if ( ( behavToSend != MBEHAV::IDLE && (isSwimming() || isStunned() || isDead() ) ) ) + { + return; + } + + if( sCustomPhrase.empty() ) + { + // Create the message and send. + const string msgName = "COMMAND:EMOTE"; + CBitMemStream out; + if(GenericMsgHeaderMngr.pushNameToStream(msgName, out)) + { + out.serialEnum(behavToSend); + out.serial(phraseNbToSend); + NetMngr.push(out); + //nlinfo("impulseCallBack : %s %d %d sent", msgName.c_str(), (uint32)behavToSend, phraseNbToSend); + } + else + nlwarning("command 'emote': unknown message named '%s'.", msgName.c_str()); + } + else + { + // Create the message and send. + const string msgName = "COMMAND:CUSTOM_EMOTE"; + CBitMemStream out; + if(GenericMsgHeaderMngr.pushNameToStream(msgName, out)) + { + ucstring ucstr; + ucstr.fromUtf8(sCustomPhrase); + + if( sCustomPhrase == "none" ) + { + if( behavToSend == MBEHAV::IDLE ) + { + // display "no animation for emote" + CInterfaceManager *pIM= CInterfaceManager::getInstance(); + ucstring msg = CI18N::get("msgCustomizedEmoteNoAnim"); + string cat = getStringCategory(msg, msg); + pIM->displaySystemInfo(msg, cat); + return; + } + } + else + { + ucstr = ucstring("&EMT&") + UserEntity->getDisplayName() + ucstring(" ") + ucstr; + } + + out.serialEnum(behavToSend); + out.serial(ucstr); + NetMngr.push(out); + //nlinfo("impulseCallBack : %s %d %s sent", msgName.c_str(), (uint32)behavToSend, sCustomPhrase.c_str()); + } + else + nlwarning("command 'emote': unknown message named '%s'.", msgName.c_str()); + } + } +}; +REGISTER_ACTION_HANDLER( CHandlerEmote, "emote"); \ No newline at end of file diff --git a/code/ryzom/client/src/interface_v3/interface_manager.cpp b/code/ryzom/client/src/interface_v3/interface_manager.cpp index 3e665e7ba..b002e019f 100644 --- a/code/ryzom/client/src/interface_v3/interface_manager.cpp +++ b/code/ryzom/client/src/interface_v3/interface_manager.cpp @@ -29,7 +29,6 @@ // Globals #include "interface_manager.h" -#include "input_handler_manager.h" #include "interface_config.h" #include "task_bar_manager.h" #include "guild_manager.h" @@ -97,7 +96,6 @@ #include "../login.h" #include "../sheet_manager.h" // for emotes -//#include "../global.h" // for emotes #include "../entity_animation_manager.h" // for emotes #include "../net_manager.h" // for emotes #include "../client_chat_manager.h" // for emotes @@ -127,7 +125,6 @@ extern CContinentManager ContinentMngr; extern CStringMapper *_UIStringMapper; extern bool IsInRingSession; extern CEventsListener EventsListener; -extern CEntityAnimationManager *EAM; namespace R2 { @@ -164,7 +161,6 @@ using namespace NLNET; // ------------------------------------------------------------------------------------------------ -//extern NL3D::UDriver *Driver; extern bool loginFinished; // Edit actions CActionsManager EditActions; @@ -5497,126 +5493,6 @@ bool CInterfaceManager::CEmoteCmd::execute(const std::string &/* rawCommandStrin return true; } -// ---------------------------------------------------------------------------- -static bool isSwimming() -{ - if (UserEntity != NULL) - return (UserEntity->mode() == MBEHAV::SWIM || UserEntity->mode() == MBEHAV::MOUNT_SWIM); - else - return false; -} - -static bool isStunned() -{ - if (UserEntity != NULL) - return (UserEntity->behaviour() == MBEHAV::STUNNED); - else - return false; -} - -static bool isDead() -{ - if (UserEntity != NULL) - return (UserEntity->mode() == MBEHAV::DEATH); - else - return false; -} - -// *************************************************************************** -class CHandlerEmote : public IActionHandler -{ -public: - void execute (CCtrlBase * /* pCaller */, const std::string &sParams) - { - // An emote is 2 things : a phrase and an animation - // Phrase is the phrase that server returns in chat system - // Behav is the animation played - // CustomPhrase is an user phrase which can replace default phrase - string sPhraseNb = getParam(sParams, "nb"); - string sBehav = getParam(sParams, "behav"); - string sCustomPhrase = getParam(sParams, "custom_phrase"); - - uint32 phraseNb; - fromString(sPhraseNb, phraseNb); - uint8 behaviour; - fromString(sBehav, behaviour); - - MBEHAV::EBehaviour behavToSend = (MBEHAV::EBehaviour)(MBEHAV::EMOTE_BEGIN + behaviour); - uint16 phraseNbToSend = (uint16)phraseNb; - - if (EAM) - { - const uint nbBehav = EAM->getNbEmots(); // Miscalled: this is the number of behaviour for all emotes - if ((behaviour >= nbBehav) || (behaviour == 255)) - behavToSend = MBEHAV::IDLE; - } - else - { - if (behaviour == 255) - behavToSend = MBEHAV::IDLE; - } - - /* Emotes forbidden when dead, emotes with behav forbidden when - * stunned or swimming */ - if ( ( behavToSend != MBEHAV::IDLE && (isSwimming() || isStunned() || isDead() ) ) ) - { - return; - } - - if( sCustomPhrase.empty() ) - { - // Create the message and send. - const string msgName = "COMMAND:EMOTE"; - CBitMemStream out; - if(GenericMsgHeaderMngr.pushNameToStream(msgName, out)) - { - out.serialEnum(behavToSend); - out.serial(phraseNbToSend); - NetMngr.push(out); - //nlinfo("impulseCallBack : %s %d %d sent", msgName.c_str(), (uint32)behavToSend, phraseNbToSend); - } - else - nlwarning("command 'emote': unknown message named '%s'.", msgName.c_str()); - } - else - { - // Create the message and send. - const string msgName = "COMMAND:CUSTOM_EMOTE"; - CBitMemStream out; - if(GenericMsgHeaderMngr.pushNameToStream(msgName, out)) - { - ucstring ucstr; - ucstr.fromUtf8(sCustomPhrase); - - if( sCustomPhrase == "none" ) - { - if( behavToSend == MBEHAV::IDLE ) - { - // display "no animation for emote" - CInterfaceManager *pIM= CInterfaceManager::getInstance(); - ucstring msg = CI18N::get("msgCustomizedEmoteNoAnim"); - string cat = getStringCategory(msg, msg); - pIM->displaySystemInfo(msg, cat); - return; - } - } - else - { - ucstr = ucstring("&EMT&") + UserEntity->getDisplayName() + ucstring(" ") + ucstr; - } - - out.serialEnum(behavToSend); - out.serial(ucstr); - NetMngr.push(out); - //nlinfo("impulseCallBack : %s %d %s sent", msgName.c_str(), (uint32)behavToSend, sCustomPhrase.c_str()); - } - else - nlwarning("command 'emote': unknown message named '%s'.", msgName.c_str()); - } - } -}; -REGISTER_ACTION_HANDLER( CHandlerEmote, "emote"); - // *************************************************************************** bool CInterfaceManager::testDragCopyKey() {