您不能選擇超過 %s 個話題 話題必須以字母或數字為開頭,可包含連接號 ('-') 且最長為 35 個字

92 行
2.4 KiB

  1. MJFramework={}
  2. local paths={}
  3. local files={}
  4. function MJFramework.MJImport(name,gameId)
  5. local fileName=string.gsub(name, "%.", "/")
  6. local gameConfig = getSubGameConfig(gameId or app.gameId)
  7. local rootName=gameConfig.rootName
  8. local findMjHsb = string.find(name, 'mj_hsb')
  9. -- 判断是否有旧mj_hsb路径
  10. if not findMjHsb then
  11. local newFileName=string.gsub(fileName, "MJ", gameConfig.fileName)
  12. newFileName=string.gsub(newFileName, "mj", rootName)
  13. local newName=string.gsub(name, "MJ", gameConfig.fileName)
  14. newName=string.gsub(newName, "mj", rootName)
  15. local luaFile = newFileName..".lua"
  16. local luacFile = newFileName..".luac"
  17. local isFileExist = cc.FileUtils:getInstance():isFileExist(luacFile)
  18. if not isFileExist then
  19. isFileExist = cc.FileUtils:getInstance():isFileExist(luaFile)
  20. end
  21. if isFileExist then
  22. name=newName
  23. end
  24. else
  25. local newFileName=string.gsub(fileName, "MJ", gameConfig.fileName)
  26. newFileName=string.gsub(newFileName, "mj_hsb", rootName)
  27. local newName=string.gsub(name, "MJ", gameConfig.fileName)
  28. newName=string.gsub(newName, "mj_hsb", rootName)
  29. local luaFile = newFileName..".lua"
  30. local luacFile = newFileName..".luac"
  31. local isFileExist = cc.FileUtils:getInstance():isFileExist(luacFile)
  32. if not isFileExist then
  33. isFileExist = cc.FileUtils:getInstance():isFileExist(luaFile)
  34. end
  35. if isFileExist then
  36. name=newName
  37. end
  38. end
  39. files[name]=true
  40. print("MJImport:"..name)
  41. return require(name)
  42. end
  43. function MJFramework.ImportWanFa(name,gameId)
  44. local fileName=string.gsub(name, "%.", "/")
  45. local gameConfig = getSubGameConfig(gameId or app.gameId)
  46. local rootName=gameConfig.rootName
  47. local newFileName=string.gsub(fileName, "MJ", gameConfig.fileName)
  48. local newName=string.gsub(name, "MJ", gameConfig.fileName)
  49. local luaFile = newFileName..".lua"
  50. local luacFile = newFileName..".luac"
  51. local isFileExist = cc.FileUtils:getInstance():isFileExist(luacFile)
  52. if not isFileExist then
  53. isFileExist = cc.FileUtils:getInstance():isFileExist(luaFile)
  54. end
  55. if isFileExist then
  56. name=newName
  57. end
  58. print("ImportWanFa:"..name)
  59. files[name]=true
  60. return require(name)
  61. end
  62. function MJFramework.Clean()
  63. for fileName,v in pairs(files) do
  64. print("Clean:"..fileName)
  65. package.loaded[fileName] = nil
  66. end
  67. files={}
  68. end
  69. function MJFramework.MJFrameworkClassImprot(name)
  70. print("MJFrameworkClassImprot:"..name)
  71. files[name]=true
  72. return require(name)
  73. end