yunque9/lua_probject/extend_project/extend/poker/mushi/MuShi_RightPanelView.lua

67 lines
2.2 KiB
Lua

local MainRightPanelView = require("Game.View.MainRightPanelView")
local MuShi_RightPanelView = {}
local MuShi_SettingView = import('extend.poker.mushi.MuShi_SettingView')
local M = MuShi_RightPanelView
local function __init(self,mainView,view)
local right_panel = view
local btn_setting = right_panel:GetChild("btn_setting")
btn_setting.onClick:Set(function()
local _settingView = MuShi_SettingView.new(self._blur_view)
_settingView:Show()
end)
self._tex_data = right_panel:GetChild("tex_data")
self._tex_time = right_panel:GetChild("tex_time")
self._pb_batteryLevel = right_panel:GetChild("pb_batteryLevel")
self._xinhao = right_panel:GetController("xinhao")
self.ctr_xh = right_panel:GetChild("gcm_xinhao"):GetController("c1")
self.ctr_wifi = right_panel:GetChild("gcm_wifi"):GetController("c1")
self._tex_ping = right_panel:GetChild("gcm_xinhao"):GetChild("n7")
self.ctr_log = right_panel:GetController("log")
local btn_log = right_panel:GetChild("btn_log")
btn_log.onClick:Set(function()
if self.onLogCallback then
self.onLogCallback()
end
end)
self._total_time = 0
self:__UpdateTime()
-- self._timer = Timer.New(handler(self,self.__UpdateTime),10,-1,true)
-- self._timer:Start()
end
function MuShi_RightPanelView.new(mainView,view)
setmetatable(M, {__index = MainRightPanelView})
local self = setmetatable({}, {__index = M})
self.class = "MuShi_RightPanelView"
__init(self,mainView,view)
return self
end
function M:__UpdateTime()
self._tex_data.text = os.date("%Y-%m-%d")
self._tex_time.text = os.date("%H:%M")
if Application.platform == RuntimePlatform.IPhonePlayer or Application.platform == RuntimePlatform.Android then
self._pb_batteryLevel.value = GameApplication.Instance:GetBatteryLevel()
end
local NetworkReachability = UnityEngine.NetworkReachability
local _client = ControllerManager.GameNetClinet
if not _client then return end
local ping = _client:getAveragePingTime()
if not ping then return end
ping = math.floor(ping / 2)
if ping > 300 then ping =300 end
if ping <= 100 then
self.ctr_xh.selectedIndex = 0
elseif ping <= 300 then
self.ctr_xh.selectedIndex = 1
else
self.ctr_xh.selectedIndex = 2
end
self._tex_ping.text = ping .. "ms"
end
return M