源战役客户端
25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

93 lines
2.3 KiB

  1. GamePlatformRes = GamePlatformRes or {}
  2. local GamePlatformRes = GamePlatformRes
  3. GamePlatformRes.Define =
  4. {
  5. UPDATE_BG = "phone/update.jpg",
  6. LOGIN_BG = "phone/login.jpg",
  7. CREATE_ROLE_BG = "phone/create_role.jpg",
  8. LOAD_SCENE_BG = "phone/load_scene.jpg",
  9. LOGIN_LOGO = "phone/login_logo.png",
  10. HEAD_LOGO = "phone/head_logo.png",
  11. }
  12. GamePlatformRes.Data =
  13. {
  14. }
  15. GamePlatformRes.APPRES =
  16. {
  17. }
  18. GamePlatformRes.InitSucceed = false
  19. function GamePlatformRes.Load()
  20. local need_load_count = 0
  21. local cur_load_count = 0
  22. local check_load_finish = function()
  23. cur_load_count = cur_load_count + 1
  24. if cur_load_count >= need_load_count then
  25. GamePlatformRes.InitSucceed = true
  26. end
  27. end
  28. local loadback = function(res, result)
  29. if result then
  30. local real_res = res
  31. if ClientConfig.phone_dir then
  32. real_res = GamePlatformRes.APPRES[res]
  33. end
  34. GamePlatformRes.Data[real_res] = true
  35. end
  36. check_load_finish()
  37. end
  38. local plat_res = GameConfig:GetValue("PlatCustomRes") -- "login.jpg,login_logo.png"
  39. if plat_res ~= "" then
  40. local res_list = Split(plat_res,",")
  41. need_load_count = #res_list
  42. local phone_dir = ClientConfig.phone_dir or "phone"
  43. for index,res_name in pairs(res_list) do
  44. local app_path = phone_dir .. "/" .. res_name
  45. local res_path = "phone/" .. res_name
  46. if ClientConfig.phone_dir then
  47. res_path = GamePlatformRes.APPRES[app_path]
  48. end
  49. if res_path then
  50. local full_path = Util.DataPath .. res_path
  51. local fils_exist = Util.FileExists(full_path)
  52. if not fils_exist then
  53. resMgr:CopyFileFormApp(app_path,res_path,loadback)
  54. else
  55. GamePlatformRes.Data[res_path] = true
  56. check_load_finish()
  57. end
  58. else
  59. check_load_finish()
  60. end
  61. end
  62. else
  63. GamePlatformRes.InitSucceed = true
  64. end
  65. end
  66. function GamePlatformRes.LoadPlatImage(res_name,raw_image,load_callback,is_rawimage)
  67. if ClientConfig.custom_logo_mode or GamePlatformRes.Data[res_name] then
  68. local func = function( image )
  69. if image and raw_image and not raw_image:IsDestroyed() then
  70. if is_rawimage then
  71. raw_image.texture = image
  72. else
  73. raw_image.sprite = Util.TextureToSprite(image)
  74. end
  75. raw_image:SetNativeSize()
  76. end
  77. if load_callback then
  78. load_callback()
  79. end
  80. end
  81. local local_path = Util.DataPath .. res_name
  82. Util.LoadRawTexture(local_path,func)
  83. end
  84. end