local function __ShowTip(_version_view,text, callback) local ctr_state = _version_view:GetController("state") ctr_state.selectedIndex = 1 _version_view:GetChild("tex_tip").text = text _version_view:GetChild("btn_ok").onClick:Set(function() ctr_state.selectedIndex = 0 if (callback ~= null) then callback:DynamicInvoke() end end) local btn_close = _version_view:GetChild("btn_close") if btn_close then btn_close.onClick:Set(function() _version_view:Dispose() _version_view = nil end) end end local function __update_check(data,onback, _version_view) local tex_tip = _version_view:GetChild("tex_info") for k,game_data in ipairs(data) do local asset_path = game_data["bundle"] asset_path = string.gsub(asset_path,"%.", "/") local local_version = Version.DEFUALT local server_version = Version(game_data["version"]) local version_update = Hotupdate(asset_path .. "/", local_version, server_version) version_update.AssetName = game_data["name"] version_update:SetTipCallback(function(text,callback) __ShowTip(_version_view,text, callback) end) version_update:LoadAsset() while (not version_update.Done) do onback(version_update.Progress, false) tex_tip.text = version_update.TextTip coroutine.step() end ResourcesManager.ReadAssetConfig(asset_path) onback(0, false) end onback(1, true) end ExtendHotupdate = { -- 正常 VERSION_NORMAL = 0, -- 下载 VERSION_DOWN = 1, -- 更新 VERSION_UPDATE = 2, } function ExtendHotupdate.UpdateGameList(list, callback) if (not GameApplication.Instance.buildApp) then callback() return end local _version_view = UIPackage.CreateObjectFromURL("ui://Hotupdate/Version") _version_view.x = (GRoot.inst.width - _version_view.width) / 2 _version_view:GetChild("tex_info").text = "正在检查资源。。。" local _pd = _version_view:GetChild("pb_progress") _pd.value = 0 GRoot.inst:AddChild(_version_view) coroutine.start(__update_check,list, function(progress, finish) _pd.value = progress * 100 if (finish) then callback() _version_view:Dispose() _version_view = nil end end, _version_view) end function ExtendHotupdate.UpdateGame(data,callback) if (not GameApplication.Instance.buildApp) then ExtendManager.UpdateExtend(data) if callback then callback() end return end ViewUtil.CloseModalWait() NetResetConnectWindow.CloseNetReset() local _version_view = UIPackage.CreateObjectFromURL("ui://Common/ExtendHotUpdate") _version_view:GetChild("tex_info").text = "正在检查资源。。。" local _pd = _version_view:GetChild("pb_progress") _pd.value = 0 _version_view:AddRelation(GRoot.inst, RelationType.Size) GRoot.inst:AddChild(_version_view) _version_view:MakeFullScreen() coroutine.start(__update_check,{data}, function(progress, finish) _pd.value = progress * 100 if (finish) then ExtendManager.UpdateExtend(data) if callback then callback() end _version_view:Dispose() end end, _version_view) end function ExtendHotupdate.CheckVersion(game_data) if (not GameApplication.Instance.buildApp) then ExtendManager.UpdateExtend(game_data) return ExtendHotupdate.VERSION_NORMAL end if (not game_data) then return ExtendHotupdate.VERSION_DOWN end local asset_path = game_data.bundle asset_path = string.gsub(asset_path,'%.', '/') local local_version = Hotupdate.GetLocalVersion(asset_path.. "/") local server_version =Version(game_data.version) if not local_version then return ExtendHotupdate.VERSION_DOWN end if local_version:ContainAll(server_version) then return ExtendHotupdate.VERSION_UPDATE end ResourcesManager.ReadAssetConfig(asset_path) ExtendManager.UpdateExtend(game_data) return ExtendHotupdate.VERSION_NORMAL end