local TableBG = import('Game.Data.TableBG') local M = {} setmetatable(M, { __index = PlayBackView }) local pk_default_bg = 1 local pk_bg_config = { { id = 1, url = "base/main_poker/bg/bg1", thumb = "ui://Main_Poker/bg1" }, { id = 2, url = "base/main_poker/bg/bg2", thumb = "ui://Main_Poker/bg2" }, { id = 3, url = "base/main_poker/bg/bg3", thumb = "ui://Main_Poker/bg3" }, } function M:InitView(url, ex_defaultbg, ex_bgconfig) UIPackage.AddPackage("base/main_poker/ui/Main_Poker") PlayBackView.InitView(self, url) local _view = self._view local default_bg = ex_defaultbg or pk_default_bg local bg_config = ex_bgconfig or pk_bg_config TableBG.LoadTableBG(default_bg, self._room.game_id, self._root_view, bg_config) UpdateBeat:Add(self.OnUpdate, self) end function M:NextRecordPlay() self:RemoveCursor() local result = PlayBackView.NextRecordPlay(self) if not result then return end self:ChangePlayState(true) self._speed = 1 self._playFoward = true self:ChangeTextSpeed() end function M:LastRecordPlay() self:RemoveCursor() local result = PlayBackView.LastRecordPlay(self) if not result then return end self:ChangePlayState(true) self._speed = 1 self._playFoward = true self:ChangeTextSpeed() end function M:RestartRecordPlay() self:ChangeAlpha() self._currentStep = 0 self._speed = 1 self._playFoward = true self:ChangeTextSpeed() self:ChangePlayState(true) end function M:Play() self:ChangeAlpha() self:ChangePlayState(not self._play) if not self._play then return end if (self._currentStep == #self.cmdList and self._playFoward) or (self._currentStep == 0 and not self._playFoward) then self._currentStep = 0 self._speed = 1 self._playFoward = true self:ChangeTextSpeed() end end function M:ChangePlayState(state) self._play = state self:ChangeTextSpeed() local btn_play = self._view:GetChild("panel_record"):GetChild("btn_play") if self._play then btn_play:GetController("state").selectedIndex = 1 else btn_play:GetController("state").selectedIndex = 0 end --开始时,隐藏显示结算界面 if state then if self.result then self.result:Destroy() self.result = nil end end end function M:ChangeTextSpeed() -- local str1 = self._play and self._speed or "" -- self._view:GetChild("panel_record"):GetChild("tex_speed").text = str1 -- local str2 = not self._play and (self._playFoward and "播放暂停" or "回退暂停") or -- self._playFoward and (self._speed == 1 and "播放" or "快进") or (self._speed == 1 and "回退" or "快退") -- self._view:GetChild("panel_record"):GetChild("tex_2").text = str2 -- local str3 = self._play and "倍速度" or "" -- self._view:GetChild("panel_record"):GetChild("tex_1").text = str3 self._record:GetChild('tex_speed').text = self._speed end function M:CmdLeftArrows() self:ChangeAlpha() self:ChangePlayState(true) if not self._playFoward then if self._speed < 5 then self._speed = self._speed + 1 else self._speed = 1 end self:ChangeTextSpeed() else self._speed = 1 self._playFoward = false self:ChangeTextSpeed() end end function M:CmdRightArrows() self:ChangeAlpha() self:ChangePlayState(true) if self._playFoward then if self._speed < 5 then self._speed = self._speed + 1 else self._speed = 1 end self:ChangeTextSpeed() else self._speed = 1 self._playFoward = true self:ChangeTextSpeed() end end function M:MaxSpeedArriws() self:ChangeAlpha() self:ChangePlayState(true) self._speed = 30 end function M:OnUpdate() if self._play then if (self._currentStep == #self.cmdList and self._playFoward) then self:ChangePlayState(false) ViewUtil.ErrorTip(nil, "当前已是录像结尾了,再次点击播放按钮可重新播放") return elseif (self._currentStep == 0 and not self._playFoward) then self:ChangePlayState(false) ViewUtil.ErrorTip(nil, "当前已是录像开头了,再次点击播放按钮可重新播放") return end self._timer = self._timer + Time.deltaTime if self._timer >= 1 / self._speed then self._timer = 0 local step = self._playFoward and 1 or -1 self._currentStep = self._currentStep + step self:ShowStep(self._currentStep) end end end function M:Destroy() UpdateBeat:Remove(self.OnUpdate, self) PlayBackView.Destroy(self) end return M