Files
tianrunCRM/Assets/trCRM/upgradeRes4Dev/priority/lua/CLLMainLua.lua
2020-07-16 23:06:09 +08:00

217 lines
6.9 KiB
Lua
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

-- --[[
-- // ooOoo
-- // 8888888
-- // 88" . "88
-- // (| -_- |)
-- // O\ = /O
-- // ____/`---'\____
-- // .' \\| |// `.
-- // / \\||| : |||// \
-- // / _||||| -:- |||||- \
-- // | | \\\ - /// | |
-- // | \_| ''\---/'' |_/ |
-- // \ .-\__ `-` ___/-. /
-- // ___`. .' /--.--\ `. . ___
-- // ."" '< `.___\_<|>_/___.' >' "".
-- // | | : ` - \`.`\ _ /`.`/- ` : | |
-- // \ \ `-. \_ __\ /__ _/ .-` / /
-- //======`-.____`-.___\_____/___.-`____.-'======
-- // `=---='
-- //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-- // 佛祖保佑 永无BUG
-- // 游戏大卖 公司腾飞
-- //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-- --]]
require("public.CLLIncludeBase")
CLLMainLua = {}
local mApplicationPauseDelegate = {}
CLLMainLua.init = function()
MyCfg.mode = GameMode.none
-- 日志logveiw
if ReporterMessageReceiver.self ~= nil then
ReporterMessageReceiver.self.gameObject:SetActive(false)
ReporterMessageReceiver.self.luaPath = "trCRM/upgradeRes/priority/lua/toolkit/KKLogListener.lua"
ReporterMessageReceiver.self:setLua()
end
-- 设置显示状态栏
local success, msg = pcall(CLLMainLua.setAndroidStatusBar)
if not success then
printe(msg)
end
--设置帧率
Application.targetFrameRate = 30
-- QualitySettings.SetQualityLevel(1, false)
Time.fixedDeltaTime = 0.5
-- 设置是否测试环境
-- if (Prefs.getTestMode()) then
-- local url = Prefs.getTestModeUrl()
-- if (not isNilOrEmpty(url)) then
-- CLAlert.add("Test...", Color.red, -1, 1, false)
-- CLVerManager.self.baseUrl = url
-- end
-- end
local fps = CLMainBase.self:GetComponent("CLFPS")
fps.displayRect = Rect(10, 200, 640, 40)
fps.enabled = false
-- if Net.self.switchNetType == NetWorkType.publish then
-- fps.enabled = false
-- end
-- 统计sprite的使用情况
if CLCfgBase.self.isEditMode and CLCfgBase.self.isContBorrowSpriteTimes then
UIAtlas.onBorrowSpriteCallback = onBorrowedSpriteCB
end
end
function CLLMainLua.setAndroidStatusBar()
printe(SystemInfo.deviceName, "====", SystemInfo.deviceModel)
if CLPathCfg.self.platform ~= "Android" then
return
end
local mode = SystemInfo.deviceModel
if string.find(mode, "huawei") then
AndroidStatusBar.setFlags(AndroidStatusBar.WINDOW_FLAG_FORCE_NOT_FULLSCREEN)
AndroidStatusBar.setColor(AndroidStatusBar.DEFAULT_BACKGROUND_COLOR)
else
ApplicationChrome.statusBarState = ApplicationChrome.States.Visible
ApplicationChrome.dimmed = false
end
-- Screen.fullScreen = false
-- AndroidStatusBar.setColor(AndroidStatusBar.DEFAULT_BACKGROUND_COLOR)
-- AndroidStatusBar.statusBarState = AndroidStatusBar.States.Visible
-- AndroidStatusBar.dimmed = false
-- AndroidStatusBar.setFlags(AndroidStatusBar.WINDOW_FLAG_FORCE_NOT_FULLSCREEN)
-- CS.ApplicationChrome.statusBarState = CS.ApplicationChrome.States.Visible
-- CS.ApplicationChrome.dimmed = false
-- CS.ApplicationChrome.setSoftInputMode(CS.ApplicationChrome.ADJUST_RESIZE);
end
-- 当离线调用
function CLLMainLua.onOffline()
local ok, result = pcall(procOffLine)
if not ok then
printe(result)
end
end
-- 退出游戏确认
function CLLMainLua.exitGmaeConfirm()
if (CLCfgBase.self.isGuidMode) then
return
end
-- 退出确认
if (CLPanelManager.topPanel == nil or (not CLPanelManager.topPanel:hideSelfOnKeyBack())) then
CLUIUtl.showConfirm(Localization.Get("MsgExitGame"), CLLMainLua.doExitGmae, nil)
end
end
-- 退出游戏
function CLLMainLua.doExitGmae(...)
Application.Quit()
end
-- 暂停游戏或恢复游戏
function CLLMainLua.OnApplicationPause(isPause)
if (isPause) then
--设置帧率
Application.targetFrameRate = 1
-- 内存释放
GC.Collect()
else
-- 设置帧率
Application.targetFrameRate = 30
end
for k, v in pairs(mApplicationPauseDelegate) do
Utl.doCallback(v, isPause)
end
end
-- 设置应用暂停代理
function CLLMainLua.addApplicationPauseCallback(callback)
mApplicationPauseDelegate[callback] = callback
end
-- 移除应用暂停代理
function CLLMainLua.removeApplicationPauseCallback(callback)
mApplicationPauseDelegate[callback] = nil
end
function CLLMainLua.OnApplicationQuit()
__ApplicationQuit__ = true
if CLCfgBase.self.isEditMode and CLCfgBase.self.isContBorrowSpriteTimes then
onApplicationPauseCallback4CountAtlas()
end
end
--=========================================
function CLLMainLua.showPanelStart()
if (CLPanelManager.topPanel ~= nil and CLPanelManager.topPanel.name == "PanelStart") then
CLPanelManager.topPanel:show()
else
--异步方式打开页面
CLPanelManager.getPanelAsy("PanelSplash", CLLMainLua.showSplash)
end
end
function CLLMainLua.showSplash(p)
CLPanelManager.showPanel(p)
end
--------------------------------------------
---------- 验证热更新器是否需要更新------------
--------------------------------------------
function CLLMainLua.onCheckUpgrader(isHaveUpdated)
if (isHaveUpdated) then
-- 说明热更新器有更新需要重新加载lua
CLMainBase.self:reStart()
else
if (CLCfgBase.self.isEditMode) then
--主初始化完后,打开下一个页面
CLLMainLua.showPanelStart()
else
-- 先执行一次热更新注意isdoUpgrade=False,因为如果更新splash的atalse资源时会用到
CLLVerManager.init(
nil,
--主初始化完后,打开下一个页面
CLLMainLua.showPanelStart,
false,
""
)
end
end
end
function CLLMainLua.begain()
local success, msg = pcall(CLLMainLua.init)
if not success then
printe(msg)
end
-- 处理开始
if (CLCfgBase.self.isEditMode) then
CLLMainLua.onCheckUpgrader(false)
else
-- 更新热更新器
local ret, msg = pcall(CLLUpdateUpgrader.checkUpgrader, CLLMainLua.onCheckUpgrader)
if not ret then
printe(msg)
CLLMainLua.onCheckUpgrader(false)
end
end
end
--------------------------------------------
--------------------------------------------
CLLMainLua.begain()
--------------------------------------------
--------------------------------------------
return CLLMainLua