add
This commit is contained in:
184
Assets/trCRM/upgradeRes4Dev/priority/lua/CLLMainLua.lua
Normal file
184
Assets/trCRM/upgradeRes4Dev/priority/lua/CLLMainLua.lua
Normal file
@@ -0,0 +1,184 @@
|
||||
-- --[[
|
||||
-- // ooOoo
|
||||
-- // 8888888
|
||||
-- // 88" . "88
|
||||
-- // (| -_- |)
|
||||
-- // O\ = /O
|
||||
-- // ____/`---'\____
|
||||
-- // .' \\| |// `.
|
||||
-- // / \\||| : |||// \
|
||||
-- // / _||||| -:- |||||- \
|
||||
-- // | | \\\ - /// | |
|
||||
-- // | \_| ''\---/'' |_/ |
|
||||
-- // \ .-\__ `-` ___/-. /
|
||||
-- // ___`. .' /--.--\ `. . ___
|
||||
-- // ."" '< `.___\_<|>_/___.' >' "".
|
||||
-- // | | : ` - \`.`\ _ /`.`/- ` : | |
|
||||
-- // \ \ `-. \_ __\ /__ _/ .-` / /
|
||||
-- //======`-.____`-.___\_____/___.-`____.-'======
|
||||
-- // `=---='
|
||||
-- //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
-- // 佛祖保佑 永无BUG
|
||||
-- // 游戏大卖 公司腾飞
|
||||
-- //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
-- --]]
|
||||
require("public.CLLIncludeBase")
|
||||
CLLMainLua = {}
|
||||
|
||||
local mApplicationPauseDelegate = {}
|
||||
|
||||
CLLMainLua.init = function()
|
||||
MyCfg.mode = GameMode.none
|
||||
-- 设置显示状态栏
|
||||
AndroidStatusBar.setFlags(AndroidStatusBar.WINDOW_FLAG_FORCE_NOT_FULLSCREEN)
|
||||
AndroidStatusBar.setColor(AndroidStatusBar.DEFAULT_WHITE_COLOR)
|
||||
--设置帧率
|
||||
Application.targetFrameRate = 10
|
||||
QualitySettings.SetQualityLevel(1, false)
|
||||
Time.fixedDeltaTime = 60
|
||||
|
||||
-- 设置是否测试环境
|
||||
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)
|
||||
|
||||
if Net.self.switchNetType == NetWorkType.publish then
|
||||
fps.enabled = false
|
||||
end
|
||||
|
||||
-- 日志logveiw
|
||||
if ReporterMessageReceiver.self ~= nil then
|
||||
ReporterMessageReceiver.self.luaPath = "KOK/upgradeRes/priority/lua/toolkit/KKLogListener.lua"
|
||||
ReporterMessageReceiver.self:setLua()
|
||||
end
|
||||
|
||||
-- 统计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()
|
||||
pcall(CLLMainLua.init)
|
||||
|
||||
-- 处理开始
|
||||
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
|
||||
Reference in New Issue
Block a user