增加List处理功能
This commit is contained in:
@@ -13,11 +13,15 @@ extern "C"
|
||||
////////////////////////////////////////////////////////////////////////////////////
|
||||
void registerNPKLuaLibs(lua_State* L)
|
||||
{
|
||||
//register global functions
|
||||
lua_tinker::def(L, "getLastErrorCode", &NPK::getLastErrorCode);
|
||||
lua_tinker::def(L, "getLastErrorMessage", &NPK::getLastErrorMessage);
|
||||
|
||||
lua_tinker::def(L, "createNPKFile", &LuaNPKFile::create);
|
||||
lua_tinker::def(L, "destroyNPKFile", &LuaNPKFile::destroy);
|
||||
|
||||
lua_tinker::def(L, "createEmptyFileList", &LuaNPKFileList::createEmpty);
|
||||
lua_tinker::def(L, "destroyFileList", &LuaNPKFileList::destroy);
|
||||
lua_tinker::def(L, "getLastErrorMessage", &NPK::getLastErrorMessage);
|
||||
|
||||
lua_tinker::class_add<LuaNPKFile>(L, "NPKFile");
|
||||
lua_tinker::class_def<LuaNPKFile>(L, "openPakFile", &LuaNPKFile::openPakFile);
|
||||
@@ -42,8 +46,13 @@ void registerNPKLuaLibs(lua_State* L)
|
||||
lua_tinker::class_mem<LuaNPKFileItemFullInfo>(L, "fileCRC", &LuaNPKFileItemFullInfo::fileCRC);
|
||||
|
||||
lua_tinker::class_add<LuaNPKFileList>(L, "LuaNPKFileList");
|
||||
lua_tinker::class_def<LuaNPKFileList>(L, "loadListFromFile", &LuaNPKFileList::loadListFromFile);
|
||||
lua_tinker::class_def<LuaNPKFileList>(L, "dumpToLocalFile", &LuaNPKFileList::dumpToLocalFile);
|
||||
lua_tinker::class_def<LuaNPKFileList>(L, "mergeOtherListInto", &LuaNPKFileList::mergeOtherListInto);
|
||||
lua_tinker::class_def<LuaNPKFileList>(L, "applyToLocalNPKFiles", &LuaNPKFileList::applyToLocalNPKFiles);
|
||||
lua_tinker::class_def<LuaNPKFileList>(L, "getFileCounts", &LuaNPKFileList::getFileCounts);
|
||||
lua_tinker::class_def<LuaNPKFileList>(L, "getFileItem", &LuaNPKFileList::getFileItem);
|
||||
lua_tinker::class_def<LuaNPKFileList>(L, "getFileItemFromIndex", &LuaNPKFileList::getFileItemFromIndex);
|
||||
lua_tinker::class_def<LuaNPKFileList>(L, "getFileItemFromName", &LuaNPKFileList::getFileItemFromName);
|
||||
|
||||
lua_tinker::class_add<LuaNPKFileStream>(L, "NPKFileStream");
|
||||
lua_tinker::class_def<LuaNPKFileStream>(L, "name", &LuaNPKFileStream::name);
|
||||
@@ -189,12 +198,67 @@ void LuaNPKFileList::destroy(LuaNPKFileList* instance)
|
||||
delete instance;
|
||||
}
|
||||
|
||||
bool LuaNPKFileList::loadListFromFile(const char* wszListFile/*utf8*/, const char* prefix, uint32_t flags, bool bEnableDuplicate)
|
||||
{
|
||||
bool bNpkBase = (flags >> 4) & 1;
|
||||
bool bNpkName = (flags >> 3) & 1;
|
||||
bool bFileOffset = (flags >> 2) & 1;
|
||||
bool bFileSize = (flags >> 1) & 1;
|
||||
bool bFileCRC = flags & 1;
|
||||
|
||||
if (m_pFileList)
|
||||
{
|
||||
std::wstring wstrListFile = convertUtf8StringToWide(wszListFile);
|
||||
return m_pFileList->loadListFromFile(wstrListFile.c_str(), prefix,
|
||||
bNpkBase, bNpkName, bFileOffset, bFileSize, bFileCRC,
|
||||
bEnableDuplicate);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool LuaNPKFileList::dumpToLocalFile(const char* wszListFile/*utf8*/, uint32_t flags)
|
||||
{
|
||||
bool bNpkBase = (flags >> 4) & 1;
|
||||
bool bNpkName = (flags >> 3) & 1;
|
||||
bool bFileOffset = (flags >> 2) & 1;
|
||||
bool bFileSize = (flags >> 1) & 1;
|
||||
bool bFileCRC = flags & 1;
|
||||
if (m_pFileList)
|
||||
{
|
||||
std::wstring wstrListFile = convertUtf8StringToWide(wszListFile);
|
||||
return m_pFileList->dumpToLocalFile(wstrListFile.c_str(),
|
||||
bNpkBase, bNpkName, bFileOffset, bFileSize, bFileCRC
|
||||
);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool LuaNPKFileList::mergeOtherListInto(const LuaNPKFileList* sourceFileList, bool bEnableDuplicate)
|
||||
{
|
||||
if (m_pFileList)
|
||||
{
|
||||
return m_pFileList->mergeOtherListInto(sourceFileList->m_pFileList, bEnableDuplicate);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool LuaNPKFileList::applyToLocalNPKFiles(const char* wszNPKBase/*utf8*/)
|
||||
{
|
||||
if (m_pFileList)
|
||||
{
|
||||
std::wstring strNPKBase = convertUtf8StringToWide(wszNPKBase);
|
||||
return m_pFileList->applyToLocalNPKFiles(strNPKBase.c_str());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
int32_t LuaNPKFileList::getFileCounts(void) const
|
||||
{
|
||||
return m_pFileList ? m_pFileList->getFileCounts() : 0;
|
||||
}
|
||||
|
||||
LuaNPKFileItemFullInfo LuaNPKFileList::getFileItem(int32_t index) const
|
||||
|
||||
LuaNPKFileItemFullInfo LuaNPKFileList::getFileItemFromIndex(int32_t index) const
|
||||
{
|
||||
LuaNPKFileItemFullInfo fullInfo;
|
||||
if (m_pFileList)
|
||||
@@ -203,3 +267,14 @@ LuaNPKFileItemFullInfo LuaNPKFileList::getFileItem(int32_t index) const
|
||||
}
|
||||
return fullInfo;
|
||||
}
|
||||
|
||||
LuaNPKFileItemFullInfo LuaNPKFileList::getFileItemFromName(const char* szKeyName) const
|
||||
{
|
||||
LuaNPKFileItemFullInfo fullInfo;
|
||||
if (m_pFileList)
|
||||
{
|
||||
m_pFileList->getFileItem(szKeyName, &fullInfo);
|
||||
}
|
||||
return fullInfo;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user