You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

73 lines
1.7 KiB

  1. PKFramework={}
  2. local paths={}
  3. local files={}
  4. function PKFramework.PKImport(name,gameId)
  5. local fileName=string.gsub(name, "%.", "/")
  6. local gameConfig = getSubGameConfig(gameId or app.gameId)
  7. local rootName=gameConfig.rootName
  8. local newFileName=string.gsub(fileName, "PK", gameConfig.fileName)
  9. newFileName=string.gsub(newFileName, "pk_base", rootName)
  10. local newName=string.gsub(name, "PK", gameConfig.fileName)
  11. newName=string.gsub(newName, "pk_base", rootName)
  12. local luaFile = newFileName..".lua"
  13. local luacFile = newFileName..".luac"
  14. local isFileExist = cc.FileUtils:getInstance():isFileExist(luacFile)
  15. if not isFileExist then
  16. isFileExist = cc.FileUtils:getInstance():isFileExist(luaFile)
  17. end
  18. if isFileExist then
  19. name=newName
  20. end
  21. files[name]=true
  22. print("PKImport:"..name)
  23. return require(name)
  24. end
  25. function PKFramework.ImportWanFa(name,gameId)
  26. local fileName=string.gsub(name, "%.", "/")
  27. local gameConfig = getSubGameConfig(gameId or app.gameId)
  28. local rootName=gameConfig.rootName
  29. local newFileName=string.gsub(fileName, "PK", gameConfig.fileName)
  30. local newName=string.gsub(name, "PK", gameConfig.fileName)
  31. local luaFile = newFileName..".lua"
  32. local luacFile = newFileName..".luac"
  33. local isFileExist = cc.FileUtils:getInstance():isFileExist(luacFile)
  34. if not isFileExist then
  35. isFileExist = cc.FileUtils:getInstance():isFileExist(luaFile)
  36. end
  37. if isFileExist then
  38. name=newName
  39. end
  40. print("ImportWanFa:"..name)
  41. files[name]=true
  42. return require(name)
  43. end
  44. function PKFramework.Clean()
  45. for fileName,v in pairs(files) do
  46. print("Clean:"..fileName)
  47. package.loaded[fileName] = nil
  48. end
  49. files={}
  50. end
  51. function PKFramework.PKFrameworkClassImprot(name)
  52. print("PKFrameworkClassImprot:"..name)
  53. files[name]=true
  54. return require(name)
  55. end