Files
tianrunCRM/Assets/trCRM/upgradeRes4Dev/priority/lua/CLLMainLua.lua

195 lines
6.1 KiB
Lua
Raw Normal View History

2020-07-04 14:41:25 +08:00
-- --[[
-- // ooOoo
-- // 8888888
-- // 88" . "88
-- // (| -_- |)
-- // O\ = /O
-- // ____/`---'\____
-- // .' \\| |// `.
-- // / \\||| : |||// \
-- // / _||||| -:- |||||- \
-- // | | \\\ - /// | |
-- // | \_| ''\---/'' |_/ |
-- // \ .-\__ `-` ___/-. /
-- // ___`. .' /--.--\ `. . ___
-- // ."" '< `.___\_<|>_/___.' >' "".
-- // | | : ` - \`.`\ _ /`.`/- ` : | |
-- // \ \ `-. \_ __\ /__ _/ .-` / /
-- //======`-.____`-.___\_____/___.-`____.-'======
-- // `=---='
-- //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-- // 佛祖保佑 永无BUG
-- // 游戏大卖 公司腾飞
-- //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-- --]]
require("public.CLLIncludeBase")
CLLMainLua = {}
local mApplicationPauseDelegate = {}
CLLMainLua.init = function()
MyCfg.mode = GameMode.none
2020-07-08 08:01:34 +08:00
-- 日志logveiw
if ReporterMessageReceiver.self ~= nil then
2020-07-10 23:45:38 +08:00
ReporterMessageReceiver.self.gameObject:SetActive(false)
2020-07-08 08:01:34 +08:00
ReporterMessageReceiver.self.luaPath = "KOK/upgradeRes/priority/lua/toolkit/KKLogListener.lua"
ReporterMessageReceiver.self:setLua()
end
2020-07-04 14:41:25 +08:00
-- 设置显示状态栏
2020-07-10 23:32:07 +08:00
-- Screen.fullScreen = false
2020-07-08 08:01:34 +08:00
-- AndroidStatusBar.setColor(AndroidStatusBar.DEFAULT_BACKGROUND_COLOR)
-- AndroidStatusBar.statusBarState = AndroidStatusBar.States.Visible
-- AndroidStatusBar.dimmed = false
-- AndroidStatusBar.setFlags(AndroidStatusBar.WINDOW_FLAG_FORCE_NOT_FULLSCREEN)
2020-07-10 23:32:07 +08:00
-- CS.ApplicationChrome.statusBarState = CS.ApplicationChrome.States.Visible
-- CS.ApplicationChrome.dimmed = false
2020-07-08 08:01:34 +08:00
2020-07-04 14:41:25 +08:00
--设置帧率
Application.targetFrameRate = 10
2020-07-08 08:01:34 +08:00
-- QualitySettings.SetQualityLevel(1, false)
Time.fixedDeltaTime = 0.5
2020-07-04 14:41:25 +08:00
-- 设置是否测试环境
2020-07-09 08:50:24 +08:00
-- 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
2020-07-04 14:41:25 +08:00
local fps = CLMainBase.self:GetComponent("CLFPS")
fps.displayRect = Rect(10, 200, 640, 40)
2020-07-08 08:01:34 +08:00
fps.enabled = false
-- if Net.self.switchNetType == NetWorkType.publish then
-- fps.enabled = false
-- end
2020-07-04 14:41:25 +08:00
-- 统计sprite的使用情况
if CLCfgBase.self.isEditMode and CLCfgBase.self.isContBorrowSpriteTimes then
UIAtlas.onBorrowSpriteCallback = onBorrowedSpriteCB
end
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 = 10
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()
2020-07-08 08:01:34 +08:00
local success, msg = pcall(CLLMainLua.init)
if not success then
printe(msg)
end
2020-07-04 14:41:25 +08:00
-- 处理开始
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