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 e49a7a106..1d1b01684 100644 --- a/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp +++ b/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp @@ -565,6 +565,7 @@ void CLuaIHMRyzom::RegisterRyzomFunctions(NLGUI::CLuaState &ls) LUABIND_FUNC(isDynStringAvailable), LUABIND_FUNC(isFullyPatched), LUABIND_FUNC(getSheetType), + LUABIND_FUNC(getSheetShape), LUABIND_FUNC(getSheetFamily), LUABIND_FUNC(getSheetName), LUABIND_FUNC(getFameIndex), @@ -1245,7 +1246,7 @@ int CLuaIHMRyzom::getMousePos(CLuaState &ls) CTool::getMousePos(x, y); ls.push(x); ls.push(y); - + return 2; } @@ -1257,7 +1258,7 @@ int CLuaIHMRyzom::getMouseDown(CLuaState &ls) ls.push(down); ls.push(x); ls.push(y); - + return 3; } @@ -1266,11 +1267,11 @@ int CLuaIHMRyzom::getMouseMiddleDown(CLuaState &ls) sint32 x, y; bool down; CTool::getMouseMiddleDown(down, x, y); - + ls.push(down); ls.push(x); ls.push(y); - + return 3; } @@ -1279,11 +1280,11 @@ int CLuaIHMRyzom::getMouseRightDown(CLuaState &ls) sint32 x, y; bool down; CTool::getMouseRightDown(down, x, y); - + ls.push(down); ls.push(x); ls.push(y); - + return 3; } @@ -1294,10 +1295,10 @@ int CLuaIHMRyzom::getShapeIdAt(CLuaState &ls) CLuaIHM::checkArgCount(ls, funcName, 2); CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER); CLuaIHM::checkArgType(ls, funcName, 2, LUA_TNUMBER); - + uint32 x = (uint32)ls.toInteger(1); - uint32 y = (uint32)ls.toInteger(2); - + uint32 y = (uint32)ls.toInteger(2); + uint32 w, h; CViewRenderer &viewRender = *CViewRenderer::getInstance(); viewRender.getScreenSize(w, h); @@ -1308,11 +1309,11 @@ int CLuaIHMRyzom::getShapeIdAt(CLuaState &ls) float cursX = (float)x/(float)w; float cursY = (float)y/(float)h; - + sint32 instance_idx; EntitiesMngr.getShapeInstanceUnderPos(cursX, cursY, instance_idx); ls.push(instance_idx); - + return 1; } @@ -1339,7 +1340,7 @@ int CLuaIHMRyzom::getGroundAtMouse(CLuaState &ls) worldViewRay.Up = camMatrix.getK().normed(); CVector sceneInter; CTool::TRayIntersectionType rayInterType = CTool::computeLandscapeRayIntersection(worldViewRay, sceneInter); - + ls.push(sceneInter.x); ls.push(sceneInter.y); ls.push(sceneInter.z); @@ -1367,7 +1368,7 @@ int CLuaIHMRyzom::moveCam(CLuaState &ls) float z = (float)ls.toNumber(3); CVector moves(x, y, z); UserEntity->setCameraMoves(moves); - + return 0; } @@ -1541,7 +1542,7 @@ int CLuaIHMRyzom::moveToTarget(CLuaState &ls) const std::string &url = ls.toString(1); CEntityCL *target = getTargetEntity(); if (!target) return 0; - + CLuaManager::getInstance().executeLuaScript("ArkTargetUrl = [["+url+"]]", 0); UserEntity->moveTo(UserEntity->selection(), 1.0, CUserEntity::OpenArkUrl); return 0; @@ -2180,7 +2181,7 @@ int CLuaIHMRyzom::addShape(CLuaState &ls) CLuaIHM::checkArgType(ls, funcName, 1, LUA_TSTRING); sint32 idx = -1; - + if (!Scene) { nlwarning("No scene available"); @@ -2189,7 +2190,7 @@ int CLuaIHMRyzom::addShape(CLuaState &ls) } string shape = ls.toString(1); - + float x = 0.0f, y = 0.0f, z = 0.0f; float scale = 1.0f; string context, url, skeleton, texture; @@ -2197,7 +2198,7 @@ int CLuaIHMRyzom::addShape(CLuaState &ls) bool transparency = false; bool collision = true; bool inIgZone = false; - + if (ls.getTop() >= 2) { CLuaIHM::checkArgType(ls, funcName, 2, LUA_TNUMBER); @@ -2223,14 +2224,14 @@ int CLuaIHMRyzom::addShape(CLuaState &ls) y = UserEntity->pos().y; z = UserEntity->pos().z; } - + CVector userDir = UserEntity->dir(); - + if (ls.getTop() >= 5) { CLuaIHM::checkArgType(ls, funcName, 5, LUA_TSTRING); string angle = ls.toString(5); - + if (angle != "user") { float a; @@ -2238,7 +2239,7 @@ int CLuaIHMRyzom::addShape(CLuaState &ls) userDir = CVector(sin(a), cos(a), 0.f); } } - + if (ls.getTop() >= 6) { CLuaIHM::checkArgType(ls, funcName, 6, LUA_TNUMBER); @@ -2250,19 +2251,19 @@ int CLuaIHMRyzom::addShape(CLuaState &ls) CLuaIHM::checkArgType(ls, funcName, 7, LUA_TBOOLEAN); collision = ls.toBoolean(7); } - + if (ls.getTop() >= 8) { CLuaIHM::checkArgType(ls, funcName, 8, LUA_TSTRING); context = ls.toString(8); } - + if (ls.getTop() >= 9) { CLuaIHM::checkArgType(ls, funcName, 9, LUA_TSTRING); url = ls.toString(9); } - + if (ls.getTop() >= 10) { CLuaIHM::checkArgType(ls, funcName, 10, LUA_TBOOLEAN); @@ -2274,25 +2275,25 @@ int CLuaIHMRyzom::addShape(CLuaState &ls) CLuaIHM::checkArgType(ls, funcName, 11, LUA_TBOOLEAN); transparency = ls.toBoolean(11); } - + if (ls.getTop() >= 12) { CLuaIHM::checkArgType(ls, funcName, 12, LUA_TSTRING); texture = ls.toString(12); } - + if (ls.getTop() >= 13) { CLuaIHM::checkArgType(ls, funcName, 13, LUA_TSTRING); skeleton = ls.toString(13); } - + if (ls.getTop() >= 14) { CLuaIHM::checkArgType(ls, funcName, 14, LUA_TBOOLEAN); inIgZone = ls.toBoolean(14); } - + CShapeInstanceReference instref = EntitiesMngr.createInstance(shape, CVector(x, y, z), context, url, collision, inIgZone, idx); UInstance instance = instref.Instance; @@ -2373,9 +2374,9 @@ int CLuaIHMRyzom::addShape(CLuaState &ls) instance.setPos(CVector(x, y, z)); instance.setRotQuat(dir.getRot()); } - + instance.setTransformMode(UTransformable::RotEuler); - + // if the shape is a particle system, additionnal parameters are user params UParticleSystemInstance psi; psi.cast (instance); @@ -2398,7 +2399,7 @@ int CLuaIHMRyzom::addShape(CLuaState &ls) } } }*/ - + UMovePrimitive *primitive = instref.Primitive; if (primitive) { @@ -2408,7 +2409,7 @@ int CLuaIHMRyzom::addShape(CLuaState &ls) primitive->setReactionType(UMovePrimitive::Slide); primitive->setTriggerType(UMovePrimitive::NotATrigger); primitive->setAbsorbtion(0); - + primitive->setPrimitiveType(UMovePrimitive::_2DOrientedBox); primitive->setSize((bbox.getMax().x - bbox.getMin().x)*scale, (bbox.getMax().y - bbox.getMin().y)*scale); primitive->setHeight((bbox.getMax().z - bbox.getMin().z)*scale); @@ -2416,10 +2417,10 @@ int CLuaIHMRyzom::addShape(CLuaState &ls) primitive->setCollisionMask(MaskColPlayer | MaskColNpc | MaskColDoor); primitive->setOcclusionMask(MaskColPlayer | MaskColNpc | MaskColDoor); primitive->setObstacle(true); - - + + primitive->setGlobalPosition(instance.getPos(), dynamicWI); - + primitive->insertInWorldImage(dynamicWI); } } @@ -2434,9 +2435,9 @@ int CLuaIHMRyzom::setupShape(CLuaState &ls) CLuaIHM::checkArgCount(ls, funcName, 2); CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER); CLuaIHM::checkArgType(ls, funcName, 2, LUA_TTABLE); - + uint32 idx = (uint32)ls.toInteger(1); - + std::vector keys; std::vector values; CLuaObject params; @@ -2459,12 +2460,12 @@ int CLuaIHMRyzom::setupShape(CLuaState &ls) values.push_back(it.nextValue().toString()); keys.push_back(it.nextKey().toString()); } - + if (EntitiesMngr.setupInstance(idx, keys, values)) ls.push(1); else ls.pushNil(); - + return 1; } @@ -2476,15 +2477,15 @@ int CLuaIHMRyzom::moveShape(CLuaState &ls) CLuaIHM::checkArgType(ls, funcName, 2, LUA_TSTRING); CLuaIHM::checkArgType(ls, funcName, 3, LUA_TSTRING); CLuaIHM::checkArgType(ls, funcName, 4, LUA_TSTRING); - + uint32 idx = (uint32)ls.toInteger(1); - + CVector pos = EntitiesMngr.getInstancePos(idx); string x = ls.toString(2); string y = ls.toString(3); string z = ls.toString(4); - + float move_x = 0; float move_y = 0; float move_z = 0; @@ -2502,7 +2503,7 @@ int CLuaIHMRyzom::moveShape(CLuaState &ls) pos.x = move_x; } } - + if (!y.empty()) { if (y[0] == '+') @@ -2516,7 +2517,7 @@ int CLuaIHMRyzom::moveShape(CLuaState &ls) pos.y = move_y; } } - + if (!z.empty()) { if (z[0] == '+') @@ -2530,12 +2531,12 @@ int CLuaIHMRyzom::moveShape(CLuaState &ls) pos.z = move_z; } } - + if (EntitiesMngr.setInstancePos(idx, pos)) ls.push(1); else ls.pushNil(); - + return 1; } @@ -2547,9 +2548,9 @@ int CLuaIHMRyzom::rotateShape(CLuaState &ls) CLuaIHM::checkArgType(ls, funcName, 2, LUA_TSTRING); CLuaIHM::checkArgType(ls, funcName, 3, LUA_TSTRING); CLuaIHM::checkArgType(ls, funcName, 4, LUA_TSTRING); - + uint32 idx = (uint32)ls.toInteger(1); - + CVector rot = EntitiesMngr.getInstanceRot(idx); string x = ls.toString(2); @@ -2573,7 +2574,7 @@ int CLuaIHMRyzom::rotateShape(CLuaState &ls) rot.x = rot_x; } } - + if (!y.empty()) { if (y[0] == '+') @@ -2587,7 +2588,7 @@ int CLuaIHMRyzom::rotateShape(CLuaState &ls) rot.y = rot_y; } } - + if (!z.empty()) { if (z[0] == '+') @@ -2601,12 +2602,12 @@ int CLuaIHMRyzom::rotateShape(CLuaState &ls) rot.z = rot_z; } } - + if (EntitiesMngr.setInstanceRot(idx, rot)) ls.push(1); else ls.pushNil(); - + return 1; } @@ -2615,7 +2616,7 @@ int CLuaIHMRyzom::deleteShape(CLuaState &ls) const char* funcName = "deleteShape"; CLuaIHM::checkArgCount(ls, funcName, 1); CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER); - + if (EntitiesMngr.deleteInstance((uint32)ls.toInteger(1))) ls.push(1); else @@ -2629,9 +2630,9 @@ int CLuaIHMRyzom::getShapePos(CLuaState &ls) const char* funcName = "getShapePos"; CLuaIHM::checkArgCount(ls, funcName, 1); CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER); - + uint32 idx = (uint32)ls.toInteger(1); - + CVector pos = EntitiesMngr.getInstancePos(idx); ls.push(pos.x); @@ -2645,9 +2646,9 @@ int CLuaIHMRyzom::getShapeRot(CLuaState &ls) const char* funcName = "getShapeRot"; CLuaIHM::checkArgCount(ls, funcName, 1); CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER); - + uint32 idx = (uint32)ls.toInteger(1); - + CVector rot = EntitiesMngr.getInstanceRot(idx); ls.push(rot.x); @@ -2661,11 +2662,11 @@ int CLuaIHMRyzom::getShapeScale(CLuaState &ls) const char* funcName = "getShapeScale"; CLuaIHM::checkArgCount(ls, funcName, 1); CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER); - + uint32 idx = (uint32)ls.toInteger(1); - + CVector scale = EntitiesMngr.getInstanceScale(idx); - + ls.push(scale.x); ls.push(scale.y); ls.push(scale.z); @@ -2677,11 +2678,11 @@ int CLuaIHMRyzom::getShapeColPos(CLuaState &ls) const char* funcName = "getShapeColPos"; CLuaIHM::checkArgCount(ls, funcName, 1); CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER); - + uint32 idx = (uint32)ls.toInteger(1); - + CVector pos = EntitiesMngr.getInstanceColPos(idx); - + ls.push(pos.x); ls.push(pos.y); ls.push(pos.z); @@ -2693,11 +2694,11 @@ int CLuaIHMRyzom::getShapeColScale(CLuaState &ls) const char* funcName = "getShapeColScale"; CLuaIHM::checkArgCount(ls, funcName, 1); CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER); - + uint32 idx = (uint32)ls.toInteger(1); - + CVector scale = EntitiesMngr.getInstanceColScale(idx); - + ls.push(scale.x); ls.push(scale.y); ls.push(scale.z); @@ -2709,11 +2710,11 @@ int CLuaIHMRyzom::getShapeColOrient(CLuaState &ls) const char* funcName = "getShapeColOrient"; CLuaIHM::checkArgCount(ls, funcName, 1); CLuaIHM::checkArgType(ls, funcName, 1, LUA_TNUMBER); - + uint32 idx = (uint32)ls.toInteger(1); - + double orient = EntitiesMngr.getInstanceColOrient(idx); - + ls.push(orient); return 1; } @@ -3469,6 +3470,30 @@ std::string CLuaIHMRyzom::getSheetType(const std::string &sheet) return CEntitySheet::typeToString(sheetPtr->Type); } +// *************************************************************************** +std::string CLuaIHMRyzom::getSheetShape(const std::string &sheet) +{ + //H_AUTO(Lua_CLuaIHM_getSheetType) + const CEntitySheet *sheetPtr = SheetMngr.get(CSheetId(sheet)); + + if (!sheetPtr) + return ""; + + if (sheetPtr->type() == CEntitySheet::ITEM) + { + CItemSheet *sheet = (CItemSheet*)sheetPtr; + return sheet->getShape(); + } + else if (sheetPtr->type() == CEntitySheet::FAUNA) + { + CCharacterSheet *sheet = (CCharacterSheet*)(sheetPtr); + return sheet->Body.getItem(); + } + + return ""; +} + + // *************************************************************************** std::string CLuaIHMRyzom::getSheetFamily(const std::string &sheet) @@ -3481,7 +3506,7 @@ std::string CLuaIHMRyzom::getSheetFamily(const std::string &sheet) if (pIS) return ITEMFAMILY::toString(pIS->Family); } - + return ""; } @@ -3712,7 +3737,7 @@ float CLuaIHMRyzom::setChar3dDBfromVPX(const std::string &branch, const std::str cs.People = EGSPD::CPeople::fromString(people); SCharacter3DSetup::setupDBFromCharacterSummary(branch, cs); - + return cs.VisualPropC.PropertySubData.CharacterHeight; } @@ -3879,42 +3904,42 @@ sint32 CLuaIHMRyzom::getPlayerLevel() // *************************************************************************** std::string CLuaIHMRyzom::getPlayerVpaHex() { - sint64 prop = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:Entities:E0:P" + toString("%d", CLFECOMMON::PROPERTY_VPA))->getValue64(); + uint64 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(); + uint64 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(); + uint64 prop = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:Entities:E0:P" + toString("%d", CLFECOMMON::PROPERTY_VPC))->getValue64(); return NLMISC::toString("%X", prop); } // *************************************************************************** sint64 CLuaIHMRyzom::getPlayerVpa() { - sint64 prop = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:Entities:E0:P" + toString("%d", CLFECOMMON::PROPERTY_VPA))->getValue64(); + uint64 prop = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:Entities:E0:P" + toString("%d", CLFECOMMON::PROPERTY_VPA))->getValue64(); return prop; } // *************************************************************************** sint64 CLuaIHMRyzom::getPlayerVpb() { - sint64 prop = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:Entities:E0:P" + toString("%d", CLFECOMMON::PROPERTY_VPB))->getValue64(); + uint64 prop = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:Entities:E0:P" + toString("%d", CLFECOMMON::PROPERTY_VPB))->getValue64(); return prop; } // *************************************************************************** sint64 CLuaIHMRyzom::getPlayerVpc() { - sint64 prop = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:Entities:E0:P" + toString("%d", CLFECOMMON::PROPERTY_VPB))->getValue64(); + uint64 prop = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:Entities:E0:P" + toString("%d", CLFECOMMON::PROPERTY_VPC))->getValue64(); return prop; } @@ -3964,7 +3989,7 @@ 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(); + uint64 prop = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:Entities:E" + toString("%d", getTargetSlotNr()) + ":P" + toString("%d", CLFECOMMON::PROPERTY_VPA))->getValue64(); return NLMISC::toString("%X", prop); } @@ -3974,7 +3999,7 @@ 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(); + uint64 prop = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:Entities:E" + toString("%d", getTargetSlotNr()) + ":P" + toString("%d", CLFECOMMON::PROPERTY_VPB))->getValue64(); return NLMISC::toString("%X", prop); } @@ -3984,7 +4009,7 @@ 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_VPC))->getValue64(); + uint64 prop = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:Entities:E" + toString("%d", getTargetSlotNr()) + ":P" + toString("%d", CLFECOMMON::PROPERTY_VPC))->getValue64(); return NLMISC::toString("%X", prop); } @@ -3994,7 +4019,7 @@ sint64 CLuaIHMRyzom::getTargetVpa() 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(); + uint64 prop = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:Entities:E" + toString("%d", getTargetSlotNr()) + ":P" + toString("%d", CLFECOMMON::PROPERTY_VPA))->getValue64(); return prop; } @@ -4172,12 +4197,12 @@ int CLuaIHMRyzom::addLandMark(CLuaState &ls) point.LeftClickParam = ls.toString(6); point.RightClickAction = ls.toString(7); point.RightClickParam = ls.toString(8); - + point.Color = CRGBA(255,255,255,255); if (ls.getTop() >= 9) CLuaIHM::pop(ls, point.Color); - + CGroupMap *pMap = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface:map:content:map_content:actual_map")); if (pMap != NULL) pMap->addArkPoint(point);