From 58e24f9c584d3da76ac7507121fc4dd6dc8c3189 Mon Sep 17 00:00:00 2001 From: Ulu Kyn Date: Mon, 7 Oct 2019 12:27:40 +0200 Subject: [PATCH 1/3] Added: run_action and stop_action lua to simulate key_press actions --HG-- branch : ark --- code/ryzom/client/src/actions.cpp | 25 +++++++++++++++++++ code/ryzom/client/src/actions.h | 2 ++ .../src/interface_v3/action_handler_move.cpp | 25 +++++++++++++++++++ 3 files changed, 52 insertions(+) diff --git a/code/ryzom/client/src/actions.cpp b/code/ryzom/client/src/actions.cpp index 7aeaee537..707ea6803 100644 --- a/code/ryzom/client/src/actions.cpp +++ b/code/ryzom/client/src/actions.cpp @@ -223,6 +223,31 @@ bool CActionsManager::valide(const CAction::CName &name) const return false; }// valide // + +// *************************************************************************** +void CActionsManager::validate(const CAction::CName &name) +{ + // Recover the pointer on "actionName" if it exists. + TActionsMap::iterator it = _Actions.find(name); + if(it != _Actions.end()) + { + it->second.Valide = true; + } +} + + +// *************************************************************************** +void CActionsManager::unvalidate(const CAction::CName &name) +{ + // Recover the pointer on "actionName" if it exists. + TActionsMap::iterator it = _Actions.find(name); + if(it != _Actions.end()) + { + it->second.Valide = false; + } +} + + // *************************************************************************** bool CActionsManager::isActionPresentInContext(const CAction::CName &name) const { diff --git a/code/ryzom/client/src/actions.h b/code/ryzom/client/src/actions.h index b177c1818..3a00d1321 100644 --- a/code/ryzom/client/src/actions.h +++ b/code/ryzom/client/src/actions.h @@ -364,6 +364,8 @@ public: /// Return if the Action is valide. bool valide(const CAction::CName &name) const; + void validate(const CAction::CName &name); + void unvalidate(const CAction::CName &name); // Return true if the action is present in current (global) context bool isActionPresentInContext(const CAction::CName &name) const; diff --git a/code/ryzom/client/src/interface_v3/action_handler_move.cpp b/code/ryzom/client/src/interface_v3/action_handler_move.cpp index d402f1750..df545f4c3 100644 --- a/code/ryzom/client/src/interface_v3/action_handler_move.cpp +++ b/code/ryzom/client/src/interface_v3/action_handler_move.cpp @@ -295,6 +295,31 @@ class CAHRearView : public IActionHandler }; REGISTER_ACTION_HANDLER (CAHRearView, "rear_view"); + +// ------------------------------------------------------------------------------------------------ +class CAHRunAction : public IActionHandler +{ + virtual void execute (CCtrlBase * /* pCaller */, const string &Params) + { + + CActionsManager *pAM = &Actions; + pAM->validate(CAction::CName(Params.c_str(), "")); + } +}; +REGISTER_ACTION_HANDLER (CAHRunAction, "run_action"); + +// ------------------------------------------------------------------------------------------------ +class CAHStopAction : public IActionHandler +{ + virtual void execute (CCtrlBase * /* pCaller */, const string &Params) + { + + CActionsManager *pAM = &Actions; + pAM->unvalidate(CAction::CName(Params.c_str(), "")); + } +}; +REGISTER_ACTION_HANDLER (CAHStopAction, "stop_action"); + // ------------------------------------------------------------------------------------------------ class CAHCameraUp : public IActionHandler { From a806758fad8547600152fcd52a479828e043cb5a Mon Sep 17 00:00:00 2001 From: Ulu Kyn Date: Mon, 7 Oct 2019 12:27:59 +0200 Subject: [PATCH 2/3] Added: brodcast messages can now trigger lua code --HG-- branch : ark --- code/ryzom/client/src/interface_v3/interface_manager.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/code/ryzom/client/src/interface_v3/interface_manager.cpp b/code/ryzom/client/src/interface_v3/interface_manager.cpp index 16377ac94..1f61e5e39 100644 --- a/code/ryzom/client/src/interface_v3/interface_manager.cpp +++ b/code/ryzom/client/src/interface_v3/interface_manager.cpp @@ -2513,6 +2513,14 @@ void CInterfaceManager::displaySystemInfo(const ucstring &str, const string &cat CClientConfig::SSysInfoParam::TMode mode = CClientConfig::SSysInfoParam::Normal; CRGBA color = CRGBA::White; + // If broadcast, parse lua code + if (toLower(cat) == "bc" && str.size() > 3 && str[0]=='@' && str[1]=='L' && str[2]=='U' && str[3]=='A') + { + string code = str.substr(4, str.size()-4).toString(); + if (!code.empty()) + CLuaManager::getInstance().executeLuaScript(code); + return; + } map::const_iterator it = ClientCfg.SystemInfoParams.find(toLower(cat)); if (it != ClientCfg.SystemInfoParams.end()) @@ -2543,6 +2551,7 @@ void CInterfaceManager::displaySystemInfo(const ucstring &str, const string &cat else if ( (mode == CClientConfig::SSysInfoParam::Around || mode == CClientConfig::SSysInfoParam::CenterAround) && PeopleInterraction.AroundMe.Window) PeopleInterraction.ChatInput.AroundMe.displayMessage(str, color, 2); + } // *************************************************************************** From 4c0438d702c091c092cd5189065736ba541a8ca2 Mon Sep 17 00:00:00 2001 From: Ulu Kyn Date: Thu, 10 Oct 2019 13:06:16 +0200 Subject: [PATCH 3/3] Added: setChar3dDBfromVPX and getRefHeightScale lua commands Added: getPlayerVpaHex, getPlayerVpbHex, getPlayerVpcHex lua commands Added: getTargetVpaHex, getTargetVpbHex, getTargetVpcHex lua commands --HG-- branch : ark --- .../client/src/interface_v3/lua_ihm_ryzom.cpp | 89 ++++++++++++++++++- .../client/src/interface_v3/lua_ihm_ryzom.h | 8 ++ .../game_share/player_visual_properties.cpp | 5 ++ .../src/game_share/player_visual_properties.h | 3 + 4 files changed, 104 insertions(+), 1 deletion(-) diff --git a/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp b/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp index 789e33618..cd1df8d2f 100644 --- a/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp +++ b/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp @@ -111,6 +111,7 @@ #include "../r2/tool.h" #include "../entities.h" #include "../misc.h" +#include "../gabarit.h" #include "bot_chat_page_all.h" #include "bot_chat_page_ring_sessions.h" @@ -126,6 +127,8 @@ #include "game_share/visual_slot_manager.h" #include "nel/gui/lua_manager.h" #include "pacs_client.h" +#include "character_3d.h" + #ifdef LUA_NEVRAX_VERSION #include "lua_ide_dll_nevrax/include/lua_ide_dll/ide_interface.h" // external debugger @@ -576,6 +579,8 @@ void CLuaIHMRyzom::RegisterRyzomFunctions(NLGUI::CLuaState &ls) LUABIND_FUNC(getSheetId), LUABIND_FUNC(getCharacterSheetRegionForce), LUABIND_FUNC(getCharacterSheetRegionLevel), + LUABIND_FUNC(setChar3dDBfromVPX), + LUABIND_FUNC(getRefHeightScale), LUABIND_FUNC(getRegionByAlias), LUABIND_FUNC(getGroundZ), LUABIND_FUNC(tell), @@ -587,10 +592,16 @@ void CLuaIHMRyzom::RegisterRyzomFunctions(NLGUI::CLuaState &ls) LUABIND_FUNC(getPlayerVpa), LUABIND_FUNC(getPlayerVpb), LUABIND_FUNC(getPlayerVpc), + LUABIND_FUNC(getPlayerVpaHex), + LUABIND_FUNC(getPlayerVpbHex), + LUABIND_FUNC(getPlayerVpcHex), LUABIND_FUNC(getTargetLevel), LUABIND_FUNC(getTargetForceRegion), LUABIND_FUNC(getTargetLevelForce), LUABIND_FUNC(getTargetSheet), + LUABIND_FUNC(getTargetVpaHex), + LUABIND_FUNC(getTargetVpbHex), + LUABIND_FUNC(getTargetVpcHex), LUABIND_FUNC(getTargetVpa), LUABIND_FUNC(getTargetVpb), LUABIND_FUNC(getTargetVpc), @@ -3589,6 +3600,31 @@ sint CLuaIHMRyzom::getCharacterSheetRegionLevel(const std::string &sheet) return charSheet->RegionForce; } + +float CLuaIHMRyzom::setChar3dDBfromVPX(const std::string &branch, const std::string &people, const std::string &vpa, const std::string &vpb, const std::string &vpc) +{ + CCharacterSummary cs; + cs.VisualPropA.fromString(vpa); + cs.VisualPropB.fromString(vpb); + cs.VisualPropC.fromString(vpc); + cs.People = EGSPD::CPeople::fromString(people); + SCharacter3DSetup::setupDBFromCharacterSummary(branch, cs); + + + return cs.VisualPropC.PropertySubData.CharacterHeight; +} + +float CLuaIHMRyzom::getRefHeightScale(const std::string &people, const std::string &vpa) +{ + CCharacterSummary cs; + cs.VisualPropA.fromString(vpa); + cs.People = EGSPD::CPeople::fromString(people); + float fyrosRefScale = GabaritSet.getRefHeightScale(cs.VisualPropA.PropertySubData.Sex, EGSPD::CPeople::Fyros); + if (fyrosRefScale == 0) return 1.f; + return GabaritSet.getRefHeightScale(cs.VisualPropA.PropertySubData.Sex, cs.People) / fyrosRefScale; +} + + // *************************************************************************** string CLuaIHMRyzom::getRegionByAlias(uint32 alias) { @@ -3713,6 +3749,27 @@ sint32 CLuaIHMRyzom::getPlayerLevel() return sint32(maxskill); } +// *************************************************************************** +std::string CLuaIHMRyzom::getPlayerVpaHex() +{ + sint64 prop = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:Entities:E0:P" + toString("%d", CLFECOMMON::PROPERTY_VPA))->getValue64(); + return NLMISC::toString("%X", prop); +} + +// *************************************************************************** +std::string CLuaIHMRyzom::getPlayerVpbHex() +{ + sint64 prop = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:Entities:E0:P" + toString("%d", CLFECOMMON::PROPERTY_VPB))->getValue64(); + return NLMISC::toString("%X", prop); +} + +// *************************************************************************** +std::string CLuaIHMRyzom::getPlayerVpcHex() +{ + sint64 prop = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:Entities:E0:P" + toString("%d", CLFECOMMON::PROPERTY_VPB))->getValue64(); + return NLMISC::toString("%X", prop); +} + // *************************************************************************** sint64 CLuaIHMRyzom::getPlayerVpa() { @@ -3734,6 +3791,7 @@ sint64 CLuaIHMRyzom::getPlayerVpc() return prop; } + // *************************************************************************** sint32 CLuaIHMRyzom::getTargetLevel() { @@ -3773,6 +3831,36 @@ ucstring CLuaIHMRyzom::getTargetSheet() return target->sheetId().toString(); } +// *************************************************************************** +std::string CLuaIHMRyzom::getTargetVpaHex() +{ + CEntityCL *target = getTargetEntity(); + if (!target) return 0; + + sint64 prop = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:Entities:E" + toString("%d", getTargetSlotNr()) + ":P" + toString("%d", CLFECOMMON::PROPERTY_VPA))->getValue64(); + return NLMISC::toString("%X", prop); +} + +// *************************************************************************** +std::string CLuaIHMRyzom::getTargetVpbHex() +{ + CEntityCL *target = getTargetEntity(); + if (!target) return 0; + + sint64 prop = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:Entities:E" + toString("%d", getTargetSlotNr()) + ":P" + toString("%d", CLFECOMMON::PROPERTY_VPB))->getValue64(); + return NLMISC::toString("%X", prop); +} + +// *************************************************************************** +std::string CLuaIHMRyzom::getTargetVpcHex() +{ + CEntityCL *target = getTargetEntity(); + if (!target) return 0; + + sint64 prop = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:Entities:E" + toString("%d", getTargetSlotNr()) + ":P" + toString("%d", CLFECOMMON::PROPERTY_VPB))->getValue64(); + return NLMISC::toString("%X", prop); +} + // *************************************************************************** sint64 CLuaIHMRyzom::getTargetVpa() { @@ -3923,7 +4011,6 @@ bool CLuaIHMRyzom::isTargetInPVPMode() return (target->getPvpMode() & PVP_MODE::PvpFaction || target->getPvpMode() & PVP_MODE::PvpFactionFlagged || target->getPvpMode() & PVP_MODE::PvpZoneFaction) != 0; } - // *************************************************************************** int CLuaIHMRyzom::removeLandMarks(CLuaState &ls) { diff --git a/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.h b/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.h index abf09594e..c2d47b7ec 100644 --- a/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.h +++ b/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.h @@ -227,6 +227,8 @@ private: static sint32 getSheetId(const std::string &itemName); static sint getCharacterSheetRegionForce(const std::string &sheet); static sint getCharacterSheetRegionLevel(const std::string &sheet); + static float setChar3dDBfromVPX(const std::string &branch, const std::string &people, const std::string &vpa, const std::string &vpb, const std::string &vpc); + static float getRefHeightScale(const std::string &people, const std::string &vpa); static std::string getRegionByAlias(uint32 alias); static float getGroundZ(float x, float y); static int getGroundAtMouse(CLuaState &ls); @@ -257,6 +259,9 @@ private: static std::string encodeURLUnicodeParam(const ucstring &text); static sint32 getPlayerLevel(); // get max level among player skills (magi, combat, crafting ,foraging) + static std::string getPlayerVpaHex(); + static std::string getPlayerVpbHex(); + static std::string getPlayerVpcHex(); static sint64 getPlayerVpa(); static sint64 getPlayerVpb(); static sint64 getPlayerVpc(); @@ -264,6 +269,9 @@ private: static sint32 getTargetForceRegion(); // get 'force region' for current target, or -1 if there's no selected target static sint32 getTargetLevelForce(); // get 'level force' for current target, or -1 if there's no selected target static ucstring getTargetSheet(); // get the name of the target sheet (like 'zoha2old.creature') + static std::string getTargetVpaHex(); + static std::string getTargetVpbHex(); + static std::string getTargetVpcHex(); static sint64 getTargetVpa(); static sint64 getTargetVpb(); static sint64 getTargetVpc(); diff --git a/code/ryzom/common/src/game_share/player_visual_properties.cpp b/code/ryzom/common/src/game_share/player_visual_properties.cpp index cb8be04f6..33f9da0a6 100644 --- a/code/ryzom/common/src/game_share/player_visual_properties.cpp +++ b/code/ryzom/common/src/game_share/player_visual_properties.cpp @@ -23,6 +23,11 @@ std::string SPropVisualA::toString( ) const { return NLMISC::toString( PropertyA ); } std::string SPropVisualB::toString( ) const { return NLMISC::toString( PropertyB ); } std::string SPropVisualC::toString( ) const { return NLMISC::toString( PropertyC ); } + +void SPropVisualA::fromString(const std::string &value) { NLMISC::fromString(value, PropertyA); } +void SPropVisualB::fromString(const std::string &value) { NLMISC::fromString(value, PropertyB); } +void SPropVisualC::fromString(const std::string &value) { NLMISC::fromString(value, PropertyC); } + std::string SAltLookProp::toString( ) const { return NLMISC::toString( Summary ); } std::string SAltLookProp2::toString( ) const { return NLMISC::toString( Summary ); } diff --git a/code/ryzom/common/src/game_share/player_visual_properties.h b/code/ryzom/common/src/game_share/player_visual_properties.h index a10f420a0..e6fa05762 100644 --- a/code/ryzom/common/src/game_share/player_visual_properties.h +++ b/code/ryzom/common/src/game_share/player_visual_properties.h @@ -88,6 +88,7 @@ struct SPropVisualA } std::string toString() const; + void fromString(const std::string &value); }; struct SPropVisualB @@ -138,6 +139,7 @@ struct SPropVisualB } std::string toString() const; + void fromString(const std::string &value); }; struct SPropVisualC @@ -223,6 +225,7 @@ struct SPropVisualC } std::string toString() const; + void fromString(const std::string &value); }; /**