luabind-diff-2.diff

artart78, 05/09/2010 03:50 pm

Download (11.1 kB)

b/code/ryzom/client/src/interface_v3/lua_ihm.cpp Sun May 09 15:48:54 2010 +0200
441 441

442 442
// ***************************************************************************
443 443
#define LUA_REGISTER_BASIC(_type_)															\
444
yes_t is_user_defined(by_value<_type_>);													\
445
_type_ convert_lua_to_cpp(lua_State* L,    by_value<_type_>,    int index)						\
444
luabind::detail::yes_t is_user_defined(luabind::detail::by_value<_type_>);													\
445
_type_ convert_lua_to_cpp(lua_State* L,    luabind::detail::by_value<_type_>,    int index)						\
446 446
{																							\
447 447
	return (_type_)lua_tonumber(L,    index);													\
448 448
}																							\
449
int match_lua_to_cpp(lua_State* L,    by_value<_type_>,    int index)								\
449
int match_lua_to_cpp(lua_State* L,    luabind::detail::by_value<_type_>,    int index)								\
450 450
{																							\
451 451
	if (lua_isnumber(L,    index)) return 0; else return -1;									\
452 452
}																							\
......
476 476
{
477 477
	//H_AUTO(Lua_CLuaIHM_registerBasics)
478 478
	using namespace luabind;
479
	using namespace luabind::detail;
480

479 481
	lua_State	*L= ls.getStatePointer();
480 482

481 483
	// RGBA
......
1193 1195
}
1194 1196

1195 1197
#define LUABIND_ENUM(__enum__, __name__, __num__, __toStringFunc__) \
1196
	createLuaEnumTable(ls, __name__); \
1197 1198
	for (uint e=0 ; e<__num__ ; e++) \
1198 1199
	{ \
1199
		std::string str = __toStringFunc__((__enum__)e); \
1200
		std::string temp = __name__ + toString(".") + __toStringFunc__((__enum__)e) + " = " + toString("%d;", e); \
1201
		ls.executeScript(temp); \
1202
	} \
1200
		luabind::module(L) [ \
1201
			luabind::class_<__enum__>(__name__).enum_("constants") [ \
1202
				value(__toStringFunc__((__enum__)e), (__enum__)e), \
1203
			] \
1204
		]; \
1205
	}
1203 1206

1204 1207
// ***************************************************************************
1205
#define LUABIND_FUNC(__func__) luabind::function(L,    #__func__,    &__func__);
1208
#define LUABIND_FUNC(__func__) luabind::def(#__func__,    &__func__)
1206 1209
void	CLuaIHM::registerIHM(CLuaState &ls)
1207 1210
{
1211
	using namespace luabind;
1208 1212
	//H_AUTO(Lua_CLuaIHM_registerIHM)
1209 1213
	CLuaStackChecker lsc(&ls);
1210 1214

......
1323 1327
	ls.registerFunc("getUserRace",  getUserRace);
1324 1328
	// Through LUABind API
1325 1329
	lua_State	*L= ls.getStatePointer();
1326
	LUABIND_FUNC(getDbProp);
1327
	LUABIND_FUNC(setDbProp);
1328
	LUABIND_FUNC(debugInfo);
1329
	LUABIND_FUNC(rawDebugInfo);
1330
	LUABIND_FUNC(dumpCallStack);
1331
	LUABIND_FUNC(getDefine);
1332
	LUABIND_FUNC(setContextHelpText);
1333
	luabind::function(L,    "messageBox",    (void(*)(const ucstring &)) &messageBox);
1334
	luabind::function(L,    "messageBox",    (void(*)(const ucstring &, const std::string &)) &messageBox);
1335
	luabind::function(L,    "messageBox",    (void(*)(const ucstring &, const std::string &, int caseMode)) &messageBox);
1336
	luabind::function(L,    "messageBox",    (void(*)(const std::string &)) &messageBox);
1337
	luabind::function(L,    "messageBoxWithHelp",    (void(*)(const ucstring &)) &messageBoxWithHelp);
1338
	luabind::function(L,    "messageBoxWithHelp",    (void(*)(const ucstring &, const std::string &)) &messageBoxWithHelp);
1339
	luabind::function(L,    "messageBoxWithHelp",    (void(*)(const ucstring &, const std::string &, int caseMode)) &messageBoxWithHelp);
1340
	luabind::function(L,    "messageBoxWithHelp",    (void(*)(const std::string &)) &messageBoxWithHelp);
1341
	luabind::function(L,    "findReplaceAll",    (std::string(*)(const std::string &,  const std::string &,  const std::string &)) &findReplaceAll);
1342
	luabind::function(L,    "findReplaceAll",    (ucstring(*)(const ucstring &,  const ucstring &,  const ucstring &)) &findReplaceAll);
1343
	luabind::function(L,    "findReplaceAll",    (ucstring(*)(const ucstring &,  const std::string &,  const std::string &)) &findReplaceAll);
1344
	luabind::function(L,    "findReplaceAll",    (ucstring(*)(const ucstring &,  const ucstring &,  const std::string &)) &findReplaceAll);
1345
	luabind::function(L,    "findReplaceAll",    (ucstring(*)(const ucstring &,  const std::string &,  const ucstring &)) &findReplaceAll);
1346
	LUABIND_FUNC(getPlayerSelectedSlot)
1347
	LUABIND_FUNC(isInGame)
1348
	LUABIND_FUNC(pauseBGDownloader);
1349
	LUABIND_FUNC(unpauseBGDownloader);
1350
	LUABIND_FUNC(requestBGDownloaderPriority);
1351
	LUABIND_FUNC(getBGDownloaderPriority);
1352
	LUABIND_FUNC(getPatchLastErrorMessage);
1353
	LUABIND_FUNC(isPlayerSlotNewbieLand)
1354
	LUABIND_FUNC(getSkillIdFromName);
1355
	LUABIND_FUNC(getSkillLocalizedName);
1356
	LUABIND_FUNC(getMaxSkillValue);
1357
	LUABIND_FUNC(getBaseSkillValueMaxChildren);
1358
	LUABIND_FUNC(getMagicResistChance);
1359
	LUABIND_FUNC(getDodgeParryChance);
1360
	LUABIND_FUNC(browseNpcWebPage);
1361
	LUABIND_FUNC(clearHtmlUndoRedo);
1362
	LUABIND_FUNC(getDynString);
1363
	LUABIND_FUNC(isDynStringAvailable);
1364
	LUABIND_FUNC(isFullyPatched);
1365
	LUABIND_FUNC(getSheetType);
1366
	LUABIND_FUNC(getSheetName);
1367
	LUABIND_FUNC(getFameIndex);
1368
	LUABIND_FUNC(getFameName);
1369
	LUABIND_FUNC(getFameDBIndex);
1370
	LUABIND_FUNC(getFirstTribeFameIndex);
1371
	LUABIND_FUNC(getNbTribeFameIndex);
1372
	LUABIND_FUNC(getClientCfg);
1373
	LUABIND_FUNC(fileExists);
1374
	LUABIND_FUNC(sendMsgToServer);
1375
	LUABIND_FUNC(sendMsgToServerPvpTag);
1376
	LUABIND_FUNC(isGuildQuitAvailable);
1377
	LUABIND_FUNC(sortGuildMembers);
1378
	LUABIND_FUNC(getNbGuildMembers);
1379
	LUABIND_FUNC(getGuildMemberName);
1380
	LUABIND_FUNC(getGuildMemberGrade);
1381
	LUABIND_FUNC(isR2Player);
1382
	LUABIND_FUNC(getR2PlayerRace);
1383
	LUABIND_FUNC(isR2PlayerMale);
1384
	LUABIND_FUNC(getCharacterSheetSkel);
1385
	LUABIND_FUNC(getSheetId)
1386
	LUABIND_FUNC(getCharacterSheetRegionForce)
1387
	LUABIND_FUNC(getCharacterSheetRegionLevel)
1388
	LUABIND_FUNC(replacePvpEffectParam);
1389
	LUABIND_FUNC(getRegionByAlias);
1390
	LUABIND_FUNC(tell);
1391
	LUABIND_FUNC(isRingAccessPointInReach);
1392
	LUABIND_FUNC(updateTooltipCoords);
1393
	LUABIND_FUNC(secondsSince1970ToHour);
1394
	LUABIND_FUNC(isCtrlKeyDown);
1395
	LUABIND_FUNC(encodeURLUnicodeParam);
1396

1397
	LUABIND_ENUM(PVP_CLAN::TPVPClan, "game.TPVPClan", PVP_CLAN::NbClans, PVP_CLAN::toString)
1398
	LUABIND_ENUM(BONUS_MALUS::TBonusMalusSpecialTT, "game.TBonusMalusSpecialTT", BONUS_MALUS::NbSpecialTT, BONUS_MALUS::toString)
1399

1400
	LUABIND_FUNC(getPlayerLevel);
1401
	LUABIND_FUNC(getTargetLevel);
1402
	LUABIND_FUNC(getTargetForceRegion);
1403
	LUABIND_FUNC(getTargetLevelForce);
1404
	LUABIND_FUNC(isTargetNPC)
1405
	LUABIND_FUNC(isTargetPlayer) // return 'true' if the target is an npc
1406
	LUABIND_FUNC(isTargetUser)
1407
	LUABIND_FUNC(isPlayerInPVPMode)
1408
	LUABIND_FUNC(isTargetInPVPMode)
1330
	luabind::module(L)
1331
	[
1332
		LUABIND_FUNC(getDbProp),
1333
		LUABIND_FUNC(setDbProp),
1334
		LUABIND_FUNC(debugInfo),
1335
		LUABIND_FUNC(rawDebugInfo),
1336
		LUABIND_FUNC(dumpCallStack),
1337
		LUABIND_FUNC(getDefine),
1338
		LUABIND_FUNC(setContextHelpText),
1339
		luabind::def("messageBox",    (void(*)(const ucstring &)) &messageBox),
1340
		luabind::def("messageBox",    (void(*)(const ucstring &, const std::string &)) &messageBox),
1341
		luabind::def("messageBox",    (void(*)(const ucstring &, const std::string &, int caseMode)) &messageBox),
1342
		luabind::def("messageBox",    (void(*)(const std::string &)) &messageBox),
1343
		luabind::def("messageBoxWithHelp",    (void(*)(const ucstring &)) &messageBoxWithHelp),
1344
		luabind::def("messageBoxWithHelp",    (void(*)(const ucstring &, const std::string &)) &messageBoxWithHelp),
1345
		luabind::def("messageBoxWithHelp",    (void(*)(const ucstring &, const std::string &, int caseMode)) &messageBoxWithHelp),
1346
		luabind::def("messageBoxWithHelp",    (void(*)(const std::string &)) &messageBoxWithHelp),
1347
		luabind::def("findReplaceAll",    (std::string(*)(const std::string &,  const std::string &,  const std::string &)) &findReplaceAll),
1348
		luabind::def("findReplaceAll",    (ucstring(*)(const ucstring &,  const ucstring &,  const ucstring &)) &findReplaceAll),
1349
		luabind::def("findReplaceAll",    (ucstring(*)(const ucstring &,  const std::string &,  const std::string &)) &findReplaceAll),
1350
		luabind::def("findReplaceAll",    (ucstring(*)(const ucstring &,  const ucstring &,  const std::string &)) &findReplaceAll),
1351
		luabind::def("findReplaceAll",    (ucstring(*)(const ucstring &,  const std::string &,  const ucstring &)) &findReplaceAll),
1352
		LUABIND_FUNC(getPlayerSelectedSlot),
1353
		LUABIND_FUNC(isInGame),
1354
		LUABIND_FUNC(pauseBGDownloader),
1355
		LUABIND_FUNC(unpauseBGDownloader),
1356
		LUABIND_FUNC(requestBGDownloaderPriority),
1357
		LUABIND_FUNC(getBGDownloaderPriority),
1358
		LUABIND_FUNC(getPatchLastErrorMessage),
1359
		LUABIND_FUNC(isPlayerSlotNewbieLand),
1360
		LUABIND_FUNC(getSkillIdFromName),
1361
		LUABIND_FUNC(getSkillLocalizedName),
1362
		LUABIND_FUNC(getMaxSkillValue),
1363
		LUABIND_FUNC(getBaseSkillValueMaxChildren),
1364
		LUABIND_FUNC(getMagicResistChance),
1365
		LUABIND_FUNC(getDodgeParryChance),
1366
		LUABIND_FUNC(browseNpcWebPage),
1367
		LUABIND_FUNC(clearHtmlUndoRedo),
1368
		LUABIND_FUNC(getDynString),
1369
		LUABIND_FUNC(isDynStringAvailable),
1370
		LUABIND_FUNC(isFullyPatched),
1371
		LUABIND_FUNC(getSheetType),
1372
		LUABIND_FUNC(getSheetName),
1373
		LUABIND_FUNC(getFameIndex),
1374
		LUABIND_FUNC(getFameName),
1375
		LUABIND_FUNC(getFameDBIndex),
1376
		LUABIND_FUNC(getFirstTribeFameIndex),
1377
		LUABIND_FUNC(getNbTribeFameIndex),
1378
		LUABIND_FUNC(getClientCfg),
1379
		LUABIND_FUNC(fileExists),
1380
		LUABIND_FUNC(sendMsgToServer),
1381
		LUABIND_FUNC(sendMsgToServerPvpTag),
1382
		LUABIND_FUNC(isGuildQuitAvailable),
1383
		LUABIND_FUNC(sortGuildMembers),
1384
		LUABIND_FUNC(getNbGuildMembers),
1385
		LUABIND_FUNC(getGuildMemberName),
1386
		LUABIND_FUNC(getGuildMemberGrade),
1387
		LUABIND_FUNC(isR2Player),
1388
		LUABIND_FUNC(getR2PlayerRace),
1389
		LUABIND_FUNC(isR2PlayerMale),
1390
		LUABIND_FUNC(getCharacterSheetSkel),
1391
		LUABIND_FUNC(getSheetId),
1392
		LUABIND_FUNC(getCharacterSheetRegionForce),
1393
		LUABIND_FUNC(getCharacterSheetRegionLevel),
1394
		LUABIND_FUNC(replacePvpEffectParam),
1395
		LUABIND_FUNC(getRegionByAlias),
1396
		LUABIND_FUNC(tell),
1397
		LUABIND_FUNC(isRingAccessPointInReach),
1398
		LUABIND_FUNC(updateTooltipCoords),
1399
		LUABIND_FUNC(secondsSince1970ToHour),
1400
		LUABIND_FUNC(isCtrlKeyDown),
1401
		LUABIND_FUNC(encodeURLUnicodeParam),
1402

1403
		LUABIND_FUNC(getPlayerLevel),
1404
		LUABIND_FUNC(getTargetLevel),
1405
		LUABIND_FUNC(getTargetForceRegion),
1406
		LUABIND_FUNC(getTargetLevelForce),
1407
		LUABIND_FUNC(isTargetNPC),
1408
		LUABIND_FUNC(isTargetPlayer), // return 'true' if the target is an npc
1409
		LUABIND_FUNC(isTargetUser),
1410
		LUABIND_FUNC(isPlayerInPVPMode),
1411
		LUABIND_FUNC(isTargetInPVPMode)
1412
	];
1413

1414
	LUABIND_ENUM(PVP_CLAN::TPVPClan, "TPVPClan", PVP_CLAN::NbClans, PVP_CLAN::toString)
1415
	LUABIND_ENUM(BONUS_MALUS::TBonusMalusSpecialTT, "TBonusMalusSpecialTT", BONUS_MALUS::NbSpecialTT, BONUS_MALUS::toString)
1409 1416

1410 1417
	// inside i18n table
1411 1418
	luabind::module(L, "i18n")
......
1432 1439

1433 1440

1434 1441
	#if !FINAL_VERSION
1435
		LUABIND_FUNC(openDoc)
1442
	luabind::module(L)
1443
	[
1444
		LUABIND_FUNC(openDoc),
1436 1445
		LUABIND_FUNC(launchProgram)
1446
	];
1437 1447
	#endif
1438 1448

1439 1449
	#ifdef NL_OS_WINDOWS
......
1450 1460
			#endif
1451 1461
			}
1452 1462
		};
1453
		luabind::function(L,    "fileLookup",    CMiscFunctions::fileLookup);
1454
		luabind::function(L,    "shellExecute",    CMiscFunctions::shellExecute);
1463
		luabind::module(L)
1464
		[
1465
			luabind::def("fileLookup",    CMiscFunctions::fileLookup),
1466
			luabind::def("shellExecute",    CMiscFunctions::shellExecute)
1467
		];
1455 1468
	#endif
1456 1469
}
1457 1470