初始化提交
commit
623618f78e
|
|
@ -0,0 +1,116 @@
|
||||||
|
{
|
||||||
|
// 使用 IntelliSense 了解相关属性。
|
||||||
|
// 悬停以查看现有属性的描述。
|
||||||
|
// 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
|
||||||
|
"version": "0.2.0",
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
"name": "Cocos2-launch",
|
||||||
|
"type": "lua",
|
||||||
|
"request": "launch",
|
||||||
|
"runtimeType": "Cocos2",
|
||||||
|
"localRoot": "${workspaceRoot}",
|
||||||
|
"commandLine": "-workdir ${workspaceRoot}/../ -file src/main.lua",
|
||||||
|
"port": 7003,
|
||||||
|
"exePath": "",
|
||||||
|
"fileExtNames": [
|
||||||
|
".lua",
|
||||||
|
".txt",
|
||||||
|
".lua.txt",
|
||||||
|
".bytes"
|
||||||
|
],
|
||||||
|
"isFoxGloryProject": false,
|
||||||
|
"printType": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "COCOS(remote debugging)",
|
||||||
|
"type": "lua",
|
||||||
|
"request": "attach",
|
||||||
|
"runtimeType": "Cocos2",
|
||||||
|
"localRoot": "${workspaceRoot}",
|
||||||
|
"port": 7003,
|
||||||
|
"fileExtNames": [
|
||||||
|
".lua",
|
||||||
|
".txt",
|
||||||
|
".lua.txt",
|
||||||
|
".bytes"
|
||||||
|
],
|
||||||
|
"isFoxGloryProject": false,
|
||||||
|
"printType": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Unity-ulua",
|
||||||
|
"type": "lua",
|
||||||
|
"request": "attach",
|
||||||
|
"runtimeType": "Unity",
|
||||||
|
"localRoot": "${workspaceRoot}",
|
||||||
|
"fileExtNames": [
|
||||||
|
".lua",
|
||||||
|
".txt",
|
||||||
|
".lua.txt",
|
||||||
|
".bytes"
|
||||||
|
],
|
||||||
|
"port": 7003,
|
||||||
|
"printType": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Unity-slua",
|
||||||
|
"type": "lua",
|
||||||
|
"request": "attach",
|
||||||
|
"runtimeType": "Unity",
|
||||||
|
"localRoot": "${workspaceRoot}",
|
||||||
|
"fileExtNames": [
|
||||||
|
".lua",
|
||||||
|
".txt",
|
||||||
|
".lua.txt",
|
||||||
|
".bytes"
|
||||||
|
],
|
||||||
|
"port": 7003,
|
||||||
|
"printType": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Unity-xlua",
|
||||||
|
"type": "lua",
|
||||||
|
"request": "attach",
|
||||||
|
"runtimeType": "Unity",
|
||||||
|
"localRoot": "${workspaceRoot}",
|
||||||
|
"fileExtNames": [
|
||||||
|
".lua",
|
||||||
|
".txt",
|
||||||
|
".lua.txt",
|
||||||
|
".bytes"
|
||||||
|
],
|
||||||
|
"port": 7003,
|
||||||
|
"printType": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "OpenResty",
|
||||||
|
"type": "lua",
|
||||||
|
"request": "attach",
|
||||||
|
"runtimeType": "OpenResty",
|
||||||
|
"localRoot": "${workspaceRoot}",
|
||||||
|
"port": 7003,
|
||||||
|
"fileExtNames": [
|
||||||
|
".lua"
|
||||||
|
],
|
||||||
|
"printType": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "LuaTest",
|
||||||
|
"type": "lua",
|
||||||
|
"request": "launch",
|
||||||
|
"runtimeType": "LuaTest",
|
||||||
|
"mainFile": "${fileBasenameNoExtension}",
|
||||||
|
"localRoot": "${fileDirname}",
|
||||||
|
"curFileExtname": "${fileExtname}",
|
||||||
|
"fileExtNames": [
|
||||||
|
".lua",
|
||||||
|
".txt",
|
||||||
|
".lua.txt",
|
||||||
|
".bytes"
|
||||||
|
],
|
||||||
|
"port": 7003,
|
||||||
|
"printType": 1
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,8 @@
|
||||||
|
{
|
||||||
|
"cSpell.words": [
|
||||||
|
"card",
|
||||||
|
"clear",
|
||||||
|
"list"
|
||||||
|
],
|
||||||
|
"editor.snippetSuggestions": "bottom"
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,17 @@
|
||||||
|
{
|
||||||
|
// 使用 IntelliSense 了解相关属性。
|
||||||
|
// 悬停以查看现有属性的描述。
|
||||||
|
// 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
|
||||||
|
"version": "0.2.0",
|
||||||
|
"configurations": [
|
||||||
|
|
||||||
|
|
||||||
|
{
|
||||||
|
"type": "pwa-chrome",
|
||||||
|
"request": "launch",
|
||||||
|
"name": "Launch Chrome against localhost",
|
||||||
|
"url": "http://localhost:8080",
|
||||||
|
"webRoot": "${workspaceFolder}"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
{
|
||||||
|
"editor.snippetSuggestions": "bottom"
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,192 @@
|
||||||
|
--网络核心功能处理类
|
||||||
|
--author:--
|
||||||
|
|
||||||
|
-- a net client
|
||||||
|
NetClient = {
|
||||||
|
}
|
||||||
|
|
||||||
|
ConnectionProtocol = {
|
||||||
|
Tcp = 0,
|
||||||
|
--http 短连接
|
||||||
|
Web = 1,
|
||||||
|
}
|
||||||
|
|
||||||
|
SocketCode = {
|
||||||
|
--连接成功
|
||||||
|
Connect = 0,
|
||||||
|
--断开
|
||||||
|
Disconnect = 1,
|
||||||
|
--未知异常
|
||||||
|
Exception = 2,
|
||||||
|
--连接服务异常
|
||||||
|
ExceptionOnConnect = 3,
|
||||||
|
--发送数据流错误
|
||||||
|
SendError = 4,
|
||||||
|
--接收服务器数据流异常
|
||||||
|
ExceptionOnReceive = 5,
|
||||||
|
--服务器连接超时
|
||||||
|
TimeoutDisconnect = 6,
|
||||||
|
--服务器断开连接
|
||||||
|
DisconnectByServer = 7,
|
||||||
|
--客户端网络异常
|
||||||
|
NetworkException = 8,
|
||||||
|
--连接安全异常,一般为防火墙阻止
|
||||||
|
SecurityExceptionOnConnect = 9
|
||||||
|
}
|
||||||
|
|
||||||
|
---
|
||||||
|
-- @type NetClient
|
||||||
|
local R = {
|
||||||
|
--网络地址
|
||||||
|
hsot = "",
|
||||||
|
--网络端口
|
||||||
|
port = 0,
|
||||||
|
--session
|
||||||
|
session = "",
|
||||||
|
--网络类型
|
||||||
|
protocol = ConnectionProtocol.Tcp,
|
||||||
|
--c#端处理类
|
||||||
|
c__netClient = nil,
|
||||||
|
--拦截
|
||||||
|
holdCallback = nil
|
||||||
|
}
|
||||||
|
|
||||||
|
local LuaNetClient = taurus.unity.LuaNetClient
|
||||||
|
|
||||||
|
--- Create a new NetClient
|
||||||
|
-- @function [parent=#NetClient] new
|
||||||
|
-- @param #string host
|
||||||
|
-- @param #string game
|
||||||
|
-- @param #number protocol
|
||||||
|
-- @return #NetClient the created NetClient
|
||||||
|
function NetClient.new(host, game, protocol)
|
||||||
|
local self = {}
|
||||||
|
self.host = host or ""
|
||||||
|
self.game = game or ""
|
||||||
|
self.protocol = protocol or ConnectionProtocol.Tcp
|
||||||
|
-- self.responseMap = {}
|
||||||
|
self.onevent = event("onevent", false)
|
||||||
|
self.onconnect = event("onconnect", false)
|
||||||
|
--print("222222222222222222222222222222222222222222 ",host," ",host," ",game," ",self.protocol)
|
||||||
|
|
||||||
|
self.c__netClient = LuaNetClient(host, game, self, self.protocol)
|
||||||
|
self.c__netClient:SetCallBackListener(R.c__ondata)
|
||||||
|
self.c__netClient:SetNetEventListener(R.c__onevent)
|
||||||
|
self.c__netClient:SetNetConnectListener(R.c__onconnect)
|
||||||
|
setmetatable(self, { __index = R })
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
function R.connect(self)
|
||||||
|
if self.c__netClient == nil then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
self.c__netClient:Connect()
|
||||||
|
end
|
||||||
|
|
||||||
|
local TYPE_STRING = "string"
|
||||||
|
local TYPE_FUNC = "function"
|
||||||
|
local TYPE_TABLE = "table"
|
||||||
|
local NULL_JSON = "{}"
|
||||||
|
|
||||||
|
--- send
|
||||||
|
function R.send(self, cmd, data, callback)
|
||||||
|
if (debug_print) then
|
||||||
|
print("send host:" .. self.host)
|
||||||
|
end
|
||||||
|
if self.c__netClient == nil then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
if callback and type(callback) ~= TYPE_FUNC then return end
|
||||||
|
if data then
|
||||||
|
if type(data) ~= TYPE_TABLE then return end
|
||||||
|
end
|
||||||
|
local str = NULL_JSON
|
||||||
|
if data then
|
||||||
|
str = json.encode(data)
|
||||||
|
end
|
||||||
|
self.c__netClient:Send(cmd, str, callback)
|
||||||
|
end
|
||||||
|
|
||||||
|
---c#网络层回调函数
|
||||||
|
function R.c__ondata(self, cmd, result, data, func)
|
||||||
|
local _response = nil
|
||||||
|
|
||||||
|
if type(data) == TYPE_STRING and string.len(data) > 0 then
|
||||||
|
_response = json.decode(data)
|
||||||
|
end
|
||||||
|
local new_response = {}
|
||||||
|
new_response.ReturnCode = result
|
||||||
|
new_response.Data = _response
|
||||||
|
|
||||||
|
|
||||||
|
if self.holdCallback ~= nil then
|
||||||
|
if self.holdCallback(new_response) then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
func(new_response)
|
||||||
|
end
|
||||||
|
|
||||||
|
function R.setSession(self, session)
|
||||||
|
printlog("setSession==>>>", session)
|
||||||
|
|
||||||
|
self.session = session
|
||||||
|
if self.c__netClient == nil then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
self.c__netClient.Session = session
|
||||||
|
end
|
||||||
|
|
||||||
|
function R.getSession(self)
|
||||||
|
printlog("getSession===>>>", self.session)
|
||||||
|
return self.session
|
||||||
|
end
|
||||||
|
|
||||||
|
function R.getAveragePingTime(self)
|
||||||
|
if self.c__netClient == nil then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
return self.c__netClient.AveragePingTime
|
||||||
|
end
|
||||||
|
|
||||||
|
---c#网络层回调函数
|
||||||
|
function R.c__onevent(self, cmd, data)
|
||||||
|
local new_response = {}
|
||||||
|
local _response = data and json.decode(data) or nil
|
||||||
|
new_response.Command = cmd
|
||||||
|
new_response.Data = _response
|
||||||
|
self.onevent(new_response)
|
||||||
|
end
|
||||||
|
|
||||||
|
function R.clearActionQueue(self)
|
||||||
|
if self.c__netClient == nil then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
self.c__netClient:ClearResponse()
|
||||||
|
end
|
||||||
|
|
||||||
|
---c#网络层回调函数
|
||||||
|
function R.c__onconnect(self, code)
|
||||||
|
if (debug_print) then
|
||||||
|
print("codeccccccccccccccccccccccccccccccccccccccc" .. code)
|
||||||
|
end
|
||||||
|
self.onconnect(code)
|
||||||
|
end
|
||||||
|
|
||||||
|
function R.clearEvent(self)
|
||||||
|
self.onevent:Clear()
|
||||||
|
self.onconnect:Clear()
|
||||||
|
end
|
||||||
|
|
||||||
|
function R.setHold(self, func)
|
||||||
|
self.holdcallback = func
|
||||||
|
end
|
||||||
|
|
||||||
|
function R.destroy(self)
|
||||||
|
if self.c__netClient then self.c__netClient:Destroy() end
|
||||||
|
self.onconnect:Clear()
|
||||||
|
self.onevent:Clear()
|
||||||
|
self.c__netClient = nil
|
||||||
|
end
|
||||||
|
|
@ -0,0 +1,89 @@
|
||||||
|
Queue = {}
|
||||||
|
|
||||||
|
|
||||||
|
function Queue.new(capacity)
|
||||||
|
local self = {}
|
||||||
|
setmetatable(self,{__index = Queue})
|
||||||
|
self.capacity = capacity
|
||||||
|
self.queue = {}
|
||||||
|
self.size_ = 0
|
||||||
|
self.head = -1
|
||||||
|
self.rear = -1
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
function Queue:Enqueue(element)
|
||||||
|
if self.size_ == 0 then
|
||||||
|
self.head = 0
|
||||||
|
self.rear = 1
|
||||||
|
self.size_ = 1
|
||||||
|
self.queue[self.rear] = element
|
||||||
|
else
|
||||||
|
local temp = (self.rear + 1) % self.capacity
|
||||||
|
--print("1111111111111111111====>>>>")
|
||||||
|
--print(temp)
|
||||||
|
if temp == self.head then
|
||||||
|
error("Error: capacity is full.")
|
||||||
|
ViewUtil.ErrorTip(10001,"Error: capacity is full.")
|
||||||
|
return
|
||||||
|
else
|
||||||
|
self.rear = temp
|
||||||
|
end
|
||||||
|
|
||||||
|
self.queue[self.rear] = element
|
||||||
|
self.size_ = self.size_ + 1
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
function Queue:Dequeue()
|
||||||
|
if self:IsEmpty() then
|
||||||
|
ViewUtil.ErrorTip(10002,"Error: The Queue is empty.")
|
||||||
|
error("Error: The Queue is empty.")
|
||||||
|
return
|
||||||
|
end
|
||||||
|
self.size_ = self.size_ - 1
|
||||||
|
self.head = (self.head + 1) % self.capacity
|
||||||
|
local value = self.queue[self.head]
|
||||||
|
return value
|
||||||
|
end
|
||||||
|
|
||||||
|
function Queue:Clear()
|
||||||
|
self.queue = nil
|
||||||
|
self.queue = {}
|
||||||
|
self.size_ = 0
|
||||||
|
self.head = -1
|
||||||
|
self.rear = -1
|
||||||
|
end
|
||||||
|
|
||||||
|
function Queue:IsEmpty()
|
||||||
|
if self.size_ == 0 then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
function Queue:Count()
|
||||||
|
return self.size_
|
||||||
|
end
|
||||||
|
|
||||||
|
function Queue:dump()
|
||||||
|
local h = self.head
|
||||||
|
local r = self.rear
|
||||||
|
local str = nil
|
||||||
|
local first_flag = true
|
||||||
|
while h ~= r do
|
||||||
|
if first_flag == true then
|
||||||
|
str = "{"..self.queue[h]
|
||||||
|
h = (h + 1) % self.capacity
|
||||||
|
first_flag = false
|
||||||
|
else
|
||||||
|
str = str..","..self.queue[h]
|
||||||
|
h = (h + 1) % self.capacity
|
||||||
|
end
|
||||||
|
end
|
||||||
|
str = str..","..self.queue[r].."}"
|
||||||
|
if(debug_print) then
|
||||||
|
print(str)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
@ -0,0 +1,96 @@
|
||||||
|
TimerManager={}
|
||||||
|
|
||||||
|
local timerList={}
|
||||||
|
|
||||||
|
local isEnableTimer=false
|
||||||
|
|
||||||
|
function TimerManager.New()
|
||||||
|
timerList={}
|
||||||
|
|
||||||
|
UpdateBeat:Add(TimerManager.UpdateTimer)
|
||||||
|
isEnableTimer=true
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function TimerManager.IsHas(funcIns)
|
||||||
|
if timerList then
|
||||||
|
for k,v in pairs(timerList) do
|
||||||
|
if v.Self==funcIns then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function TimerManager.AddTimer(timerFunc,funcIns)
|
||||||
|
if timerFunc then
|
||||||
|
if TimerManager.IsHas(funcIns) then
|
||||||
|
printlog("已经存在计时器对象")
|
||||||
|
return
|
||||||
|
end
|
||||||
|
local tempList={}
|
||||||
|
tempList.func=timerFunc
|
||||||
|
tempList.Self=funcIns
|
||||||
|
table.insert(timerList,tempList)
|
||||||
|
else
|
||||||
|
printlog("添加计时器失败===>>>")
|
||||||
|
if debug_print==true then
|
||||||
|
printlog(debug.traceback())
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function TimerManager.RemoveTimer(timerFunc,Self)
|
||||||
|
if timerFunc then
|
||||||
|
for k,v in pairs(timerList) do
|
||||||
|
if v.func==timerFunc and v.Self==self then
|
||||||
|
timerList[k]=nil
|
||||||
|
--table.remove(timerList,k)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function TimerManager.IsEnableTimer(isEnabe)
|
||||||
|
isEnableTimer=isEnabe
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function TimerManager.UpdateTimer()
|
||||||
|
if isEnableTimer and #timerList>0 then
|
||||||
|
for k,v in pairs(timerList) do
|
||||||
|
if v.func then
|
||||||
|
v.func(v.Self)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function TimerManager.Clear()
|
||||||
|
timerList={}
|
||||||
|
end
|
||||||
|
|
||||||
|
function TimerManager.EnableTimer()
|
||||||
|
isEnableTimer=true
|
||||||
|
end
|
||||||
|
|
||||||
|
function TimerManager.StopAllTimer()
|
||||||
|
isEnableTimer=false
|
||||||
|
timerList={}
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
return TimerManager
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -0,0 +1,13 @@
|
||||||
|
TweenUtils = {}
|
||||||
|
|
||||||
|
function TweenUtils.TweenFloat(from, to, duration, opupdate)
|
||||||
|
return DSTween.To(from,to,duration,opupdate)
|
||||||
|
end
|
||||||
|
|
||||||
|
function TweenUtils.OnComplete(tweener,callback)
|
||||||
|
tweener:OnComplete(callback)
|
||||||
|
end
|
||||||
|
|
||||||
|
function TweenUtils.Kill(tweener)
|
||||||
|
tweener:Stop()
|
||||||
|
end
|
||||||
|
|
@ -0,0 +1,136 @@
|
||||||
|
--[[
|
||||||
|
位操作
|
||||||
|
]]
|
||||||
|
--bit={data32={}}
|
||||||
|
bit = bit or {}
|
||||||
|
function bit.init32()
|
||||||
|
bit.data32 = {}
|
||||||
|
for i=1,32 do
|
||||||
|
bit.data32[i]=2^(32-i)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
bit.init32()
|
||||||
|
|
||||||
|
function bit:d2b(arg) --bit:d2b
|
||||||
|
local tr={}
|
||||||
|
for i=1,32 do
|
||||||
|
if arg >= self.data32[i] then
|
||||||
|
tr[i]=1
|
||||||
|
arg=arg-self.data32[i]
|
||||||
|
else
|
||||||
|
tr[i]=0
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return tr
|
||||||
|
end
|
||||||
|
|
||||||
|
function bit:b2d(arg) --bit:b2d
|
||||||
|
local nr=0
|
||||||
|
for i=1,32 do
|
||||||
|
if arg[i] ==1 then
|
||||||
|
nr=nr+2^(32-i)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return nr
|
||||||
|
end
|
||||||
|
|
||||||
|
function bit:_xor(a,b) --bit:xor
|
||||||
|
local op1=self:d2b(a)
|
||||||
|
local op2=self:d2b(b)
|
||||||
|
local r={}
|
||||||
|
|
||||||
|
for i=1,32 do
|
||||||
|
if op1[i]==op2[i] then
|
||||||
|
r[i]=0
|
||||||
|
else
|
||||||
|
r[i]=1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return self:b2d(r)
|
||||||
|
end
|
||||||
|
|
||||||
|
function bit:_and(a,b) --bit:_and
|
||||||
|
local op1=self:d2b(a)
|
||||||
|
local op2=self:d2b(b)
|
||||||
|
local r={}
|
||||||
|
|
||||||
|
for i=1,32 do
|
||||||
|
if op1[i]==1 and op2[i]==1 then
|
||||||
|
r[i]=1
|
||||||
|
else
|
||||||
|
r[i]=0
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return self:b2d(r)
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
function bit:_or(a,b) --bit:_or
|
||||||
|
local op1=self:d2b(a)
|
||||||
|
local op2=self:d2b(b)
|
||||||
|
local r={}
|
||||||
|
|
||||||
|
for i=1,32 do
|
||||||
|
if op1[i]==1 or op2[i]==1 then
|
||||||
|
r[i]=1
|
||||||
|
else
|
||||||
|
r[i]=0
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return self:b2d(r)
|
||||||
|
end
|
||||||
|
|
||||||
|
function bit:_not(a) --bit:_not
|
||||||
|
local op1=self:d2b(a)
|
||||||
|
local r={}
|
||||||
|
|
||||||
|
for i=1,32 do
|
||||||
|
if op1[i]==1 then
|
||||||
|
r[i]=0
|
||||||
|
else
|
||||||
|
r[i]=1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return self:b2d(r)
|
||||||
|
end
|
||||||
|
|
||||||
|
function bit:_rshift(a,n) --bit:_rshift
|
||||||
|
local op1=self:d2b(a)
|
||||||
|
local r=self:d2b(0)
|
||||||
|
|
||||||
|
if n < 32 and n > 0 then
|
||||||
|
for i=1,n do
|
||||||
|
for i=31,1,-1 do
|
||||||
|
op1[i+1]=op1[i]
|
||||||
|
end
|
||||||
|
op1[1]=0
|
||||||
|
end
|
||||||
|
r=op1
|
||||||
|
end
|
||||||
|
return self:b2d(r)
|
||||||
|
end
|
||||||
|
|
||||||
|
function bit:_lshift(a,n) --bit:_lshift
|
||||||
|
local op1=self:d2b(a)
|
||||||
|
local r=self:d2b(0)
|
||||||
|
|
||||||
|
if n < 32 and n > 0 then
|
||||||
|
for i=1,n do
|
||||||
|
for i=1,31 do
|
||||||
|
op1[i]=op1[i+1]
|
||||||
|
end
|
||||||
|
op1[32]=0
|
||||||
|
end
|
||||||
|
r=op1
|
||||||
|
end
|
||||||
|
return self:b2d(r)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function bit:print(ta)
|
||||||
|
local sr=""
|
||||||
|
for i=1,32 do
|
||||||
|
sr=sr..ta[i]
|
||||||
|
end
|
||||||
|
print(sr)
|
||||||
|
end
|
||||||
|
|
@ -0,0 +1,304 @@
|
||||||
|
local setmetatable = setmetatable
|
||||||
|
|
||||||
|
function class(classname, super)
|
||||||
|
local superType = type(super)
|
||||||
|
local cls
|
||||||
|
|
||||||
|
if superType ~= "function" and superType ~= "table" then
|
||||||
|
superType = nil
|
||||||
|
super = nil
|
||||||
|
end
|
||||||
|
|
||||||
|
if superType == "function" or (super and super.__ctype == 1) then
|
||||||
|
-- inherited from native C++ Object
|
||||||
|
cls = {}
|
||||||
|
|
||||||
|
if superType == "table" then
|
||||||
|
-- copy fields from super
|
||||||
|
for k,v in pairs(super) do cls[k] = v end
|
||||||
|
cls.__create = super.__create
|
||||||
|
cls.super = super
|
||||||
|
else
|
||||||
|
cls.__create = super
|
||||||
|
cls.ctor = function() end
|
||||||
|
end
|
||||||
|
|
||||||
|
cls.__cname = classname
|
||||||
|
cls.__ctype = 1
|
||||||
|
|
||||||
|
function cls.new(...)
|
||||||
|
local instance = cls.__create(...)
|
||||||
|
-- copy fields from class to native object
|
||||||
|
for k,v in pairs(cls) do instance[k] = v end
|
||||||
|
instance.class = cls
|
||||||
|
instance:ctor(...)
|
||||||
|
return instance
|
||||||
|
end
|
||||||
|
|
||||||
|
else
|
||||||
|
-- inherited from Lua Object
|
||||||
|
if super then
|
||||||
|
cls = {}
|
||||||
|
setmetatable(cls, {__index = super})
|
||||||
|
cls.super = super
|
||||||
|
else
|
||||||
|
cls = {ctor = function() end}
|
||||||
|
end
|
||||||
|
|
||||||
|
cls.__cname = classname
|
||||||
|
cls.__ctype = 2 -- lua
|
||||||
|
cls.__index = cls
|
||||||
|
|
||||||
|
function cls.new(...)
|
||||||
|
local instance = setmetatable({}, cls)
|
||||||
|
instance.class = cls
|
||||||
|
instance:ctor(...)
|
||||||
|
return instance
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return cls
|
||||||
|
end
|
||||||
|
|
||||||
|
-- 刘海偏移
|
||||||
|
function get_offset(full_offset)
|
||||||
|
if full_offset then
|
||||||
|
local r = GRoot.inst.width / GRoot.inst.height
|
||||||
|
if r >= 2 then
|
||||||
|
local d = (Screen.dpi /160)
|
||||||
|
return d * 20
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return 0
|
||||||
|
end
|
||||||
|
|
||||||
|
---lua table 浅拷贝
|
||||||
|
function membe_clone(orig)
|
||||||
|
local copy
|
||||||
|
if type(orig) == "table" then
|
||||||
|
copy = {}
|
||||||
|
for orig_key, orig_value in pairs(orig) do
|
||||||
|
copy[orig_key] = orig_value
|
||||||
|
end
|
||||||
|
else -- number, string, boolean, etc
|
||||||
|
copy = orig
|
||||||
|
end
|
||||||
|
return copy
|
||||||
|
end
|
||||||
|
|
||||||
|
-- lua table 深拷贝
|
||||||
|
function membe_deep_clone(orig)
|
||||||
|
local copy
|
||||||
|
if type(orig) == "table" then
|
||||||
|
copy = {}
|
||||||
|
for orig_key, orig_value in pairs(orig) do
|
||||||
|
copy[membe_deep_clone(orig_key)] = membe_deep_clone(orig_value)
|
||||||
|
end
|
||||||
|
else
|
||||||
|
copy = orig
|
||||||
|
end
|
||||||
|
return copy
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
---字符串分割函数
|
||||||
|
function split(str, delimiter)
|
||||||
|
if str==nil or str=='' or delimiter==nil then
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
|
||||||
|
local result = {}
|
||||||
|
for match in (str..delimiter):gmatch("(.-)"..delimiter) do
|
||||||
|
table.insert(result, match)
|
||||||
|
end
|
||||||
|
return result
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function handler( obj,func)
|
||||||
|
return function(...)
|
||||||
|
return func(obj, ...)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
--重新require一个lua文件,替代系统文件。
|
||||||
|
function unimport(moduleName,currentModuleName)
|
||||||
|
local package = package
|
||||||
|
local currentModuleNameParts
|
||||||
|
local moduleFullName = moduleName
|
||||||
|
local offset = 1
|
||||||
|
|
||||||
|
while true do
|
||||||
|
if string.byte(moduleName, offset) ~= 46 then -- .
|
||||||
|
moduleFullName = string.sub(moduleName, offset)
|
||||||
|
if currentModuleNameParts and #currentModuleNameParts > 0 then
|
||||||
|
moduleFullName = table.concat(currentModuleNameParts, ".") .. "." .. moduleFullName
|
||||||
|
end
|
||||||
|
break
|
||||||
|
end
|
||||||
|
offset = offset + 1
|
||||||
|
|
||||||
|
if not currentModuleNameParts then
|
||||||
|
if not currentModuleName then
|
||||||
|
local n,v = debug.getlocal(3, 1)
|
||||||
|
currentModuleName = v
|
||||||
|
end
|
||||||
|
|
||||||
|
currentModuleNameParts = string.split(currentModuleName, ".")
|
||||||
|
end
|
||||||
|
table.remove(currentModuleNameParts, #currentModuleNameParts)
|
||||||
|
end
|
||||||
|
|
||||||
|
package.loaded[moduleFullName] = nil
|
||||||
|
package.preload[moduleFullName] = nil
|
||||||
|
end
|
||||||
|
|
||||||
|
function table.nums(t)
|
||||||
|
local count = 0
|
||||||
|
for k, v in pairs(t) do
|
||||||
|
count = count + 1
|
||||||
|
end
|
||||||
|
return count
|
||||||
|
end
|
||||||
|
|
||||||
|
-- @param t 要检查的表格(t表示是table)
|
||||||
|
-- @param table 返回指定表格的所有键(key),它是一个键集合的表格
|
||||||
|
--]]
|
||||||
|
function table.keys( t )
|
||||||
|
local keys = {}
|
||||||
|
for k, _ in pairs( t ) do
|
||||||
|
keys[#keys + 1] = k
|
||||||
|
end
|
||||||
|
return keys
|
||||||
|
end
|
||||||
|
|
||||||
|
function list_remove(t,item)
|
||||||
|
for i,v in ipairs(t) do
|
||||||
|
if v == item then
|
||||||
|
table.remove(t,i)
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function list_check(t,item)
|
||||||
|
for i,v in ipairs(t) do
|
||||||
|
if v == item then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
function list_index(t,item)
|
||||||
|
for i,v in ipairs(t) do
|
||||||
|
if v == item then
|
||||||
|
return i
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return 0
|
||||||
|
end
|
||||||
|
|
||||||
|
function list_concat(des,tag)
|
||||||
|
for i = 1, #tag do
|
||||||
|
table.insert(des, tag[i])
|
||||||
|
end
|
||||||
|
return des
|
||||||
|
end
|
||||||
|
|
||||||
|
function vardump(object, label)
|
||||||
|
local lookupTable = {}
|
||||||
|
local result = {}
|
||||||
|
|
||||||
|
local function _v(v)
|
||||||
|
if type(v) == "string" then
|
||||||
|
v = "\"" .. v .. "\""
|
||||||
|
end
|
||||||
|
return tostring(v)
|
||||||
|
end
|
||||||
|
|
||||||
|
local function _vardump(object, label, indent, nest)
|
||||||
|
label = label or "<var>"
|
||||||
|
local postfix = ""
|
||||||
|
if nest > 1 then postfix = "," end
|
||||||
|
if type(object) ~= "table" then
|
||||||
|
-- if type(label) == "string" then
|
||||||
|
result[#result +1] = string.format("%s%s = %s%s", indent, label, _v(object), postfix)
|
||||||
|
-- else
|
||||||
|
-- result[#result +1] = string.format("%s%s%s", indent, _v(object), postfix)
|
||||||
|
-- end
|
||||||
|
elseif not lookupTable[object] then
|
||||||
|
lookupTable[object] = true
|
||||||
|
|
||||||
|
-- if type(label) == "string" then
|
||||||
|
result[#result +1 ] = string.format("%s%s = {", indent, label)
|
||||||
|
-- else
|
||||||
|
-- result[#result +1 ] = string.format("%s{", indent)
|
||||||
|
-- end
|
||||||
|
local indent2 = indent .. " "
|
||||||
|
local keys = {}
|
||||||
|
local values = {}
|
||||||
|
for k, v in pairs(object) do
|
||||||
|
keys[#keys + 1] = k
|
||||||
|
values[k] = v
|
||||||
|
end
|
||||||
|
table.sort(keys, function(a, b)
|
||||||
|
if type(a) == "number" and type(b) == "number" then
|
||||||
|
return a < b
|
||||||
|
else
|
||||||
|
return tostring(a) < tostring(b)
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
for i, k in ipairs(keys) do
|
||||||
|
_vardump(values[k], k, indent2, nest + 1)
|
||||||
|
end
|
||||||
|
result[#result +1] = string.format("%s}%s", indent, postfix)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
_vardump(object, label, "", 1)
|
||||||
|
|
||||||
|
return table.concat(result, "\n")
|
||||||
|
end
|
||||||
|
|
||||||
|
function sysrandom(min,max)
|
||||||
|
local num = math.random(min,max)
|
||||||
|
return num
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function IsHasDictionary(currentTarget,list)
|
||||||
|
if list and #list>0 then
|
||||||
|
for k,v in ipairs(list) do
|
||||||
|
if v==currentTarget then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return false
|
||||||
|
else
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function CheckDictionaryFromContent(target,list)
|
||||||
|
if list and #list>0 then
|
||||||
|
for k,v in pairs(list) do
|
||||||
|
if v.card==target then
|
||||||
|
return true,k
|
||||||
|
end
|
||||||
|
end
|
||||||
|
else
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function CombineDictionaryAndRemoveSomeItem(list1,list2)
|
||||||
|
local tempList=membe_clone(list2)
|
||||||
|
for i=1,#list1 do
|
||||||
|
if IsHasDictionary(list1[i],list2)==false then
|
||||||
|
table.insert(tempList,list1[i])
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return tempList
|
||||||
|
end
|
||||||
|
|
@ -0,0 +1,20 @@
|
||||||
|
|
||||||
|
|
||||||
|
import(".functions")
|
||||||
|
import(".string")
|
||||||
|
import(".Queue")
|
||||||
|
import(".NetClient")
|
||||||
|
import(".TweenUtils")
|
||||||
|
import(".bit")
|
||||||
|
ds = {
|
||||||
|
tween = {}
|
||||||
|
}
|
||||||
|
|
||||||
|
import(".tween.DSTweenManager")
|
||||||
|
import(".tween.DSTween")
|
||||||
|
import(".tween.DSTweenQuaternion")
|
||||||
|
|
||||||
|
DSTween = ds.tween.DSTween
|
||||||
|
DSTweenManager = ds.tween.DSTweenManager
|
||||||
|
|
||||||
|
import(".TimerManager")
|
||||||
|
|
@ -0,0 +1,305 @@
|
||||||
|
|
||||||
|
|
||||||
|
string._htmlspecialchars_set = {}
|
||||||
|
string._htmlspecialchars_set["&"] = "&"
|
||||||
|
string._htmlspecialchars_set["\""] = """
|
||||||
|
string._htmlspecialchars_set["'"] = "'"
|
||||||
|
string._htmlspecialchars_set["<"] = "<"
|
||||||
|
string._htmlspecialchars_set[">"] = ">"
|
||||||
|
|
||||||
|
--[[--
|
||||||
|
将特殊字符转为 HTML 转义符
|
||||||
|
~~~ lua
|
||||||
|
print(string.htmlspecialchars("<ABC>"))
|
||||||
|
-- 输出 <ABC>
|
||||||
|
~~~
|
||||||
|
@param string input 输入字符串
|
||||||
|
@return string 转换结果
|
||||||
|
]]
|
||||||
|
function string.htmlspecialchars(input)
|
||||||
|
for k, v in pairs(string._htmlspecialchars_set) do
|
||||||
|
input = string.gsub(input, k, v)
|
||||||
|
end
|
||||||
|
return input
|
||||||
|
end
|
||||||
|
|
||||||
|
--[[--
|
||||||
|
将 HTML 转义符还原为特殊字符,功能与 string.htmlspecialchars() 正好相反
|
||||||
|
~~~ lua
|
||||||
|
print(string.restorehtmlspecialchars("<ABC>"))
|
||||||
|
-- 输出 <ABC>
|
||||||
|
~~~
|
||||||
|
@param string input 输入字符串
|
||||||
|
@return string 转换结果
|
||||||
|
]]
|
||||||
|
function string.restorehtmlspecialchars(input)
|
||||||
|
for k, v in pairs(string._htmlspecialchars_set) do
|
||||||
|
input = string.gsub(input, v, k)
|
||||||
|
end
|
||||||
|
return input
|
||||||
|
end
|
||||||
|
|
||||||
|
--[[--
|
||||||
|
将字符串中的 \n 换行符转换为 HTML 标记
|
||||||
|
~~~ lua
|
||||||
|
print(string.nl2br("Hello\nWorld"))
|
||||||
|
-- 输出
|
||||||
|
-- Hello<br />World
|
||||||
|
~~~
|
||||||
|
@param string input 输入字符串
|
||||||
|
@return string 转换结果
|
||||||
|
]]
|
||||||
|
function string.nl2br(input)
|
||||||
|
return string.gsub(input, "\n", "<br />")
|
||||||
|
end
|
||||||
|
|
||||||
|
--[[--
|
||||||
|
将字符串中的特殊字符和 \n 换行符转换为 HTML 转移符和标记
|
||||||
|
~~~ lua
|
||||||
|
print(string.nl2br("<Hello>\nWorld"))
|
||||||
|
-- 输出
|
||||||
|
-- <Hello><br />World
|
||||||
|
~~~
|
||||||
|
@param string input 输入字符串
|
||||||
|
@return string 转换结果
|
||||||
|
]]
|
||||||
|
function string.text2html(input)
|
||||||
|
input = string.gsub(input, "\t", " ")
|
||||||
|
input = string.htmlspecialchars(input)
|
||||||
|
input = string.gsub(input, " ", " ")
|
||||||
|
input = string.nl2br(input)
|
||||||
|
return input
|
||||||
|
end
|
||||||
|
|
||||||
|
--[[--
|
||||||
|
用指定字符或字符串分割输入字符串,返回包含分割结果的数组
|
||||||
|
~~~ lua
|
||||||
|
local input = "Hello,World"
|
||||||
|
local res = string.split(input, ",")
|
||||||
|
-- res = {"Hello", "World"}
|
||||||
|
local input = "Hello-+-World-+-Quick"
|
||||||
|
local res = string.split(input, "-+-")
|
||||||
|
-- res = {"Hello", "World", "Quick"}
|
||||||
|
~~~
|
||||||
|
@param string input 输入字符串
|
||||||
|
@param string delimiter 分割标记字符或字符串
|
||||||
|
@return array 包含分割结果的数组
|
||||||
|
]]
|
||||||
|
function string.split(input, delimiter)
|
||||||
|
input = tostring(input)
|
||||||
|
delimiter = tostring(delimiter)
|
||||||
|
if (delimiter=='') then return false end
|
||||||
|
local pos,arr = 0, {}
|
||||||
|
-- for each divider found
|
||||||
|
for st,sp in function() return string.find(input, delimiter, pos, true) end do
|
||||||
|
table.insert(arr, string.sub(input, pos, st - 1))
|
||||||
|
pos = sp + 1
|
||||||
|
end
|
||||||
|
table.insert(arr, string.sub(input, pos))
|
||||||
|
return arr
|
||||||
|
end
|
||||||
|
|
||||||
|
--[[--
|
||||||
|
去除输入字符串头部的空白字符,返回结果
|
||||||
|
~~~ lua
|
||||||
|
local input = " ABC"
|
||||||
|
print(string.ltrim(input))
|
||||||
|
-- 输出 ABC,输入字符串前面的两个空格被去掉了
|
||||||
|
~~~
|
||||||
|
空白字符包括:
|
||||||
|
- 空格
|
||||||
|
- 制表符 \t
|
||||||
|
- 换行符 \n
|
||||||
|
- 回到行首符 \r
|
||||||
|
@param string input 输入字符串
|
||||||
|
@return string 结果
|
||||||
|
@see string.rtrim, string.trim
|
||||||
|
]]
|
||||||
|
function string.ltrim(input)
|
||||||
|
return string.gsub(input, "^[ \t\n\r]+", "")
|
||||||
|
end
|
||||||
|
|
||||||
|
--[[--
|
||||||
|
去除输入字符串尾部的空白字符,返回结果
|
||||||
|
~~~ lua
|
||||||
|
local input = "ABC "
|
||||||
|
print(string.ltrim(input))
|
||||||
|
-- 输出 ABC,输入字符串最后的两个空格被去掉了
|
||||||
|
~~~
|
||||||
|
@param string input 输入字符串
|
||||||
|
@return string 结果
|
||||||
|
@see string.ltrim, string.trim
|
||||||
|
]]
|
||||||
|
function string.rtrim(input)
|
||||||
|
return string.gsub(input, "[ \t\n\r]+$", "")
|
||||||
|
end
|
||||||
|
|
||||||
|
--[[--
|
||||||
|
去掉字符串首尾的空白字符,返回结果
|
||||||
|
@param string input 输入字符串
|
||||||
|
@return string 结果
|
||||||
|
@see string.ltrim, string.rtrim
|
||||||
|
]]
|
||||||
|
function string.trim(input)
|
||||||
|
input = string.gsub(input, "^[ \t\n\r]+", "")
|
||||||
|
return string.gsub(input, "[ \t\n\r]+$", "")
|
||||||
|
end
|
||||||
|
|
||||||
|
--[[--
|
||||||
|
将字符串的第一个字符转为大写,返回结果
|
||||||
|
~~~ lua
|
||||||
|
local input = "hello"
|
||||||
|
print(string.ucfirst(input))
|
||||||
|
-- 输出 Hello
|
||||||
|
~~~
|
||||||
|
@param string input 输入字符串
|
||||||
|
@return string 结果
|
||||||
|
]]
|
||||||
|
function string.ucfirst(input)
|
||||||
|
return string.upper(string.sub(input, 1, 1)) .. string.sub(input, 2)
|
||||||
|
end
|
||||||
|
|
||||||
|
local function urlencodechar(char)
|
||||||
|
return "%" .. string.format("%02X", string.byte(char))
|
||||||
|
end
|
||||||
|
|
||||||
|
--[[--
|
||||||
|
将字符串转换为符合 URL 传递要求的格式,并返回转换结果
|
||||||
|
~~~ lua
|
||||||
|
local input = "hello world"
|
||||||
|
print(string.urlencode(input))
|
||||||
|
-- 输出
|
||||||
|
-- hello%20world
|
||||||
|
~~~
|
||||||
|
@param string input 输入字符串
|
||||||
|
@return string 转换后的结果
|
||||||
|
@see string.urldecode
|
||||||
|
]]
|
||||||
|
function string.urlencode(input)
|
||||||
|
-- convert line endings
|
||||||
|
input = string.gsub(tostring(input), "\n", "\r\n")
|
||||||
|
-- escape all characters but alphanumeric, '.' and '-'
|
||||||
|
input = string.gsub(input, "([^%w%.%- ])", urlencodechar)
|
||||||
|
-- convert spaces to "+" symbols
|
||||||
|
return string.gsub(input, " ", "+")
|
||||||
|
end
|
||||||
|
|
||||||
|
--[[--
|
||||||
|
将 URL 中的特殊字符还原,并返回结果
|
||||||
|
~~~ lua
|
||||||
|
local input = "hello%20world"
|
||||||
|
print(string.urldecode(input))
|
||||||
|
-- 输出
|
||||||
|
-- hello world
|
||||||
|
~~~
|
||||||
|
@param string input 输入字符串
|
||||||
|
@return string 转换后的结果
|
||||||
|
@see string.urlencode
|
||||||
|
]]
|
||||||
|
function string.urldecode(input)
|
||||||
|
input = string.gsub (input, "+", " ")
|
||||||
|
input = string.gsub (input, "%%(%x%x)", function(h) return string.char(checknumber(h,16)) end)
|
||||||
|
input = string.gsub (input, "\r\n", "\n")
|
||||||
|
return input
|
||||||
|
end
|
||||||
|
|
||||||
|
--[[--
|
||||||
|
计算 UTF8 字符串的长度,每一个中文算一个字符
|
||||||
|
~~~ lua
|
||||||
|
local input = "你好World"
|
||||||
|
print(string.utf8len(input))
|
||||||
|
-- 输出 7
|
||||||
|
~~~
|
||||||
|
@param string input 输入字符串
|
||||||
|
@return integer 长度
|
||||||
|
]]
|
||||||
|
function string.utf8len(input)
|
||||||
|
if input == nil then return 0 end
|
||||||
|
if type(input) ~= "string" then return 0 end
|
||||||
|
local len = string.len(input)
|
||||||
|
local left = len
|
||||||
|
local cnt = 0
|
||||||
|
local arr = {0, 0xc0, 0xe0, 0xf0, 0xf8, 0xfc}
|
||||||
|
while left ~= 0 do
|
||||||
|
local tmp = string.byte(input, -left)
|
||||||
|
local i = #arr
|
||||||
|
while arr[i] do
|
||||||
|
if tmp >= arr[i] then
|
||||||
|
left = left - i
|
||||||
|
break
|
||||||
|
end
|
||||||
|
i = i - 1
|
||||||
|
end
|
||||||
|
cnt = cnt + 1
|
||||||
|
end
|
||||||
|
return cnt
|
||||||
|
end
|
||||||
|
|
||||||
|
--[[
|
||||||
|
截取utf8字符串
|
||||||
|
@param string input 输入字符串
|
||||||
|
@param integer index、endIndex 截取的开始和结束索引,如果没有结束索引,就从1截到index
|
||||||
|
@return string 目标字符串
|
||||||
|
]]
|
||||||
|
function string.utf8sub(input, index, endIndex)
|
||||||
|
if input == nil or type(input) ~= "string" then return nil end
|
||||||
|
if not endIndex then
|
||||||
|
endIndex = index
|
||||||
|
index = 1
|
||||||
|
end
|
||||||
|
local len = string.len(input)
|
||||||
|
local left = len
|
||||||
|
local cnt = 0
|
||||||
|
local head, tail = 0, 0
|
||||||
|
local arr = {0, 0xc0, 0xe0, 0xf0, 0xf8, 0xfc}
|
||||||
|
while left ~= 0 do
|
||||||
|
if cnt + 1 == index then
|
||||||
|
head = len - left + 1
|
||||||
|
end
|
||||||
|
local tmp = string.byte(input, -left)
|
||||||
|
local i = #arr
|
||||||
|
while arr[i] do
|
||||||
|
if tmp >= arr[i] then
|
||||||
|
left = left - i
|
||||||
|
break
|
||||||
|
end
|
||||||
|
i = i - 1
|
||||||
|
end
|
||||||
|
cnt = cnt + 1
|
||||||
|
if cnt == endIndex or left == 0 then
|
||||||
|
tail = len - left
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
local rt = string.sub(input, head, tail)
|
||||||
|
return rt
|
||||||
|
end
|
||||||
|
|
||||||
|
--[[--
|
||||||
|
将数值格式化为包含千分位分隔符的字符串
|
||||||
|
~~~ lua
|
||||||
|
print(string.formatnumberthousands(1924235))
|
||||||
|
-- 输出 1,924,235
|
||||||
|
~~~
|
||||||
|
@param number num 数值
|
||||||
|
@return string 格式化结果
|
||||||
|
]]
|
||||||
|
function string.formatnumberthousands(num)
|
||||||
|
local formatted = tostring(checknumber(num))
|
||||||
|
local k
|
||||||
|
while true do
|
||||||
|
formatted, k = string.gsub(formatted, "^(-?%d+)(%d%d%d)", '%1,%2')
|
||||||
|
if k == 0 then break end
|
||||||
|
end
|
||||||
|
return formatted
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function string.concat( ... )
|
||||||
|
local str = {}
|
||||||
|
local tem = {...}
|
||||||
|
for _,v in ipairs(tem) do
|
||||||
|
str[#str + 1] = v
|
||||||
|
end
|
||||||
|
return table.concat(str , "")
|
||||||
|
end
|
||||||
|
|
@ -0,0 +1,398 @@
|
||||||
|
--Tween 核心基类
|
||||||
|
--author:--
|
||||||
|
|
||||||
|
local DSAxis = {
|
||||||
|
None = 0,
|
||||||
|
X = 2,
|
||||||
|
Y = 4,
|
||||||
|
Z = 8,
|
||||||
|
}
|
||||||
|
|
||||||
|
local DSEase = {
|
||||||
|
Linear=0,
|
||||||
|
InSine=1,
|
||||||
|
OutSine=2,
|
||||||
|
InOutSine=3,
|
||||||
|
InQuad=4,
|
||||||
|
OutQuad=5,
|
||||||
|
InOutQuad=6,
|
||||||
|
InCubic=7,
|
||||||
|
OutCubic=8,
|
||||||
|
InOutCubic=9,
|
||||||
|
InQuart=10,
|
||||||
|
OutQuart=11,
|
||||||
|
InOutQuart=12,
|
||||||
|
InQuint=13,
|
||||||
|
OutQuint=14,
|
||||||
|
InOutQuint=15,
|
||||||
|
InExpo=16,
|
||||||
|
OutExpo=17,
|
||||||
|
InOutExpo=18,
|
||||||
|
InCirc=19,
|
||||||
|
OutCirc=20,
|
||||||
|
InOutCirc=21,
|
||||||
|
InElastic=22,
|
||||||
|
OutElastic=23,
|
||||||
|
InOutElastic=24,
|
||||||
|
InBack=25,
|
||||||
|
OutBack=26,
|
||||||
|
InOutBack=27,
|
||||||
|
InBounce=28,
|
||||||
|
OutBounce=29,
|
||||||
|
InOutBounce=30,
|
||||||
|
}
|
||||||
|
|
||||||
|
local DSTweenState = ds.tween.DSTweenState
|
||||||
|
|
||||||
|
local DSTween = {
|
||||||
|
_from = 0,
|
||||||
|
_to = 1,
|
||||||
|
_duration = 0,
|
||||||
|
_currenTime = 0,
|
||||||
|
_ease = DSEase.Linear,
|
||||||
|
_state = DSTweenState.Play,
|
||||||
|
_autoRemove=true,
|
||||||
|
_loop = 1,
|
||||||
|
_currenLoop=1,
|
||||||
|
_delay = 0,
|
||||||
|
_currenDelay = 0
|
||||||
|
}
|
||||||
|
|
||||||
|
ds.tween.DSAxis = DSAxis
|
||||||
|
ds.tween.DSEase = DSEase
|
||||||
|
ds.tween.DSTween = DSTween
|
||||||
|
|
||||||
|
local function new(duration,onUpdate)
|
||||||
|
local self = {}
|
||||||
|
setmetatable(self,{__index = DSTween})
|
||||||
|
DSTween.init(self,duration,onUpdate)
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
function DSTween:init( duration,onUpdate)
|
||||||
|
self._duration = duration
|
||||||
|
self._onUpdate = onUpdate
|
||||||
|
self._ease = DSEase.Linear
|
||||||
|
self._state = DSTweenState.Play
|
||||||
|
self._autoRemove=true
|
||||||
|
self._loop = 1
|
||||||
|
self._currenLoop = 1
|
||||||
|
end
|
||||||
|
|
||||||
|
local _PiOver2 = 1.57079637
|
||||||
|
local _TwoPi = 6.28318548
|
||||||
|
local _EaseOvershootOrAmplitude = 1.70158
|
||||||
|
local _EaseOne = 1
|
||||||
|
local _EaseTwo = 2
|
||||||
|
local _EaseZPFive = 0.5
|
||||||
|
|
||||||
|
local function EaseOut(time,duration)
|
||||||
|
time = time /duration
|
||||||
|
if (time < 0.363636374) then
|
||||||
|
return 7.5625 * time * time
|
||||||
|
end
|
||||||
|
if (time < 0.727272749) then
|
||||||
|
time = time -0.545454562
|
||||||
|
return 7.5625 * time * time + 0.75
|
||||||
|
end
|
||||||
|
if (time < 0.909090936) then
|
||||||
|
time = time - 0.8181818
|
||||||
|
return 7.5625 * time * time + 0.9375
|
||||||
|
end
|
||||||
|
time =time - 0.954545438
|
||||||
|
return 7.5625 * time * time + 0.984375
|
||||||
|
end
|
||||||
|
|
||||||
|
local function EaseIn(time,duration)
|
||||||
|
return _EaseOne - EaseOut(duration - time, duration)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
local function EaseInOut(time,duration)
|
||||||
|
if (time < duration * _EaseZPFive) then
|
||||||
|
return EaseIn(time * _EaseTwo, duration) * _EaseZPFive
|
||||||
|
end
|
||||||
|
return EaseOut(time * _EaseTwo - duration, duration) * _EaseZPFive + _EaseZPFive
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
local function Evaluate(easeType, time, duration)
|
||||||
|
local period = 0
|
||||||
|
if (easeType == DSEase.Linear) then
|
||||||
|
return time / duration
|
||||||
|
elseif (easeType == DSEase.InSine) then
|
||||||
|
return -math.cos((time / duration * _PiOver2)) + _EaseOne
|
||||||
|
elseif (easeType == DSEase.OutSine) then
|
||||||
|
return math.sin((time / duration * _PiOver2))
|
||||||
|
elseif (easeType == DSEase.InOutSine) then
|
||||||
|
return -_EaseZPFive * (math.cos((math.pi * time / duration)) - _EaseOne)
|
||||||
|
elseif (easeType == DSEase.InQuad) then
|
||||||
|
time = time /duration
|
||||||
|
return time * time
|
||||||
|
elseif (easeType == DSEase.OutQuad) then
|
||||||
|
time = time /duration
|
||||||
|
return -time * (time - _EaseTwo)
|
||||||
|
elseif (easeType == DSEase.InOutQuad) then
|
||||||
|
time = time / (duration * _EaseZPFive)
|
||||||
|
if (time < _EaseOne) then
|
||||||
|
return _EaseZPFive * time * time
|
||||||
|
end
|
||||||
|
time = time - _EaseOne
|
||||||
|
return -_EaseZPFive * (time * (time - _EaseTwo) - _EaseOne)
|
||||||
|
elseif (easeType == DSEase.InCubic) then
|
||||||
|
time = time / duration
|
||||||
|
return time * time * time
|
||||||
|
elseif (easeType == DSEase.OutCubic) then
|
||||||
|
time = time /duration - _EaseOne
|
||||||
|
return time * time * time + _EaseOne
|
||||||
|
elseif (easeType == DSEase.InOutCubic) then
|
||||||
|
time = time/(duration * _EaseZPFive)
|
||||||
|
if (time < _EaseOne) then
|
||||||
|
return _EaseZPFive * time * time * time
|
||||||
|
end
|
||||||
|
time = time - _EaseTwo
|
||||||
|
return _EaseZPFive * (time * time * time + _EaseTwo)
|
||||||
|
elseif (easeType == DSEase.InQuart) then
|
||||||
|
time = time /duration
|
||||||
|
return time* time * time * time
|
||||||
|
elseif (easeType == DSEase.OutQuart) then
|
||||||
|
time = time / duration - _EaseOne
|
||||||
|
return -(time * time * time * time - _EaseOne);
|
||||||
|
elseif (easeType == DSEase.InOutQuart) then
|
||||||
|
time = time /( duration * _EaseZPFive)
|
||||||
|
if (time < _EaseOne) then
|
||||||
|
return _EaseZPFive * time * time * time * time
|
||||||
|
end
|
||||||
|
time = time - _EaseTwo
|
||||||
|
return -_EaseZPFive * (time * time * time * time - _EaseTwo)
|
||||||
|
elseif (easeType == DSEase.InQuint) then
|
||||||
|
time = time / duration
|
||||||
|
return time * time * time * time * time;
|
||||||
|
elseif (easeType == DSEase.OutQuint) then
|
||||||
|
time = time / duration - _EaseOne
|
||||||
|
return time * time * time * time * time + _EaseOne
|
||||||
|
elseif (easeType == DSEase.InOutQuint) then
|
||||||
|
time = time / (duration * _EaseZPFive)
|
||||||
|
if (time < _EaseOne) then
|
||||||
|
return _EaseZPFive * time * time * time * time * time
|
||||||
|
end
|
||||||
|
time = time - _EaseTwo
|
||||||
|
return _EaseZPFive * (time * time * time * time * time + _EaseTwo)
|
||||||
|
elseif (easeType == DSEase.InExpo) then
|
||||||
|
if (time ~= 0) then
|
||||||
|
return math.pow(_EaseTwo, 10 * (time / duration - _EaseOne))
|
||||||
|
end
|
||||||
|
return 0
|
||||||
|
elseif (easeType == DSEase.OutExpo) then
|
||||||
|
if (time == duration) then
|
||||||
|
return 1
|
||||||
|
end
|
||||||
|
return -math.pow(_EaseTwo, (-10 * time / duration)) + _EaseOne
|
||||||
|
elseif (easeType == DSEase.InOutExpo) then
|
||||||
|
if (time == 0) then
|
||||||
|
return 0
|
||||||
|
end
|
||||||
|
if (time == duration) then
|
||||||
|
return _EaseOne
|
||||||
|
end
|
||||||
|
time = time/( duration * _EaseZPFive)
|
||||||
|
if (time < _EaseOne) then
|
||||||
|
return _EaseZPFive * math.pow(_EaseTwo, (10 * (time - _EaseOne)))
|
||||||
|
end
|
||||||
|
time = time - _EaseOne
|
||||||
|
return _EaseZPFive * (-math.pow(_EaseTwo, (-10 * time) + 2))
|
||||||
|
elseif (easeType == DSEase.InCirc) then
|
||||||
|
time = time / duration
|
||||||
|
return -(math.sqrt((_EaseOne - time * time)) - _EaseOne)
|
||||||
|
elseif (easeType == DSEase.OutCirc) then
|
||||||
|
time = time / duration - _EaseOne
|
||||||
|
return math.sqrt((_EaseOne - time * time))
|
||||||
|
elseif (easeType == DSEase.InOutCirc) then
|
||||||
|
time = time / (duration * _EaseZPFive)
|
||||||
|
if (time < _EaseOne) then
|
||||||
|
return -_EaseZPFive * (math.sqrt((_EaseOne - time * time)) - _EaseOne)
|
||||||
|
end
|
||||||
|
time = time - _EaseTwo
|
||||||
|
return _EaseZPFive * (math.sqrt((_EaseOne - time * time)) + _EaseOne)
|
||||||
|
elseif (easeType == DSEase.InElastic) then
|
||||||
|
if (time == 0) then
|
||||||
|
return 0
|
||||||
|
end
|
||||||
|
time = time / duration
|
||||||
|
if (time == _EaseOne) then
|
||||||
|
return _EaseOne
|
||||||
|
end
|
||||||
|
period = duration * 0.3
|
||||||
|
local num = period / _TwoPi * math.asin((_EaseOne / _EaseOvershootOrAmplitude))
|
||||||
|
time = time -_EaseOne
|
||||||
|
return -(_EaseOvershootOrAmplitude * math.pow(_EaseTwo, (10.0 * time)) * math.sin((time * duration - num) * _TwoPi / period))
|
||||||
|
elseif (easeType == DSEase.OutElastic) then
|
||||||
|
if (time == 0) then
|
||||||
|
return 0
|
||||||
|
end
|
||||||
|
time = time / duration
|
||||||
|
if (time == _EaseOne) then
|
||||||
|
return _EaseOne
|
||||||
|
end
|
||||||
|
period = duration * 0.3
|
||||||
|
local num2 = period / _TwoPi * math.asin((_EaseOne / _EaseOvershootOrAmplitude))
|
||||||
|
return _EaseOvershootOrAmplitude * math.pow(_EaseTwo, -10 * time) * math.sin((time * duration - num2) * _TwoPi / period) + _EaseOne
|
||||||
|
elseif (easeType == DSEase.InOutElastic) then
|
||||||
|
if (time == 0) then
|
||||||
|
return 0
|
||||||
|
end
|
||||||
|
time = time / (duration * _EaseZPFive)
|
||||||
|
if (time == _EaseTwo) then
|
||||||
|
return _EaseOne
|
||||||
|
end
|
||||||
|
period = duration * 0.450000018
|
||||||
|
local num3 = period / _TwoPi * math.asin(_EaseOne / _EaseOvershootOrAmplitude)
|
||||||
|
if (time < _EaseOne) then
|
||||||
|
time = time - _EaseOne
|
||||||
|
return -_EaseZPFive * (_EaseOvershootOrAmplitude * math.pow(_EaseTwo, (10 * time)) * math.sin(((time * duration - num3) * _TwoPi / period)))
|
||||||
|
end
|
||||||
|
time = time - _EaseOne
|
||||||
|
return _EaseOvershootOrAmplitude * math.pow(_EaseTwo, (-10 * time)) * math.sin(((time * duration - num3) * _TwoPi / period)) * _EaseZPFive + _EaseOne;
|
||||||
|
elseif (easeType == DSEase.InBack) then
|
||||||
|
time = time / duration
|
||||||
|
return time * time * ((_EaseOvershootOrAmplitude + _EaseOne) * time - _EaseOvershootOrAmplitude)
|
||||||
|
elseif (easeType == DSEase.OutBack) then
|
||||||
|
time = time / duration - _EaseOne
|
||||||
|
return time * time * ((_EaseOvershootOrAmplitude + _EaseOne) * time + _EaseOvershootOrAmplitude) + _EaseOne
|
||||||
|
elseif (easeType == DSEase.InOutBack) then
|
||||||
|
local overshootOrAmplitude = _EaseOvershootOrAmplitude
|
||||||
|
time = time / (duration * _EaseZPFive)
|
||||||
|
if (time < _EaseOne) then
|
||||||
|
overshootOrAmplitude = overshootOrAmplitude * 1.525
|
||||||
|
return _EaseZPFive * (time * time * ((overshootOrAmplitude + _EaseOne) * time - overshootOrAmplitude))
|
||||||
|
end
|
||||||
|
time = time -_EaseTwo
|
||||||
|
overshootOrAmplitude = overshootOrAmplitude * 1.525
|
||||||
|
return _EaseZPFive * (time * time * ((overshootOrAmplitude + _EaseOne) * time + overshootOrAmplitude) + _EaseTwo)
|
||||||
|
elseif (easeType == DSEase.InBounce) then
|
||||||
|
return _EaseOne - EaseOut(duration - time, duration)
|
||||||
|
elseif (easeType == DSEase.OutBounce) then
|
||||||
|
return EaseOut(time, duration)
|
||||||
|
elseif (easeType == DSEase.InOutBounce) then
|
||||||
|
return EaseInOut(time, duration)
|
||||||
|
else
|
||||||
|
time = time / duration
|
||||||
|
return -time * (time - _EaseTwo)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function DSTween:CallUpdate(value)
|
||||||
|
if (self._onUpdate ~= nil) then
|
||||||
|
self._onUpdate(value)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function DSTween:Update(deltaTime)
|
||||||
|
local _state = self._state
|
||||||
|
local _currenTime = self._currenTime
|
||||||
|
local _duration = self._duration
|
||||||
|
if (_state == DSTweenState.Stop) then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
if (_state == DSTweenState.Delay) then
|
||||||
|
if (_currenDelay >= _delay) then
|
||||||
|
_state = DSTweenState.Play
|
||||||
|
else
|
||||||
|
self._currenDelay = self._currenDelay + deltaTime
|
||||||
|
return
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
_currenTime = math.min(_currenTime, _duration)
|
||||||
|
local value = Evaluate(self._ease, _currenTime, _duration)
|
||||||
|
|
||||||
|
local tem = self._from + (self._to - self._from) * value
|
||||||
|
self:CallUpdate(tem)
|
||||||
|
if (_currenTime >= _duration) then
|
||||||
|
if (self._loop == -1 or self._currenLoop < self._loop) then
|
||||||
|
self._currenTime = 0
|
||||||
|
self._currenLoop = self._currenLoop + 1
|
||||||
|
return
|
||||||
|
end
|
||||||
|
self._state = DSTweenState.Stop
|
||||||
|
if (self._onComplete ~= nil) then
|
||||||
|
self._onComplete(self)
|
||||||
|
end
|
||||||
|
return
|
||||||
|
end
|
||||||
|
self._currenTime = _currenTime + deltaTime
|
||||||
|
end
|
||||||
|
|
||||||
|
-- 停止
|
||||||
|
function DSTween:Stop()
|
||||||
|
self._state = DSTweenState.Stop
|
||||||
|
self._currenDelay = 0
|
||||||
|
self._currenTime = 0
|
||||||
|
self._currenLoop = 1
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
-- 重新启动
|
||||||
|
function DSTween:Play()
|
||||||
|
self._state = self._delay>0 and DSTweenState.Delay or DSTweenState.Play
|
||||||
|
self._currenDelay = 0
|
||||||
|
self._currenTime = 0
|
||||||
|
self._currenLoop = 1
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- 重新启动
|
||||||
|
function DSTween:Restart()
|
||||||
|
return self:Play()
|
||||||
|
end
|
||||||
|
|
||||||
|
-- 设置循环次数
|
||||||
|
function DSTween:SetLoop(loop)
|
||||||
|
self._loop = loop
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- 重新设置Tween参数
|
||||||
|
function DSTween:ChangeValues(from,to,duration)
|
||||||
|
self._from = from
|
||||||
|
self._to = to
|
||||||
|
self._duration = duration
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
---设置Tween补间类型
|
||||||
|
function DSTween:SetEase(ease)
|
||||||
|
self._ease = ease
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- 设置完成事件监听
|
||||||
|
function DSTween:OnComplete(onComplete)
|
||||||
|
self._onComplete = onComplete
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
function DSTween:SetDelay(delay)
|
||||||
|
self._delay = delay
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
function DSTween:GetState()
|
||||||
|
return self._state
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
local DSTweenManager = ds.tween.DSTweenManager
|
||||||
|
|
||||||
|
function DSTween.To(from,to,duration,onUpdate)
|
||||||
|
local tween = new(duration, onUpdate)
|
||||||
|
tween._from = from
|
||||||
|
tween._to = to
|
||||||
|
DSTweenManager.AddActiveTween(tween);
|
||||||
|
return tween
|
||||||
|
end
|
||||||
|
|
@ -0,0 +1,51 @@
|
||||||
|
--Tween 管理
|
||||||
|
--author:--
|
||||||
|
|
||||||
|
local _MaxActiveTween=200
|
||||||
|
local _totActiveTweens = 0
|
||||||
|
local _activeTweens = {}
|
||||||
|
|
||||||
|
local DSTweenManager = {}
|
||||||
|
|
||||||
|
local DSTweenState = {
|
||||||
|
Play = 0,
|
||||||
|
Stop = 1,
|
||||||
|
Delay = 2
|
||||||
|
}
|
||||||
|
ds.tween.DSTweenState = DSTweenState
|
||||||
|
|
||||||
|
function DSTweenManager.Update(deltaTime)
|
||||||
|
if (deltaTime == 0) then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
local i = 1
|
||||||
|
while i <= #_activeTweens do
|
||||||
|
local t = _activeTweens[i]
|
||||||
|
if t ~=nil then
|
||||||
|
if (not (t._autoRemove and t._state == DSTweenState.Stop)) then
|
||||||
|
t:Update(deltaTime)
|
||||||
|
i = i +1
|
||||||
|
else
|
||||||
|
table.remove(_activeTweens,i)
|
||||||
|
i = i -1
|
||||||
|
_totActiveTweens = _totActiveTweens - 1
|
||||||
|
end
|
||||||
|
else
|
||||||
|
i = i +1
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function DSTweenManager.AddActiveTween(t)
|
||||||
|
_activeTweens[#_activeTweens+1] = t
|
||||||
|
t:Play()
|
||||||
|
_totActiveTweens = _totActiveTweens + 1
|
||||||
|
end
|
||||||
|
|
||||||
|
function DSTweenManager.ClearTween()
|
||||||
|
_activeTweens = {}
|
||||||
|
_totActiveTweens = 0
|
||||||
|
end
|
||||||
|
|
||||||
|
ds.tween.DSTweenManager = DSTweenManager
|
||||||
|
|
@ -0,0 +1,62 @@
|
||||||
|
--Tween Quaternion
|
||||||
|
--author:--
|
||||||
|
|
||||||
|
local DSTween = ds.tween.DSTween
|
||||||
|
|
||||||
|
local DSTweenQuaternion = {}
|
||||||
|
|
||||||
|
ds.tween.DSTweenQuaternion = DSTweenQuaternion
|
||||||
|
|
||||||
|
local function new(duration,onUpdate)
|
||||||
|
local self = {}
|
||||||
|
setmetatable(DSTweenQuaternion,{__index = DSTween})
|
||||||
|
setmetatable(self,{__index = DSTweenQuaternion})
|
||||||
|
DSTween.init(self,duration,onUpdate)
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
function DSTweenQuaternion:CallUpdate(value)
|
||||||
|
local vector = self._startValue
|
||||||
|
vector = self._startValue + self._changeValue * value
|
||||||
|
local r = Quaternion.Euler(vector.x,vector.y,vector.z)
|
||||||
|
if (self._target ~= null) then
|
||||||
|
self._target.rotation = r
|
||||||
|
end
|
||||||
|
if (self._onUpdate ~= nil) then
|
||||||
|
self._onUpdate(r)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local DSTweenManager = ds.tween.DSTweenManager
|
||||||
|
|
||||||
|
function DSTweenQuaternion.To(target,to,duration,onUpdate)
|
||||||
|
local tween = new(duration, onUpdate)
|
||||||
|
tween._startValue = target.rotation.eulerAngles
|
||||||
|
tween._target = target
|
||||||
|
local endValue = to
|
||||||
|
if (endValue.x > 360) then
|
||||||
|
endValue.x = endValue.x % 360
|
||||||
|
end
|
||||||
|
if (endValue.y > 360) then
|
||||||
|
endValue.y = endValue.y % 360
|
||||||
|
end
|
||||||
|
if (endValue.z > 360) then
|
||||||
|
endValue.z = endValue.z % 360
|
||||||
|
end
|
||||||
|
local changeValue = endValue - tween._startValue
|
||||||
|
local num = (changeValue.x > 0) and changeValue.x or (-changeValue.x)
|
||||||
|
if (num > 180) then
|
||||||
|
changeValue.x = ((changeValue.x > 0) and (-(360 - num)) or (360 - num))
|
||||||
|
end
|
||||||
|
num = ((changeValue.y > 0) and changeValue.y or (-changeValue.y))
|
||||||
|
if (num > 180) then
|
||||||
|
changeValue.y = ((changeValue.y > 0) and (-(360 - num)) or (360 - num))
|
||||||
|
end
|
||||||
|
num = ((changeValue.z > 0) and changeValue.z or (-changeValue.z))
|
||||||
|
if (num > 180) then
|
||||||
|
changeValue.z = ((changeValue.z > 0) and (-(360 - num)) or (360 - num))
|
||||||
|
end
|
||||||
|
tween._changeValue = changeValue
|
||||||
|
DSTweenManager.AddActiveTween(tween)
|
||||||
|
return tween
|
||||||
|
end
|
||||||
|
|
@ -0,0 +1,141 @@
|
||||||
|
EventContext = FairyGUI.EventContext
|
||||||
|
EventListener = FairyGUI.EventListener
|
||||||
|
EventDispatcher = FairyGUI.EventDispatcher
|
||||||
|
InputEvent = FairyGUI.InputEvent
|
||||||
|
NTexture = FairyGUI.NTexture
|
||||||
|
Container = FairyGUI.Container
|
||||||
|
Image = FairyGUI.Image
|
||||||
|
Stage = FairyGUI.Stage
|
||||||
|
Controller = FairyGUI.Controller
|
||||||
|
GObject = FairyGUI.GObject
|
||||||
|
GGraph = FairyGUI.GGraph
|
||||||
|
GGroup = FairyGUI.GGroup
|
||||||
|
GImage = FairyGUI.GImage
|
||||||
|
GLoader = FairyGUI.GLoader
|
||||||
|
GMovieClip = FairyGUI.GMovieClip
|
||||||
|
TextFormat = FairyGUI.TextFormat
|
||||||
|
GTextField = FairyGUI.GTextField
|
||||||
|
GRichTextField = FairyGUI.GRichTextField
|
||||||
|
GTextInput = FairyGUI.GTextInput
|
||||||
|
GComponent = FairyGUI.GComponent
|
||||||
|
GList = FairyGUI.GList
|
||||||
|
GRoot = FairyGUI.GRoot
|
||||||
|
GLabel = FairyGUI.GLabel
|
||||||
|
GButton = FairyGUI.GButton
|
||||||
|
GComboBox = FairyGUI.GComboBox
|
||||||
|
GProgressBar = FairyGUI.GProgressBar
|
||||||
|
GSlider = FairyGUI.GSlider
|
||||||
|
PopupMenu = FairyGUI.PopupMenu
|
||||||
|
ScrollPane = FairyGUI.ScrollPane
|
||||||
|
Transition = FairyGUI.Transition
|
||||||
|
UIPackage = FairyGUI.UIPackage
|
||||||
|
Window = FairyGUI.Window
|
||||||
|
GObjectPool = FairyGUI.GObjectPool
|
||||||
|
Relations = FairyGUI.Relations
|
||||||
|
RelationType = FairyGUI.RelationType
|
||||||
|
UIPanel = FairyGUI.UIPanel
|
||||||
|
UIPainter = FairyGUI.UIPainter
|
||||||
|
TypingEffect = FairyGUI.TypingEffect
|
||||||
|
GTween = FairyGUI.GTween
|
||||||
|
GTweener = FairyGUI.GTweener
|
||||||
|
EaseType = FairyGUI.EaseType
|
||||||
|
|
||||||
|
fgui = {}
|
||||||
|
|
||||||
|
--[[
|
||||||
|
用于继承FairyGUI的Window类,同时派生的Window类可以继续被继承。可以重写的方法有(与Window类里的同名方法含义完全相同)
|
||||||
|
OnInit、DoHideAnimation、DoShowAnimation、OnShown、OnHide。
|
||||||
|
例子:
|
||||||
|
MyWinClass = fgui.window_class()
|
||||||
|
function MyWinClass:ctor()
|
||||||
|
print('MyWinClass-ctor')
|
||||||
|
self.contentPane = UIPackage.CreateObject("Basics", "WindowA")
|
||||||
|
end
|
||||||
|
function MyWinClass:OnShown()
|
||||||
|
print('MyWinClass-onShown')
|
||||||
|
end
|
||||||
|
local win = MyWinClass.New()
|
||||||
|
win:Show()
|
||||||
|
]]
|
||||||
|
function fgui.window_class(base)
|
||||||
|
local o = {}
|
||||||
|
|
||||||
|
local base = base or FairyGUI.Window
|
||||||
|
setmetatable(o, base)
|
||||||
|
|
||||||
|
o.__index = o
|
||||||
|
o.base = base
|
||||||
|
|
||||||
|
o.New = function(...)
|
||||||
|
local t = {}
|
||||||
|
setmetatable(t, o)
|
||||||
|
|
||||||
|
local ins = FairyGUI.Window.New()
|
||||||
|
tolua.setpeer(ins, t)
|
||||||
|
ins:SetLuaPeer(t)
|
||||||
|
if t.ctor then
|
||||||
|
t.ctor(ins,...)
|
||||||
|
end
|
||||||
|
|
||||||
|
return ins
|
||||||
|
end
|
||||||
|
|
||||||
|
return o
|
||||||
|
end
|
||||||
|
|
||||||
|
--[[
|
||||||
|
注册组件扩展,用于继承FairyGUI原来的组件类。
|
||||||
|
|
||||||
|
例子:
|
||||||
|
|
||||||
|
MyButton = fgui.extension_class(GButton)
|
||||||
|
fgui.register_extension("ui://包名/我的按钮", MyButton)
|
||||||
|
|
||||||
|
function MyButton:ctor() --当组件构建完成时此方法被调用
|
||||||
|
print(self:GetChild("n1"))
|
||||||
|
end
|
||||||
|
|
||||||
|
--添加自定义的方法和字段
|
||||||
|
function MyButton:Test()
|
||||||
|
print('test')
|
||||||
|
end
|
||||||
|
|
||||||
|
local get = tolua.initget(MyButton)
|
||||||
|
local set = tolua.initset(MyButton)
|
||||||
|
get.myProp = function(self)
|
||||||
|
return self._myProp
|
||||||
|
end
|
||||||
|
|
||||||
|
set.myProp = function(self, value)
|
||||||
|
self._myProp = value
|
||||||
|
self:GetChild('n1').text = value
|
||||||
|
end
|
||||||
|
|
||||||
|
local myButton = someComponent:GetChild("myButton") --这个myButton的资源是“我的按钮”
|
||||||
|
myButton:Test()
|
||||||
|
myButton.myProp = 'hello'
|
||||||
|
|
||||||
|
local myButton2 = UIPackage.CreateObject("包名","我的按钮")
|
||||||
|
myButton2:Test()
|
||||||
|
myButton2.myProp = 'world'
|
||||||
|
]]
|
||||||
|
|
||||||
|
function fgui.register_extension(url, extension)
|
||||||
|
FairyGUI.UIObjectFactory.SetExtension(url, typeof(extension.base), extension.Extend)
|
||||||
|
end
|
||||||
|
|
||||||
|
function fgui.extension_class(base)
|
||||||
|
local o = {}
|
||||||
|
o.__index = o
|
||||||
|
|
||||||
|
o.base = base or GComponent
|
||||||
|
|
||||||
|
o.Extend = function(ins)
|
||||||
|
local t = {}
|
||||||
|
setmetatable(t, o)
|
||||||
|
tolua.setpeer(ins,t)
|
||||||
|
return t
|
||||||
|
end
|
||||||
|
|
||||||
|
return o
|
||||||
|
end
|
||||||
|
|
@ -0,0 +1,627 @@
|
||||||
|
--- Base GameEvent
|
||||||
|
|
||||||
|
GameEvent = {
|
||||||
|
-- 状态
|
||||||
|
PlayerState = 'PlayerState',
|
||||||
|
-- 聊天
|
||||||
|
Interaction = 'Interaction',
|
||||||
|
-- 玩家离开
|
||||||
|
PlayerLeave = 'PlayerLeave',
|
||||||
|
-- 玩家进入
|
||||||
|
PlayerEnter = 'PlayerEnter',
|
||||||
|
-- 玩家准备
|
||||||
|
PlayerReady = 'PlayerReady',
|
||||||
|
-- 解散
|
||||||
|
DeskBreak = 'DeskBreak',
|
||||||
|
-- 被踢出房间
|
||||||
|
OnKicked = 'OnKicked',
|
||||||
|
-- 更新玩家信息
|
||||||
|
OnUpdateInfo = 'OnUpdateInfo',
|
||||||
|
|
||||||
|
--打开托管
|
||||||
|
TupGuanOpen='TupGuanOpen',
|
||||||
|
--关闭托管
|
||||||
|
TupGuanClose='TupGuanClose',
|
||||||
|
|
||||||
|
--麻将修改牌大小
|
||||||
|
MJModifySzie='MJModifySzie',
|
||||||
|
}
|
||||||
|
|
||||||
|
--- Base GameController
|
||||||
|
GameController = {
|
||||||
|
_name = '',
|
||||||
|
--事件MAP
|
||||||
|
_eventmap = nil,
|
||||||
|
--事件缓存
|
||||||
|
_cacheEvent = nil,
|
||||||
|
--事件发送器
|
||||||
|
_dispatcher = nil
|
||||||
|
}
|
||||||
|
|
||||||
|
local M = GameController
|
||||||
|
|
||||||
|
setmetatable(M, {__index = IController})
|
||||||
|
|
||||||
|
function M:init(name)
|
||||||
|
self._name = name
|
||||||
|
self.baseType = GameController
|
||||||
|
self._cacheEvent = Queue.new(1000)
|
||||||
|
self._eventmap = {}
|
||||||
|
self._dispatcher = {}
|
||||||
|
self._eventmap[Protocol.FGMGR_EVT_UPDATE_RECONECT]=self.ResetConnect
|
||||||
|
|
||||||
|
self._eventmap[Protocol.GAME_EVT_PLAYER_JOIN] = self.OnEventPlayerEnter
|
||||||
|
self._eventmap[Protocol.GAME_EVT_PLAYER_NET_STATE] = self.OnEventOnlineState
|
||||||
|
self._eventmap[Protocol.GAME_EVT_PLAYER_EXIT] = self.OnEventPlayerLeave
|
||||||
|
self._eventmap[Protocol.GAME_EVT_READY] = self.OnEventPlayerReady
|
||||||
|
self._eventmap[Protocol.GAME_EVT_READY_AND_XIPAI] = self.OnEventPlayerXiPaiReady
|
||||||
|
|
||||||
|
self._eventmap[Protocol.GAME_EVT_EXIT_ROOM_DISMISS] = self.OnEventExitRoomDismiss
|
||||||
|
self._eventmap[Protocol.GAME_EVT_DISMISS_ROOM] = self.OnEventDismissRoom
|
||||||
|
self._eventmap[Protocol.GAME_EVT_DISMISS_ROOM_VOTE] = self.OnEventDismissRoomVote
|
||||||
|
self._eventmap[Protocol.GAME_EVT_DISMISS_ROOM_FAIL] = self.OnEventDismissRoomFail
|
||||||
|
|
||||||
|
self._eventmap[Protocol.GAME_EVT_INTERACTION] = self.OnEventInteraction
|
||||||
|
self._eventmap[Protocol.GAME_EVT_UPDATE_GPS] = self.OnEventUpdateGPS
|
||||||
|
|
||||||
|
self._eventmap[Protocol.GAME_EVT_KICKED] = self.OnEventKicked
|
||||||
|
self._eventmap[Protocol.GAME_EVT_UPDATE_PLAYERINFO] = self.OnEvtUpdateInfo
|
||||||
|
|
||||||
|
self._eventmap[Protocol.GAME_EVT_READY_ENTRUST] = self.OnEvtOpenTupGTips
|
||||||
|
self._eventmap[Protocol.GAME_EVT_CANCEL_READY_ENTRUST] = self.OnEvtCloseTupGTips
|
||||||
|
|
||||||
|
--self._eventmap[Protocol.GAME_AUTO_CARD] = self.OnEvtOpenGameHuTuoGtips
|
||||||
|
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
function DispatchEvent(_dispatcher, evt_name, ...)
|
||||||
|
local func = _dispatcher[evt_name]
|
||||||
|
if func then
|
||||||
|
func(...)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:AddEventListener(evt_name, func)
|
||||||
|
self._dispatcher[evt_name] = func
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function M:ResetConnect()
|
||||||
|
-- print("断线重连================")
|
||||||
|
--ControllerManager.OnConnect(SocketCode.TimeoutDisconnect)
|
||||||
|
ViewManager.refreshGameView()
|
||||||
|
end
|
||||||
|
|
||||||
|
----------------------请求------------------------------------
|
||||||
|
|
||||||
|
--请求准备
|
||||||
|
function M:PlayerReady()
|
||||||
|
local _client = ControllerManager.GameNetClinet
|
||||||
|
if not _client then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
_client:send(Protocol.GAME_READY)
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:PlayerXiPai()
|
||||||
|
local _client = ControllerManager.GameNetClinet
|
||||||
|
if not _client then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
_client:send(Protocol.GAME_READY_AND_XIPAI)
|
||||||
|
end
|
||||||
|
|
||||||
|
--请求准备
|
||||||
|
function M:StartGame()
|
||||||
|
local _client = ControllerManager.GameNetClinet
|
||||||
|
if not _client then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
_client:send(Protocol.GAME_START)
|
||||||
|
end
|
||||||
|
|
||||||
|
--聊天
|
||||||
|
--<param name="playid"></param>
|
||||||
|
--<param name="type">1表情 2固定语音 3语音 4文本 5互动</param>
|
||||||
|
--<param name="parm"></param>
|
||||||
|
function M:SendInteraction(playid, type, parm, callback)
|
||||||
|
local _client = ControllerManager.GameNetClinet
|
||||||
|
if not _client then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
local _data = {}
|
||||||
|
_data['playerid'] = playid
|
||||||
|
_data['type'] = type
|
||||||
|
_data['parm'] = parm
|
||||||
|
_client:send(Protocol.GAME_INTERACTION, _data)
|
||||||
|
end
|
||||||
|
|
||||||
|
--请求离开房间
|
||||||
|
function M:LevelRoom(callBack)
|
||||||
|
local _client = ControllerManager.GameNetClinet
|
||||||
|
if not _client then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
_client:send(
|
||||||
|
Protocol.GAME_EXIT_ROOM,
|
||||||
|
nil,
|
||||||
|
function(res)
|
||||||
|
if res.ReturnCode == 0 then
|
||||||
|
ControllerManager.ChangeController(LoddyController)
|
||||||
|
end
|
||||||
|
callBack(res)
|
||||||
|
end
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
--请求解散房间
|
||||||
|
function M:AskDismissRoom()
|
||||||
|
local _curren_msg = MsgWindow.new(self._root_view, '是否发起解散?', MsgWindow.MsgMode.OkAndCancel)
|
||||||
|
_curren_msg.onOk:Add(function()
|
||||||
|
local _client = ControllerManager.GameNetClinet
|
||||||
|
if not _client then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
_client:send(Protocol.GAME_ASK_DISMISS_ROOM,nil,function (res)
|
||||||
|
if res.ReturnCode == 84 then
|
||||||
|
ViewUtil.ErrorTip(res.ReturnCode,"解散失败")
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end)
|
||||||
|
_curren_msg:Show()
|
||||||
|
end
|
||||||
|
|
||||||
|
--解散房间投票
|
||||||
|
function M:DismissRoomVote(agree)
|
||||||
|
local _client = ControllerManager.GameNetClinet
|
||||||
|
if not _client then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
-- print(agree)
|
||||||
|
local _data = {}
|
||||||
|
_data['result'] = agree
|
||||||
|
_client:send(Protocol.GAME_DISMISS_ROOM_VOTE, _data)
|
||||||
|
end
|
||||||
|
|
||||||
|
--发送GPS坐标
|
||||||
|
function M:SendGPS(str)
|
||||||
|
local _client = ControllerManager.GameNetClinet
|
||||||
|
if not _client then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
local _data = {}
|
||||||
|
_data['pos'] = str
|
||||||
|
_client:send(Protocol.GAME_SEND_GPS, _data)
|
||||||
|
end
|
||||||
|
|
||||||
|
--------------------事件-----------------------------------
|
||||||
|
|
||||||
|
-- 房主退出 房间解散
|
||||||
|
function M:OnEventExitRoomDismiss(evt_data)
|
||||||
|
self._cacheEvent:Enqueue(
|
||||||
|
function()
|
||||||
|
ControllerManager.ChangeController(LoddyController)
|
||||||
|
DispatchEvent(self._dispatcher, GameEvent.DeskBreak, 1)
|
||||||
|
end
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- 显示投票选择
|
||||||
|
function M:OnEventDismissRoom(evt_data)
|
||||||
|
self._cacheEvent:Enqueue(
|
||||||
|
function()
|
||||||
|
local room = DataManager.CurrenRoom
|
||||||
|
local req_aid = evt_data['req_aid']
|
||||||
|
evt_data.req_p = room:GetPlayerById(req_aid)
|
||||||
|
local player_list = room.player_list
|
||||||
|
local tem_list = {}
|
||||||
|
local list = evt_data['list']
|
||||||
|
|
||||||
|
for k = 1, #player_list do
|
||||||
|
local p = nil
|
||||||
|
for i = 1, #list do
|
||||||
|
local tem = list[i]
|
||||||
|
if tem.aid == player_list[k].self_user.account_id then
|
||||||
|
tem.player = player_list[k]
|
||||||
|
p = tem
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if not p then
|
||||||
|
p = {}
|
||||||
|
p.player = player_list[k]
|
||||||
|
p.result = 0
|
||||||
|
end
|
||||||
|
tem_list[k] = p
|
||||||
|
end
|
||||||
|
evt_data['list'] = tem_list
|
||||||
|
|
||||||
|
DispatchEvent(self._dispatcher, GameEvent.DeskBreak, 0, evt_data)
|
||||||
|
end
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- -- 投票结果
|
||||||
|
-- function M:OnEventDismissRoomVote(evt_data)
|
||||||
|
-- local aid = evt_data["aid"]
|
||||||
|
-- local result = evt_data["result"]
|
||||||
|
-- local p = DataManager.CurrenRoom:GetPlayerById(aid)
|
||||||
|
-- DispatchEvent(self._dispatcher,GameEvent.DeskBreak, 2,p,result)
|
||||||
|
-- end
|
||||||
|
|
||||||
|
-- 解散失敗
|
||||||
|
function M:OnEventDismissRoomFail(evt_data)
|
||||||
|
self._cacheEvent:Enqueue(
|
||||||
|
function()
|
||||||
|
DispatchEvent(self._dispatcher, GameEvent.DeskBreak, 3)
|
||||||
|
end
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- 玩家进
|
||||||
|
function M:OnEventPlayerEnter(evt_data)
|
||||||
|
--print("进入房间++++++++++++++++++++++++++++++++++++++")
|
||||||
|
self._cacheEvent:Enqueue(
|
||||||
|
function()
|
||||||
|
local p = self._room:NewPlayer()
|
||||||
|
local _user
|
||||||
|
_user = User.new()
|
||||||
|
_user.account_id = evt_data['aid']
|
||||||
|
_user.host_ip = evt_data['ip']
|
||||||
|
_user.nick_name = evt_data['nick']
|
||||||
|
_user.head_url = evt_data['portrait']
|
||||||
|
_user.sex = evt_data['sex']
|
||||||
|
_user.location = Location.new(evt_data['pos'] or '')
|
||||||
|
p.seat = evt_data['seat']
|
||||||
|
p.ready = evt_data['ready'] == 1 and true or false
|
||||||
|
p.cur_hp = evt_data['cur_hp'] or 0
|
||||||
|
p.spectator = evt_data['spectator']
|
||||||
|
-- p.total_hp = evt_data["total_hp"] or 0
|
||||||
|
if evt_data['hp_info'] then
|
||||||
|
p.cur_hp = evt_data.hp_info.cur_hp
|
||||||
|
-- p.total_hp = evt_data.hp_info.total_hp
|
||||||
|
end
|
||||||
|
p.self_user = _user
|
||||||
|
p.line_state = 1
|
||||||
|
DataManager.CurrenRoom:AddPlayer(p)
|
||||||
|
DispatchEvent(self._dispatcher, GameEvent.PlayerEnter, p)
|
||||||
|
|
||||||
|
end
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- 玩家离开
|
||||||
|
function M:OnEventPlayerLeave(evt_data)
|
||||||
|
self._cacheEvent:Enqueue(
|
||||||
|
function()
|
||||||
|
local playerid = evt_data['aid']
|
||||||
|
local p = DataManager.CurrenRoom:GetPlayerById(playerid)
|
||||||
|
self._room:RemovePlayer(p)
|
||||||
|
DispatchEvent(self._dispatcher, GameEvent.PlayerLeave, p)
|
||||||
|
end
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- 网络状态更新
|
||||||
|
function M:OnEventOnlineState(evt_data)
|
||||||
|
self._cacheEvent:Enqueue(
|
||||||
|
function()
|
||||||
|
local playerid = evt_data['aid']
|
||||||
|
local online = evt_data['online']
|
||||||
|
local player = DataManager.CurrenRoom:GetPlayerById(playerid)
|
||||||
|
if player ~= nil then
|
||||||
|
player.line_state = online
|
||||||
|
DispatchEvent(self._dispatcher, GameEvent.PlayerState, player)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- 玩家准备
|
||||||
|
function M:OnEventPlayerReady(evt_data)
|
||||||
|
self._cacheEvent:Enqueue(
|
||||||
|
function()
|
||||||
|
local pid = evt_data['aid']
|
||||||
|
local p = self._room:GetPlayerById(pid)
|
||||||
|
p.ready = true
|
||||||
|
if evt_data.start~=nil then
|
||||||
|
if evt_data.start==1 then
|
||||||
|
p.isSendCardState=true
|
||||||
|
else
|
||||||
|
p.isSendCardState=false
|
||||||
|
end
|
||||||
|
|
||||||
|
else
|
||||||
|
p.isSendCardState=false
|
||||||
|
end
|
||||||
|
|
||||||
|
DispatchEvent(self._dispatcher, GameEvent.PlayerReady, p)
|
||||||
|
end
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function M:OnEventPlayerXiPaiReady(evt_data)
|
||||||
|
self._cacheEvent:Enqueue(
|
||||||
|
function()
|
||||||
|
local pid = evt_data['aid']
|
||||||
|
local p = self._room:GetPlayerById(pid)
|
||||||
|
p.ready = true
|
||||||
|
if evt_data.start~=nil then
|
||||||
|
if evt_data.start==1 then
|
||||||
|
p.isSendCardState=true
|
||||||
|
else
|
||||||
|
p.isSendCardState=false
|
||||||
|
end
|
||||||
|
|
||||||
|
else
|
||||||
|
p.isSendCardState=false
|
||||||
|
end
|
||||||
|
|
||||||
|
DispatchEvent(self._dispatcher, GameEvent.PlayerReady, p)
|
||||||
|
end
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
-- 聊天事件
|
||||||
|
function M:OnEventInteraction(evt_data)
|
||||||
|
if self._room.ban_chat1 == false or self._room.ban_chat2 == false then
|
||||||
|
self._cacheEvent:Enqueue(
|
||||||
|
function()
|
||||||
|
local playerid = evt_data['playerid']
|
||||||
|
local p = self._room:GetPlayerById(playerid)
|
||||||
|
local type1 = evt_data['type']
|
||||||
|
local parm = evt_data['parm']
|
||||||
|
DispatchEvent(self._dispatcher, GameEvent.Interaction, p, type1, parm)
|
||||||
|
end
|
||||||
|
)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- GPS更新事件
|
||||||
|
function M:OnEventUpdateGPS(evt_data)
|
||||||
|
self._cacheEvent:Enqueue(
|
||||||
|
function()
|
||||||
|
local seat = evt_data['seat']
|
||||||
|
local pos = evt_data['pos']
|
||||||
|
if seat == 0 or seat == 'skip' then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
local p = self._room:GetPlayerBySeat(seat)
|
||||||
|
p.self_user.location = Location.new(pos)
|
||||||
|
end
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- 被踢出房间事件
|
||||||
|
function M:OnEventKicked()
|
||||||
|
if ViewManager.GetCurrenView().dview_class == LobbyView then
|
||||||
|
DataManager.CurrenRoom = nil
|
||||||
|
ControllerManager.SetGameNetClient(nil, true)
|
||||||
|
ControllerManager.ChangeController(LoddyController)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
self._cacheEvent:Enqueue(
|
||||||
|
function()
|
||||||
|
DataManager.CurrenRoom = nil
|
||||||
|
ControllerManager.SetGameNetClient(nil, true)
|
||||||
|
ControllerManager.ChangeController(LoddyController)
|
||||||
|
DispatchEvent(self._dispatcher, GameEvent.OnKicked)
|
||||||
|
end
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- 托管
|
||||||
|
function M:Entrust(ok, info)
|
||||||
|
local _client = ControllerManager.GameNetClinet
|
||||||
|
if not _client then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
local data = {}
|
||||||
|
data.ok = ok
|
||||||
|
data.info = info
|
||||||
|
_client:send(Protocol.GAME_ENTRUST, data)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- 入座
|
||||||
|
function M:JoinSeat(callback)
|
||||||
|
local _client = ControllerManager.GameNetClinet
|
||||||
|
if not _client then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
_client:send(Protocol.GAME_JOIN_SEAT, nil, function(res)
|
||||||
|
if res.ReturnCode == 0 then
|
||||||
|
self._room.self_player.spectator = false
|
||||||
|
end
|
||||||
|
if callback then
|
||||||
|
callback(res)
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- 更新事件
|
||||||
|
function M:OnEvtUpdateInfo(evt_data)
|
||||||
|
self._cacheEvent:Enqueue(
|
||||||
|
function()
|
||||||
|
local pid = evt_data['aid']
|
||||||
|
local p = self._room:GetPlayerById(pid)
|
||||||
|
local t = evt_data['type']
|
||||||
|
if t == 5 then
|
||||||
|
p.entrust = evt_data['entrust']
|
||||||
|
end
|
||||||
|
DispatchEvent(self._dispatcher, GameEvent.OnUpdateInfo, p, t)
|
||||||
|
end
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:ClearPlayerData()
|
||||||
|
local _room = self._room
|
||||||
|
for i = 1, #_room.player_list do
|
||||||
|
_room.player_list[i]:Clear()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:PopEvent()
|
||||||
|
local _cacheEvent = self._cacheEvent
|
||||||
|
if (_cacheEvent:Count() > 0) then
|
||||||
|
return _cacheEvent:Dequeue()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local function list_add(list, val)
|
||||||
|
if not list_check(list, val) then
|
||||||
|
table.insert(list, val)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
-- 检查 gps距离、ip地址
|
||||||
|
function M:CheckGPS()
|
||||||
|
local plist = {}
|
||||||
|
local warnList = {}
|
||||||
|
local ipList = {}
|
||||||
|
local player_list = self._room.player_list
|
||||||
|
-- GPS
|
||||||
|
for i = 1, #player_list do
|
||||||
|
local player1 = player_list[i]
|
||||||
|
if player1.self_user ~= DataManager.SelfUser then
|
||||||
|
local loc1 = player1.self_user.location
|
||||||
|
if not loc1 or loc1.default then
|
||||||
|
-- 数据类型:gps警告,只有此处使用了
|
||||||
|
-- type:0.没有打开gps,1.距离过近,2.ip地址一样
|
||||||
|
local warn = {}
|
||||||
|
warn.type = 0
|
||||||
|
warn.seat = player1.seat
|
||||||
|
return true
|
||||||
|
elseif i < #player_list then
|
||||||
|
for j = i + 1, #player_list do
|
||||||
|
local player2 = player_list[j]
|
||||||
|
if player2.self_user ~= DataManager.SelfUser then
|
||||||
|
local loc2 = player2.self_user.location
|
||||||
|
if not loc2 or loc2.default then
|
||||||
|
local warn = {}
|
||||||
|
warn.type = 0
|
||||||
|
warn.seat = player2.seat
|
||||||
|
return true
|
||||||
|
else
|
||||||
|
local dist = loc1:CalcDistance(loc2)
|
||||||
|
if dist < 0.2 then
|
||||||
|
local warn = {}
|
||||||
|
warn.type = 1
|
||||||
|
warn.seat = player1.seat
|
||||||
|
warn.seat2 = player2.seat
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
local p = player1
|
||||||
|
if p.self_user ~= DataManager.SelfUser then
|
||||||
|
local ip = p.self_user.host_ip
|
||||||
|
if not list_check(ipList, ip) then
|
||||||
|
table.insert(ipList, ip)
|
||||||
|
else
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:GetGPS()
|
||||||
|
-- if not DataManager.SelfUser.location.default then return end
|
||||||
|
-- 获取GPS
|
||||||
|
get_gps(
|
||||||
|
function()
|
||||||
|
self:SendGPS(DataManager.SelfUser.location:Location2String())
|
||||||
|
end
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:OnEnter()
|
||||||
|
if (debug_print) then
|
||||||
|
print(self._name .. '进入Game控制器')
|
||||||
|
end
|
||||||
|
self._room = DataManager.CurrenRoom
|
||||||
|
local _client = ControllerManager.GameNetClinet
|
||||||
|
_client.onevent:Add(self.__OnNetEvent, self)
|
||||||
|
|
||||||
|
-- self:GetGPS()
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:OnExit()
|
||||||
|
if (debug_print) then
|
||||||
|
print(self._name .. ' 离开Game控制器')
|
||||||
|
end
|
||||||
|
ControllerManager.SetGameNetClient(nil)
|
||||||
|
self._cacheEvent:Clear()
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:__OnNetEvent(msg)
|
||||||
|
--print("Game消息ID===>>"..msg.Command)
|
||||||
|
local func = self._eventmap[msg.Command]
|
||||||
|
if (func ~= nil) then
|
||||||
|
func(self, msg.Data)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:ReturnToRoom()
|
||||||
|
local roomCtr = ControllerManager.GetController(RoomController)
|
||||||
|
roomCtr:PublicJoinRoom(
|
||||||
|
Protocol.WEB_FG_JOIN_ROOM,
|
||||||
|
self.tmpRoomID,
|
||||||
|
false,
|
||||||
|
function(response)
|
||||||
|
if (response.ReturnCode == -1) then
|
||||||
|
ViewUtil.CloseModalWait('join_room')
|
||||||
|
RestartGame()
|
||||||
|
return
|
||||||
|
end
|
||||||
|
ViewManager.ChangeView(ViewManager.View_Main, DataManager.CurrenRoom.game_id)
|
||||||
|
ViewUtil.CloseModalWait('join_room')
|
||||||
|
end,
|
||||||
|
self.tmpGroupID
|
||||||
|
)
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function M:OnEvtOpenTupGTips(msg)
|
||||||
|
--print("显示托管倒计时=====================")
|
||||||
|
pt(msg)
|
||||||
|
local pid = msg['aid']
|
||||||
|
local p = self._room:GetPlayerById(pid)
|
||||||
|
local t=msg['time']
|
||||||
|
DispatchEvent(self._dispatcher, GameEvent.TupGuanOpen, p,true, t)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function M:OnEvtCloseTupGTips(msg)
|
||||||
|
--print("关闭托管倒计时=================")
|
||||||
|
--pt(msg)
|
||||||
|
local pid = msg['aid']
|
||||||
|
local p = self._room:GetPlayerById(pid)
|
||||||
|
local t=msg['time']
|
||||||
|
DispatchEvent(self._dispatcher, GameEvent.TupGuanOpen, p,false, t)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function M:DispatchEventTuoGuan(p,isShow,t)
|
||||||
|
DispatchEvent(self._dispatcher, GameEvent.TupGuanOpen, p,isShow, t)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function M:OnEvtOpenGameHuTuoGtips(isAuto)
|
||||||
|
local _client = ControllerManager.GameNetClinet
|
||||||
|
if not _client then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
local data = {}
|
||||||
|
data.autoCard = isAuto
|
||||||
|
_client:send(Protocol.GAME_AUTO_CARD, data)
|
||||||
|
end
|
||||||
|
|
@ -0,0 +1,372 @@
|
||||||
|
--- Base GameEvent
|
||||||
|
|
||||||
|
GroupMgrEvent = {
|
||||||
|
AddPlay = "add_play",
|
||||||
|
DelPlay = "del_play",
|
||||||
|
UpdatePlay = "update_play",
|
||||||
|
AddRoom = "add_room",
|
||||||
|
DelRoom = "del_room",
|
||||||
|
UpdateRoom = "update_room",
|
||||||
|
UpdatePlayerInfo = "update_player_info",
|
||||||
|
UpdateMessage = "update_msg",
|
||||||
|
BeInvited = "be_invited",
|
||||||
|
UpdateGroup = "UpdateGroup",
|
||||||
|
NewMailTip = "NewMailTip",
|
||||||
|
}
|
||||||
|
|
||||||
|
GroupMgrController = {
|
||||||
|
_name = "",
|
||||||
|
--事件MAP
|
||||||
|
_eventmap = nil,
|
||||||
|
--事件缓存
|
||||||
|
_cacheEvent = nil,
|
||||||
|
--事件发送器
|
||||||
|
_dispatcher = nil
|
||||||
|
}
|
||||||
|
|
||||||
|
local M = GroupMgrController
|
||||||
|
|
||||||
|
--- Create a new GroupMgrController
|
||||||
|
function GroupMgrController.new()
|
||||||
|
setmetatable(M, { __index = IController })
|
||||||
|
local self = setmetatable({}, { __index = M })
|
||||||
|
self.baseType = GroupMgrController
|
||||||
|
self._cacheEvent = Queue.new(1000)
|
||||||
|
self._eventmap = {}
|
||||||
|
self._dispatcher = {}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
self._eventmap[Protocol.FGMGR_EVT_ADD_PLAY] = self.OnEvtAddPlay
|
||||||
|
self._eventmap[Protocol.FGMGR_EVT_DEL_PLAY] = self.OnEvtDelPlay
|
||||||
|
self._eventmap[Protocol.FGMGR_EVT_UPDATE_PLAY] = self.OnEvtUpdatePlay
|
||||||
|
self._eventmap[Protocol.FGMGR_EVT_ADD_ROOM] = self.OnEvtAddRoom
|
||||||
|
self._eventmap[Protocol.FGMGR_EVT_DEL_ROOM] = self.OnEvtDelRoom
|
||||||
|
self._eventmap[Protocol.FGMGR_EVT_UPDATE_ROOM] = self.OnEvtUpdateRoom
|
||||||
|
self._eventmap[Protocol.FGMGR_EVT_UPDATE_PLAYER_INFO] = self.OnEvtUpdatePlayerInfo
|
||||||
|
self._eventmap[Protocol.FGMGR_EVT_MESSAGE] = self.OnEvtMessage
|
||||||
|
self._eventmap[Protocol.FGMGR_EVT_INVITED] = self.OnEvtInvited
|
||||||
|
self._eventmap[Protocol.FGMGR_EVT_UPDATE_GROUP] = self.OnEvtUpdateGroup
|
||||||
|
self._eventmap[Protocol.FGMGR_EVT_NEW_MAIL] = self.OnEvtNewMailTip
|
||||||
|
-- self:connect(callback)
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
function DispatchEvent(_dispatcher, evt_name, ...)
|
||||||
|
local func = _dispatcher[evt_name]
|
||||||
|
if func then
|
||||||
|
func(...)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:AddEventListener(evt_name, func)
|
||||||
|
self._dispatcher[evt_name] = func
|
||||||
|
end
|
||||||
|
|
||||||
|
----------------------请求------------------------------------
|
||||||
|
function M:connect(host, groupId, callback)
|
||||||
|
self.host = host
|
||||||
|
self.groupId = groupId
|
||||||
|
self.connecting = true
|
||||||
|
if self._mgr_client then
|
||||||
|
self._mgr_client:destroy()
|
||||||
|
self._mgr_client = nil
|
||||||
|
end
|
||||||
|
print("666666666666666666666666666 ", host)
|
||||||
|
local _mgr_client = NetClient.new(self.host, "mgr_group")
|
||||||
|
self._mgr_client = _mgr_client
|
||||||
|
_mgr_client:connect()
|
||||||
|
_mgr_client.onconnect:Add(function(code)
|
||||||
|
self.code = code
|
||||||
|
if (code == SocketCode.Connect) then
|
||||||
|
local _data = {}
|
||||||
|
_data.session = ControllerManager.WebClient:getSession()
|
||||||
|
if _data.session == nil then
|
||||||
|
self.connecting = false
|
||||||
|
_mgr_client:destroy()
|
||||||
|
ViewUtil.ErrorTip(1234567, "圈子数据异常!!!")
|
||||||
|
return
|
||||||
|
end
|
||||||
|
_data.groupId = self.groupId
|
||||||
|
--printlog(debug.traceback())
|
||||||
|
--printlog("session===1111111111>>>", _data.session)
|
||||||
|
--pt(_data)
|
||||||
|
_mgr_client:send(Protocol.FGMGR_ENTER_GROUP, _data, function(res)
|
||||||
|
self.connecting = false
|
||||||
|
if res.ReturnCode == 0 then
|
||||||
|
-- printlog("2222222222222222222222222222222")
|
||||||
|
-- pt(res)
|
||||||
|
_mgr_client.onevent:Add(self.__OnNetEvent, self)
|
||||||
|
_mgr_client.onconnect:Add(self.__OnConnect, self)
|
||||||
|
if callback then
|
||||||
|
self:OnEnter()
|
||||||
|
end
|
||||||
|
local group = DataManager.groups:get(groupId)
|
||||||
|
group:clearPlay()
|
||||||
|
local play_list = res.Data.play_list
|
||||||
|
printlog("2222222222222222")
|
||||||
|
pt(play_list)
|
||||||
|
for i = 1, #play_list do
|
||||||
|
local m = play_list[i]
|
||||||
|
group:addPlay(m)
|
||||||
|
end
|
||||||
|
local rooms = res.Data.rooms
|
||||||
|
for i = 1, #rooms do
|
||||||
|
local m = rooms[i]
|
||||||
|
if m.status ~= 2 then
|
||||||
|
group:addRoom(m)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
group.ban = res.Data.ban
|
||||||
|
group.ban_ip = res.Data.ban_ip
|
||||||
|
group.ban_gps = res.Data.ban_gps
|
||||||
|
group.hp = res.Data.hp
|
||||||
|
group.lev = res.Data.lev
|
||||||
|
group.joins = res.Data.joins
|
||||||
|
group.kick_opt = res.Data.kick_opt
|
||||||
|
group.partnerLev = res.Data.partnerLev
|
||||||
|
group.dissolve_opt = res.Data.dissolve_opt
|
||||||
|
group.permission = res.Data.permission
|
||||||
|
group.diamo = res.Data.diamo or 0
|
||||||
|
group.apply = res.Data.ban_apply or 0
|
||||||
|
group.update_room = true
|
||||||
|
group.mail_tip = res.Data.mail_tip
|
||||||
|
group.ban_chat1 = res.Data.ban_chat1
|
||||||
|
group.ban_chat2 = res.Data.ban_chat2
|
||||||
|
group.isvip = res.Data.isvip
|
||||||
|
else
|
||||||
|
self.code = SocketCode.ExceptionOnConnect
|
||||||
|
_mgr_client:destroy()
|
||||||
|
end
|
||||||
|
if callback then
|
||||||
|
callback(res)
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
else
|
||||||
|
self.connecting = false
|
||||||
|
_mgr_client:destroy()
|
||||||
|
if callback then
|
||||||
|
callback({ ReturnCode = 101 })
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:disconnect()
|
||||||
|
self.connecting = false
|
||||||
|
if self._mgr_client then
|
||||||
|
self._mgr_client:destroy()
|
||||||
|
end
|
||||||
|
self.host = nil
|
||||||
|
self.groupId = nil
|
||||||
|
if self._reconnect then
|
||||||
|
self._reconnect:Stop()
|
||||||
|
self._reconnect = nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
--------------------事件-----------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
-- 添加玩法
|
||||||
|
function M:OnEvtAddPlay(evt_data)
|
||||||
|
local group = DataManager.groups:get(self.groupId)
|
||||||
|
group:addPlay(evt_data)
|
||||||
|
local pid = evt_data.id
|
||||||
|
DispatchEvent(self._dispatcher, GroupMgrEvent.AddPlay, pid)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- 删除玩法
|
||||||
|
function M:OnEvtDelPlay(evt_data)
|
||||||
|
local pid = evt_data.pid
|
||||||
|
local group = DataManager.groups:get(self.groupId)
|
||||||
|
group:delPlay(pid)
|
||||||
|
DispatchEvent(self._dispatcher, GroupMgrEvent.DelPlay)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- 更新玩法
|
||||||
|
function M:OnEvtUpdatePlay(evt_data)
|
||||||
|
--print("更新玩法=============》》》")
|
||||||
|
--pt(evt_data)
|
||||||
|
local pid = evt_data.pid
|
||||||
|
local group = DataManager.groups:get(self.groupId)
|
||||||
|
group:addPlay(evt_data)
|
||||||
|
group.update_play = true
|
||||||
|
DispatchEvent(self._dispatcher, GroupMgrEvent.UpdatePlay)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- 添加房间
|
||||||
|
function M:OnEvtAddRoom(evt_data)
|
||||||
|
-- local group = DataManager.groups:get(self.groupId)
|
||||||
|
-- group:addRoom(evt_data)
|
||||||
|
-- group.update_room = true
|
||||||
|
-- DispatchEvent(self._dispatcher,GroupMgrEvent.AddRoom)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- 删除玩法
|
||||||
|
function M:OnEvtDelRoom(evt_data)
|
||||||
|
-- local roomid = evt_data.roomid
|
||||||
|
-- local group = DataManager.groups:get(self.groupId)
|
||||||
|
-- group:delRoom(roomid)
|
||||||
|
-- group.update_room = true
|
||||||
|
-- DispatchEvent(self._dispatcher,GroupMgrEvent.DelRoom)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- 更新房间
|
||||||
|
function M:OnEvtUpdateRoom(evt_data)
|
||||||
|
local group = DataManager.groups:get(self.groupId)
|
||||||
|
local cmds = evt_data.cmds
|
||||||
|
for i = 1, #cmds do
|
||||||
|
local cmd = cmds[i]
|
||||||
|
local ct = cmd["$ct"]
|
||||||
|
if ct == 3 then
|
||||||
|
group:delRoom(cmd.roomid)
|
||||||
|
else
|
||||||
|
group:addRoom(cmd)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
group.update_room = true
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:OnEvtUpdatePlayerInfo(evt_data)
|
||||||
|
--type:1体力值 2管理员等级 3合伙人等级
|
||||||
|
local itype = evt_data.type
|
||||||
|
local value = evt_data.value
|
||||||
|
local group = DataManager.groups:get(self.groupId)
|
||||||
|
local memb = group:getMember(DataManager.SelfUser.account_id)
|
||||||
|
if itype == 1 then
|
||||||
|
if memb then
|
||||||
|
memb.hp = value
|
||||||
|
end
|
||||||
|
group.hp = value
|
||||||
|
elseif itype == 2 then
|
||||||
|
memb.lev = value
|
||||||
|
group.lev = value
|
||||||
|
elseif itype == 3 then
|
||||||
|
memb.partnerLev = value
|
||||||
|
group.partnerLev = value
|
||||||
|
elseif itype == 4 then
|
||||||
|
group.diamo = evt_data.diamo
|
||||||
|
end
|
||||||
|
group.update_info = true
|
||||||
|
-- DispatchEvent(self._dispatcher,GroupMgrEvent.UpdatePlayerInfo)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- 更新申请列表
|
||||||
|
function M:OnEvtMessage(evt_data)
|
||||||
|
local group = DataManager.groups:get(self.groupId)
|
||||||
|
group.joins = evt_data.joins
|
||||||
|
group.update_joins = true
|
||||||
|
end
|
||||||
|
|
||||||
|
-- 被邀请事件
|
||||||
|
function M:OnEvtInvited(evt_data)
|
||||||
|
DispatchEvent(self._dispatcher, GroupMgrEvent.BeInvited, evt_data)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- 更新圈子
|
||||||
|
function M:OnEvtUpdateGroup(evt_data)
|
||||||
|
local group = DataManager.groups:get(self.groupId)
|
||||||
|
group.name = evt_data.name
|
||||||
|
group.ban = evt_data.ban == 1
|
||||||
|
group.notice = evt_data.notice
|
||||||
|
group.option = evt_data.option
|
||||||
|
group.show_num = evt_data.show_num
|
||||||
|
DispatchEvent(self._dispatcher, GroupMgrEvent.UpdateGroup, evt_data)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- 未读邮件通知
|
||||||
|
function M:OnEvtNewMailTip(evt_data)
|
||||||
|
local group = DataManager.groups:get(self.groupId)
|
||||||
|
group.mail_tip = 1
|
||||||
|
DispatchEvent(self._dispatcher, GroupMgrEvent.NewMailTip, evt_data)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- 获取在线玩家
|
||||||
|
function M:FG_GetOnlinePlayers(callback)
|
||||||
|
self._mgr_client:send(Protocol.FGMGR_GET_ONLINE_PLAYERS, nil, function(res)
|
||||||
|
callback(res)
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- 邀请在线玩家
|
||||||
|
function M:FG_InvitePlayer(tag, roomid, pid, game_name, callback)
|
||||||
|
local _data = {}
|
||||||
|
_data.tagId = tag
|
||||||
|
_data.roomid = roomid
|
||||||
|
_data.pid = pid
|
||||||
|
_data.g_name = game_name
|
||||||
|
self._mgr_client:send(Protocol.FGMGR_INVITE_PLAYER, _data, function(res)
|
||||||
|
callback(res)
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- 回复邀请
|
||||||
|
function M:FG_ResponseInvited(id, refuse)
|
||||||
|
local _data = {}
|
||||||
|
_data.invi_id = id
|
||||||
|
_data.refuse = refuse
|
||||||
|
self._mgr_client:send(Protocol.FGMGR_RESPONSE_INVITE, _data)
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:PopEvent()
|
||||||
|
local _cacheEvent = self._cacheEvent
|
||||||
|
if (_cacheEvent:Count() > 0) then
|
||||||
|
return _cacheEvent:Dequeue()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:OnEnter()
|
||||||
|
self._reconnect = Timer.New(function()
|
||||||
|
if not self.connecting and self.code ~= SocketCode.Connect then
|
||||||
|
local _client = self._mgr_client
|
||||||
|
if _client then
|
||||||
|
_client:destroy()
|
||||||
|
end
|
||||||
|
if not self.host or not self.groupId then return end
|
||||||
|
self:connect(self.host, self.groupId)
|
||||||
|
end
|
||||||
|
end, 2, -1, true)
|
||||||
|
self._reconnect:Start()
|
||||||
|
-- self._reconnect = coroutine.start(function()
|
||||||
|
-- while true do
|
||||||
|
-- coroutine.wait(2)
|
||||||
|
-- if not self.connecting and self.code ~= SocketCode.Connect then
|
||||||
|
-- self:connect()
|
||||||
|
-- end
|
||||||
|
-- end
|
||||||
|
-- end)
|
||||||
|
local _client = self._mgr_client
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:OnExit()
|
||||||
|
if self._reconnect then
|
||||||
|
self._reconnect:Stop()
|
||||||
|
self._reconnect = nil
|
||||||
|
end
|
||||||
|
local _client = self._mgr_client
|
||||||
|
if _client then
|
||||||
|
_client:destroy()
|
||||||
|
end
|
||||||
|
local group = DataManager.groups:get(self.groupId)
|
||||||
|
group:clear()
|
||||||
|
self._cacheEvent:Clear()
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:__OnNetEvent(msg)
|
||||||
|
--print("消息ID===>>"..msg.Command)
|
||||||
|
local func = self._eventmap[msg.Command]
|
||||||
|
if (func ~= nil) then func(self, msg.Data) end
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:__OnConnect(code)
|
||||||
|
self.code = code
|
||||||
|
if code ~= SocketCode.Connect then
|
||||||
|
local _client = self._mgr_client
|
||||||
|
self._mgr_client = nil
|
||||||
|
_client:destroy()
|
||||||
|
self._cacheEvent:Clear()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return M
|
||||||
|
|
@ -0,0 +1,16 @@
|
||||||
|
--控制器基类
|
||||||
|
--author:--
|
||||||
|
|
||||||
|
|
||||||
|
---
|
||||||
|
--@type IController
|
||||||
|
IController = {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function IController.OnEnter(self)
|
||||||
|
end
|
||||||
|
|
||||||
|
function IController.OnExit(self)
|
||||||
|
end
|
||||||
|
|
@ -0,0 +1,437 @@
|
||||||
|
|
||||||
|
LoddyController = {}
|
||||||
|
|
||||||
|
local M = {}
|
||||||
|
|
||||||
|
--- Create a new LoddyController
|
||||||
|
function LoddyController.new()
|
||||||
|
setmetatable(M, {__index = IController})
|
||||||
|
local self = setmetatable({}, {__index = M})
|
||||||
|
self.baseType = LoddyController
|
||||||
|
self.class = "Loddy"
|
||||||
|
self.recordList = {}
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
function M.OnEnter(self)
|
||||||
|
--print(vardump(self,"loddy controller enter"))
|
||||||
|
end
|
||||||
|
|
||||||
|
function M.OnExit(self)
|
||||||
|
--print(vardump(self,"loddy controller exit"))
|
||||||
|
end
|
||||||
|
|
||||||
|
local function __FillRoomData(s2croom)
|
||||||
|
local room = DataManager.CurrenRoom
|
||||||
|
local extend = ExtendManager.GetExtendConfig(room.game_id)
|
||||||
|
extend:FillRoomData(s2croom)
|
||||||
|
end
|
||||||
|
|
||||||
|
local function __ConntectGameServer(cmd,room, host, _data,callback)
|
||||||
|
-- local _data = {}
|
||||||
|
_data["session"] = room.session
|
||||||
|
local _game_client = NetClient.new(host, "game")
|
||||||
|
_game_client:connect()
|
||||||
|
ControllerManager.SetGameNetClient(_game_client)
|
||||||
|
_game_client.onconnect:Add(function(code)
|
||||||
|
if (code == SocketCode.Connect) then
|
||||||
|
_game_client:send(cmd, _data, function (response)
|
||||||
|
if (response.ReturnCode == 0) then
|
||||||
|
_game_client.onconnect:Clear()
|
||||||
|
_game_client.onconnect:Add(ControllerManager.OnConnect)
|
||||||
|
callback(response)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
_game_client:destroy()
|
||||||
|
if ControllerManager.GameNetClinet == _game_client then
|
||||||
|
ControllerManager.GameNetClinet =nil
|
||||||
|
end
|
||||||
|
callback(response)
|
||||||
|
end)
|
||||||
|
|
||||||
|
else
|
||||||
|
if ControllerManager.GameNetClinet == _game_client then
|
||||||
|
ControllerManager.GameNetClinet =nil
|
||||||
|
end
|
||||||
|
_game_client:destroy()
|
||||||
|
callback({ReturnCode = 101})
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function M:CreateRoom(game_id, _data, callback)
|
||||||
|
local _client = ControllerManager.WebClient
|
||||||
|
local data = {}
|
||||||
|
data.game_id = game_id
|
||||||
|
data["platform"] = GetPlatform()
|
||||||
|
data.config_data = _data
|
||||||
|
-- local runtime = os.clock()
|
||||||
|
_client:send(Protocol.WEB_CREATE_ROOM, data, function(res)
|
||||||
|
if ( res.ReturnCode == Table_Error_code.ERR_IN_ROOM or res.ReturnCode == Table_Error_code.ERR_CREATE_ROOM) then
|
||||||
|
self:JoinRoom("000000",callback)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
if (res.ReturnCode == 0) then
|
||||||
|
local json = res.Data
|
||||||
|
local game_info = json["game_info"]
|
||||||
|
if ExtendHotupdate.CheckVersion(game_info) ~= ExtendHotupdate.VERSION_NORMAL then
|
||||||
|
ExtendHotupdate.UpdateGame(game_info,function()
|
||||||
|
res.ReturnCode = -2
|
||||||
|
callback(res)
|
||||||
|
end)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
local game_id = game_info.game_id
|
||||||
|
local room_id = json["room_id"]
|
||||||
|
local server_ip = json["server_ip"]
|
||||||
|
local server_port = json["server_port"]
|
||||||
|
|
||||||
|
local room = ExtendManager.GetExtendConfig(game_id):NewRoom()
|
||||||
|
room.game_id = game_id
|
||||||
|
room.room_id = room_id
|
||||||
|
room.server_host = string.concat(server_ip, ":", server_port)
|
||||||
|
room.session = _client:getSession()
|
||||||
|
DataManager.CurrenRoom = room
|
||||||
|
|
||||||
|
local game_net = nil
|
||||||
|
|
||||||
|
local j_data = {}
|
||||||
|
j_data["session"] = room.session
|
||||||
|
if not DataManager.SelfUser.location then
|
||||||
|
DataManager.SelfUser.location = Location.new()
|
||||||
|
end
|
||||||
|
j_data["pos"] = DataManager.SelfUser.location:Location2String()
|
||||||
|
|
||||||
|
-- game_net =
|
||||||
|
__ConntectGameServer(Protocol.GAME_JOIN_ROOM,room,room.server_host, j_data, function (response)
|
||||||
|
if (response.ReturnCode == 0) then
|
||||||
|
-- game_net:clearEvent()
|
||||||
|
local _s2croom = response.Data
|
||||||
|
-- ControllerManager.SetGameNetClient(game_net)
|
||||||
|
room.owner_id = _s2croom["owner"]
|
||||||
|
room.banker_seat = _s2croom["manor"]
|
||||||
|
if _s2croom.createTime then
|
||||||
|
room.create_time = _s2croom["createTime"]
|
||||||
|
end
|
||||||
|
room.agent = _s2croom.agent == 1 and true or false
|
||||||
|
local extend = ExtendManager.GetExtendConfig(room.game_id)
|
||||||
|
extend:FillRoomData(_s2croom)
|
||||||
|
ControllerManager.ChangeController(GameController)
|
||||||
|
-- print("create room:"..(os.clock()-runtime))
|
||||||
|
callback(response)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
-- game_net:destroy()
|
||||||
|
callback(response)
|
||||||
|
end)
|
||||||
|
else
|
||||||
|
if callback then callback(res) end
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
local join_room_frame = 0
|
||||||
|
function M:PublicJoinRoom(cmd,room_id,callback,group_id,group_layer)
|
||||||
|
-- 同一帧不重复调用
|
||||||
|
local last_frame = join_room_frame
|
||||||
|
join_room_frame = Time.frameCount
|
||||||
|
if join_room_frame == last_frame then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
-- 防止游戏没有离开控制器
|
||||||
|
ControllerManager.ChangeController(LoddyController)
|
||||||
|
local _data = {}
|
||||||
|
_data["room_id"] = room_id
|
||||||
|
_data["group_id"] = group_id
|
||||||
|
_data["floor"] = group_layer
|
||||||
|
_data["platform"] = GetPlatform()
|
||||||
|
local _client = ControllerManager.WebClient;
|
||||||
|
_client:send(cmd, _data, function( res)
|
||||||
|
if (res.ReturnCode == 0) then
|
||||||
|
local json = res.Data
|
||||||
|
local game_info = json["game_info"]
|
||||||
|
if ExtendHotupdate.CheckVersion(game_info) ~= ExtendHotupdate.VERSION_NORMAL then
|
||||||
|
ExtendHotupdate.UpdateGame(game_info,function()
|
||||||
|
res.ReturnCode = -2
|
||||||
|
callback(res)
|
||||||
|
end)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
local game_id = game_info.game_id
|
||||||
|
local server_ip = json["server_ip"]
|
||||||
|
local server_port = json["server_port"]
|
||||||
|
|
||||||
|
local room = ExtendManager.GetExtendConfig(game_id):NewRoom()
|
||||||
|
room.lev = json["lev"] -- 自己在当前房间所在圈子的职位,1盟主,2管理员,3用户,非圈子房间就是3
|
||||||
|
room.room_id = json["room_id"]
|
||||||
|
room.game_id = game_id
|
||||||
|
room.status = json["status"]
|
||||||
|
room.server_host = string.concat(server_ip, ":", server_port)
|
||||||
|
room.session = _client:getSession()
|
||||||
|
room.group_id = json["groupId"]
|
||||||
|
room.play_id = json["pid"]
|
||||||
|
-- 体力值开关
|
||||||
|
room.hpOnOff = json["hpOnOff"]
|
||||||
|
-- 体力值倍数
|
||||||
|
room.score_times = json.hp_times and d2ad(json.hp_times) or 1
|
||||||
|
DataManager.CurrenRoom = room
|
||||||
|
local j_data = {}
|
||||||
|
if not DataManager.SelfUser.location then
|
||||||
|
DataManager.SelfUser.location = Location.new()
|
||||||
|
end
|
||||||
|
j_data["pos"] = DataManager.SelfUser.location:Location2String()
|
||||||
|
-- local game_net = nil
|
||||||
|
--print(vardump(room))
|
||||||
|
-- game_net =
|
||||||
|
__ConntectGameServer(Protocol.GAME_JOIN_ROOM,room,room.server_host, j_data,function ( res1)
|
||||||
|
if (res1.ReturnCode ~= 0 ) then
|
||||||
|
if (callback) then callback(res1) end
|
||||||
|
else
|
||||||
|
local _s2croom = res1.Data
|
||||||
|
room.owner_id = _s2croom["owner"]
|
||||||
|
if _s2croom.createTime then
|
||||||
|
room.create_time = _s2croom["createTime"]
|
||||||
|
end
|
||||||
|
if _s2croom.manor then
|
||||||
|
room.banker_seat = _s2croom.manor
|
||||||
|
end
|
||||||
|
room.agent = _s2croom.agent == 1 and true or false
|
||||||
|
-- ControllerManager.SetGameNetClient(game_net)
|
||||||
|
local extend = ExtendManager.GetExtendConfig(room.game_id)
|
||||||
|
extend:FillRoomData(_s2croom)
|
||||||
|
ControllerManager.ChangeController(GameController)
|
||||||
|
if callback then callback(res1) end
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
-- callback(res)
|
||||||
|
else
|
||||||
|
if callback then callback(res) end
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:JoinRoom(room_id,callback,group_id,group_layer)
|
||||||
|
self:PublicJoinRoom(Protocol.WEB_JOIN_ROOM,room_id,callback,group_id,group_layer)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function M:ResetJionRoom(callback)
|
||||||
|
local _game = ControllerManager.GetController(GameController)
|
||||||
|
local o_room = DataManager.CurrenRoom
|
||||||
|
local j_data = {}
|
||||||
|
if not DataManager.SelfUser.location then
|
||||||
|
DataManager.SelfUser.location = Location.new()
|
||||||
|
end
|
||||||
|
j_data["pos"] = DataManager.SelfUser.location:Location2String()
|
||||||
|
local room = ExtendManager.GetExtendConfig(o_room.game_id):NewRoom()
|
||||||
|
room.lev = o_room.lev
|
||||||
|
room.room_id = o_room.room_id
|
||||||
|
room.game_id = o_room.game_id
|
||||||
|
room.status = o_room.status
|
||||||
|
room.server_host = o_room.server_host
|
||||||
|
room.session = o_room.session
|
||||||
|
room.group_id = o_room.group_id
|
||||||
|
-- 体力值倍数
|
||||||
|
room.score_times = o_room.score_times
|
||||||
|
room.play_id = o_room.play_id
|
||||||
|
-- 体力值开关
|
||||||
|
room.hpOnOff = o_room.hpOnOff
|
||||||
|
room.owner_id = o_room.owner_id
|
||||||
|
room.create_time = o_room.create_time
|
||||||
|
room:SetReloadStatus(true)
|
||||||
|
DataManager.CurrenRoom = room
|
||||||
|
__ConntectGameServer(Protocol.GAME_JOIN_ROOM,room,room.server_host, j_data,function ( res1)
|
||||||
|
room:SetReloadStatus(false)
|
||||||
|
if (res1.ReturnCode ~= 0 ) then
|
||||||
|
if (callback) then callback(res1) end
|
||||||
|
else
|
||||||
|
printlog("ResetJionRoom==>>>")
|
||||||
|
pt(res1)
|
||||||
|
ControllerManager.enterPlayerData=res1.Data.tableInfo.playerData
|
||||||
|
local _s2croom = res1.Data
|
||||||
|
local extend = ExtendManager.GetExtendConfig(room.game_id)
|
||||||
|
extend:FillRoomData(_s2croom)
|
||||||
|
ControllerManager.ChangeController(GameController)
|
||||||
|
if callback then callback(res1) end
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:UpdatePlayerInfo(callback)
|
||||||
|
local _client = ControllerManager.WebClient
|
||||||
|
_client:send(Protocol.WEB_UPDATE_INFO, nil, function (res)
|
||||||
|
if res.ReturnCode == 0 then
|
||||||
|
DataManager.SelfUser.diamo = res.Data.diamo
|
||||||
|
DataManager.SelfUser.invited = res.Data.invitation
|
||||||
|
if callback then callback(true, res.Data) end
|
||||||
|
-- DataManager.SelfUser.raffle = res.Data.raffle
|
||||||
|
else
|
||||||
|
if callback then callback(false) end
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:UpdateNotice(id,callback)
|
||||||
|
local _client = ControllerManager.WebClient
|
||||||
|
local _data = {}
|
||||||
|
_data.id = id
|
||||||
|
_client:send(Protocol.WEB_UPDATE_NOTICE, _data, function (res)
|
||||||
|
--print("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ",res)
|
||||||
|
--pt(res)
|
||||||
|
if res.ReturnCode == 0 and #res.Data.notice_list > 0 then
|
||||||
|
callback(true, res.Data)
|
||||||
|
else
|
||||||
|
callback(false)
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:RequestRecordList(callback, roomid)
|
||||||
|
local _client = ControllerManager.WebClient
|
||||||
|
local _data = {}
|
||||||
|
_data["platform"] = GetPlatform()
|
||||||
|
local proto
|
||||||
|
if not roomid then
|
||||||
|
proto = Protocol.WEB_GET_MILITARY
|
||||||
|
else
|
||||||
|
proto = Protocol.WEB_GET_MILITARY_BY_ROOMID
|
||||||
|
_data.roomId = roomid
|
||||||
|
end
|
||||||
|
_client:send(proto, _data, function (res)
|
||||||
|
self.recordList = nil
|
||||||
|
-- print(vardump(res))
|
||||||
|
if (res.ReturnCode == 0 or res.ReturnCode == 19 ) then
|
||||||
|
--self:RequestRankList(callback)
|
||||||
|
self.recordList = {}
|
||||||
|
if res.ReturnCode == 19 then return end
|
||||||
|
local recordData = res.Data
|
||||||
|
local record_info_list = recordData["military_list"]
|
||||||
|
if record_info_list ~= nil then
|
||||||
|
for i = 1, #record_info_list do
|
||||||
|
local record_list_item = record_info_list[i]
|
||||||
|
local record_list = MResult.new() -- new 战绩
|
||||||
|
record_list.GameId = tonumber(record_list_item["game_id"])
|
||||||
|
record_list.GameInfo = record_list_item["game_info"]
|
||||||
|
record_list.RoomId = record_list_item["room_id"]
|
||||||
|
record_list.group_id = record_list_item["groupId"]
|
||||||
|
record_list.Time = record_list_item["create_time"]
|
||||||
|
record_list.PlayBackId = record_list_item["military_id"]
|
||||||
|
record_list.hpData = record_list_item["hpData"]
|
||||||
|
record_list.hpOnOff = record_list_item["hpOnOff"]
|
||||||
|
record_list.hp_times = d2ad(record_list_item["hp_times"])
|
||||||
|
local total_score_str = record_list_item["totalScore"]
|
||||||
|
if total_score_str then
|
||||||
|
local total_score_item = json.decode(total_score_str)
|
||||||
|
for j = 1, #total_score_item do
|
||||||
|
local m_playerScore = MPlayerScore.new()
|
||||||
|
local total_score_str = total_score_item[j]
|
||||||
|
m_playerScore.Name = total_score_str["nick"]
|
||||||
|
m_playerScore.Score = total_score_str["score"]
|
||||||
|
m_playerScore.Id = total_score_str["accId"]
|
||||||
|
m_playerScore.Portrait = total_score_str["portrait"]
|
||||||
|
record_list.TotalScoreList[#record_list.TotalScoreList + 1] = m_playerScore
|
||||||
|
end
|
||||||
|
end
|
||||||
|
local round_count = record_list_item["round"]
|
||||||
|
|
||||||
|
for j = 1,round_count do
|
||||||
|
local round_score_str = record_list_item["round_"..j]
|
||||||
|
local m_round_game = MGameTimes.new()
|
||||||
|
if round_score_str then
|
||||||
|
local round_score_item = json.decode(round_score_str)
|
||||||
|
for k = 1, #round_score_item do
|
||||||
|
local m_player_score = MPlayerScore.new()
|
||||||
|
m_player_score.Name = round_score_item[k]["nick"]
|
||||||
|
m_player_score.Score = round_score_item[k]["score"]
|
||||||
|
m_round_game.PlayerList[#m_round_game.PlayerList + 1] = m_player_score
|
||||||
|
end
|
||||||
|
record_list.GameTimes[#record_list.GameTimes + 1] = m_round_game
|
||||||
|
end
|
||||||
|
end
|
||||||
|
self.recordList[#self.recordList + 1] = record_list
|
||||||
|
end
|
||||||
|
end
|
||||||
|
callback(res.ReturnCode)
|
||||||
|
else
|
||||||
|
callback(res.ReturnCode)
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function M:RequestPlayBack(_data,callback,game_info)
|
||||||
|
if game_info and ExtendHotupdate.CheckVersion(game_info) ~= ExtendHotupdate.VERSION_NORMAL then
|
||||||
|
ExtendHotupdate.UpdateGame(game_info,function()
|
||||||
|
self:RequestPlayBack(_data,callback)
|
||||||
|
end)
|
||||||
|
return
|
||||||
|
else
|
||||||
|
local _client = ControllerManager.WebClient
|
||||||
|
_client:send(Protocol.WEB_GET_PLAY_BACK , _data , function (res)
|
||||||
|
if res.ReturnCode == 0 then
|
||||||
|
local data = json.decode(res.Data.playback)
|
||||||
|
local cmdList = data.cmdList
|
||||||
|
local info = data.info
|
||||||
|
local extend = ExtendManager.GetExtendConfig(info.game_id)
|
||||||
|
local room = extend:NewRoom()
|
||||||
|
room.game_id = info.game_id
|
||||||
|
DataManager.CurrenRoom = room
|
||||||
|
extend:FillPlayBackData(data)
|
||||||
|
if not room.self_player then
|
||||||
|
room.self_player = room:GetPlayerBySeat(1)
|
||||||
|
end
|
||||||
|
callback(res.ReturnCode,data)
|
||||||
|
else
|
||||||
|
callback(res.ReturnCode,nil)
|
||||||
|
end
|
||||||
|
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
--获取手机验证码
|
||||||
|
function M:GetPhoneCode(phone,callback)
|
||||||
|
local _client = ControllerManager.WebClient
|
||||||
|
local _data = {}
|
||||||
|
_data["phone"]=phone
|
||||||
|
_client:send(Protocol.WEB_GET_VERIFCATION_CODE, _data, function(res)
|
||||||
|
callback(res)
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function M:GetUserInfo(callback)
|
||||||
|
local _client = ControllerManager.WebClient
|
||||||
|
_client:send(Protocol.WEB_GET_USER_INFO, nil, function(res)
|
||||||
|
if res.ReturnCode == 0 then
|
||||||
|
local user = DataManager.SelfUser
|
||||||
|
local data = res.Data
|
||||||
|
user.real_info = data.real_info
|
||||||
|
user.address = data.address
|
||||||
|
user.invitation = data.invitation
|
||||||
|
user.phone = data.phone
|
||||||
|
user.password = data.password
|
||||||
|
end
|
||||||
|
callback(res)
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:UpdateUserInfo(_data,callback)
|
||||||
|
local _client = ControllerManager.WebClient
|
||||||
|
_client:send(Protocol.WEB_UPDATE_USER_INFO, _data, function(res)
|
||||||
|
callback(res)
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- 设置被邀请开关
|
||||||
|
function M:SetInvited(on, callback)
|
||||||
|
local _client = ControllerManager.WebClient
|
||||||
|
local _data = {}
|
||||||
|
_data["invitation"] = on
|
||||||
|
_client:send(Protocol.WEB_SET_GROUP_INVITATED, _data, function(res)
|
||||||
|
callback(res)
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
@ -0,0 +1,216 @@
|
||||||
|
LoginController = {}
|
||||||
|
|
||||||
|
|
||||||
|
local M = {}
|
||||||
|
|
||||||
|
--- Create a new LoginController
|
||||||
|
function LoginController.new()
|
||||||
|
setmetatable(M, { __index = IController })
|
||||||
|
local self = setmetatable({}, { __index = M })
|
||||||
|
self.baseType = LoginController
|
||||||
|
self.class = "Login"
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
local _LocalConfigAllGame = {
|
||||||
|
10,
|
||||||
|
66, 86, 87, 88, 89
|
||||||
|
}
|
||||||
|
|
||||||
|
local FilterGame = function(games)
|
||||||
|
local tempGames = {}
|
||||||
|
for k, v in pairs(games) do
|
||||||
|
v.bundle = v.bundle:gsub("\r\n", "")
|
||||||
|
if IsHasDictionary(v.game_id, _LocalConfigAllGame) then
|
||||||
|
table.insert(tempGames, v)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return tempGames
|
||||||
|
end
|
||||||
|
|
||||||
|
local function __Login(cmd, _data, callBack)
|
||||||
|
local _client = ControllerManager.WebClient
|
||||||
|
_client:send(cmd, _data, function(res)
|
||||||
|
printlog("1111111111111111222222222222")
|
||||||
|
-- pt(cmd)
|
||||||
|
-- pt(res)
|
||||||
|
if (res.ReturnCode == 0) then
|
||||||
|
local data = res.Data
|
||||||
|
local account = data["account"]
|
||||||
|
local user = DataManager.SelfUser
|
||||||
|
user.acc = account.acc
|
||||||
|
user.account_id = account["id"]
|
||||||
|
user.diamo = account["diamo"]
|
||||||
|
user.nick_name = account["nick"]
|
||||||
|
user.sex = account["sex"]
|
||||||
|
user.head_url = account["portrait"]
|
||||||
|
user.room_id = account["roomid"]
|
||||||
|
user.group_id = account["groupId"]
|
||||||
|
user.type = account["type"]
|
||||||
|
user.agent = account["mng"]
|
||||||
|
|
||||||
|
user.real_info = account.real_info
|
||||||
|
user.phone = account.phone
|
||||||
|
user.address = account.address
|
||||||
|
user.games = FilterGame(data.games)
|
||||||
|
if Application.platform == RuntimePlatform.WindowsPlayer or Application.platform == RuntimePlatform.WindowsEditor then
|
||||||
|
--GameApplication.Instance.printLog = true
|
||||||
|
else
|
||||||
|
--GameApplication.Instance.printLog = user.type == 2
|
||||||
|
end
|
||||||
|
|
||||||
|
_client:setSession(data["session_id"] .. "," .. data["token"])
|
||||||
|
print("11111111111111111111111111111111")
|
||||||
|
pt(data)
|
||||||
|
ControllerManager.GroupClient = NetClient.new(data.groupWeb, "web_group", ConnectionProtocol.Web)
|
||||||
|
ControllerManager.GroupClient:setSession((data["session_id"] .. "," .. data["token"]))
|
||||||
|
end
|
||||||
|
|
||||||
|
if (callBack ~= nil) then
|
||||||
|
callBack(res)
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
local function __LoginNew(cmd, _data, callBack)
|
||||||
|
local _client = ControllerManager.WebClient
|
||||||
|
_client:send(cmd, _data, function(res)
|
||||||
|
printlog("1111111111111111222222222222")
|
||||||
|
-- pt(cmd)
|
||||||
|
-- pt(res)
|
||||||
|
|
||||||
|
if (res.Data.type == 0) then
|
||||||
|
local data = res.Data
|
||||||
|
print(data.userData)
|
||||||
|
local userInfo = stringToTAble(data.userData)
|
||||||
|
printlog("===========================loginuserqian=======================")
|
||||||
|
for k, v in pairs(userInfo) do
|
||||||
|
printlog(k)
|
||||||
|
printlog(v)
|
||||||
|
end
|
||||||
|
printlog("===========================loginuserqian=======================")
|
||||||
|
local user = DataManager.SelfUser
|
||||||
|
user.acc = userInfo.acc
|
||||||
|
user.account_id = userInfo.id
|
||||||
|
user.diamo = userInfo.diamo
|
||||||
|
user.nick_name = userInfo.nick
|
||||||
|
user.sex = userInfo.sex
|
||||||
|
user.head_url = userInfo.portrait
|
||||||
|
user.room_id = userInfo.roomid
|
||||||
|
user.group_id = userInfo.groupId
|
||||||
|
user.type = userInfo.type
|
||||||
|
user.agent = userInfo.mng
|
||||||
|
|
||||||
|
user.real_info = userInfo.real_info
|
||||||
|
user.phone = userInfo.phone
|
||||||
|
user.address = userInfo.address
|
||||||
|
printlog("===========================loginuser=======================")
|
||||||
|
printlog(user.acc)
|
||||||
|
for k, v in pairs(user) do
|
||||||
|
printlog(k)
|
||||||
|
printlog(v)
|
||||||
|
end
|
||||||
|
printlog("===========================loginuser=======================")
|
||||||
|
user.games = FilterGame(data.games)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if Application.platform == RuntimePlatform.WindowsPlayer or Application.platform == RuntimePlatform.WindowsEditor then
|
||||||
|
--GameApplication.Instance.printLog = true
|
||||||
|
else
|
||||||
|
--GameApplication.Instance.printLog = user.type == 2
|
||||||
|
end
|
||||||
|
|
||||||
|
_client:setSession(data.session_id .. "," .. data.token)
|
||||||
|
printlog("11111111111111111111111111111111")
|
||||||
|
pt(data)
|
||||||
|
ControllerManager.GroupClient = NetClient.new(data.groupWeb, "web_group", ConnectionProtocol.Web)
|
||||||
|
ControllerManager.GroupClient:setSession((data["session_id"] .. "," .. data["token"]))
|
||||||
|
end
|
||||||
|
|
||||||
|
if (callBack ~= nil) then
|
||||||
|
callBack(res)
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
--手机登录
|
||||||
|
function M:GetPhoneCode(phone, callback)
|
||||||
|
--不走登录逻辑
|
||||||
|
local _client = ControllerManager.WebClient
|
||||||
|
local _data = {}
|
||||||
|
_data["phone"] = phone
|
||||||
|
_client:send(Protocol.WEB_GET_VERIFCATION_CODE, _data, function(res)
|
||||||
|
if (callback ~= nil) then
|
||||||
|
callback(res)
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:PhoneLogin(phone, code, callback)
|
||||||
|
local _data = {}
|
||||||
|
_data["phone"] = phone
|
||||||
|
_data["code"] = code
|
||||||
|
__LoginNew(Protocol.WEB_PHONE_LOGIN, _data, callback)
|
||||||
|
end
|
||||||
|
|
||||||
|
--手机密码登录
|
||||||
|
function M:PhonePasswordLogin(phone, password, callback)
|
||||||
|
local _data = {}
|
||||||
|
_data["phone"] = phone
|
||||||
|
_data["password"] = password
|
||||||
|
__Login(Protocol.WEB_PHONE_PASSWORD_LOGIN, _data, callback)
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:IdPasswordLogin(uid, password, callback)
|
||||||
|
local _data = {}
|
||||||
|
_data["id"] = tonumber(uid)
|
||||||
|
_data["password"] = password
|
||||||
|
__Login(Protocol.WEB_ID_PASSWORD_LOGIN, _data, callback)
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:Login(callback)
|
||||||
|
local user = DataManager.SelfUser
|
||||||
|
local _data = {}
|
||||||
|
_data["acc"] = user.acc
|
||||||
|
_data["nick"] = user.nick_name
|
||||||
|
_data["sex"] = user.sex
|
||||||
|
_data["portrait"] = user.head_url
|
||||||
|
__Login(Protocol.WEB_USER_LOGIN, _data, callback)
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:QuickLogin(session_id, callback)
|
||||||
|
local _data = {}
|
||||||
|
local _client = ControllerManager.WebClient
|
||||||
|
_client:setSession(session_id)
|
||||||
|
-- ControllerManager.GroupClient:setSession(session_id)
|
||||||
|
__Login(Protocol.WEB_QUICK_LOGIN, _data, callback)
|
||||||
|
end
|
||||||
|
|
||||||
|
function M.OnEnter(self)
|
||||||
|
--print("login controller enter")
|
||||||
|
end
|
||||||
|
|
||||||
|
function M.OnExit(self)
|
||||||
|
--print("login controller exit")
|
||||||
|
end
|
||||||
|
|
||||||
|
--字符串类json格式转化为表
|
||||||
|
function stringToTAble(data)
|
||||||
|
local returnTable = {}
|
||||||
|
for key, value in string.gmatch(data, "(%w+)=([^,]*)") do
|
||||||
|
value = value:gsub("^%s*(.-)%s*$", "%1") -- 去除前后空格
|
||||||
|
if value == "" then
|
||||||
|
returnTable[key] = nil -- 空值转换为 nil
|
||||||
|
elseif tonumber(value) then
|
||||||
|
returnTable[key] = tonumber(value) -- 数值转换
|
||||||
|
elseif value:match("^https?://") then
|
||||||
|
returnTable[key] = value -- URL 直接保留
|
||||||
|
else
|
||||||
|
returnTable[key] = value:gsub("\\u(%x%x%x%x)", function(hex)
|
||||||
|
return utf8.char(tonumber(hex, 16)) -- 处理 Unicode(\u8dc3 -> 跃)
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return returnTable
|
||||||
|
end
|
||||||
File diff suppressed because it is too large
Load Diff
|
|
@ -0,0 +1,227 @@
|
||||||
|
RoomController = {}
|
||||||
|
|
||||||
|
local M = {}
|
||||||
|
|
||||||
|
--- Create a new RoomController
|
||||||
|
function RoomController.new()
|
||||||
|
setmetatable(M, { __index = IController })
|
||||||
|
local self = setmetatable({}, { __index = M })
|
||||||
|
self.baseType = RoomController
|
||||||
|
self.class = "Room"
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
local function __ConntectGameServer(cmd, room, host, _data, callback)
|
||||||
|
-- local _data = {}
|
||||||
|
_data["session"] = room.session
|
||||||
|
local _game_client = NetClient.new(host, "game")
|
||||||
|
_game_client:connect()
|
||||||
|
ControllerManager.SetGameNetClient(_game_client)
|
||||||
|
_game_client.onconnect:Add(function(code)
|
||||||
|
if (code == SocketCode.Connect) then
|
||||||
|
_game_client:send(cmd, _data, function(response)
|
||||||
|
if (response.ReturnCode == 0) then
|
||||||
|
_game_client.onconnect:Clear()
|
||||||
|
_game_client.onconnect:Add(ControllerManager.OnConnect)
|
||||||
|
callback(response)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
_game_client:destroy()
|
||||||
|
if ControllerManager.GameNetClinet == _game_client then
|
||||||
|
ControllerManager.GameNetClinet = nil
|
||||||
|
end
|
||||||
|
callback(response)
|
||||||
|
end)
|
||||||
|
else
|
||||||
|
if ControllerManager.GameNetClinet == _game_client then
|
||||||
|
ControllerManager.GameNetClinet = nil
|
||||||
|
end
|
||||||
|
_game_client:destroy()
|
||||||
|
callback({ ReturnCode = 101 })
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
-- return _game_client
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function M:CreateRoom(game_id, _data, callback)
|
||||||
|
local _client = ControllerManager.WebClient
|
||||||
|
local data = {}
|
||||||
|
data.game_id = game_id
|
||||||
|
data["platform"] = GetPlatform()
|
||||||
|
data.config_data = _data
|
||||||
|
-- local runtime = os.clock()
|
||||||
|
_client:send(Protocol.WEB_CREATE_ROOM, data, function(res)
|
||||||
|
-- if ( res.ReturnCode == Table_Error_code.ERR_IN_ROOM or res.ReturnCode == Table_Error_code.ERR_CREATE_ROOM) then
|
||||||
|
-- self:JoinRoom("000000",callback)
|
||||||
|
-- return
|
||||||
|
-- end
|
||||||
|
if (res.ReturnCode == 0) then
|
||||||
|
local json = res.Data
|
||||||
|
local game_info = json["game_info"]
|
||||||
|
if ExtendHotupdate.CheckVersion(game_info) ~= ExtendHotupdate.VERSION_NORMAL then
|
||||||
|
ExtendHotupdate.UpdateGame(game_info, function()
|
||||||
|
res.ReturnCode = -2
|
||||||
|
callback(res)
|
||||||
|
end)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
local game_id = game_info.game_id
|
||||||
|
local room_id = json["room_id"]
|
||||||
|
local server_ip = json["server_ip"]
|
||||||
|
local server_port = json["server_port"]
|
||||||
|
|
||||||
|
local room = ExtendManager.GetExtendConfig(game_id):NewRoom()
|
||||||
|
room.game_id = game_id
|
||||||
|
room.room_id = room_id
|
||||||
|
room.server_host = string.concat(server_ip, ":", server_port)
|
||||||
|
room.session = _client:getSession()
|
||||||
|
DataManager.CurrenRoom = room
|
||||||
|
|
||||||
|
local game_net = nil
|
||||||
|
|
||||||
|
local j_data = {}
|
||||||
|
j_data["session"] = room.session
|
||||||
|
if not DataManager.SelfUser.location then
|
||||||
|
DataManager.SelfUser.location = Location.new()
|
||||||
|
end
|
||||||
|
j_data["pos"] = DataManager.SelfUser.location:Location2String()
|
||||||
|
|
||||||
|
-- game_net =
|
||||||
|
__ConntectGameServer(Protocol.GAME_JOIN_ROOM, room, room.server_host, j_data, function(response)
|
||||||
|
if (response.ReturnCode == 0) then
|
||||||
|
-- game_net:clearEvent()
|
||||||
|
local _s2croom = response.Data
|
||||||
|
-- ControllerManager.SetGameNetClient(game_net)
|
||||||
|
room.owner_id = _s2croom["owner"]
|
||||||
|
room.banker_seat = _s2croom["manor"]
|
||||||
|
if _s2croom.createTime then
|
||||||
|
room.create_time = _s2croom["createTime"]
|
||||||
|
end
|
||||||
|
room.agent = _s2croom.agent == 1 and true or false
|
||||||
|
local extend = ExtendManager.GetExtendConfig(room.game_id)
|
||||||
|
extend:FillRoomData(_s2croom)
|
||||||
|
ControllerManager.ChangeController(GameController)
|
||||||
|
-- print("create room:"..(os.clock()-runtime))
|
||||||
|
callback(response)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
-- game_net:destroy()
|
||||||
|
callback(response)
|
||||||
|
end)
|
||||||
|
else
|
||||||
|
if callback then callback(res) end
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
local join_room_frame = 0
|
||||||
|
function M:PublicJoinRoom(cmd, roomid, tem, callback, group_id, pid)
|
||||||
|
printlog("公共进入房间接口=============PublicJoinRoom")
|
||||||
|
-- 同一帧不重复调用
|
||||||
|
local last_frame = join_room_frame
|
||||||
|
join_room_frame = Time.frameCount
|
||||||
|
if join_room_frame == last_frame then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
-- 防止游戏没有离开控制器
|
||||||
|
ControllerManager.ChangeController(LoddyController)
|
||||||
|
local _data = {}
|
||||||
|
if cmd == Protocol.WEB_FG_MATCH_ROOM then
|
||||||
|
_data["is_null"] = tem
|
||||||
|
elseif cmd == Protocol.WEB_FG_QUEUE_ROOM then
|
||||||
|
_data["is_null"] = tem
|
||||||
|
_data["room_id"] = roomid
|
||||||
|
else
|
||||||
|
_data["room_id"] = roomid
|
||||||
|
end
|
||||||
|
_data["id"] = group_id
|
||||||
|
_data["pid"] = pid
|
||||||
|
_data["platform"] = GetPlatform()
|
||||||
|
pt(_data)
|
||||||
|
local _client = ControllerManager.GroupClient
|
||||||
|
_client:send(cmd, _data, function(res)
|
||||||
|
printlog("++++++++++++111111111111111111111111111111111111")
|
||||||
|
pt(res)
|
||||||
|
if (res.ReturnCode == 0) then
|
||||||
|
local json = res.Data
|
||||||
|
local game_info = json["game_info"]
|
||||||
|
pt(game_info)
|
||||||
|
if ExtendHotupdate.CheckVersion(game_info) ~= ExtendHotupdate.VERSION_NORMAL then
|
||||||
|
ExtendHotupdate.UpdateGame(game_info, function()
|
||||||
|
res.ReturnCode = -2
|
||||||
|
callback(res)
|
||||||
|
end)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
local game_id = game_info.game_id
|
||||||
|
local server_ip = json["server_ip"]
|
||||||
|
local server_port = json["server_port"]
|
||||||
|
|
||||||
|
local room = ExtendManager.GetExtendConfig(game_id):NewRoom()
|
||||||
|
room.lev = json["lev"] -- 自己在当前房间所在圈子的职位,1盟主,2管理员,3用户,非圈子房间就是3
|
||||||
|
room.room_id = json["room_id"]
|
||||||
|
room.game_id = game_id
|
||||||
|
room.status = json["status"]
|
||||||
|
room.server_host = string.concat(server_ip, ":", server_port)
|
||||||
|
room.session = _client:getSession()
|
||||||
|
-- 圈子信息,圈子id和玩法id
|
||||||
|
room.group_id = json["groupId"]
|
||||||
|
-- 圈子禁止文字聊天,禁止语音聊天
|
||||||
|
room.ban_chat1 = json["ban_chat1"]
|
||||||
|
room.ban_chat2 = json["ban_chat2"]
|
||||||
|
-- 玩法id
|
||||||
|
room.play_id = json["pid"]
|
||||||
|
-- 体力值开关
|
||||||
|
room.hpOnOff = json["hpOnOff"]
|
||||||
|
-- 体力值倍数
|
||||||
|
room.score_times = d2ad(json.hp_times) or 1
|
||||||
|
DataManager.CurrenRoom = room
|
||||||
|
local j_data = {}
|
||||||
|
if not DataManager.SelfUser.location then
|
||||||
|
DataManager.SelfUser.location = Location.new()
|
||||||
|
end
|
||||||
|
j_data["pos"] = DataManager.SelfUser.location:Location2String()
|
||||||
|
printlog("++++++++++++++++++++++++++++++++++++++++++")
|
||||||
|
__ConntectGameServer(Protocol.GAME_JOIN_ROOM, room, room.server_host, j_data, function(res1)
|
||||||
|
printlog("===============================-------------")
|
||||||
|
pt(res1)
|
||||||
|
ControllerManager.IsSendCard = false
|
||||||
|
if (res1.ReturnCode ~= 0) then
|
||||||
|
if (callback) then callback(res1) end
|
||||||
|
else
|
||||||
|
ControllerManager.enterPlayerData = res1.Data.tableInfo.playerData
|
||||||
|
local _s2croom = res1.Data
|
||||||
|
room.owner_id = _s2croom["owner"]
|
||||||
|
if _s2croom.createTime then
|
||||||
|
room.create_time = _s2croom["createTime"]
|
||||||
|
end
|
||||||
|
if _s2croom.manor then
|
||||||
|
room.banker_seat = _s2croom.manor
|
||||||
|
end
|
||||||
|
room.agent = _s2croom.agent == 1 and true or false
|
||||||
|
-- ControllerManager.SetGameNetClient(game_net)
|
||||||
|
local extend = ExtendManager.GetExtendConfig(room.game_id)
|
||||||
|
extend:FillRoomData(_s2croom)
|
||||||
|
ControllerManager.ChangeController(GameController)
|
||||||
|
local gamectr = ControllerManager.GetCurrenController()
|
||||||
|
gamectr.tmpRoomID = room.room_id
|
||||||
|
gamectr.tmpGroupID = room.group_id
|
||||||
|
if callback then callback(res1) end
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
else
|
||||||
|
if callback then callback(res) end
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:JoinRoom(room_id, callback)
|
||||||
|
self:PublicJoinRoom(Protocol.WEB_JOIN_ROOM, room_id, false, callback, group_id, group_layer)
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:ResetJionRoom(callback)
|
||||||
|
local _game = ControllerManager.GetController(GameController)
|
||||||
|
local o_room = DataManager.CurrenRoom
|
||||||
|
self:JoinRoom(o_room.room_id, callback)
|
||||||
|
end
|
||||||
|
|
@ -0,0 +1,112 @@
|
||||||
|
import(".Protocol")
|
||||||
|
import(".Controller.IController")
|
||||||
|
import(".Controller.LoginController")
|
||||||
|
import(".Controller.LoddyController")
|
||||||
|
import(".Controller.GameController")
|
||||||
|
import(".Controller.NewGroupController")
|
||||||
|
import(".Controller.RoomController")
|
||||||
|
import(".Controller.GroupMgrController")
|
||||||
|
---
|
||||||
|
-- a net ControllerManager
|
||||||
|
ControllerManager = {
|
||||||
|
|
||||||
|
-- http网络连接
|
||||||
|
WebClient = nil,
|
||||||
|
-- game网络长连接
|
||||||
|
GameNetClinet = nil,
|
||||||
|
reset_join_room = 0
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
local _currenController = nil
|
||||||
|
local _controllerMap = {}
|
||||||
|
|
||||||
|
|
||||||
|
function ControllerManager.Init()
|
||||||
|
_controllerMap[LoginController] = LoginController.new()
|
||||||
|
_controllerMap[LoddyController] = LoddyController.new()
|
||||||
|
_controllerMap[NewGroupController] = NewGroupController.new()
|
||||||
|
_controllerMap[RoomController] = RoomController.new()
|
||||||
|
_controllerMap[GroupMgrController] = GroupMgrController.new()
|
||||||
|
|
||||||
|
local hostIp = GetGameInfo("login_url")
|
||||||
|
if (debug_print) then
|
||||||
|
print("hostIp:::" .. hostIp)
|
||||||
|
end
|
||||||
|
ControllerManager.WebClient = NetClient.new(hostIp, "majiang", ConnectionProtocol.Web)
|
||||||
|
--ControllerManager.GroupClient = nil--NetClient.new("http://192.168.0.1:8081/", "web_group", ConnectionProtocol.Web)
|
||||||
|
end
|
||||||
|
|
||||||
|
function ControllerManager.ChangeController(type)
|
||||||
|
if (_currenController ~= nil) then
|
||||||
|
_currenController:OnExit()
|
||||||
|
end
|
||||||
|
_currenController = ControllerManager.GetController(type)
|
||||||
|
_currenController:OnEnter()
|
||||||
|
return _currenController
|
||||||
|
end
|
||||||
|
|
||||||
|
-- 获取当前控制器
|
||||||
|
function ControllerManager.GetCurrenController()
|
||||||
|
return _currenController
|
||||||
|
end
|
||||||
|
|
||||||
|
---
|
||||||
|
--@function [parent=#ControllerManager] GetController
|
||||||
|
--@return Game.Controller.IController#IController description
|
||||||
|
function ControllerManager.GetController(cls)
|
||||||
|
if (cls == GameController) then
|
||||||
|
if DataManager.CurrenRoom then
|
||||||
|
local exconfig = ExtendManager.GetExtendConfig(DataManager.CurrenRoom.game_id)
|
||||||
|
return exconfig.GetGameController()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
local c = _controllerMap[cls]
|
||||||
|
return c
|
||||||
|
end
|
||||||
|
|
||||||
|
function ControllerManager.SetGameNetClient(client)
|
||||||
|
if (ControllerManager.GameNetClinet ~= nil) then
|
||||||
|
ControllerManager.GameNetClinet:destroy()
|
||||||
|
end
|
||||||
|
ControllerManager.GameNetClinet = client
|
||||||
|
-- if (client ) then
|
||||||
|
-- client.onconnect:Add(ControllerManager.OnConnect)
|
||||||
|
-- end
|
||||||
|
end
|
||||||
|
|
||||||
|
function ControllerManager.OnConnect(code)
|
||||||
|
print("=======================================ControllerManager", code)
|
||||||
|
if (code ~= SocketCode.Connect) then
|
||||||
|
ControllerManager.SetGameNetClient(nil)
|
||||||
|
if code ~= SocketCode.DisconnectByServer then
|
||||||
|
ControllerManager.OnGameConnect(SocketCode.TimeoutDisconnect)
|
||||||
|
ControllerManager.reset_join_room = 0
|
||||||
|
ControllerManager.ResetJionRoom()
|
||||||
|
else
|
||||||
|
ControllerManager.OnGameConnect(SocketCode.DisconnectByServer)
|
||||||
|
end
|
||||||
|
else
|
||||||
|
ControllerManager.OnGameConnect(SocketCode.Connect)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function ControllerManager.ResetJionRoom()
|
||||||
|
ControllerManager.reset_join_room = ControllerManager.reset_join_room + 1
|
||||||
|
if ControllerManager.reset_join_room > 3 then
|
||||||
|
ControllerManager.OnGameConnect(SocketCode.NetworkException)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
ControllerManager.ChangeController(LoddyController)
|
||||||
|
local loddyctr = ControllerManager.GetController(LoddyController)
|
||||||
|
loddyctr:ResetJionRoom(function(res)
|
||||||
|
if res.ReturnCode == 11 or res.ReturnCode == 81 or res.ReturnCode == 1005 then
|
||||||
|
ControllerManager.OnGameConnect(SocketCode.Disconnect)
|
||||||
|
return
|
||||||
|
elseif res.ReturnCode ~= 0 then
|
||||||
|
ControllerManager.ResetJionRoom()
|
||||||
|
return
|
||||||
|
end
|
||||||
|
ControllerManager.OnGameConnect(SocketCode.Connect)
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
@ -0,0 +1,283 @@
|
||||||
|
local M = class("GroupData")
|
||||||
|
|
||||||
|
function M:ctor()
|
||||||
|
self.id = 0
|
||||||
|
self.name = ""
|
||||||
|
-- 盟主ID
|
||||||
|
self.owner = 0
|
||||||
|
--盟主昵称
|
||||||
|
self.o_nick = ""
|
||||||
|
--盟主头像
|
||||||
|
self.o_portrait = ""
|
||||||
|
--自己在圈子的职位
|
||||||
|
self.lev = 3
|
||||||
|
self.top_time = 0
|
||||||
|
--已获取成员数
|
||||||
|
self.member_num = 0
|
||||||
|
-- 总成员数
|
||||||
|
self.total_member_num = 0
|
||||||
|
--圈子房间数
|
||||||
|
self.room_num = 0
|
||||||
|
-- 1普通圈子2大联盟
|
||||||
|
self.type = 1
|
||||||
|
-- 1是房主支付2AA支付
|
||||||
|
self.pay_type = 1
|
||||||
|
--成员列表
|
||||||
|
self.members = {}
|
||||||
|
self.memberMap = {}
|
||||||
|
--房间列表
|
||||||
|
self.rooms = {}
|
||||||
|
--默认房间列表
|
||||||
|
self.default_rooms = {}
|
||||||
|
--玩法列表
|
||||||
|
self.playList = {}
|
||||||
|
--加圈子申请数
|
||||||
|
self.joins = 0
|
||||||
|
--自动解散
|
||||||
|
self.dissolve_opt = 1
|
||||||
|
--占座踢出
|
||||||
|
self.kick_opt = 1
|
||||||
|
--玩家申请
|
||||||
|
self.apply = 0
|
||||||
|
--盟主钻石
|
||||||
|
self.diamo = 0
|
||||||
|
--隐藏功能
|
||||||
|
self.hide_action = 0
|
||||||
|
--是否开启全民推广
|
||||||
|
self.promote = false
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
-- 添加成员
|
||||||
|
function M:addMember(member)
|
||||||
|
local _tem = self.memberMap[member.uid]
|
||||||
|
if _tem then
|
||||||
|
for k, v in pairs(member) do
|
||||||
|
_tem[k] = v
|
||||||
|
end
|
||||||
|
else
|
||||||
|
self.memberMap[member.uid] = member
|
||||||
|
self.members[#self.members + 1] = member
|
||||||
|
self.member_num = #self.members
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- 删除成员
|
||||||
|
function M:delMember(id)
|
||||||
|
local _tem = self.memberMap[id]
|
||||||
|
if _tem then
|
||||||
|
self.memberMap[id] = nil
|
||||||
|
for i=1,#self.members do
|
||||||
|
local member = self.members[i]
|
||||||
|
if member.uid == id then
|
||||||
|
table.remove(self.members,i)
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
self.member_num = #self.members
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:clearMember()
|
||||||
|
self.members = {}
|
||||||
|
self.memberMap = {}
|
||||||
|
self.member_num = 0
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:getMember(id)
|
||||||
|
return self.memberMap[id]
|
||||||
|
end
|
||||||
|
|
||||||
|
-- 添加房间
|
||||||
|
function M:addRoom(room)
|
||||||
|
local pid = room.pid
|
||||||
|
local play = self:getPlay(pid)
|
||||||
|
if not play then return end
|
||||||
|
for i=1,#self.rooms do
|
||||||
|
local tem = self.rooms[i]
|
||||||
|
if room.id == tem.id then
|
||||||
|
self.rooms[i] = room
|
||||||
|
for j = 1, #play.rooms do
|
||||||
|
if room.id == play.rooms[j].id then
|
||||||
|
play.rooms[j] = room
|
||||||
|
return
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return
|
||||||
|
end
|
||||||
|
end
|
||||||
|
self.rooms[#self.rooms+1] = room
|
||||||
|
-- 把房间加入对应的玩法下的列表
|
||||||
|
play.rooms[#play.rooms + 1] = room
|
||||||
|
end
|
||||||
|
|
||||||
|
-- 删除房间
|
||||||
|
function M:delRoom(id)
|
||||||
|
local pid = 0
|
||||||
|
for i=1,#self.rooms do
|
||||||
|
local room = self.rooms[i]
|
||||||
|
if room.id == id then
|
||||||
|
pid = room.pid
|
||||||
|
table.remove(self.rooms,i)
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if pid == 0 then return end
|
||||||
|
local play = self:getPlay(pid)
|
||||||
|
if not play then return end
|
||||||
|
for i = 1, #play.rooms do
|
||||||
|
local room = play.rooms[i]
|
||||||
|
if room.id == id then
|
||||||
|
table.remove(play.rooms, i)
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- 添加玩法
|
||||||
|
function M:addPlay(play)
|
||||||
|
--printlog("添加玩法addPlay===>>>")
|
||||||
|
--pt(play)
|
||||||
|
local maxRound=0
|
||||||
|
if play.maxRound then
|
||||||
|
maxRound=play.maxRound
|
||||||
|
else
|
||||||
|
local hpdata = json.decode(play.hpData)
|
||||||
|
maxRound=hpdata.maxRound
|
||||||
|
end
|
||||||
|
|
||||||
|
local pnum = play.maxPlayers
|
||||||
|
local room = {maxPlayers = pnum, status = -1, default = true, pid = play.id,times=maxRound}
|
||||||
|
|
||||||
|
play.rooms = {}
|
||||||
|
local index = self:getPlayIndex(play.id)
|
||||||
|
if index ~= -1 then
|
||||||
|
self.playList[index] = play
|
||||||
|
self.default_rooms[index] = room
|
||||||
|
return
|
||||||
|
end
|
||||||
|
self.playList[#self.playList + 1] = play
|
||||||
|
-- 房间列表中,给每个玩法添加一个对应的空房间
|
||||||
|
self.default_rooms[#self.default_rooms + 1] = room
|
||||||
|
--self.playList=self:SortPlay(self.playList)
|
||||||
|
--pt(self.playList)
|
||||||
|
--self.default_rooms=self:SortDefaultPlay(self.default_rooms)
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function M:SortPlay(list)
|
||||||
|
local singlePlayList={}
|
||||||
|
local otherPlayList={}
|
||||||
|
|
||||||
|
for i=1,#list do
|
||||||
|
local hpdata=json.decode(list[i].hpData)
|
||||||
|
if hpdata.maxRound and hpdata.maxRound==1 then
|
||||||
|
table.insert(singlePlayList,list[i])
|
||||||
|
else
|
||||||
|
table.insert(otherPlayList,list[i])
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
for i=1,#otherPlayList do
|
||||||
|
table.insert(singlePlayList,otherPlayList[i])
|
||||||
|
end
|
||||||
|
|
||||||
|
return singlePlayList
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function M:SortDefaultPlay(list)
|
||||||
|
local singlePlayList={}
|
||||||
|
local otherPlayList={}
|
||||||
|
|
||||||
|
for i=1,#list do
|
||||||
|
if list[i].times and list[i].times==1 then
|
||||||
|
table.insert(singlePlayList,list[i])
|
||||||
|
else
|
||||||
|
table.insert(otherPlayList,list[i])
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
for i=1,#otherPlayList do
|
||||||
|
table.insert(singlePlayList,otherPlayList[i])
|
||||||
|
end
|
||||||
|
|
||||||
|
return singlePlayList
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
-- 删除玩法
|
||||||
|
function M:delPlay(pid)
|
||||||
|
local index = self:getPlayIndex(pid)
|
||||||
|
if index ~= -1 then
|
||||||
|
table.remove(self.playList,index)
|
||||||
|
table.remove(self.default_rooms, index)
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
-- 禁止玩法
|
||||||
|
function M:banPlay(pid, ban)
|
||||||
|
local play = self:getPlay(pid)
|
||||||
|
--printlog("禁止玩法===>>>")
|
||||||
|
--pt(play)
|
||||||
|
play.ban = ban
|
||||||
|
end
|
||||||
|
|
||||||
|
-- 标记玩法
|
||||||
|
function M:markPlay(pid, ban)
|
||||||
|
local play = self:getPlay(pid)
|
||||||
|
--printlog("标记玩法===>>>")
|
||||||
|
play.mark = ban
|
||||||
|
--pt(play)
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:getPlay(pid)
|
||||||
|
local index = self:getPlayIndex(pid)
|
||||||
|
if index ~= -1 then
|
||||||
|
return self.playList[index]
|
||||||
|
end
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:getPlayName(pid)
|
||||||
|
local index = self:getPlayIndex(pid)
|
||||||
|
if index ~= -1 then
|
||||||
|
return self.playList[index].name
|
||||||
|
end
|
||||||
|
return "已删除"
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:getPlayIndex(pid)
|
||||||
|
for i=1,#self.playList do
|
||||||
|
local tem = self.playList[i]
|
||||||
|
if tem.id == pid then
|
||||||
|
return i
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return -1
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:clearPlay()
|
||||||
|
self.playList = {}
|
||||||
|
self.rooms = {}
|
||||||
|
self.default_rooms={}
|
||||||
|
for i = 1, #self.playList do
|
||||||
|
self.playList[i].rooms = {}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:clear()
|
||||||
|
self.playList = {}
|
||||||
|
self.members = {}
|
||||||
|
self.memberMap = {}
|
||||||
|
self.rooms = {}
|
||||||
|
self.default_rooms = {}
|
||||||
|
end
|
||||||
|
|
||||||
|
return M
|
||||||
|
|
@ -0,0 +1,46 @@
|
||||||
|
local M = class("Groups")
|
||||||
|
|
||||||
|
function M:ctor()
|
||||||
|
self.groupList = {}
|
||||||
|
self.groupMap = {}
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:add(group)
|
||||||
|
local _tem = self.groupMap[group.id]
|
||||||
|
if _tem then
|
||||||
|
for k, v in pairs(group) do
|
||||||
|
_tem[k] = v
|
||||||
|
end
|
||||||
|
else
|
||||||
|
self.groupMap[group.id] = group
|
||||||
|
self.groupList[#self.groupList + 1] = group
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:del(id)
|
||||||
|
local _tem = self.groupMap[id]
|
||||||
|
if _tem then
|
||||||
|
local list = self.groupList
|
||||||
|
self.groupMap[id] = nil
|
||||||
|
for i=1,#list do
|
||||||
|
local group = list[i]
|
||||||
|
if group.id == id then
|
||||||
|
table.remove(list,i)
|
||||||
|
self.groupMap[id] = nil
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:get(id)
|
||||||
|
local _tem = self.groupMap[id]
|
||||||
|
return _tem
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:clear()
|
||||||
|
self.groupMap = {}
|
||||||
|
self.groupList = {}
|
||||||
|
end
|
||||||
|
|
||||||
|
return M
|
||||||
|
|
@ -0,0 +1,83 @@
|
||||||
|
-- Edit By ChenGY
|
||||||
|
-- 记录玩家位置,距离计算
|
||||||
|
|
||||||
|
Location = {
|
||||||
|
longitude = 0,
|
||||||
|
latitude = 0,
|
||||||
|
default = true,
|
||||||
|
address = nil,
|
||||||
|
}
|
||||||
|
|
||||||
|
local M = Location
|
||||||
|
|
||||||
|
function M.new(str)
|
||||||
|
local self = {}
|
||||||
|
setmetatable(self, {__index = M})
|
||||||
|
self:LoadLocation(str)
|
||||||
|
if str and str ~= "" then
|
||||||
|
self.default = false
|
||||||
|
else
|
||||||
|
self.default = true
|
||||||
|
end
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
-- 获取详细地址
|
||||||
|
function M:GetAddress(obj)
|
||||||
|
if self.address then
|
||||||
|
obj.text = self.address
|
||||||
|
else
|
||||||
|
coroutine.start(self.DownloadAddressInfo, self, obj)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:DownloadAddressInfo(obj)
|
||||||
|
-- bd09ll gcj02 wgs84ll
|
||||||
|
local coordtype = "&coordtype=wgs84ll"
|
||||||
|
-- if Application.platform == RuntimePlatform.Android then
|
||||||
|
-- coordtype = ""
|
||||||
|
-- end
|
||||||
|
local url = string.format("http://api.map.baidu.com/geocoder/v2/?ak=Z6qXIddQtwO8xaKunX4CURbwcV0GLSrG&location=%s,%s&output=json%s", self.latitude, self.longitude, coordtype)
|
||||||
|
local www = UnityEngine.WWW(url)
|
||||||
|
coroutine.www(www)
|
||||||
|
if string.utf8len(www.error) == 0 then
|
||||||
|
local txt = www.text
|
||||||
|
local json_add = json.decode(txt)
|
||||||
|
self.address = json_add.result.formatted_address
|
||||||
|
obj.text = self.address
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- 计算距离
|
||||||
|
function M:CalcDistance(loc)
|
||||||
|
local EARTH_RADIUS = 6378.137
|
||||||
|
|
||||||
|
local radLat1 = math.rad(self.latitude)
|
||||||
|
local radLat2 = math.rad(loc.latitude)
|
||||||
|
local a = radLat1 - radLat2
|
||||||
|
local b = math.rad(self.longitude) - math.rad(loc.longitude)
|
||||||
|
|
||||||
|
local s = 2 * math.asin(math.sqrt(math.pow(math.sin(a/2),2) + math.cos(radLat1)*math.cos(radLat2)*math.pow(math.sin(b/2),2)))
|
||||||
|
s = s * EARTH_RADIUS
|
||||||
|
local dist = math.floor(s * 10000 +.5) / 10000
|
||||||
|
return dist
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:Location2String()
|
||||||
|
if self.default then return "" end
|
||||||
|
local str = self.longitude .. "," .. self.latitude
|
||||||
|
return str
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:String2Location()
|
||||||
|
local loc = string.split(str, ",")
|
||||||
|
return loc
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:LoadLocation(str)
|
||||||
|
local loc = string.split(str, ",")
|
||||||
|
self.longitude = tonumber(loc[1])
|
||||||
|
self.latitude = tonumber(loc[2])
|
||||||
|
end
|
||||||
|
|
||||||
|
return M
|
||||||
|
|
@ -0,0 +1,38 @@
|
||||||
|
--玩家数据对象
|
||||||
|
|
||||||
|
|
||||||
|
local Player ={
|
||||||
|
-- 玩家对应的User对象
|
||||||
|
self_user = nil,
|
||||||
|
-- 网络状态 1 在线 0 离线
|
||||||
|
line_state = 1,
|
||||||
|
-- 座位号
|
||||||
|
seat = 0,
|
||||||
|
-- 是否准备
|
||||||
|
ready = false,
|
||||||
|
-- 当前局积分
|
||||||
|
curren_score = 0,
|
||||||
|
-- 总积分
|
||||||
|
total_score = 0,
|
||||||
|
-- 托管
|
||||||
|
entrust = false,
|
||||||
|
}
|
||||||
|
---
|
||||||
|
-- @type Player
|
||||||
|
local M = Player
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
--- Create a new Player
|
||||||
|
function Player.new()
|
||||||
|
local self = {}
|
||||||
|
setmetatable(self, {__index = M})
|
||||||
|
self.hand_cards = {}
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
-- 清理玩家数据
|
||||||
|
function M:Clear()
|
||||||
|
end
|
||||||
|
|
||||||
|
return M
|
||||||
|
|
@ -0,0 +1,45 @@
|
||||||
|
|
||||||
|
RecordData = class ("RecordData")
|
||||||
|
|
||||||
|
function RecordData:ctor()
|
||||||
|
self.Result_Map = {}
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
MResult = class ("MResult")
|
||||||
|
|
||||||
|
function MResult:ctor()
|
||||||
|
-- 游戏类型
|
||||||
|
self.GameId = 0
|
||||||
|
-- 房间ID
|
||||||
|
self.RoomId = 0
|
||||||
|
-- 回放ID
|
||||||
|
self.PlayBackId = ""
|
||||||
|
-- 对战时间
|
||||||
|
self.Time = ""
|
||||||
|
|
||||||
|
-- 玩家列表
|
||||||
|
self.TotalScoreList = {}
|
||||||
|
|
||||||
|
-- 每一小局列表
|
||||||
|
self.GameTimes = {}
|
||||||
|
end
|
||||||
|
|
||||||
|
MPlayerScore = class ("MPlayerScore")
|
||||||
|
|
||||||
|
function MPlayerScore:ctor()
|
||||||
|
|
||||||
|
-- 玩家名称
|
||||||
|
self.Name = ""
|
||||||
|
|
||||||
|
-- 分数
|
||||||
|
self.Score = 0
|
||||||
|
end
|
||||||
|
|
||||||
|
MGameTimes = class ("MGameTimes")
|
||||||
|
function MGameTimes:ctor()
|
||||||
|
self.PlayerList = {}
|
||||||
|
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
|
@ -0,0 +1,219 @@
|
||||||
|
-- 房间基本数据类
|
||||||
|
--author:--
|
||||||
|
|
||||||
|
StateType =
|
||||||
|
{
|
||||||
|
Ready = 0,
|
||||||
|
Palying = 1,
|
||||||
|
PalyingWait = 2
|
||||||
|
}
|
||||||
|
|
||||||
|
---房间数据对象
|
||||||
|
local Room = {
|
||||||
|
-- 房间ID
|
||||||
|
room_id = "",
|
||||||
|
-- 游戏ID
|
||||||
|
game_id = 0,
|
||||||
|
-- 服务器地址
|
||||||
|
server_host = "",
|
||||||
|
-- 玩家session
|
||||||
|
session = "",
|
||||||
|
-- 自己
|
||||||
|
self_player = nil,
|
||||||
|
-- 房主ID
|
||||||
|
owner_id = "",
|
||||||
|
-- 庄家座位号
|
||||||
|
banker_seat = 0,
|
||||||
|
-- 当前回合
|
||||||
|
curren_round = 0,
|
||||||
|
-- 当前转向的座位号
|
||||||
|
curren_turn_seat = 0,
|
||||||
|
|
||||||
|
-- 房间配置
|
||||||
|
room_config = nil,
|
||||||
|
|
||||||
|
-- 玩家列表
|
||||||
|
player_list = nil,
|
||||||
|
|
||||||
|
-- 游戏中
|
||||||
|
playing = false,
|
||||||
|
|
||||||
|
create_time = "",
|
||||||
|
|
||||||
|
group_id = 0,
|
||||||
|
-- 自己在当前房间所在圈子的职位,1盟主,2管理员,3用户,非圈子房间就是3
|
||||||
|
lev = 3,
|
||||||
|
-- 房间倍数
|
||||||
|
score_times = 1,
|
||||||
|
-- 体力值开关
|
||||||
|
hpOnOff = 0,
|
||||||
|
-- 牌友圈的游戏id
|
||||||
|
pid = 0,
|
||||||
|
|
||||||
|
-- 房间重连标记
|
||||||
|
reloading = false,
|
||||||
|
}
|
||||||
|
|
||||||
|
---
|
||||||
|
-- a RoomConfig
|
||||||
|
RoomConfig = {
|
||||||
|
-- 人数
|
||||||
|
people_num = 2,
|
||||||
|
-- 回合数
|
||||||
|
opt_round = 1,
|
||||||
|
}
|
||||||
|
|
||||||
|
---
|
||||||
|
-- @type Room
|
||||||
|
local M = Room
|
||||||
|
|
||||||
|
|
||||||
|
--- Create a new Room
|
||||||
|
function Room.new()
|
||||||
|
local self = {}
|
||||||
|
setmetatable(self, {__index = M})
|
||||||
|
self:init()
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:init()
|
||||||
|
self.player_list = {}
|
||||||
|
self.room_config ={}
|
||||||
|
end
|
||||||
|
|
||||||
|
-- 创建玩家
|
||||||
|
function M:NewPlayer()
|
||||||
|
return Player.new()
|
||||||
|
end
|
||||||
|
|
||||||
|
-- 添加玩家
|
||||||
|
function M:AddPlayer(player)
|
||||||
|
if (not player) then return end
|
||||||
|
for k , tem in ipairs(self.player_list) do
|
||||||
|
if(tem.self_user.account_id == player.self_user.account_id) then
|
||||||
|
-- tem = player
|
||||||
|
self.player_list[k] = player
|
||||||
|
return
|
||||||
|
end
|
||||||
|
end
|
||||||
|
self.player_list[#self.player_list+1] = player
|
||||||
|
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
-- 是否为不可负分房间
|
||||||
|
function M:checkHpNonnegative()
|
||||||
|
local isNonnegative = self.room_config.isNonnegative
|
||||||
|
if isNonnegative and isNonnegative == 1 then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- 删除指定玩家
|
||||||
|
-- <param name="player"></param>
|
||||||
|
function M:RemovePlayer(player)
|
||||||
|
for i , _player in ipairs(self.player_list) do
|
||||||
|
if _player == player then
|
||||||
|
table.remove(self.player_list , i)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- 获取指定玩家_userid
|
||||||
|
-- <param name="id"></param>
|
||||||
|
-- <returns></returns>
|
||||||
|
function M:GetPlayerById(id)
|
||||||
|
for _ , tem in pairs(self.player_list) do
|
||||||
|
if (tem.self_user.account_id == id) then
|
||||||
|
return tem
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return nil;
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- 获取指定玩家_桌号
|
||||||
|
-- <param name="id"></param>
|
||||||
|
-- <returns></returns>
|
||||||
|
function M:GetPlayerBySeat(seat)
|
||||||
|
for _ , tem in ipairs(self.player_list) do
|
||||||
|
if (tem.seat == seat) then
|
||||||
|
return tem
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
|
||||||
|
-- 获取大结算显示的积分
|
||||||
|
function M:GetTotalScore(score)
|
||||||
|
if self.hpOnOff == 1 then
|
||||||
|
return d2ad(score)
|
||||||
|
else
|
||||||
|
return score
|
||||||
|
end
|
||||||
|
end
|
||||||
|
-- 获取乘倍数前的积分
|
||||||
|
function M:GetOriginScore(total_score)
|
||||||
|
if self.hpOnOff == 1 then
|
||||||
|
return total_score / self.score_times
|
||||||
|
else
|
||||||
|
return total_score
|
||||||
|
end
|
||||||
|
end
|
||||||
|
-- 设置房间重连状态
|
||||||
|
function M:SetReloadStatus(flag)
|
||||||
|
self.reloading = flag
|
||||||
|
end
|
||||||
|
-- 获取房间重连状态
|
||||||
|
function M:GetReloadStatus()
|
||||||
|
return self.reloading
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Create a new RoomConfig
|
||||||
|
function RoomConfig:init(config)
|
||||||
|
--人数
|
||||||
|
self.people_num = config["maxPlayers"]
|
||||||
|
--支付类型
|
||||||
|
self.AA = config["AA"] == 1 and true or false
|
||||||
|
--托管
|
||||||
|
self.tuoguan = config["tuoguan"]
|
||||||
|
self.tuoguan_active_time = config["tuoguan_active_time"]
|
||||||
|
self.tuoguan_result_type = config["tuoguan_result_type"]
|
||||||
|
--不可负分
|
||||||
|
self.isNonnegative = config["isNonnegative"]
|
||||||
|
self.pid = config["pid"]
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
local str_tuoguan = {"当局结算", "二局结算", "三局结算","满局结算"}
|
||||||
|
function RoomConfig:GetDes(sp, str_people_num)
|
||||||
|
local str = ""
|
||||||
|
if not str_people_num and self.people_num then
|
||||||
|
str = str .. self.people_num .. "人"
|
||||||
|
--str = str .. sp
|
||||||
|
end
|
||||||
|
-- if self.AA then
|
||||||
|
-- str = str .. "AA支付" .. sp
|
||||||
|
-- else
|
||||||
|
-- str = str .. "房主支付" .. sp
|
||||||
|
-- end
|
||||||
|
-- if self.isNonnegative == 1 then
|
||||||
|
-- str = str .. "不可负分" .. sp
|
||||||
|
-- end
|
||||||
|
if self.tuoguan then
|
||||||
|
str = str .. "托管" .. sp
|
||||||
|
str = str .. "离线" .. self.tuoguan_active_time .. "秒托管" .. sp
|
||||||
|
str = str .. str_tuoguan[self.tuoguan_result_type] .. sp
|
||||||
|
end
|
||||||
|
return str
|
||||||
|
end
|
||||||
|
|
||||||
|
function RoomConfig:GetGameName()
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
return M
|
||||||
|
|
@ -0,0 +1,29 @@
|
||||||
|
--结算数据对象
|
||||||
|
local m = class("RoomResult")
|
||||||
|
|
||||||
|
function m:ctor()
|
||||||
|
-- 房间ID
|
||||||
|
self.RoomID = 0
|
||||||
|
|
||||||
|
-- 结果类型
|
||||||
|
self.Type = RoomResultType.Normal
|
||||||
|
|
||||||
|
-- 庄家
|
||||||
|
self.BankerSeat = 0
|
||||||
|
|
||||||
|
|
||||||
|
-- 剩余牌数
|
||||||
|
self.LeftNum = 0
|
||||||
|
|
||||||
|
-- 当前局
|
||||||
|
self.CurrenRound = 0
|
||||||
|
|
||||||
|
-- 总局
|
||||||
|
self.ToalRound = 0
|
||||||
|
|
||||||
|
-- 玩家列表
|
||||||
|
-- list.new()
|
||||||
|
self.PlayerList = {}
|
||||||
|
end
|
||||||
|
|
||||||
|
return m
|
||||||
|
|
@ -0,0 +1,92 @@
|
||||||
|
-- Edit By ChenGY
|
||||||
|
-- 记录各游戏的桌面背景
|
||||||
|
|
||||||
|
local TableBG = {}
|
||||||
|
|
||||||
|
local M = TableBG
|
||||||
|
local bg_config = {
|
||||||
|
{id = 1, url = "base/tablebg/bg/bg1", thumb = "ui://Common/b04"},
|
||||||
|
{id = 2, url = "base/tablebg/bg/bg2", thumb = "ui://Common/b05"},
|
||||||
|
{id = 3, url = "base/tablebg/bg/bg3", thumb = "ui://Common/b06"},
|
||||||
|
{id = 4, url = "base/tablebg/bg/bg7", thumb = "ui://Common/b01"},
|
||||||
|
{id = 5, url = "base/tablebg/bg/bg5", thumb = "ui://Common/b02"},
|
||||||
|
{id = 6, url = "base/tablebg/bg/bg4", thumb = "ui://Common/b03"},
|
||||||
|
}
|
||||||
|
|
||||||
|
function TableBG.GetBGConfig(config)
|
||||||
|
return config or bg_config
|
||||||
|
end
|
||||||
|
|
||||||
|
local function GetBG(data, game_id)
|
||||||
|
local bg_id = 0
|
||||||
|
for i = 1, #data do
|
||||||
|
if data[i].game_id == game_id then
|
||||||
|
bg_id = data[i].bg_id
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return bg_id
|
||||||
|
end
|
||||||
|
local function SetBG(data, game_id, bg_id)
|
||||||
|
local contain_key = false
|
||||||
|
for i = 1, #data do
|
||||||
|
if data[i].game_id == game_id then
|
||||||
|
contain_key = true
|
||||||
|
if data[i].bg_id ~= bg_id then
|
||||||
|
data[i].bg_id = bg_id
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if not contain_key then
|
||||||
|
local _data = {}
|
||||||
|
_data.game_id = game_id
|
||||||
|
_data.bg_id = bg_id
|
||||||
|
table.insert(data, _data)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function TableBG.GetTableBG(game_id)
|
||||||
|
local id = -1
|
||||||
|
local json_data = Utils.LoadLocalFile(DataManager.SelfUser.account_id .. DataManager.SelfUser.invite_code)
|
||||||
|
-- print(DataManager.SelfUser.invite_code, DataManager.SelfUser.account_id)
|
||||||
|
if json_data ~= nil then
|
||||||
|
local config_data = json.decode(json_data)
|
||||||
|
id = GetBG(config_data, game_id)
|
||||||
|
end
|
||||||
|
return id
|
||||||
|
end
|
||||||
|
|
||||||
|
function TableBG.LoadTableBG(id, game_id, main_view, config)
|
||||||
|
local bg_id = M.GetTableBG(game_id)
|
||||||
|
local index
|
||||||
|
if not bg_id then
|
||||||
|
index = 1
|
||||||
|
elseif bg_id > 0 then
|
||||||
|
index = bg_id
|
||||||
|
else
|
||||||
|
index = id
|
||||||
|
end
|
||||||
|
|
||||||
|
local con
|
||||||
|
if config then
|
||||||
|
con = config[index]
|
||||||
|
else
|
||||||
|
con = bg_config[index]
|
||||||
|
end
|
||||||
|
LoadGameBg(con and con.url or bg_config[1].url, main_view)
|
||||||
|
end
|
||||||
|
|
||||||
|
function TableBG.SaveTableBG(game_id, bg_id)
|
||||||
|
local config_data
|
||||||
|
local json_data = Utils.LoadLocalFile(DataManager.SelfUser.account_id .. DataManager.SelfUser.invite_code)
|
||||||
|
if json_data ~= nil then
|
||||||
|
config_data = json.decode(json_data)
|
||||||
|
else
|
||||||
|
config_data = {}
|
||||||
|
end
|
||||||
|
SetBG(config_data, game_id, bg_id)
|
||||||
|
Utils.SaveLocalFile(DataManager.SelfUser.account_id .. DataManager.SelfUser.invite_code, json.encode(config_data))
|
||||||
|
end
|
||||||
|
|
||||||
|
return M
|
||||||
|
|
@ -0,0 +1,110 @@
|
||||||
|
--用户账号数据类
|
||||||
|
--author:--
|
||||||
|
|
||||||
|
---
|
||||||
|
-- a user
|
||||||
|
User = {
|
||||||
|
account_id = "",
|
||||||
|
-- acc
|
||||||
|
acc ="",
|
||||||
|
--头像
|
||||||
|
head_url = "",
|
||||||
|
-- 用户IP
|
||||||
|
host_ip = "",
|
||||||
|
-- 经纬度坐标
|
||||||
|
location = nil,
|
||||||
|
-- 昵称
|
||||||
|
nick_name = "",
|
||||||
|
--性别
|
||||||
|
sex = 0,
|
||||||
|
-- 房间ID
|
||||||
|
room_id = "",
|
||||||
|
-- 房卡数
|
||||||
|
diamo = 0,
|
||||||
|
-- 代理类型,0不是代理,1普通代理,2大联盟代理
|
||||||
|
agent = 0,
|
||||||
|
invite_code = "1",
|
||||||
|
-- 当前圈子
|
||||||
|
cur_group = nil,
|
||||||
|
-- 圈子id,重连时用来标记是否在圈子房间中
|
||||||
|
group_id = 0,
|
||||||
|
|
||||||
|
playback = {},
|
||||||
|
|
||||||
|
--弹窗公告
|
||||||
|
notices = {},
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
---
|
||||||
|
-- @type User
|
||||||
|
local M = User
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
--- Create a new User
|
||||||
|
function User.new()
|
||||||
|
local self = {}
|
||||||
|
setmetatable(self, {__index = M})
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function M:getGameData(game_id)
|
||||||
|
local game_list = self.games
|
||||||
|
|
||||||
|
for i=1,#game_list do
|
||||||
|
local game = game_list[i]
|
||||||
|
if game.game_id == game_id then
|
||||||
|
return game
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:addGameData(data)
|
||||||
|
local game_list = self.games
|
||||||
|
for i=1,#game_list do
|
||||||
|
local game = game_list[i]
|
||||||
|
if game.game_id == data.game_id then
|
||||||
|
game_list[i] = data
|
||||||
|
return
|
||||||
|
end
|
||||||
|
end
|
||||||
|
game_list[#game_list+1] = data
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function M:removeGameData(game_id)
|
||||||
|
local game_list = self.games
|
||||||
|
for i=1,#game_list do
|
||||||
|
local game = game_list[i]
|
||||||
|
if game.game_id == game_id then
|
||||||
|
table.remove(game_list,i)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
--[[
|
||||||
|
local GuildData = {
|
||||||
|
--公会ID
|
||||||
|
id = 1,
|
||||||
|
--公会区名
|
||||||
|
zone = "",
|
||||||
|
--公会名称
|
||||||
|
name = "",
|
||||||
|
--游戏列表
|
||||||
|
games =nil
|
||||||
|
}
|
||||||
|
|
||||||
|
local GameInfo = {
|
||||||
|
--游戏ID
|
||||||
|
game_id = 1,
|
||||||
|
|
||||||
|
--服务器版本
|
||||||
|
version = "1.0.0",
|
||||||
|
|
||||||
|
table_data = nil
|
||||||
|
}
|
||||||
|
]]
|
||||||
|
|
||||||
|
|
@ -0,0 +1,13 @@
|
||||||
|
|
||||||
|
local DATA_MODEL_NAME = ...
|
||||||
|
|
||||||
|
Player = import(".Player")
|
||||||
|
import(".RecordData")
|
||||||
|
|
||||||
|
Room = import(".Room")
|
||||||
|
RoomResult = import(".RoomResult")
|
||||||
|
import(".User")
|
||||||
|
RecordData = import(".RecordData")
|
||||||
|
Location = import(".Location")
|
||||||
|
GroupData = import(".GroupData")
|
||||||
|
Groups = import(".Groups")
|
||||||
|
|
@ -0,0 +1,22 @@
|
||||||
|
require "Game.Data.init"
|
||||||
|
|
||||||
|
---
|
||||||
|
--@module Game.DataManager
|
||||||
|
|
||||||
|
DataManager= {
|
||||||
|
|
||||||
|
--my user
|
||||||
|
SelfUser = User.new(),
|
||||||
|
|
||||||
|
CurrenRoom = nil,
|
||||||
|
-- 互动表情时间,控制cd
|
||||||
|
InteractTime = 0,
|
||||||
|
-- 记录各游戏使用牌型的列表,现暂时只保存了麻将的数据.
|
||||||
|
CardTypeList = nil,
|
||||||
|
-- 牌友圈列表
|
||||||
|
groups = Groups.new(),
|
||||||
|
-- 禁止互动的房间ID
|
||||||
|
BanInteractRoom = nil,
|
||||||
|
-- app版本
|
||||||
|
AppVersion = "",
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,126 @@
|
||||||
|
local function __ShowTip(_version_view, text, callback)
|
||||||
|
local ctr_state = _version_view:GetController("state")
|
||||||
|
ctr_state.selectedIndex = 1
|
||||||
|
_version_view:GetChild("tex_tip").text = text
|
||||||
|
_version_view:GetChild("btn_ok").onClick:Set(function()
|
||||||
|
ctr_state.selectedIndex = 0
|
||||||
|
if (callback ~= null) then
|
||||||
|
callback:DynamicInvoke()
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
local btn_close = _version_view:GetChild("btn_close")
|
||||||
|
if btn_close then
|
||||||
|
btn_close.onClick:Set(function()
|
||||||
|
_version_view:Dispose()
|
||||||
|
_version_view = nil
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local function __update_check(data, onback, _version_view)
|
||||||
|
print("===================updateCheck")
|
||||||
|
local tex_tip = _version_view:GetChild("tex_info")
|
||||||
|
for k, game_data in ipairs(data) do
|
||||||
|
local asset_path = game_data["bundle"]:gsub("\r\n", "")
|
||||||
|
asset_path = string.gsub(asset_path, "%.", "/")
|
||||||
|
local local_version = Version.DEFUALT
|
||||||
|
local server_version = Version(game_data["version"])
|
||||||
|
local version_update = Hotupdate(asset_path .. "/", local_version, server_version)
|
||||||
|
version_update.AssetName = game_data["name"]
|
||||||
|
version_update:SetTipCallback(function(text, callback)
|
||||||
|
__ShowTip(_version_view, text, callback)
|
||||||
|
end)
|
||||||
|
version_update:LoadAsset()
|
||||||
|
while (not version_update.Done) do
|
||||||
|
onback(version_update.Progress, false)
|
||||||
|
tex_tip.text = version_update.TextTip
|
||||||
|
coroutine.step()
|
||||||
|
end
|
||||||
|
ResourcesManager.ReadAssetConfig(asset_path)
|
||||||
|
onback(0, false)
|
||||||
|
end
|
||||||
|
onback(1, true)
|
||||||
|
end
|
||||||
|
|
||||||
|
ExtendHotupdate = {
|
||||||
|
-- 正常
|
||||||
|
VERSION_NORMAL = 0,
|
||||||
|
-- 下载
|
||||||
|
VERSION_DOWN = 1,
|
||||||
|
-- 更新
|
||||||
|
VERSION_UPDATE = 2,
|
||||||
|
}
|
||||||
|
|
||||||
|
function ExtendHotupdate.UpdateGameList(list, callback)
|
||||||
|
if (not GameApplication.Instance.buildApp) then
|
||||||
|
callback()
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local _version_view = UIPackage.CreateObjectFromURL("ui://Hotupdate/Version")
|
||||||
|
_version_view.x = (GRoot.inst.width - _version_view.width) / 2
|
||||||
|
_version_view:GetChild("tex_info").text = "正在检查资源。。。"
|
||||||
|
local _pd = _version_view:GetChild("pb_progress")
|
||||||
|
_pd.value = 0
|
||||||
|
GRoot.inst:AddChild(_version_view)
|
||||||
|
|
||||||
|
coroutine.start(__update_check, list, function(progress, finish)
|
||||||
|
_pd.value = progress * 100
|
||||||
|
if (finish) then
|
||||||
|
callback()
|
||||||
|
_version_view:Dispose()
|
||||||
|
_version_view = nil
|
||||||
|
end
|
||||||
|
end, _version_view)
|
||||||
|
end
|
||||||
|
|
||||||
|
function ExtendHotupdate.UpdateGame(data, callback)
|
||||||
|
if (not GameApplication.Instance.buildApp) then
|
||||||
|
ExtendManager.UpdateExtend(data)
|
||||||
|
if callback then callback() end
|
||||||
|
return
|
||||||
|
end
|
||||||
|
ViewUtil.CloseModalWait()
|
||||||
|
NetResetConnectWindow.CloseNetReset()
|
||||||
|
local _version_view = UIPackage.CreateObjectFromURL("ui://Common/ExtendHotUpdate")
|
||||||
|
_version_view:GetChild("tex_info").text = "正在检查资源。。。"
|
||||||
|
local _pd = _version_view:GetChild("pb_progress")
|
||||||
|
_pd.value = 0
|
||||||
|
_version_view:AddRelation(GRoot.inst, RelationType.Size)
|
||||||
|
GRoot.inst:AddChild(_version_view)
|
||||||
|
_version_view:MakeFullScreen()
|
||||||
|
|
||||||
|
coroutine.start(__update_check, { data }, function(progress, finish)
|
||||||
|
_pd.value = progress * 100
|
||||||
|
if (finish) then
|
||||||
|
ExtendManager.UpdateExtend(data)
|
||||||
|
if callback then callback() end
|
||||||
|
_version_view:Dispose()
|
||||||
|
end
|
||||||
|
end, _version_view)
|
||||||
|
end
|
||||||
|
|
||||||
|
function ExtendHotupdate.CheckVersion(game_data)
|
||||||
|
if (not GameApplication.Instance.buildApp) then
|
||||||
|
ExtendManager.UpdateExtend(game_data)
|
||||||
|
return ExtendHotupdate.VERSION_NORMAL
|
||||||
|
end
|
||||||
|
if (not game_data) then
|
||||||
|
return ExtendHotupdate.VERSION_DOWN
|
||||||
|
end
|
||||||
|
|
||||||
|
local asset_path = game_data.bundle
|
||||||
|
asset_path = string.gsub(asset_path, '%.', '/')
|
||||||
|
local local_version = Hotupdate.GetLocalVersion(asset_path .. "/")
|
||||||
|
local server_version = Version(game_data.version)
|
||||||
|
if not local_version then
|
||||||
|
return ExtendHotupdate.VERSION_DOWN
|
||||||
|
end
|
||||||
|
|
||||||
|
if local_version:ContainAll(server_version) then
|
||||||
|
return ExtendHotupdate.VERSION_UPDATE
|
||||||
|
end
|
||||||
|
ResourcesManager.ReadAssetConfig(asset_path)
|
||||||
|
ExtendManager.UpdateExtend(game_data)
|
||||||
|
return ExtendHotupdate.VERSION_NORMAL
|
||||||
|
end
|
||||||
|
|
@ -0,0 +1,73 @@
|
||||||
|
require "Game.IExtendConfig"
|
||||||
|
require "Game.IGameInfo"
|
||||||
|
---
|
||||||
|
-- a net ExtendManager
|
||||||
|
ExtendManager = {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
local _extendMap = {}
|
||||||
|
|
||||||
|
local _isUpdate = false
|
||||||
|
local _isInit = false
|
||||||
|
|
||||||
|
local function __new_config(data)
|
||||||
|
local ec = reimport(data.bundle ..".ExtendConfig")
|
||||||
|
--print("初始化ExtendManager===>>>"..data.bundle)
|
||||||
|
--pt(data)
|
||||||
|
local config = ec.new()
|
||||||
|
ec.game_data = data
|
||||||
|
_extendMap[data.game_id] = config
|
||||||
|
return config
|
||||||
|
end
|
||||||
|
|
||||||
|
function ExtendManager.Init(game_list)
|
||||||
|
print("==========================================================ExtendManager")
|
||||||
|
pt(game_list)
|
||||||
|
if _isInit then return end
|
||||||
|
for i=1,#game_list do
|
||||||
|
local game = game_list[i]
|
||||||
|
__new_config(game)
|
||||||
|
end
|
||||||
|
|
||||||
|
_isInit = true
|
||||||
|
end
|
||||||
|
|
||||||
|
-- 更新扩展玩法到最新数据
|
||||||
|
function ExtendManager.UpdateExtend(data)
|
||||||
|
if not data then return end
|
||||||
|
local tem = _extendMap[data.game_id]
|
||||||
|
if tem and (not GameApplication.Instance.buildApp) then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
if tem and tem.game_data.version ~= data.version then
|
||||||
|
GameApplication.Instance:UnExtendLua(data)
|
||||||
|
tem:UnAllAssets()
|
||||||
|
end
|
||||||
|
__new_config(data)
|
||||||
|
end
|
||||||
|
|
||||||
|
function ExtendManager.RemoveExtend(data)
|
||||||
|
local tem = _extendMap[data.game_id]
|
||||||
|
if tem then
|
||||||
|
GameApplication.Instance:UnExtendLua(data)
|
||||||
|
tem:UnAllAssets()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function ExtendManager.GetExtendConfig(id)
|
||||||
|
return _extendMap[id]
|
||||||
|
end
|
||||||
|
|
||||||
|
function ExtendManager.GetGameData(id)
|
||||||
|
local data = _extendMap[id]
|
||||||
|
if not data then
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
return data.game_data
|
||||||
|
end
|
||||||
|
|
||||||
|
function ExtendManager.Destroy()
|
||||||
|
_extendMap = {}
|
||||||
|
_isInit = false
|
||||||
|
end
|
||||||
|
|
@ -0,0 +1,77 @@
|
||||||
|
---
|
||||||
|
IExtendConfig = {
|
||||||
|
extend_id = 0,
|
||||||
|
_viewMap = nil
|
||||||
|
}
|
||||||
|
|
||||||
|
local M = IExtendConfig
|
||||||
|
--
|
||||||
|
function M:GetGameInfo()
|
||||||
|
end
|
||||||
|
|
||||||
|
--卸载资源
|
||||||
|
function M:UnAssets()
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:NewRoom()
|
||||||
|
return Room.new()
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:GetGameController()
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:FillRoomData(s2croom)
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:FillPlayerData(info, player)
|
||||||
|
local room = DataManager.CurrenRoom
|
||||||
|
local playerList = info
|
||||||
|
local NewPlayer = player
|
||||||
|
if not NewPlayer then
|
||||||
|
NewPlayer = room:NewPlayer()
|
||||||
|
end
|
||||||
|
|
||||||
|
--printlog("111111111111111111111111111111111111111111")
|
||||||
|
--pt(info)
|
||||||
|
|
||||||
|
for i = 1,#playerList do
|
||||||
|
local _jp = playerList[i]
|
||||||
|
|
||||||
|
local p = NewPlayer.new()
|
||||||
|
p.seat = _jp["seat"]
|
||||||
|
local online = _jp["online"]
|
||||||
|
p.line_state = online
|
||||||
|
p.ready = _jp["ready"] == 1 and true or false
|
||||||
|
local pid = _jp["aid"]
|
||||||
|
if (DataManager.SelfUser.account_id == pid) then
|
||||||
|
room.self_player = p
|
||||||
|
p.self_user = DataManager.SelfUser
|
||||||
|
else
|
||||||
|
local u = User.new()
|
||||||
|
u.account_id = pid
|
||||||
|
p.self_user = u
|
||||||
|
u.nick_name = _jp["nick"]
|
||||||
|
u.head_url = _jp["portrait"]
|
||||||
|
u.sex = _jp["sex"]
|
||||||
|
end
|
||||||
|
p.self_user.location = Location.new(_jp["pos"] or "")
|
||||||
|
p.self_user.host_ip = _jp["ip"]
|
||||||
|
p.total_score = _jp["score"] or 0
|
||||||
|
p.cur_hp = _jp["cur_hp"] or 0
|
||||||
|
p.total_hp = _jp["total_hp"] or 0
|
||||||
|
if _jp["hp_info"] then
|
||||||
|
p.cur_hp = _jp.hp_info.cur_hp
|
||||||
|
p.total_hp = _jp.hp_info.total_hp
|
||||||
|
end
|
||||||
|
if _jp["entrust"] then
|
||||||
|
p.entrust = _jp.entrust
|
||||||
|
end
|
||||||
|
|
||||||
|
room:AddPlayer(p)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:GetView(id)
|
||||||
|
local dview_class = self._viewMap[id]
|
||||||
|
return dview_class
|
||||||
|
end
|
||||||
|
|
@ -0,0 +1,71 @@
|
||||||
|
-- Edit by ChenGY
|
||||||
|
--@type IGameInfo
|
||||||
|
|
||||||
|
--扩展UI:
|
||||||
|
--需要两个控制器,agent控制支付类型显示,Cost控制目前选中的支付类型
|
||||||
|
--回合数对应的显示价格组件统一命名为:tex_price1、tex_price2、...
|
||||||
|
--房主支付、AA支付显示价格的组件需要统一名称:tex_owner、tex_aa
|
||||||
|
|
||||||
|
IGameInfo = {
|
||||||
|
-- 回合选项数量,必填
|
||||||
|
_roundChoice = 2,
|
||||||
|
-- 玩家数量,在子类中赋值,如果玩家数量可选,需要重载 OnChangeOption 方法, 详见长沙麻将
|
||||||
|
_maxPlayer = 2,
|
||||||
|
_game_data = nil,
|
||||||
|
}
|
||||||
|
|
||||||
|
local M = IGameInfo
|
||||||
|
|
||||||
|
function M:SelectedCardNum()
|
||||||
|
return 0
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:SelectedConfigData()
|
||||||
|
return {}
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:FillData()
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:ShowRoomPrice(ctype)
|
||||||
|
local list = DataManager.SelfUser.games
|
||||||
|
if not self._game_data then
|
||||||
|
for i = 1, #list do
|
||||||
|
if list[i].game_id == self.game_data.game_id then
|
||||||
|
self._game_data = list[i]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
self:ShowVariablePrice(ctype)
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:OnChangeOption(ctype)
|
||||||
|
self:ShowRoomPrice(ctype)
|
||||||
|
local round = self._config:GetController("round")
|
||||||
|
round.onChanged:Set(function ()
|
||||||
|
self:ShowVariablePrice(ctype)
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:ShowVariablePrice(ctype)
|
||||||
|
-- 显示回合数后面的价格,tex_price1、tex_price2
|
||||||
|
|
||||||
|
for i = 1, self._roundChoice do
|
||||||
|
local price = "0"
|
||||||
|
price = self._game_data[string.format("pay%s_%s", i, self._maxPlayer)]
|
||||||
|
local tex_price = self._config:GetChild("tex_price" .. i)
|
||||||
|
if tex_price then
|
||||||
|
tex_price.text = price
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- 显示房主支付、aa支付的价格,tex_aa/tex_owner
|
||||||
|
-- local tex_aa = self._config:GetChild("tex_aa")
|
||||||
|
-- local tex_owner = self._config:GetChild("tex_owner")
|
||||||
|
-- local opt = self._config:GetController("round").selectedIndex
|
||||||
|
-- local price = self._game_data[string.format("pay%s_%s", opt + 1, self._maxPlayer)]
|
||||||
|
-- tex_aa.text = math.ceil(price / self._maxPlayer)
|
||||||
|
-- tex_owner.text = price
|
||||||
|
end
|
||||||
|
|
||||||
|
return M
|
||||||
|
|
@ -0,0 +1,452 @@
|
||||||
|
|
||||||
|
Protocol = {
|
||||||
|
-------------------- Web --------------------------
|
||||||
|
-------------- acc -----------
|
||||||
|
-- 用户登录
|
||||||
|
WEB_USER_LOGIN = "acc/regist_login",
|
||||||
|
-- 快速登录
|
||||||
|
WEB_QUICK_LOGIN = "acc/quick_login",
|
||||||
|
-- 手机密码
|
||||||
|
WEB_PHONE_PASSWORD_LOGIN = "acc/phone_pw_login",
|
||||||
|
-- 手机登录
|
||||||
|
WEB_PHONE_LOGIN = "acc/verifyVerificationCode",
|
||||||
|
-- ID密码
|
||||||
|
WEB_ID_PASSWORD_LOGIN = "acc/id_login",
|
||||||
|
-- 获取手机验证码
|
||||||
|
WEB_GET_VERIFCATION_CODE="acc/sendVerificationCode",
|
||||||
|
--绑定手机号码
|
||||||
|
WEB_BINDING_PHONE="acc/binding_phone",
|
||||||
|
--更换微信
|
||||||
|
WEB_change_weChat="acc/change_weChat",
|
||||||
|
-- 更新用户信息
|
||||||
|
WEB_UPDATE_USER_INFO = "acc/update_user_info",
|
||||||
|
-- 获取用户信息
|
||||||
|
WEB_GET_USER_INFO = "acc/get_user_info",
|
||||||
|
|
||||||
|
WEB_UPDATE_INFO = "acc/update_player_info",
|
||||||
|
|
||||||
|
-- 实名认证
|
||||||
|
WEB_REAL_NAME_IDENTIFY = "acc/certification",
|
||||||
|
|
||||||
|
----map mode----
|
||||||
|
WEB_GET_PROVINCES = "acc/get_provinces",
|
||||||
|
|
||||||
|
WEB_GET_CITIES = "acc/get_citys",
|
||||||
|
|
||||||
|
WEB_ADD_GAME = "acc/add_game",
|
||||||
|
|
||||||
|
WEB_DEL_GAME = "acc/del_game",
|
||||||
|
|
||||||
|
WEB_GET_AGENT_SECRET = "acc/agent_secret",
|
||||||
|
-- 设置被邀请开关
|
||||||
|
WEB_SET_GROUP_INVITATED = "acc/set_group_invitation",
|
||||||
|
----index----
|
||||||
|
-- 获取公告
|
||||||
|
WEB_UPDATE_NOTICE = "index/get_notice",
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
----rank----
|
||||||
|
|
||||||
|
WEB_GET_MILITARY = "military/get_military",
|
||||||
|
|
||||||
|
WEB_GET_MILITARY_BY_ROOMID = "military/get_militaryByRoomId",
|
||||||
|
--回放
|
||||||
|
WEB_GET_PLAY_BACK = "military/get_playBack",
|
||||||
|
-- 牌友圈排行
|
||||||
|
WEB_FG_RANK_LIST = "military/get_rankListByGroup",
|
||||||
|
-- 局数统计
|
||||||
|
WEB_FG_ROUND_LIST = "military/get_roundListByGroup",
|
||||||
|
-- 设置排行是否可访问
|
||||||
|
WEB_FG_SET_RANK_ACCESSIBLE = "military/set_randListRightByGroup",
|
||||||
|
|
||||||
|
----room----
|
||||||
|
-- 创建房间
|
||||||
|
WEB_CREATE_ROOM = "room/create_room",
|
||||||
|
-- 加入房间
|
||||||
|
WEB_JOIN_ROOM = "room/join_room",
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
--start::::::::::::::牌友圈协议::::::::::::::::::::
|
||||||
|
--牌友圈获取组列表
|
||||||
|
WEB_FG_GROUP_LIST = "group/get_groups",
|
||||||
|
--牌友圈创建组
|
||||||
|
WEB_FG_CREATE_GROUP = "group/create_group",
|
||||||
|
--牌友圈加入组
|
||||||
|
WEB_FG_JOIN_GROUP = "group/join_group",
|
||||||
|
--牌友圈删除组
|
||||||
|
WEB_FG_REMOVE_GROUP = "group/del_group",
|
||||||
|
--牌友圈退出圈子
|
||||||
|
WEB_FG_EXIT_GROUP = "group/exit_group",
|
||||||
|
--牌友圈更改组名
|
||||||
|
WEB_FG_GROUP_RENAME = "group/group_rename",
|
||||||
|
--牌友圈邀请列表
|
||||||
|
WEB_FG_GROUP_JOINS = "group/get_group_joins",
|
||||||
|
--牌友圈审核玩家加入
|
||||||
|
WEB_FG_GROUP_VERIFY_JOIN = "group/verify_join_group",
|
||||||
|
--牌友圈玩家列表
|
||||||
|
WEB_FG_GROUP_MEMBERS = "group/get_group_members",
|
||||||
|
--牌友圈玩家列表1
|
||||||
|
WEB_FG_GROUP_MEMBERS1 = "group/get_my_members",
|
||||||
|
--踢出玩家列表
|
||||||
|
WEB_FG_GROUP_TICHU = "group/get_kick_log",
|
||||||
|
--牌友圈删除玩家
|
||||||
|
WEB_FG_GROUP_KICK = "group/group_kick",
|
||||||
|
--牌友圈获取房间列表
|
||||||
|
WEB_FG_GROUP_ROOMS = "group/get_group_rooms",
|
||||||
|
--牌友圈创建房间
|
||||||
|
WEB_FG_GROUP_CREATE_ROOM = "group/create_group_room",
|
||||||
|
--牌友圈删除房间
|
||||||
|
WEB_FG_GROUP_DEL_ROOM = "group/del_group_room",
|
||||||
|
--牌友圈获取战绩列表
|
||||||
|
WEB_FG_GROUP_RECORD = "group/group_game_record",
|
||||||
|
-- 牌友圈创建机器人
|
||||||
|
WEB_FG_CREATE_BOT = "group/create_group_bot",
|
||||||
|
-- 牌友圈获取机器人列表
|
||||||
|
WEB_FG_GET_BOTS = "group/get_group_bots",
|
||||||
|
-- 牌友圈删除机器人
|
||||||
|
WEB_FG_DEL_BOT = "group/del_group_bot",
|
||||||
|
-- 授权副盟主
|
||||||
|
WEB_FG_SET_MANAGER = "group/set_member_mgr",
|
||||||
|
-- 设置合伙人
|
||||||
|
WEB_FG_SET_PARTNER = "group/set_partner",
|
||||||
|
-- 禁止娱乐
|
||||||
|
WEB_FG_BAN_MEMBER = "group/ban_member",
|
||||||
|
--获取heibai
|
||||||
|
GROUP_GET_BLACK_MEMBER= "group/get_black_member",
|
||||||
|
--heibai调动
|
||||||
|
GROUP_BLACK_MEMBER = "group/black_member",
|
||||||
|
-- 设置vip
|
||||||
|
WEB_FG_SET_GROUP_VIP = "group/set_group_vip",
|
||||||
|
-- 禁止同桌
|
||||||
|
WEB_FG_SET_BAN_TABLE = "group/set_ban_desk",
|
||||||
|
-- 添加玩家
|
||||||
|
WEB_FG_INVITE_MEMBER = "group/invite_group_member",
|
||||||
|
--获取添加玩家
|
||||||
|
GET_PLAYER_INFO = "group/get_player_info",
|
||||||
|
-- 玩家备注
|
||||||
|
WEB_FG_NOTE_MEMBER = "group/note_group_member",
|
||||||
|
-- 圈子备注
|
||||||
|
WEB_FG_NOTE_GROUP = "group/group_note",
|
||||||
|
-- 获取禁止同桌列表
|
||||||
|
WEB_FG_GET_BAN_TABLE = "group/get_ban_desk_list",
|
||||||
|
-- 克隆牌友圈
|
||||||
|
WEB_FG_CLONE_GROUP = "group/clone_group",
|
||||||
|
-- 改变体力值
|
||||||
|
WEB_FG_CHANGE_FAG ="group/update_member_hp",
|
||||||
|
-- 体力值详情
|
||||||
|
WEB_FG_FAG_LOG ="group/get_hp_log",
|
||||||
|
-- 体力值记录
|
||||||
|
WEB_FG_FAG_UPDATE_LOG ="group/get_hpUpdate_log",
|
||||||
|
-- 体力值设置
|
||||||
|
WEB_FG_FAG_HPDATA ="group/set_group_hpData",
|
||||||
|
-- 设置体力值权限
|
||||||
|
WEB_FG_SHOW_FAG ="group/show_hp",
|
||||||
|
-- 查看整线体力值
|
||||||
|
GET_HP_TOTAL = "group/get_hp_total",
|
||||||
|
-- 添加层
|
||||||
|
WEB_FG_CREATE_SUB_GROUP = "group/create_subGroup",
|
||||||
|
-- 删除层
|
||||||
|
WEB_FG_DEL_SUB_GROUP = "group/del_subGroup",
|
||||||
|
-- 置顶
|
||||||
|
WEB_FG_GROUP_TOP ="group/stick_group",
|
||||||
|
-- 查看预览
|
||||||
|
WEB_FG_GROUP_PREVIEW = "group/group_preview",
|
||||||
|
-- 获取排名列表
|
||||||
|
WEB_FG_GROUP_HPRANK = "group/group_hp_ranking",
|
||||||
|
-- 核实转让对象
|
||||||
|
WEB_FG_CHECK_REMIT_MEMBER = "group/transfer_accounts_query",
|
||||||
|
-- 转让体力值
|
||||||
|
WEB_FG_REMIT = "group/transfer_accounts",
|
||||||
|
-- 添加玩法
|
||||||
|
WEB_FG_ADD_PLAY = "group/add_play",
|
||||||
|
-- 删除玩法
|
||||||
|
WEB_FG_DEL_PLAY = "group/del_play",
|
||||||
|
-- 更新玩法
|
||||||
|
WEB_FG_UPDATE_PLAY = "group/update_play",
|
||||||
|
-- 禁止、恢复玩法
|
||||||
|
WEB_FG_BAN_PLAY = "group/ban_play",
|
||||||
|
-- 进入圈子
|
||||||
|
WEB_ENTER_GROUP = "group/enter_group",
|
||||||
|
-- 获取上级合伙人
|
||||||
|
WEB_GET_SUPERIOR_PARTNERS = "group/get_member_parents",
|
||||||
|
--获取积分转移限制
|
||||||
|
WEB_GET_TRANS_HP_LIMIT = "group/get_trans_hp_limit",
|
||||||
|
--设置积分转移限制
|
||||||
|
WEB_SET_TRANS_HP_LIMIT = "group/set_trans_hp_limit",
|
||||||
|
-- 查询成员
|
||||||
|
WEB_FG_FIND_MEMBER = "group/find_member",
|
||||||
|
--搜索
|
||||||
|
WEB_FG_FIND_PARTNER_STAT = "group/log/find_partner_stat",
|
||||||
|
|
||||||
|
--搜索
|
||||||
|
WEB_FG_FIND_COST_COUNT_STAT = "group/log/find_partner_stat_cost_count",
|
||||||
|
|
||||||
|
--find_partner_stat_member
|
||||||
|
WEB_FG_FIND_PARTNER_STAT_Member = "group/log/find_partner_stat_member",
|
||||||
|
|
||||||
|
WEB_FG_FIND_PARTNER_COST_COUNT_Member = "group/log/find_partner_stat_member_cost_count",
|
||||||
|
-- 强制提取
|
||||||
|
WEB_FG_TAKE_HP = "group/group_take_hp",
|
||||||
|
-- 修改牌友圈信息
|
||||||
|
WEB_FG_UPDATE_GROUP_INFO = "group/update_info",
|
||||||
|
-- 获取合伙人列表(推广奖励)
|
||||||
|
WEB_FG_GET_PARTNERS = "group/get_group_partners",
|
||||||
|
|
||||||
|
-- 获取所有玩法
|
||||||
|
WEB_FG_GET_ALLPLAYS = "group/get_panter_allplays",
|
||||||
|
-- 设置屏蔽玩法
|
||||||
|
WEB_FG_SET_BANPLAYID = "group/set_panter_banplay",
|
||||||
|
|
||||||
|
-- 获取推广奖励值
|
||||||
|
WEB_FG_GET_REWARDS = "group/get_rewards",
|
||||||
|
-- 设置推广奖励值
|
||||||
|
WEB_FG_SET_REWARDS = "group/set_reward",
|
||||||
|
|
||||||
|
WEB_FG_SET_XIPAI = "group/set_xipai_reward",
|
||||||
|
|
||||||
|
--管理--
|
||||||
|
WEB_FG_SET_ANCHOU = "group/set_anchou_reward",
|
||||||
|
|
||||||
|
-- 获取全民推广
|
||||||
|
WEB_FG_GET_PROMOTE = "group/get_promotion",
|
||||||
|
-- 设置全民推广
|
||||||
|
WEB_FG_SET_PROMOTE = "group/update_promotion",
|
||||||
|
-- 牌友圈预览
|
||||||
|
WEB_FG_PREVIEW = "group/group_preview",
|
||||||
|
-- 调配成员
|
||||||
|
WEB_FG_DEPLOY_MEMBER = "group/distribute_member",
|
||||||
|
-- 转移合伙人
|
||||||
|
WEB_FG_MOVE_PARTNER = "group/move_partner",
|
||||||
|
-- 获取合伙人列表(合伙人管理)
|
||||||
|
WEB_FG_GET_PARTNER_DATA = "group/get_partner_data",
|
||||||
|
-- 获取合伙人列表(合伙人管理)
|
||||||
|
WEB_FG_QUERY_PARTNER_DATA = "group/query_partner_data",
|
||||||
|
-- 获取合伙人成员
|
||||||
|
WEB_FG_GET_PARTNER_MEMBERS = "group/get_partner_members",
|
||||||
|
-- 设置合伙人权限
|
||||||
|
WEB_FG_SET_PARTNER_HPOPT = "group/set_partner_hpopt",
|
||||||
|
-- 查询成员(转账)
|
||||||
|
WEB_FG_REMIT_FIND_MEMBER = "group/find_member1",
|
||||||
|
-- 转账
|
||||||
|
WEB_FG_REMIT = "group/trade_hp",
|
||||||
|
-- 获取能量包数据
|
||||||
|
WEB_FG_GET_TAKE_INFO = "group/get_take_info",
|
||||||
|
-- 提取体力值
|
||||||
|
WEB_FG_TAKE_FAG = "group/take_hp",
|
||||||
|
-- 获取能量包统计
|
||||||
|
WEB_FG_FAG_PACK_INFO = "group/log/get_hp_count_info",
|
||||||
|
-- 设置管理员权限
|
||||||
|
WEB_FG_SET_MNG_PERMISSION = "group/set_mgr_permission",
|
||||||
|
-- 获取圈子邮件
|
||||||
|
WEB_FG_GET_MAIL_LIST = "group/get_mail_list",
|
||||||
|
-- 删除圈子邮件
|
||||||
|
WEB_FG_DEL_ALL_MAIL = "group/del_mail_all",
|
||||||
|
-- 设置成员备注
|
||||||
|
WEB_FG_SET_MEMBER_TAG = "group/update_member_score",
|
||||||
|
|
||||||
|
--设置亲友圈合伙人阀值
|
||||||
|
|
||||||
|
WEB_FG_SET_AUTO_SCORE = "group/set_auto_score",
|
||||||
|
--标记玩法排行
|
||||||
|
GROUP_MARK_PLAY = "group/mark_play",
|
||||||
|
|
||||||
|
|
||||||
|
GET_BANK_HP = "group/get_bank_hp", --获取银行信息
|
||||||
|
TAKE_BANK_HP = "group/take_bank_hp",
|
||||||
|
SAVE_BANK_HP = "group/save_bake_hp",
|
||||||
|
-------------- group-log---------------------
|
||||||
|
-- 获取奖励日志
|
||||||
|
WEB_FG_GET_REWARDS_LOG = "group/log/get_reward_log",
|
||||||
|
-- 获取奖励统计
|
||||||
|
WEB_FG_GET_REWARDS_STATISTIC = "group/log/get_reward_count",
|
||||||
|
-- 获取成员排名
|
||||||
|
WEB_FG_MEMBER_RANK = "group/log/get_member_rank",
|
||||||
|
-- 获取局数统计
|
||||||
|
WEB_FG_GET_ROUND_STATISTIC = "group/log/get_round_count",
|
||||||
|
-- 成员体力值详情
|
||||||
|
WEB_FG_GET_MEMBER_HP_LOG = "group/log/get_hplog_info",
|
||||||
|
-- 获取玩法局数统计
|
||||||
|
WEB_FG_GET_GAME_ROUND_STATISTIC = "group/log/get_play_round_count",
|
||||||
|
-- 获取消耗统计
|
||||||
|
WEB_FG_GET_CONSUME_STATISTIC = "group/log/get_cost_count",
|
||||||
|
-- 获取抽水记录
|
||||||
|
WEB_FG_GET_PROPORTION_LOG = "group/log/get_hplog_pump",
|
||||||
|
-- 获取战绩
|
||||||
|
WEB_FG_GET_RECORD = "group/log/get_records",
|
||||||
|
-- 获取个人战绩
|
||||||
|
WEB_FG_GET_PERSON_RECORD = "group/log/get_person_records",
|
||||||
|
-- 获取成员战绩
|
||||||
|
WEB_FG_GET_MEMBER_STAT = "group/log/get_member_stat",
|
||||||
|
-- 获取合伙人统计
|
||||||
|
WEB_FG_GET_PARTNER_STAT = "group/log/get_partner_stat",
|
||||||
|
--获取钻石消耗统计
|
||||||
|
WEB_FG_GET_COST_COUNT_STAT = "group/log/get_partner_stat_cost_count",
|
||||||
|
--幸运号数据
|
||||||
|
WEB_FG_GET_XINGYUNHAO_INFO = "group/get_xingyunhao_info",
|
||||||
|
--获取玩家和积分
|
||||||
|
WEB_FG_GET_MEMBERS_COUNT = "group/get_members_count",
|
||||||
|
-- 获取合伙人统计
|
||||||
|
WEB_FG_GET_PARTNER_STAT_MEMBER = "group/log/get_partner_stat_member",
|
||||||
|
-- 获取直属下级统计
|
||||||
|
WEB_FG_GET_DIRECT_MEMBER_STAT = "group/log/get_direct_stat_member",
|
||||||
|
|
||||||
|
WEB_FG_GET_DIRECT_COST_COUNT = "group/log/get_direct_stat_member_cost_count",
|
||||||
|
|
||||||
|
WEB_FG_GET_PARTNER_COST_COUNT = "group/log/get_partner_stat_member_cost_count",
|
||||||
|
-- 获取合伙人统计
|
||||||
|
WEB_FG_GET_PARTNER_STAT_PLAY = "group/log/get_partner_stat_play",
|
||||||
|
-- 根据房间号查询战绩
|
||||||
|
WEB_FG_GET_RECORD_BY_ROOMID = "group/log/find_record_room",
|
||||||
|
-- 获取提取记录
|
||||||
|
WEB_FG_FAG_TAKE_LOG = "group/log/get_take_log",
|
||||||
|
--提取银行记录
|
||||||
|
WEB_FG_GET_BANK_LOG = "group/log/get_bank_log",
|
||||||
|
-- 获取管理上下分记录
|
||||||
|
WEB_FG_GET_MNG_HP_LOG = "group/log/get_hplog_mgr",
|
||||||
|
-- 获取管理员上下分统计
|
||||||
|
WEB_FG_MNG_HP_STATISTIC = "group/log/get_hplog_mgr_count",
|
||||||
|
-- 获取管理员个人上下分统计
|
||||||
|
WEB_FG_MNG_HP_INFO = "group/log/get_hplog_mgr_info",
|
||||||
|
-- 获得玩家输赢分日统计
|
||||||
|
WEB_FG_GET_PLAYER_DAILY_COUNT = "group/log/get_hpconsume_count",
|
||||||
|
-- 体力值日志牌局明细
|
||||||
|
WEB_FG_HPLOG_DETAIL_INFO = "group/log/get_hplog_detail_info",
|
||||||
|
------------- group-room ------------
|
||||||
|
-- 圈子匹配房间
|
||||||
|
WEB_FG_MATCH_ROOM = "group/room/match_room",
|
||||||
|
-- 圈子排队房间
|
||||||
|
WEB_FG_QUEUE_ROOM = "group/room/queue_room",
|
||||||
|
|
||||||
|
-- 圈子加入房间
|
||||||
|
WEB_FG_JOIN_ROOM = "group/room/join_room",
|
||||||
|
-- 圈子删除房间
|
||||||
|
WEB_FG_DEL_ROOM = "group/room/del__room",
|
||||||
|
|
||||||
|
-------------- group-mgr --------------------
|
||||||
|
-- 进入圈子
|
||||||
|
FGMGR_ENTER_GROUP = "11001",
|
||||||
|
-- 更新房间
|
||||||
|
FGMGR_EVT_UPDATE_ROOM = "12001",
|
||||||
|
-- 删除房间
|
||||||
|
FGMGR_EVT_DEL_ROOM = "12002",
|
||||||
|
-- 添加房间
|
||||||
|
FGMGR_EVT_ADD_ROOM = "12003",
|
||||||
|
-- 删除玩法
|
||||||
|
FGMGR_EVT_DEL_PLAY = "12004",
|
||||||
|
-- 添加玩法
|
||||||
|
FGMGR_EVT_ADD_PLAY = "12005",
|
||||||
|
-- 更新玩法
|
||||||
|
FGMGR_EVT_UPDATE_PLAY = "12006",
|
||||||
|
-- 圈子消息
|
||||||
|
FGMGR_EVT_MESSAGE = "12007",
|
||||||
|
-- 刷新圈子
|
||||||
|
FGMGR_EVT_UPDATE_GROUP = "12008",
|
||||||
|
-- 更新体力值
|
||||||
|
FGMGR_EVT_UPDATE_PLAYER_INFO = "12009",
|
||||||
|
-- 获取在线列表
|
||||||
|
FGMGR_GET_ONLINE_PLAYERS = "11002",
|
||||||
|
-- 邀请玩家
|
||||||
|
FGMGR_INVITE_PLAYER = "11003",
|
||||||
|
-- 邀请回复
|
||||||
|
FGMGR_RESPONSE_INVITE = "11004",
|
||||||
|
-- 收到邀请
|
||||||
|
FGMGR_EVT_INVITED = "12010",
|
||||||
|
-- 未读邮件提示事件
|
||||||
|
FGMGR_EVT_NEW_MAIL = "update_mail_tip",
|
||||||
|
|
||||||
|
--end::::::::::::::牌友圈协议::::::::::::::::::::
|
||||||
|
|
||||||
|
-------------------Game ----------------------------
|
||||||
|
-- 进入房间
|
||||||
|
GAME_JOIN_ROOM = "1002",
|
||||||
|
|
||||||
|
-- 玩家进入房间
|
||||||
|
GAME_EVT_PLAYER_JOIN = "2001",
|
||||||
|
|
||||||
|
-- 玩家退出
|
||||||
|
GAME_EVT_PLAYER_EXIT = "2002",
|
||||||
|
|
||||||
|
-- 玩家网络状态
|
||||||
|
GAME_EVT_PLAYER_NET_STATE = "2003",
|
||||||
|
|
||||||
|
-- 发送聊天
|
||||||
|
GAME_INTERACTION = "1006",
|
||||||
|
|
||||||
|
-- 聊天事件
|
||||||
|
GAME_EVT_INTERACTION = "2017",
|
||||||
|
|
||||||
|
-- 退出房间
|
||||||
|
GAME_EXIT_ROOM = "1005",
|
||||||
|
|
||||||
|
-- 房主退出房间解散
|
||||||
|
GAME_EVT_EXIT_ROOM_DISMISS = "2008",
|
||||||
|
|
||||||
|
-- 发送准备
|
||||||
|
GAME_READY = "1003",
|
||||||
|
|
||||||
|
-- 准备事件
|
||||||
|
GAME_EVT_READY = "2009",
|
||||||
|
|
||||||
|
--洗牌
|
||||||
|
GAME_READY_AND_XIPAI = "201004",
|
||||||
|
GAME_EVT_READY_AND_XIPAI = "202009",
|
||||||
|
|
||||||
|
|
||||||
|
-- 请求开始游戏
|
||||||
|
GAME_START = "1004",
|
||||||
|
|
||||||
|
-- 请求解散房间
|
||||||
|
GAME_ASK_DISMISS_ROOM = "1007",
|
||||||
|
|
||||||
|
-- 解散房间
|
||||||
|
GAME_EVT_DISMISS_ROOM = "2005",
|
||||||
|
|
||||||
|
-- 请求解散房间投票
|
||||||
|
GAME_DISMISS_ROOM_VOTE = "1008",
|
||||||
|
|
||||||
|
-- 解散房间投票事件
|
||||||
|
GAME_EVT_DISMISS_ROOM_VOTE = "2006",
|
||||||
|
|
||||||
|
-- 解散房间失败
|
||||||
|
GAME_EVT_DISMISS_ROOM_FAIL = "2027",
|
||||||
|
|
||||||
|
-- 发送GPS坐标
|
||||||
|
GAME_SEND_GPS = "1001",
|
||||||
|
|
||||||
|
-- GPS更新事件
|
||||||
|
GAME_EVT_UPDATE_GPS = "2000",
|
||||||
|
|
||||||
|
-- 更新庄家协议
|
||||||
|
GAME_EVT_UPDATE_BANKER = "2031",
|
||||||
|
|
||||||
|
-- 删除代理房间
|
||||||
|
GAME_REMOVE_AGENT_ROOM = "1000",
|
||||||
|
|
||||||
|
-- 获得红包
|
||||||
|
GAME_EVT_HONGBAO = "3000",
|
||||||
|
|
||||||
|
-- 被踢出房间
|
||||||
|
GAME_EVT_KICKED = "3001",
|
||||||
|
|
||||||
|
--托管
|
||||||
|
GAME_ENTRUST = "1301",
|
||||||
|
--入座
|
||||||
|
GAME_JOIN_SEAT = "1302",
|
||||||
|
--玩家进入观众席
|
||||||
|
GAME_EVT_JOIN_SPECTATOR = "3002",
|
||||||
|
--更新玩家信息
|
||||||
|
GAME_EVT_UPDATE_PLAYERINFO = "3003",
|
||||||
|
|
||||||
|
FGMGR_EVT_UPDATE_RECONECT = "3005",
|
||||||
|
|
||||||
|
GAME_EVT_READY_ENTRUST = "22010", --显示托管倒计时
|
||||||
|
|
||||||
|
GAME_EVT_CANCEL_READY_ENTRUST = "22011", --关闭托管倒计时
|
||||||
|
|
||||||
|
GAME_AUTO_CARD = "1303", --开启游戏托管
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,88 @@
|
||||||
|
|
||||||
|
---聊天View对象
|
||||||
|
local ChatView = {}
|
||||||
|
|
||||||
|
local M = ChatView
|
||||||
|
|
||||||
|
function ChatView.new(main_view)
|
||||||
|
UIPackage.AddPackage("base/chat/ui/Chat")
|
||||||
|
setmetatable(M, {__index = BaseWindow})
|
||||||
|
local self = setmetatable({}, {__index = M})
|
||||||
|
self.class = "ChatView"
|
||||||
|
self._main_view = main_view
|
||||||
|
self._blur_view = main_view._root_view
|
||||||
|
|
||||||
|
self:init("ui://Chat/Main")
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:init(url)
|
||||||
|
BaseWindow.init(self,url)
|
||||||
|
local lit_biaoqing1 = self._view:GetChild("lit_biaoqing1")
|
||||||
|
lit_biaoqing1.onClickItem:Set(function (context)
|
||||||
|
local _gamectr = ControllerManager.GetController(GameController)
|
||||||
|
_gamectr:SendInteraction(DataManager.SelfUser.account_id, 1, context.data.name )
|
||||||
|
self:Close()
|
||||||
|
end)
|
||||||
|
|
||||||
|
|
||||||
|
-- local lit_biaoqing2 = self._view:GetChild("lit_biaoqing2")
|
||||||
|
-- lit_biaoqing2.onClickItem:Set(function (context)
|
||||||
|
-- local _gamectr = ControllerManager.GetController(GameController)
|
||||||
|
-- _gamectr:SendInteraction(DataManager.SelfUser.account_id, 1, context.data.name )
|
||||||
|
-- self:Close()
|
||||||
|
-- end)
|
||||||
|
|
||||||
|
|
||||||
|
-- local lit_biaoqing3 = self._view:GetChild("lit_biaoqing3")
|
||||||
|
-- lit_biaoqing3.onClickItem:Set(function (context)
|
||||||
|
-- local _gamectr = ControllerManager.GetController(GameController)
|
||||||
|
-- _gamectr:SendInteraction(DataManager.SelfUser.account_id, 1, context.data.name )
|
||||||
|
-- self:Close()
|
||||||
|
-- end)
|
||||||
|
-- lit_biaoqing3:RemoveChildrenToPool()
|
||||||
|
|
||||||
|
self:FillChatMsg()
|
||||||
|
|
||||||
|
local tex_chat = self._view:GetChild("tex_chat")
|
||||||
|
local btn_send = self._view:GetChild("btn_send")
|
||||||
|
btn_send.onClick:Set(function( ... )
|
||||||
|
local chat_text = tex_chat.text
|
||||||
|
if string.utf8len(chat_text) >0 then
|
||||||
|
local _gamectr = ControllerManager.GetController(GameController)
|
||||||
|
_gamectr:SendInteraction(DataManager.SelfUser.account_id, 4,chat_text)
|
||||||
|
self:Close()
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:FillChatMsg()
|
||||||
|
local chat_msg
|
||||||
|
local language = self._main_view:GetLanguage()
|
||||||
|
if language == 1 then
|
||||||
|
chat_msg = self._main_view.Fix_Msg_Chat2
|
||||||
|
else
|
||||||
|
chat_msg = self._main_view.Fix_Msg_Chat
|
||||||
|
end
|
||||||
|
local lit_yuyin = self._view:GetChild("lit_yuyin")
|
||||||
|
lit_yuyin:RemoveChildrenToPool()
|
||||||
|
for i = 1 , #chat_msg do
|
||||||
|
local btn = lit_yuyin:AddItemFromPool()
|
||||||
|
btn.data = tostring(i)
|
||||||
|
btn.text = chat_msg[i]
|
||||||
|
btn.onClick:Set(function(context)
|
||||||
|
local g = context.sender
|
||||||
|
local _gamectr = ControllerManager.GetController(GameController)
|
||||||
|
local msg = g.data + language * 100
|
||||||
|
_gamectr:SendInteraction(DataManager.SelfUser.account_id, 2, msg)
|
||||||
|
self:Close()
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:HideInputField()
|
||||||
|
self._view:GetController("sdk").selectedIndex = 1
|
||||||
|
end
|
||||||
|
|
||||||
|
return M
|
||||||
|
|
@ -0,0 +1,79 @@
|
||||||
|
--view 基类
|
||||||
|
--author:--
|
||||||
|
|
||||||
|
|
||||||
|
---
|
||||||
|
--@type BaseView
|
||||||
|
BaseView = {
|
||||||
|
-- Id View ID
|
||||||
|
Id = 0,
|
||||||
|
-- View 是否被销毁
|
||||||
|
_is_destroy = false,
|
||||||
|
--关闭摧毁
|
||||||
|
_close_destroy = false,
|
||||||
|
-- 全屏
|
||||||
|
_full = false,
|
||||||
|
--全屏偏移
|
||||||
|
_full_offset = true,
|
||||||
|
--view description
|
||||||
|
_view = nil,
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
local M = BaseView
|
||||||
|
|
||||||
|
local view_url = {
|
||||||
|
"ui://Common/Gcm_BaseView",
|
||||||
|
"ui://Common/Gcm_BaseView_Full"
|
||||||
|
}
|
||||||
|
---
|
||||||
|
--@function [parent=#BaseView] InitView
|
||||||
|
--@param self
|
||||||
|
--@param #string url
|
||||||
|
function M:InitView(url)
|
||||||
|
self._root_view = UIPackage.CreateObjectFromURL(self._full and view_url[2] or view_url[1])
|
||||||
|
local contentPane = self._root_view:GetChild("contentPane")
|
||||||
|
self._view = UIPackage.CreateObjectFromURL(url)
|
||||||
|
printlog(self._view)
|
||||||
|
self._close_destroy = true
|
||||||
|
-- self._view.fairyBatching = true
|
||||||
|
self._view:AddRelation(contentPane, RelationType.Size)
|
||||||
|
contentPane:AddChild(self._view)
|
||||||
|
self._contentPane = contentPane
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:Show()
|
||||||
|
self._root_view.visible = true
|
||||||
|
if not self._root_view.parent then
|
||||||
|
AddPanel(self._root_view)
|
||||||
|
if self._full then
|
||||||
|
local offset = get_offset(self._full_offset)
|
||||||
|
|
||||||
|
self._contentPane.width = GRoot.inst.width - (offset * 2)
|
||||||
|
self._contentPane.height = GRoot.inst.height
|
||||||
|
self._contentPane.x = offset
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:Close()
|
||||||
|
self._root_view.visible = false
|
||||||
|
end
|
||||||
|
|
||||||
|
--游戏暂停
|
||||||
|
function M:OnApplicationPause()
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
--游戏暂停
|
||||||
|
function M:OnApplicationActive()
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
---
|
||||||
|
--@function [parent=#BaseView] Destroy
|
||||||
|
--@param self
|
||||||
|
function M:Destroy()
|
||||||
|
self._is_destroy = true
|
||||||
|
self._root_view:Dispose()
|
||||||
|
end
|
||||||
|
|
@ -0,0 +1,255 @@
|
||||||
|
--window 窗口基类
|
||||||
|
--author:--
|
||||||
|
|
||||||
|
BaseWindow = {
|
||||||
|
--view description
|
||||||
|
_view = nil,
|
||||||
|
|
||||||
|
--View 是否被销毁
|
||||||
|
_is_destroy = false,
|
||||||
|
--是否播放动画
|
||||||
|
_animation = true,
|
||||||
|
--弹出动画,0关闭,1左边,2右边
|
||||||
|
_anim_pop = 0,
|
||||||
|
--关闭摧毁
|
||||||
|
_close_destroy = false,
|
||||||
|
|
||||||
|
--点击窗口以外关闭
|
||||||
|
_close_zone = true,
|
||||||
|
|
||||||
|
--队列
|
||||||
|
_queue = true,
|
||||||
|
--全屏
|
||||||
|
_full = false,
|
||||||
|
--全屏偏移
|
||||||
|
_full_offset = true,
|
||||||
|
--新窗口隐藏队列
|
||||||
|
_new_hide = true,
|
||||||
|
--模糊组件对象
|
||||||
|
_put_map = true
|
||||||
|
}
|
||||||
|
|
||||||
|
--window 列表
|
||||||
|
local WindowMap = {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
local WindowQueue= {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
local M = BaseWindow
|
||||||
|
|
||||||
|
function BaseWindow.new(url,blur_view)
|
||||||
|
local self = setmetatable({}, {__index = M})
|
||||||
|
self.class = "BaseWindow"
|
||||||
|
-- self._blur_view = blur_view
|
||||||
|
self:init(url)
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
local win_url = {
|
||||||
|
"ui://Common/Gcm_Window",
|
||||||
|
"ui://Common/Gcm_Window_Full"
|
||||||
|
}
|
||||||
|
|
||||||
|
function M:init(url)
|
||||||
|
self._root_view = UIPackage.CreateObjectFromURL(self._full and win_url[2] or win_url[1])
|
||||||
|
local contentPane = self._root_view:GetChild("contentPane")
|
||||||
|
local ctr_hide_bg = self._root_view:GetController("hide_bg")
|
||||||
|
if self._anim_pop ~= 0 then
|
||||||
|
ctr_hide_bg.selectedIndex = 1
|
||||||
|
PopPanel = contentPane:GetChild("PopPanel")
|
||||||
|
else
|
||||||
|
ctr_hide_bg.selectedIndex = 0
|
||||||
|
end
|
||||||
|
printlog(url)
|
||||||
|
self._view = UIPackage.CreateObjectFromURL(url)
|
||||||
|
printlog(self._view)
|
||||||
|
-- self._view.fairyBatching = true
|
||||||
|
local btn_close = self._view:GetChild("btn_close")
|
||||||
|
if(btn_close) then
|
||||||
|
btn_close.onClick:Set(function()
|
||||||
|
self:CloseEvent()
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
local win_mode = self._root_view:GetChild("win_mode")
|
||||||
|
win_mode.onClick:Set(function()
|
||||||
|
if not self._close_zone then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
win_mode.touchable = false
|
||||||
|
self:CloseEvent()
|
||||||
|
end)
|
||||||
|
printlog("======================================",self._full)
|
||||||
|
if self._full then
|
||||||
|
local offset = get_offset(self._full_offset)
|
||||||
|
if self._anim_pop == 0 then
|
||||||
|
self._view:AddRelation(contentPane, RelationType.Size)
|
||||||
|
contentPane:AddChild(self._view)
|
||||||
|
else
|
||||||
|
contentPane:RemoveRelation(self._root_view, RelationType.Center_Center)
|
||||||
|
contentPane:AddRelation(self._root_view, RelationType.Middle_Middle)
|
||||||
|
PopPanel:AddChild(self._view)
|
||||||
|
local click_item = PopPanel:GetChild("click_item")
|
||||||
|
if self._anim_pop == 1 then
|
||||||
|
contentPane:AddRelation(self._root_view, RelationType.Left_Left)
|
||||||
|
self._view.x = 0
|
||||||
|
elseif self._anim_pop == 2 then
|
||||||
|
contentPane:AddRelation(self._root_view, RelationType.Right_Right)
|
||||||
|
self._view.x = GRoot.inst.width - self._view.width - offset
|
||||||
|
end
|
||||||
|
self._view.y = (PopPanel.height - self._view.height) * 0.5
|
||||||
|
click_item.xy = self._view.xy
|
||||||
|
click_item.width = self._view.width
|
||||||
|
click_item.height = self._view.height
|
||||||
|
end
|
||||||
|
else
|
||||||
|
contentPane:AddChild(self._view)
|
||||||
|
contentPane.height = self._view.height
|
||||||
|
contentPane.width = self._view.width
|
||||||
|
contentPane:Center()
|
||||||
|
end
|
||||||
|
self._contentPane = contentPane
|
||||||
|
if self._put_map then
|
||||||
|
WindowMap[#WindowMap + 1] = self
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- 显示窗口
|
||||||
|
function M:Show()
|
||||||
|
print("===========================================entershow",M.class)
|
||||||
|
local contentPane = self._root_view:GetChild("contentPane")
|
||||||
|
if self._anim_pop == 1 then
|
||||||
|
contentPane:GetTransition("left_pop"):Play()
|
||||||
|
elseif self._anim_pop == 2 then
|
||||||
|
contentPane:GetTransition("right_pop"):Play()
|
||||||
|
elseif self._animation then
|
||||||
|
local ani_in = self._root_view:GetTransition("in")
|
||||||
|
if ani_in then
|
||||||
|
ani_in:Play()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
-- if self._blur_view then
|
||||||
|
-- BlurView(self._blur_view,true)
|
||||||
|
-- end
|
||||||
|
|
||||||
|
-- 判断当前窗口是否已经在队列中,如果在就不重复添加
|
||||||
|
local _inQueue = false
|
||||||
|
|
||||||
|
if self._new_hide then
|
||||||
|
for i=1,#WindowQueue do
|
||||||
|
local win = WindowQueue[i]
|
||||||
|
if win == self then
|
||||||
|
_inQueue = true
|
||||||
|
end
|
||||||
|
if win._queue then
|
||||||
|
win._root_view:RemoveFromParent()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if self._queue and not _inQueue then
|
||||||
|
WindowQueue[#WindowQueue + 1] = self
|
||||||
|
end
|
||||||
|
AddPanel(self._root_view)
|
||||||
|
if self._full then
|
||||||
|
local offset = get_offset(self._full_offset)
|
||||||
|
self._contentPane.width = GRoot.inst.width - 2 * offset
|
||||||
|
self._contentPane.height = GRoot.inst.height
|
||||||
|
self._contentPane.x = offset
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- 关闭窗口
|
||||||
|
function M:Close()
|
||||||
|
-- if self._blur_view then
|
||||||
|
-- BlurView(self._blur_view,false)
|
||||||
|
-- end
|
||||||
|
if self._queue then
|
||||||
|
for i,v in ipairs(WindowQueue) do
|
||||||
|
if v == self then
|
||||||
|
table.remove(WindowQueue,i)
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if self._new_hide then
|
||||||
|
local win = WindowQueue[#WindowQueue]
|
||||||
|
if win and win._queue then
|
||||||
|
AddPanel(win._root_view)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
self._root_view:RemoveFromParent()
|
||||||
|
end
|
||||||
|
|
||||||
|
local _destroy_all = false
|
||||||
|
-- 销毁窗口
|
||||||
|
function M:Destroy()
|
||||||
|
if self._is_destroy then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
if not _destroy_all then
|
||||||
|
self:Close()
|
||||||
|
if self._put_map then
|
||||||
|
for i,v in ipairs(WindowMap) do
|
||||||
|
if v == self then
|
||||||
|
table.remove(WindowMap,i)
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
self._is_destroy = true
|
||||||
|
self._root_view:Dispose()
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:CloseEvent()
|
||||||
|
local win_mode = self._root_view:GetChild("win_mode")
|
||||||
|
if self._anim_pop == 0 then
|
||||||
|
if self._close_destroy then
|
||||||
|
self:Destroy()
|
||||||
|
else
|
||||||
|
self:Close()
|
||||||
|
win_mode.touchable = true
|
||||||
|
end
|
||||||
|
else
|
||||||
|
self:ActionWithAnim(function()
|
||||||
|
if self._close_destroy then
|
||||||
|
self:Destroy()
|
||||||
|
else
|
||||||
|
self:Close()
|
||||||
|
win_mode.touchable = true
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:ActionWithAnim(callback)
|
||||||
|
local contentPane = self._root_view:GetChild("contentPane")
|
||||||
|
if self._anim_pop == 1 then
|
||||||
|
contentPane:GetTransition("left_pop_back"):Play()
|
||||||
|
elseif self._anim_pop == 2 then
|
||||||
|
contentPane:GetTransition("right_pop_back"):Play()
|
||||||
|
end
|
||||||
|
if callback then
|
||||||
|
coroutine.start(function()
|
||||||
|
coroutine.wait(0.3)
|
||||||
|
callback()
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function BaseWindow.DestroyAll()
|
||||||
|
_destroy_all = true
|
||||||
|
local list = WindowMap
|
||||||
|
for i=1,#list do
|
||||||
|
local win = list[i]
|
||||||
|
win:Destroy()
|
||||||
|
end
|
||||||
|
_destroy_all = false
|
||||||
|
WindowQueue = {}
|
||||||
|
WindowMap = {}
|
||||||
|
end
|
||||||
|
|
@ -0,0 +1,85 @@
|
||||||
|
ImageLoad = {}
|
||||||
|
|
||||||
|
local imgAssetMap = {}
|
||||||
|
local imgQueue = Queue.new(2000)
|
||||||
|
|
||||||
|
local function DownLoadImg(url)
|
||||||
|
local www = UnityEngine.WWW(url)
|
||||||
|
coroutine.www(www)
|
||||||
|
if string.utf8len(www.error) == 0 then
|
||||||
|
local obj = imgAssetMap[url]
|
||||||
|
if obj and not obj.load then
|
||||||
|
local texture = www.texture
|
||||||
|
www:Dispose()
|
||||||
|
if (texture ~= null) then
|
||||||
|
local ntexture = FairyGUI.NTexture(texture)
|
||||||
|
obj.ntexture = ntexture
|
||||||
|
obj.load = true
|
||||||
|
obj.co = nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local function SetTexture()
|
||||||
|
if (imgQueue:Count() > 0) then
|
||||||
|
local tem = imgQueue:Dequeue()
|
||||||
|
local obj = imgAssetMap[tem.url]
|
||||||
|
if not tem._iconObject.isDisposed and obj then
|
||||||
|
if obj.load then
|
||||||
|
tem._iconObject.texture = obj.ntexture
|
||||||
|
if tem.callback then
|
||||||
|
tem.callback()
|
||||||
|
end
|
||||||
|
else
|
||||||
|
imgQueue:Enqueue(tem)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
UpdateBeat:Add(SetTexture)
|
||||||
|
|
||||||
|
-- group 图片分组
|
||||||
|
function ImageLoad.Load(url,_iconObject,group,callback)
|
||||||
|
if string.utf8len(url) == 0 then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
if not group then
|
||||||
|
group = "common"
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
local asset = imgAssetMap[url]
|
||||||
|
|
||||||
|
if (asset ~= nil) then
|
||||||
|
if asset.load then
|
||||||
|
_iconObject.texture = asset.ntexture
|
||||||
|
if callback then callback() end
|
||||||
|
else
|
||||||
|
imgQueue:Enqueue({url = url,_iconObject = _iconObject,callback = callback})
|
||||||
|
end
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local _co = coroutine.start(DownLoadImg,url)
|
||||||
|
-- local _co_load = coroutine.start(SetTexture,_iconObject,url,callback)
|
||||||
|
imgAssetMap[url] = {group = group,load=false,co = _co}
|
||||||
|
imgQueue:Enqueue({url = url,_iconObject = _iconObject,callback = callback})
|
||||||
|
end
|
||||||
|
|
||||||
|
function ImageLoad.Clear(group)
|
||||||
|
for i,v in pairs(imgAssetMap) do
|
||||||
|
if v.group == group then
|
||||||
|
if v.co then
|
||||||
|
coroutine.stop(v.co)
|
||||||
|
end
|
||||||
|
-- if v.co_load then
|
||||||
|
-- coroutine.stop(v.co_load)
|
||||||
|
-- end
|
||||||
|
if v.load then
|
||||||
|
imgAssetMap[i].ntexture:Unload(true)
|
||||||
|
end
|
||||||
|
imgAssetMap[i] = nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
@ -0,0 +1,53 @@
|
||||||
|
|
||||||
|
ModalWaitingWindow = {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
local M = ModalWaitingWindow
|
||||||
|
|
||||||
|
local modal_wait_win_url = "ui://Common/GlobalModalWaiting"
|
||||||
|
local modal_panel = nil
|
||||||
|
function ModalWaitingWindow.new()
|
||||||
|
local self = setmetatable({}, {__index = M})
|
||||||
|
self.class = "ModalWaitingWindow"
|
||||||
|
self._view = UIPackage.CreateObjectFromURL(modal_wait_win_url)
|
||||||
|
self.txt_title = self._view:GetChild("title")
|
||||||
|
if not modal_panel then
|
||||||
|
modal_panel = UIPackage.CreateObjectFromURL("ui://Common/UIPanel")
|
||||||
|
modal_panel.name = "GlobalModalWaiting_Win"
|
||||||
|
modal_panel:MakeFullScreen()
|
||||||
|
modal_panel:AddRelation(GRoot.inst, RelationType.Size)
|
||||||
|
end
|
||||||
|
modal_panel:AddChild(self._view)
|
||||||
|
self._view:Center()
|
||||||
|
GRoot.inst:AddChild(modal_panel)
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:Show()
|
||||||
|
modal_panel.visible = true
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:Close()
|
||||||
|
modal_panel.visible = false
|
||||||
|
end
|
||||||
|
|
||||||
|
local _inst = nil
|
||||||
|
local _msg = "正在获取数据..."
|
||||||
|
function ModalWaitingWindow.ShowModal(title)
|
||||||
|
if (_inst == nil) then
|
||||||
|
_inst = ModalWaitingWindow.new()
|
||||||
|
end
|
||||||
|
if title then
|
||||||
|
_inst.txt_title.text = title
|
||||||
|
else
|
||||||
|
_inst.txt_title.text = _msg
|
||||||
|
end
|
||||||
|
_inst:Show()
|
||||||
|
end
|
||||||
|
|
||||||
|
function ModalWaitingWindow.CloseModal()
|
||||||
|
if(_inst) then
|
||||||
|
_inst:Close()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
@ -0,0 +1,71 @@
|
||||||
|
--通用消息弹出框View
|
||||||
|
--author:--
|
||||||
|
|
||||||
|
MsgWindow = {}
|
||||||
|
|
||||||
|
MsgWindow.MsgMode = {
|
||||||
|
OkAndCancel = 1,
|
||||||
|
OnlyOk = 2
|
||||||
|
}
|
||||||
|
MsgWindow.RES_LIST = {
|
||||||
|
"MessageBox",
|
||||||
|
"MessageBox1"
|
||||||
|
}
|
||||||
|
|
||||||
|
local M = MsgWindow
|
||||||
|
|
||||||
|
|
||||||
|
function MsgWindow.new(blur_view,tip,mode,url,showCheck)
|
||||||
|
setmetatable(M, {__index = BaseWindow})
|
||||||
|
local self = setmetatable({}, {__index = M})
|
||||||
|
self.class = "MsgWindow"
|
||||||
|
self._blur_view = blur_view
|
||||||
|
self._close_destroy = true
|
||||||
|
self._tip = tip
|
||||||
|
self._mode = mode
|
||||||
|
self.onOk = event("onOk",true)
|
||||||
|
self.onCancel = event("onCancel",true)
|
||||||
|
self.showCheck = showCheck
|
||||||
|
local self_url = url and url or "ui://Common/"..MsgWindow.RES_LIST[self._mode]
|
||||||
|
self:init(self_url)
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:init(url)
|
||||||
|
BaseWindow.init(self,url)
|
||||||
|
self._close_destroy = true
|
||||||
|
self._close_zone = false
|
||||||
|
local view = self._view
|
||||||
|
local btn_ok = view:GetChild("btn_ok")
|
||||||
|
btn_ok.onClick:Add(function()
|
||||||
|
self.onOk()
|
||||||
|
self:Destroy()
|
||||||
|
end)
|
||||||
|
local tex_message = view:GetChild("tex_message")
|
||||||
|
if (self._tip) then tex_message.text = self._tip end
|
||||||
|
|
||||||
|
local btn_close = view:GetChild('btn_close1')
|
||||||
|
if (btn_close~=nil) then
|
||||||
|
btn_close.onClick:Add(
|
||||||
|
function()
|
||||||
|
self:CloseEvent()
|
||||||
|
end
|
||||||
|
|
||||||
|
)
|
||||||
|
end
|
||||||
|
self.btnCheck = view:GetChild("btnCheck")
|
||||||
|
if self.btnCheck then
|
||||||
|
self.btnCheck.visible = false
|
||||||
|
if self.showCheck then
|
||||||
|
self.btnCheck.selected = true
|
||||||
|
self.btnCheck.visible = true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:Close()
|
||||||
|
BaseWindow.Close(self)
|
||||||
|
if(self._mode == MsgWindow.MsgMode.OkAndCancel) then
|
||||||
|
self.onCancel()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
@ -0,0 +1,49 @@
|
||||||
|
--通用消息弹出框View
|
||||||
|
--author:--
|
||||||
|
|
||||||
|
NetResetConnectWindow = {}
|
||||||
|
|
||||||
|
|
||||||
|
local modal_wait_win_url = "ui://Common/GlobalModalWaiting"
|
||||||
|
local modal_panel = nil
|
||||||
|
function NetResetConnectWindow.new()
|
||||||
|
local self = setmetatable({}, {__index = NetResetConnectWindow})
|
||||||
|
self.class = "NetResetConnectWindow"
|
||||||
|
self._view = UIPackage.CreateObjectFromURL(modal_wait_win_url)
|
||||||
|
self._view:GetChild("title").text = "网络信号太差,正在检查网络中..."
|
||||||
|
if not modal_panel then
|
||||||
|
modal_panel = UIPackage.CreateObjectFromURL("ui://Common/UIPanel")
|
||||||
|
modal_panel.name = "NetResetConnectWindow_Win"
|
||||||
|
modal_panel:MakeFullScreen()
|
||||||
|
modal_panel:AddRelation(GRoot.inst, RelationType.Size)
|
||||||
|
end
|
||||||
|
-- self._circleLoader = CircleLoader.new(self._view:GetChild("gcm_qiu"))
|
||||||
|
-- self._circleLoader:start()
|
||||||
|
modal_panel:AddChild(self._view)
|
||||||
|
self._view:Center()
|
||||||
|
GRoot.inst:AddChild(modal_panel)
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
function NetResetConnectWindow:Show()
|
||||||
|
modal_panel.visible = true
|
||||||
|
end
|
||||||
|
|
||||||
|
function NetResetConnectWindow:Close()
|
||||||
|
modal_panel.visible = false
|
||||||
|
end
|
||||||
|
|
||||||
|
local _inst = nil
|
||||||
|
|
||||||
|
function NetResetConnectWindow.ShowNetReset()
|
||||||
|
if (_inst == nil) then
|
||||||
|
_inst = NetResetConnectWindow.new()
|
||||||
|
end
|
||||||
|
_inst:Show()
|
||||||
|
end
|
||||||
|
|
||||||
|
function NetResetConnectWindow.CloseNetReset()
|
||||||
|
if(_inst) then
|
||||||
|
_inst:Close()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
@ -0,0 +1,88 @@
|
||||||
|
local DismissRoomWindow = {}
|
||||||
|
|
||||||
|
local M = DismissRoomWindow
|
||||||
|
|
||||||
|
|
||||||
|
function DismissRoomWindow.new(blur_view)
|
||||||
|
setmetatable(M, {__index = BaseWindow})
|
||||||
|
local self = setmetatable({}, {__index = M})
|
||||||
|
self.class = "DismissRoomWindow"
|
||||||
|
self._currenIndex = 0
|
||||||
|
self._blur_view = blur_view
|
||||||
|
self._animation = false
|
||||||
|
self.onCallback = event("onCallback",true)
|
||||||
|
self._close_zone = false
|
||||||
|
self.time = 180
|
||||||
|
self:init("ui://Common/dismiss_room")
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function M:init(url)
|
||||||
|
BaseWindow.init(self,url)
|
||||||
|
local view = self._view
|
||||||
|
self.tex_time = view:GetChild("tex_time")
|
||||||
|
local _btn_aggree = view:GetChild("btn_aggree")
|
||||||
|
|
||||||
|
|
||||||
|
_btn_aggree.onClick:Add(function()
|
||||||
|
local _gamectr = ControllerManager.GetController(GameController)
|
||||||
|
if _gamectr then
|
||||||
|
_gamectr:DismissRoomVote(true)
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
|
local _btn_reject = view:GetChild("btn_reject")
|
||||||
|
_btn_reject.onClick:Add(function()
|
||||||
|
local _gamectr = ControllerManager.GetController(GameController)
|
||||||
|
if _gamectr then
|
||||||
|
_gamectr:DismissRoomVote(false)
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:FillData(data)
|
||||||
|
self.time = data.time
|
||||||
|
self.tex_time.text = data.time
|
||||||
|
local room = DataManager.CurrenRoom
|
||||||
|
local isHidden = false
|
||||||
|
if room.room_config and room.room_config.isHidden and room.room_config.isHidden == 1 then
|
||||||
|
isHidden = true
|
||||||
|
end
|
||||||
|
if isHidden then
|
||||||
|
self._view:GetChild("tex_tip").text = string.format("[color=#ff9d02]【%s】[/color]发起了解散房间申请,是否同意?","玩家" .. data.req_p.seat)
|
||||||
|
else
|
||||||
|
self._view:GetChild("tex_tip").text = string.format("[color=#ff9d02]【%s】[/color]发起了解散房间申请,是否同意?",data.req_p.self_user.nick_name)
|
||||||
|
end
|
||||||
|
local ctr_falg = self._view:GetController("falg")
|
||||||
|
local lst_player = self._view:GetChild("lst_player")
|
||||||
|
lst_player:RemoveChildrenToPool()
|
||||||
|
local list = data.list
|
||||||
|
for i=1,#list do
|
||||||
|
local tem = list[i]
|
||||||
|
if tem.player == DataManager.CurrenRoom.self_player then
|
||||||
|
ctr_falg.selectedIndex = tem.result
|
||||||
|
end
|
||||||
|
-- elseif tem.player ~= data.req_p then
|
||||||
|
local item = lst_player:AddItemFromPool()
|
||||||
|
if isHidden then
|
||||||
|
item:GetChild("tex_name").text = "玩家"..tem.player.seat
|
||||||
|
else
|
||||||
|
item:GetChild("tex_name").text = tem.player.self_user.nick_name
|
||||||
|
end
|
||||||
|
local ctr_item_falg = item:GetController("falg")
|
||||||
|
ctr_item_falg.selectedIndex = tem.result
|
||||||
|
-- end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:OnUpdate(deltaTime)
|
||||||
|
if self.time > 0 then
|
||||||
|
self.time = self.time - deltaTime
|
||||||
|
self.time = math.max(0, self.time)
|
||||||
|
end
|
||||||
|
self.tex_time.text = tostring(math.floor(self.time))
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
return M
|
||||||
|
|
@ -0,0 +1,131 @@
|
||||||
|
-- 牌友圈助手邀请界面
|
||||||
|
local FGAssistInviteView = {}
|
||||||
|
|
||||||
|
local M = FGAssistInviteView
|
||||||
|
setmetatable(M, {__index = BaseWindow})
|
||||||
|
|
||||||
|
function FGAssistInviteView.new(blur_view, callback)
|
||||||
|
local self = setmetatable({}, {__index = M})
|
||||||
|
self.class = "FGAssistInviteView"
|
||||||
|
self._blur_view = blur_view
|
||||||
|
self._animation = true
|
||||||
|
self._new_hide = false
|
||||||
|
self._put_map = false
|
||||||
|
self._close_destroy = true
|
||||||
|
self.callback = callback
|
||||||
|
self:initView("ui://FGAssist/panel_invite")
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:initView(url)
|
||||||
|
self:init(url)
|
||||||
|
self.lst_player = self._view:GetChild("lst_player")
|
||||||
|
local btn_refresh = self._view:GetChild("btn_refresh")
|
||||||
|
btn_refresh.onClick:Set(function()
|
||||||
|
self.lst_player:RemoveChildrenToPool()
|
||||||
|
self:FillData()
|
||||||
|
end)
|
||||||
|
|
||||||
|
self._timer = 0
|
||||||
|
self:FillData()
|
||||||
|
UpdateBeat:Add(self.OnUpdate,self)
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:FillData()
|
||||||
|
local mgr_ctr = ControllerManager.GetController(GroupMgrController)
|
||||||
|
if not mgr_ctr._mgr_client then
|
||||||
|
return
|
||||||
|
else
|
||||||
|
self:GetOnlinePlayers()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:GetOnlinePlayers()
|
||||||
|
local mgr_ctr = ControllerManager.GetController(GroupMgrController)
|
||||||
|
mgr_ctr:FG_GetOnlinePlayers(function(res)
|
||||||
|
if res.ReturnCode ~= 0 then
|
||||||
|
ViewUtil.ErrorTip(res.ReturnCode, "获取在线成员失败")
|
||||||
|
else
|
||||||
|
self.players = res.Data.onlines
|
||||||
|
self._view:GetController("empty").selectedIndex = #self.players == 0 and 1 or 0
|
||||||
|
self:ShowOnlinePlayers()
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
local function _showLeftTime(item, time)
|
||||||
|
item:GetChild("tex_left_time").text = time .. "s"
|
||||||
|
end
|
||||||
|
|
||||||
|
local _list_invite_time = {}
|
||||||
|
function M:ShowOnlinePlayers()
|
||||||
|
local players = self.players
|
||||||
|
for i = 1, #players do
|
||||||
|
if self.lst_player.isDisposed then return end
|
||||||
|
local item = self.lst_player:AddItemFromPool()
|
||||||
|
local p = players[i]
|
||||||
|
item:GetChild("tex_name").text = p.nick
|
||||||
|
item:GetChild("tex_id").text = "ID:" .. ViewUtil.HideID(p.uid)
|
||||||
|
local btn_head = item:GetChild("btn_head")
|
||||||
|
ImageLoad.Load(p.portrait, btn_head._iconObject)
|
||||||
|
local ctr_enable = item:GetController("enable")
|
||||||
|
ctr_enable.selectedIndex = 0
|
||||||
|
item:GetChild("btn_invite").onClick:Set(function()
|
||||||
|
local mgr_ctr = ControllerManager.GetController(GroupMgrController)
|
||||||
|
local room = DataManager.CurrenRoom
|
||||||
|
mgr_ctr:FG_InvitePlayer(p.uid, room.room_id, room.play_id, room.room_config:GetGameName(), function()
|
||||||
|
end)
|
||||||
|
|
||||||
|
local time = os.time()
|
||||||
|
_list_invite_time[p.uid] = time
|
||||||
|
ctr_enable.selectedIndex = 1
|
||||||
|
_showLeftTime(item, 15)
|
||||||
|
end)
|
||||||
|
local invite_time = _list_invite_time[p.uid]
|
||||||
|
if invite_time then
|
||||||
|
local i_timer = os.time() - invite_time
|
||||||
|
if i_timer < 15 then
|
||||||
|
ctr_enable.selectedIndex = 1
|
||||||
|
_showLeftTime(item, 15 - i_timer)
|
||||||
|
else
|
||||||
|
_list_invite_time[p.uid] = nil
|
||||||
|
ctr_enable.selectedIndex = 0
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:OnUpdate()
|
||||||
|
local deltaTime = Time.deltaTime
|
||||||
|
self._timer = self._timer + deltaTime
|
||||||
|
if self._timer >= 1 then
|
||||||
|
self._timer = 0
|
||||||
|
|
||||||
|
if self.lst_player.numChildren == 0 then return end
|
||||||
|
for i = 1, #self.players do
|
||||||
|
local p = self.players[i]
|
||||||
|
local invite_time = _list_invite_time[p.uid]
|
||||||
|
if invite_time then
|
||||||
|
local i_timer = os.time() - invite_time
|
||||||
|
local item = self.lst_player:GetChildAt(i - 1)
|
||||||
|
if not item then break end
|
||||||
|
if i_timer < 15 then
|
||||||
|
_showLeftTime(item, 15 - i_timer)
|
||||||
|
else
|
||||||
|
item:GetController("enable").selectedIndex = 0
|
||||||
|
_list_invite_time[p.uid] = nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:Destroy()
|
||||||
|
UpdateBeat:Remove(self.OnUpdate, self)
|
||||||
|
BaseWindow.Destroy(self)
|
||||||
|
if self.callback then
|
||||||
|
self.callback()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return M
|
||||||
|
|
@ -0,0 +1,153 @@
|
||||||
|
-- 牌友圈助手界面
|
||||||
|
local FGAssistInviteView = import(".FGAssistInviteView")
|
||||||
|
|
||||||
|
local FGAssistView = {}
|
||||||
|
|
||||||
|
local M = FGAssistView
|
||||||
|
setmetatable(M, {__index = BaseWindow})
|
||||||
|
|
||||||
|
function FGAssistView.new(blur_view, callback)
|
||||||
|
|
||||||
|
local self = setmetatable({}, {__index = M})
|
||||||
|
self.class = "FGAssistView"
|
||||||
|
self._blur_view = blur_view
|
||||||
|
self._full = true
|
||||||
|
self._anim_pop = 1
|
||||||
|
self._animation = true
|
||||||
|
|
||||||
|
self.callback = callback
|
||||||
|
self:init("ui://FGAssist/panel_assist")
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:ReloadView()
|
||||||
|
self._view:GetChild("btn_auto_invite").onClick:Clear()
|
||||||
|
self.lst_player:RemoveChildrenToPool()
|
||||||
|
self:FillData()
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:init(url)
|
||||||
|
BaseWindow.init(self, url)
|
||||||
|
self.lst_player = self._view:GetChild("lst_player")
|
||||||
|
local btn_refresh = self._view:GetChild("btn_refresh")
|
||||||
|
btn_refresh.onClick:Set(function()
|
||||||
|
self:ReloadView()
|
||||||
|
end)
|
||||||
|
|
||||||
|
self._timer = 0
|
||||||
|
UpdateBeat:Add(self.OnUpdate,self)
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:FillData()
|
||||||
|
local mgr_ctr = ControllerManager.GetController(GroupMgrController)
|
||||||
|
if not mgr_ctr._mgr_client then
|
||||||
|
return
|
||||||
|
else
|
||||||
|
self:GetOnlinePlayers()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:GetOnlinePlayers()
|
||||||
|
local mgr_ctr = ControllerManager.GetController(GroupMgrController)
|
||||||
|
mgr_ctr:FG_GetOnlinePlayers(function(res)
|
||||||
|
if res.ReturnCode ~= 0 then
|
||||||
|
ViewUtil.ErrorTip(res.ReturnCode, "获取在线成员失败")
|
||||||
|
else
|
||||||
|
self.players = res.Data.onlines
|
||||||
|
-- self._view:GetController("empty").selectedIndex = #self.players == 0 and 1 or 0
|
||||||
|
self:ShowOnlinePlayers()
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
local function _showLeftTime(item, time)
|
||||||
|
item:GetChild("tex_left_time").text = time .. "s"
|
||||||
|
end
|
||||||
|
|
||||||
|
local _list_invite_time = {}
|
||||||
|
function M:ShowOnlinePlayers()
|
||||||
|
local players = self.players
|
||||||
|
for i = 1, #players do
|
||||||
|
if self.lst_player.isDisposed then return end
|
||||||
|
local item = self.lst_player:AddItemFromPool()
|
||||||
|
local p = players[i]
|
||||||
|
item:GetChild("tex_name").text = p.nick
|
||||||
|
item:GetChild("tex_id").text = "ID:" .. ViewUtil.HideID(p.uid)
|
||||||
|
local btn_head = item:GetChild("btn_head")
|
||||||
|
ImageLoad.Load(p.portrait, btn_head._iconObject)
|
||||||
|
local ctr_enable = item:GetController("enable")
|
||||||
|
ctr_enable.selectedIndex = 0
|
||||||
|
item:GetChild("btn_invite").onClick:Set(function()
|
||||||
|
local mgr_ctr = ControllerManager.GetController(GroupMgrController)
|
||||||
|
local room = DataManager.CurrenRoom
|
||||||
|
mgr_ctr:FG_InvitePlayer(p.uid, room.room_id, room.play_id, room.room_config:GetGameName(), function()
|
||||||
|
end)
|
||||||
|
|
||||||
|
local time = os.time()
|
||||||
|
_list_invite_time[p.uid] = time
|
||||||
|
ctr_enable.selectedIndex = 1
|
||||||
|
_showLeftTime(item, 15)
|
||||||
|
end)
|
||||||
|
local invite_time = _list_invite_time[p.uid]
|
||||||
|
if invite_time then
|
||||||
|
local i_timer = os.time() - invite_time
|
||||||
|
if i_timer < 15 then
|
||||||
|
ctr_enable.selectedIndex = 1
|
||||||
|
_showLeftTime(item, 15 - i_timer)
|
||||||
|
else
|
||||||
|
_list_invite_time[p.uid] = nil
|
||||||
|
ctr_enable.selectedIndex = 0
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
local btn_auto_invite = self._view:GetChild("btn_auto_invite")
|
||||||
|
btn_auto_invite.onClick:Set(function()
|
||||||
|
local mgr_ctr = ControllerManager.GetController(GroupMgrController)
|
||||||
|
local room = DataManager.CurrenRoom
|
||||||
|
for i = 1, #players do
|
||||||
|
local p = players[i]
|
||||||
|
mgr_ctr:FG_InvitePlayer(p.uid, room.room_id, room.play_id, room.room_config:GetGameName(), function()
|
||||||
|
end)
|
||||||
|
|
||||||
|
local time = os.time()
|
||||||
|
_list_invite_time[p.uid] = time
|
||||||
|
item = self.lst_player:GetChildAt(i - 1)
|
||||||
|
item:GetController("enable").selectedIndex = 1
|
||||||
|
_showLeftTime(item, 15)
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:OnUpdate()
|
||||||
|
local deltaTime = Time.deltaTime
|
||||||
|
self._timer = self._timer + deltaTime
|
||||||
|
if self._timer >= 1 then
|
||||||
|
self._timer = 0
|
||||||
|
|
||||||
|
if self.lst_player.numChildren == 0 then return end
|
||||||
|
for i = 1, #self.players do
|
||||||
|
local p = self.players[i]
|
||||||
|
local invite_time = _list_invite_time[p.uid]
|
||||||
|
if invite_time then
|
||||||
|
local i_timer = os.time() - invite_time
|
||||||
|
local item = self.lst_player:GetChildAt(i - 1)
|
||||||
|
if not item then break end
|
||||||
|
if i_timer < 15 then
|
||||||
|
_showLeftTime(item, 15 - i_timer)
|
||||||
|
else
|
||||||
|
item:GetController("enable").selectedIndex = 0
|
||||||
|
_list_invite_time[p.uid] = nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:Close()
|
||||||
|
BaseWindow.Close(self)
|
||||||
|
if self.callback then
|
||||||
|
self.callback()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return M
|
||||||
|
|
@ -0,0 +1,120 @@
|
||||||
|
--设置窗口对象
|
||||||
|
|
||||||
|
local CreatePlayView = {}
|
||||||
|
|
||||||
|
local M = CreatePlayView
|
||||||
|
setmetatable(M, { __index = BaseWindow })
|
||||||
|
|
||||||
|
local PlayInfo = {
|
||||||
|
{
|
||||||
|
gameName = "麻将",
|
||||||
|
playListInfo = {
|
||||||
|
|
||||||
|
},
|
||||||
|
playList = {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function CreatePlayView.new()
|
||||||
|
UIPackage.AddPackage("base/Family/ui/Family")
|
||||||
|
|
||||||
|
local self = setmetatable({}, { __index = M })
|
||||||
|
self.class = 'CreatePlayView'
|
||||||
|
self._close_destroy = true
|
||||||
|
self:initePlayInfo()
|
||||||
|
self:init('ui://Family/CreatePlay')
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:init(url)
|
||||||
|
BaseWindow.init(self, url)
|
||||||
|
|
||||||
|
local view = self._view
|
||||||
|
-----设置游戏类型------------
|
||||||
|
self.gameNameCtl = view:GetController('gameName')
|
||||||
|
local list_gameName = view:GetChild('list_gameName')
|
||||||
|
list_gameName:SetVirtual()
|
||||||
|
list_gameName.itemRenderer = function(index, obj)
|
||||||
|
obj:GetChild('title').text = PlayInfo[index + 1].gameName
|
||||||
|
end
|
||||||
|
-- list_gameName.onClickItem:Add()
|
||||||
|
list_gameName.numItems = #PlayInfo
|
||||||
|
list_gameName:GetChildAt(0):GetController('button').selectedIndex = 1
|
||||||
|
-----------设置游戏名称-------------------
|
||||||
|
self.playNameCtr = view:GetController('playName')
|
||||||
|
local list_playName = view:GetChild('list_playName')
|
||||||
|
list_playName:SetVirtual()
|
||||||
|
list_playName.itemRenderer = function(index, obj)
|
||||||
|
obj:GetChild('title').text = PlayInfo[1].playList[index + 1].playName
|
||||||
|
end
|
||||||
|
list_playName.onClickItem:Add(function()
|
||||||
|
self.showView.visible = false
|
||||||
|
local index = PlayInfo[1].playList[self.playNameCtr.selectedIndex + 1].playeId
|
||||||
|
local playDetail = view:GetChild(string.format("Label_Detail_%d",index))
|
||||||
|
local playView
|
||||||
|
if not playDetail then
|
||||||
|
playDetail = UIPackage.CreateObjectFromURL(string.format("ui//Family/Label_Detail_%d",index))
|
||||||
|
if playDetail then
|
||||||
|
playView = view:AddChild(playDetail)
|
||||||
|
playView.name = string.format("Label_Detail_%d",index)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if not playDetail then
|
||||||
|
view:GetChild('buttom').visible = false
|
||||||
|
else
|
||||||
|
view:GetChild('buttom').visible = true
|
||||||
|
self.showView = playView and playView or playDetail
|
||||||
|
self.showView.visible = true
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
list_playName.numItems = #PlayInfo[1].playList
|
||||||
|
list_playName:GetChildAt(0):GetController('button').selectedIndex = 1
|
||||||
|
self.showView = view:GetChild(string.format("Label_Detail_%d",
|
||||||
|
PlayInfo[1].playList[self.playNameCtr.selectedIndex + 1].playeId))
|
||||||
|
-----------创建玩法----------
|
||||||
|
view:GetChild('btn_Create').onClick:Add(function()
|
||||||
|
self:CreatePlay()
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:CreatePlay()
|
||||||
|
ViewUtil.ShowModalWait(self._root_view,"正在创建房间...")
|
||||||
|
local loddyCtr = ControllerManager.GetController(LoddyController)
|
||||||
|
local gameId = PlayInfo[1].playList[self.playNameCtr.selectedIndex+1].playeId
|
||||||
|
local config = ExtendManager.GetExtendConfig(gameId)
|
||||||
|
print("==============================config")
|
||||||
|
pt(config)
|
||||||
|
local mode = config:GetGameInfo()
|
||||||
|
print("==============================mode")
|
||||||
|
pt(mode)
|
||||||
|
local _data = mode:SelectedConfigData()
|
||||||
|
print("==============================_data")
|
||||||
|
pt(_data)
|
||||||
|
-- loddyCtr:CreateRoom(gameId,_data, function (res)
|
||||||
|
-- self:__OnCreateRoomAction(res)
|
||||||
|
-- end)
|
||||||
|
ViewUtil.CloseModalWait()
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:initePlayInfo()
|
||||||
|
--------测试
|
||||||
|
PlayInfo[1].playListInfo[10] = {
|
||||||
|
playeId = 10,
|
||||||
|
playName = "长沙麻将"
|
||||||
|
}
|
||||||
|
PlayInfo[1].playListInfo[86] = {
|
||||||
|
playeId = 86,
|
||||||
|
playName = "南城麻将"
|
||||||
|
}
|
||||||
|
local games = DataManager.SelfUser.games
|
||||||
|
for i = 1, #games do
|
||||||
|
if PlayInfo[1].playListInfo[games[i].game_id] then
|
||||||
|
table.insert(PlayInfo[1].playList,PlayInfo[1].playListInfo[games[i].game_id])
|
||||||
|
end
|
||||||
|
end
|
||||||
|
pt(PlayInfo)
|
||||||
|
end
|
||||||
|
|
||||||
|
return M
|
||||||
|
|
@ -0,0 +1,28 @@
|
||||||
|
--设置窗口对象
|
||||||
|
|
||||||
|
local FamilyInviteFamilyView = {}
|
||||||
|
|
||||||
|
local M = FamilyInviteFamilyView
|
||||||
|
setmetatable(M, { __index = BaseWindow })
|
||||||
|
|
||||||
|
function FamilyInviteFamilyView.new()
|
||||||
|
local self = setmetatable({}, { __index = M })
|
||||||
|
self.class = 'FamilyInviteFamilyView'
|
||||||
|
self._close_destroy = true
|
||||||
|
self:init('ui://Family/InviteFamily')
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:init(url)
|
||||||
|
BaseWindow.init(self, url)
|
||||||
|
|
||||||
|
local view = self._view
|
||||||
|
view:GetChild('btn_wx').onClick:Add(function()
|
||||||
|
ViewUtil.ShowBannerOnScreenCenter("该功能还会开放,敬请期待")
|
||||||
|
end)
|
||||||
|
view:GetChild('btn_moments').onClick:Add(function()
|
||||||
|
ViewUtil.ShowBannerOnScreenCenter("该功能还会开放,敬请期待")
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
return M
|
||||||
|
|
@ -0,0 +1,555 @@
|
||||||
|
local FamilyInviteFamilyView = import('.Family.FamilyInviteFamilyView')
|
||||||
|
local CreatePlayView = import('.Family.CreatePlayView')
|
||||||
|
local GroupMngGameListView = import(".NewGroup.MngView/GroupMngGameListView")
|
||||||
|
|
||||||
|
--设置窗口对象
|
||||||
|
|
||||||
|
FamilyView = {}
|
||||||
|
|
||||||
|
local M = FamilyView
|
||||||
|
function FamilyView.new()
|
||||||
|
UIPackage.AddPackage("base/Family/ui/Family")
|
||||||
|
|
||||||
|
setmetatable(M, { __index = BaseView })
|
||||||
|
local self = setmetatable({}, { __index = M })
|
||||||
|
self.class = 'FamilyMainView'
|
||||||
|
self._full = true
|
||||||
|
self._close_destroy = false
|
||||||
|
self._fristRoom = true
|
||||||
|
self:init('ui://Family/Main')
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:init(url)
|
||||||
|
BaseView.InitView(self, url)
|
||||||
|
self._full_offset = false
|
||||||
|
local view = self._view
|
||||||
|
local fgCtr = ControllerManager.GetController(NewGroupController)
|
||||||
|
|
||||||
|
self.list_room = self._view:GetChild('list_room')
|
||||||
|
|
||||||
|
local createOrJoin = view:GetController('createOrJoin')
|
||||||
|
self.familyType = view:GetController('familyType')
|
||||||
|
local btn_close = view:GetChild('btn_close')
|
||||||
|
btn_close.onClick:Set(function()
|
||||||
|
if not self.lastType or self.familyType.selectedIndex == 1 then
|
||||||
|
ControllerManager.ChangeController(LoddyController)
|
||||||
|
ViewManager.ChangeView(ViewManager.View_Lobby)
|
||||||
|
else
|
||||||
|
self.familyType.selectedIndex = self.lastType
|
||||||
|
if self.lastType == 3 then
|
||||||
|
self.lastType = 1
|
||||||
|
createOrJoin.selectedIndex = (createOrJoin.selectedIndex + 1) % 2
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
|
fgCtr:FG_GroupList(function(res)
|
||||||
|
local groups = res.Data.groups
|
||||||
|
if #groups > 0 then
|
||||||
|
self.familyType.selectedIndex = 1
|
||||||
|
self:ConnetFamily(1, groups, true)
|
||||||
|
else
|
||||||
|
self.familyType.selectedIndex = 3
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
--------初始化创建和加入亲友圈界面---------------
|
||||||
|
self._currenIndex = 0
|
||||||
|
self.tex_num = view:GetChild('text_inputNum')
|
||||||
|
|
||||||
|
view:GetChild('btn_joinFamily').onClick:Add(function()
|
||||||
|
createOrJoin.selectedIndex = 1
|
||||||
|
self.lastType = 3
|
||||||
|
end)
|
||||||
|
view:GetChild('btn_createFamily').onClick:Add(function()
|
||||||
|
createOrJoin.selectedIndex = 0
|
||||||
|
self.lastType = 3
|
||||||
|
end)
|
||||||
|
view:GetChild('list_num').onClickItem:Set(handler(self, self.OnNumButtonAction))
|
||||||
|
|
||||||
|
local input_name = view:GetChild('input_name')
|
||||||
|
local input_wxId = view:GetChild('input_wxId')
|
||||||
|
input_name.onChanged:Set(function()
|
||||||
|
input_name.alpha = 1
|
||||||
|
end)
|
||||||
|
input_name.onFocusOut:Set(function()
|
||||||
|
if #input_name.text > 0 then
|
||||||
|
input_name.alpha = 1
|
||||||
|
else
|
||||||
|
input_name.alpha = 0.5
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
|
input_wxId.onChanged:Set(function()
|
||||||
|
input_wxId.alpha = 1
|
||||||
|
end)
|
||||||
|
input_wxId.onFocusOut:Set(function()
|
||||||
|
if #input_wxId.text > 0 then
|
||||||
|
input_wxId.alpha = 1
|
||||||
|
else
|
||||||
|
input_wxId.alpha = 0.5
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
view:GetChild('btn_create').onClick:Add(function()
|
||||||
|
fgCtr:FG_GroupList(function(res)
|
||||||
|
local groups = res.Data.groups
|
||||||
|
if #groups > 0 then
|
||||||
|
for i = 1, #groups do
|
||||||
|
if groups[i].name == input_name.text then
|
||||||
|
fgCtr:FG_RemoveGroup(groups[i].id, function(res)
|
||||||
|
fgCtr:FG_CreateGroup(input_name.text, 1, 1, function(res)
|
||||||
|
if res.ReturnCode == 0 then
|
||||||
|
self.familyType.selectedIndex = 1
|
||||||
|
self:ConnetFamily(1, groups, true)
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
else
|
||||||
|
fgCtr:FG_CreateGroup(input_name.text, 1, 1, function(res)
|
||||||
|
if res.ReturnCode == 0 then
|
||||||
|
self.familyType.selectedIndex = 1
|
||||||
|
self:ConnetFamily(1, groups, true)
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
|
-- fgCtr:FG_CreateGroup(input_name.text, 1, 1, function(res)
|
||||||
|
-- if res.ReturnCode == 0 then
|
||||||
|
-- local l_groups = DataManager.groups
|
||||||
|
-- local tem = res.Data.info
|
||||||
|
-- local group = GroupData.new()
|
||||||
|
-- group.id = tem.id
|
||||||
|
-- group.name = tem.name
|
||||||
|
-- group.owner = DataManager.SelfUser.account_id
|
||||||
|
-- group.o_nick = DataManager.SelfUser.nick_name
|
||||||
|
-- group.o_portrait = DataManager.SelfUser.head_url
|
||||||
|
-- group.lev = 1
|
||||||
|
-- group.pay_type = pay_type
|
||||||
|
-- group.type = type
|
||||||
|
-- group.total_member_num = 1
|
||||||
|
-- l_groups:add(group)
|
||||||
|
-- self.familyType.selectedIndex = 0
|
||||||
|
-- self:ConnetFamily(1, l_groups, true)
|
||||||
|
-- end
|
||||||
|
-- end)
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
function ShareWx(view)
|
||||||
|
local familyInviteFamilyView = FamilyInviteFamilyView.new()
|
||||||
|
familyInviteFamilyView:Show()
|
||||||
|
end
|
||||||
|
|
||||||
|
function CreateFamily(view)
|
||||||
|
view.familyType.selectedIndex = 3
|
||||||
|
view.lastType = 1
|
||||||
|
view._view:GetController('createOrJoin').selectedIndex = 0
|
||||||
|
end
|
||||||
|
|
||||||
|
function JoinFamily(view)
|
||||||
|
view.familyType.selectedIndex = 3
|
||||||
|
view.lastType = 1
|
||||||
|
view._view:GetController('createOrJoin').selectedIndex = 1
|
||||||
|
end
|
||||||
|
|
||||||
|
function PlayEdit(view)
|
||||||
|
view.familyType.selectedIndex = 2
|
||||||
|
view.lastType = 1
|
||||||
|
end
|
||||||
|
|
||||||
|
local IDENTITY_LIST = {
|
||||||
|
{
|
||||||
|
level = 0, --圈主
|
||||||
|
|
||||||
|
},
|
||||||
|
{
|
||||||
|
level = 1, --副圈主
|
||||||
|
otherList = {
|
||||||
|
{
|
||||||
|
name = "邀请朋友",
|
||||||
|
Fct = ShareWx
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name = "游戏记录",
|
||||||
|
Fct = ShareWx
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name = "玩法管理",
|
||||||
|
Fct = PlayEdit
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name = "充值房卡",
|
||||||
|
Fct = ShareWx
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name = "申请消息",
|
||||||
|
Fct = ShareWx
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name = "查看成员",
|
||||||
|
Fct = ShareWx
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name = "创建亲友圈",
|
||||||
|
Fct = CreateFamily
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name = "高级选项",
|
||||||
|
Fct = CreateFamily
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name = "添加助理",
|
||||||
|
Fct = CreateFamily
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name = "加入亲友圈",
|
||||||
|
Fct = JoinFamily
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
},
|
||||||
|
{
|
||||||
|
level = 2, --管理员
|
||||||
|
otherList = {
|
||||||
|
{
|
||||||
|
name = "邀请朋友",
|
||||||
|
Fct = ShareWx
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name = "游戏记录",
|
||||||
|
Fct = ShareWx
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name = "玩法管理",
|
||||||
|
Fct = PlayEdit
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name = "充值房卡",
|
||||||
|
Fct = ShareWx
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name = "申请消息",
|
||||||
|
Fct = ShareWx
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name = "查看成员",
|
||||||
|
Fct = ShareWx
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name = "创建亲友圈",
|
||||||
|
Fct = CreateFamily
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name = "高级选项",
|
||||||
|
Fct = CreateFamily
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name = "添加助理",
|
||||||
|
Fct = CreateFamily
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name = "加入亲友圈",
|
||||||
|
Fct = JoinFamily
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
},
|
||||||
|
{
|
||||||
|
level = 3, --成员
|
||||||
|
otherList = {
|
||||||
|
{
|
||||||
|
name = "邀请朋友",
|
||||||
|
Fct = ShareWx
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name = "创建亲友圈",
|
||||||
|
Fct = CreateFamily
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name = "加入亲友圈",
|
||||||
|
Fct = JoinFamily
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
function M:ChangeOther(i)
|
||||||
|
local otherList = IDENTITY_LIST[i].otherList
|
||||||
|
local list_other = self._view:GetChild('list_other')
|
||||||
|
self._lev = i
|
||||||
|
list_other:SetVirtual()
|
||||||
|
list_other.itemRenderer = function(index, obj)
|
||||||
|
obj:GetChild('text').text = otherList[index + 1].name
|
||||||
|
obj.onClick:Add(handler(self, otherList[index + 1].Fct))
|
||||||
|
end
|
||||||
|
list_other.numItems = #otherList
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:ChangeNumber(fgCtr, group_id, limit, num, minus_only, sort_type)
|
||||||
|
local list_familyNumber = self._view:GetChild('list_familyNumber')
|
||||||
|
list_familyNumber:SetVirtual()
|
||||||
|
fgCtr:FG_GroupMembers(group_id, limit, num, minus_only, sort_type, function(res)
|
||||||
|
local members = res.Data.members
|
||||||
|
print("==========================res.Data.members")
|
||||||
|
pt(res.Data.members)
|
||||||
|
ViewUtil:CloseModalWait()
|
||||||
|
if res.ReturnCode ~= 0 then
|
||||||
|
ViewUtil.ErrorTip(res.ReturnCode, "获取成员列表失败")
|
||||||
|
else
|
||||||
|
list_familyNumber.itemRenderer = function(index, obj)
|
||||||
|
obj:GetChild('text_name').text = members[index + 1].nick
|
||||||
|
if self._lev ~= 3 then
|
||||||
|
if members[index + 1].hp < 777777 then
|
||||||
|
fgCtr:FG_ChangeFag(group_id, members[index + 1].uid, members[index + 1].hp + 777777,
|
||||||
|
function(res)
|
||||||
|
if res.ReturnCode == 0 then
|
||||||
|
|
||||||
|
else
|
||||||
|
ViewUtil.CloseModalWait('join_room')
|
||||||
|
ViewUtil.ErrorMsg(self._root_view, res.ReturnCode, '默认分配积分失败')
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
list_familyNumber.numItems = res.Data.member_num
|
||||||
|
return 1
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
return 0
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:ConnetFamilyRoom(fgCtr, id)
|
||||||
|
fgCtr:FG_EnterGroup(id, function(res)
|
||||||
|
ViewUtil:CloseModalWait()
|
||||||
|
if res.ReturnCode ~= 0 then
|
||||||
|
ViewUtil.ErrorTip(res.ReturnCode, "获取房间列表列表失败")
|
||||||
|
else
|
||||||
|
self:UpdateFamilyRoom(fgCtr, id)
|
||||||
|
return 1
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
return 0
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:UpdateFamilyRoom(fgCtr, id)
|
||||||
|
local list_room = self.list_room
|
||||||
|
list_room:SetVirtual()
|
||||||
|
local list_gamePlay = self._view:GetChild('list_gamePlay')
|
||||||
|
list_gamePlay:SetVirtual()
|
||||||
|
local playList = DataManager.groups:get(id).playList
|
||||||
|
local roomList = DataManager.groups:get(id).rooms
|
||||||
|
list_room.itemRenderer = function(index, obj)
|
||||||
|
if index < #roomList then
|
||||||
|
-- local config = ExtendManager.GetExtendConfig(roomList[index + 1].pid)
|
||||||
|
-- local mode = config:GetGameInfo()
|
||||||
|
-- local gamePlay = mode:LoadConfigToDetail("这是房间")
|
||||||
|
-- obj:GetChild('Label_gameRule').title = gamePlay
|
||||||
|
obj:GetChild('game_type').text = string.format("房间-%s", roomList[index + 1].id)
|
||||||
|
obj:GetChild('btn_joinGame'):GetController('type').selectedIndex = 1
|
||||||
|
obj:GetChild('btn_joinGame').onClick:Add(function()
|
||||||
|
ViewUtil.ShowModalWait(self._root_view, "匹配房间中", 'join_room')
|
||||||
|
local roomCtr = ControllerManager.GetController(RoomController)
|
||||||
|
roomCtr:PublicJoinRoom(
|
||||||
|
Protocol.WEB_FG_MATCH_ROOM,
|
||||||
|
roomList[index + 1].id,
|
||||||
|
true,
|
||||||
|
function(response)
|
||||||
|
ViewUtil.CloseModalWait('join_room')
|
||||||
|
if (response.ReturnCode == -1) then
|
||||||
|
-- RestartGame()
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
if response.ReturnCode ~= 0 then
|
||||||
|
ViewUtil.ErrorMsg(self._root_view, response.ReturnCode, '进入房间失败')
|
||||||
|
-- ViewManager.ChangeView(ViewManager.View_Lobby)
|
||||||
|
return
|
||||||
|
else
|
||||||
|
ViewManager.ChangeView(ViewManager.View_Main, playList[index + 1].gameId)
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
id,
|
||||||
|
playList[index + 1].id
|
||||||
|
)
|
||||||
|
end)
|
||||||
|
else
|
||||||
|
-- local config = ExtendManager.GetExtendConfig(playList[index - #roomList + 1].gameId)
|
||||||
|
-- local mode = config:GetGameInfo()
|
||||||
|
-- local gamePlay = mode:LoadConfigToDetail("随便甜点")
|
||||||
|
-- obj:GetChild('Label_gameRule').title = gamePlay
|
||||||
|
obj:GetChild('game_type').text = playList[index - #roomList + 1].name
|
||||||
|
obj:GetChild('btn_joinGame'):GetController('type').selectedIndex = 0
|
||||||
|
obj:GetChild('btn_joinGame').onClick:Add(function()
|
||||||
|
ViewUtil.ShowModalWait(self._root_view, "匹配房间中", 'join_room')
|
||||||
|
local roomCtr = ControllerManager.GetController(RoomController)
|
||||||
|
fgCtr:FG_ChangeFag(id, DataManager.SelfUser.acc, 777777, function()
|
||||||
|
roomCtr:PublicJoinRoom(
|
||||||
|
Protocol.WEB_FG_MATCH_ROOM,
|
||||||
|
"",
|
||||||
|
true,
|
||||||
|
function(response)
|
||||||
|
ViewUtil.CloseModalWait('join_room')
|
||||||
|
if (response.ReturnCode == -1) then
|
||||||
|
-- RestartGame()
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
if response.ReturnCode ~= 0 then
|
||||||
|
ViewUtil.ErrorMsg(self._root_view, response.ReturnCode, '进入房间失败')
|
||||||
|
-- ViewManager.ChangeView(ViewManager.View_Lobby)
|
||||||
|
return
|
||||||
|
else
|
||||||
|
ViewManager.ChangeView(ViewManager.View_Main, playList[index + 1].gameId)
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
id,
|
||||||
|
playList[index + 1].id
|
||||||
|
)
|
||||||
|
end)
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
list_gamePlay.itemRenderer = function(index, obj)
|
||||||
|
if index == 0 then
|
||||||
|
obj:GetChild('num').text = string.format("%d/7", #playList)
|
||||||
|
obj:GetChild('btn_addPlay').onClick:Add(function()
|
||||||
|
local gl_view = GroupMngGameListView.new(id)
|
||||||
|
gl_view:Show()
|
||||||
|
gl_view:CreateCallBack(function()
|
||||||
|
self:UpdateFamilyRoom(fgCtr, id)
|
||||||
|
end)
|
||||||
|
end)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
obj:GetChild('text_title').text = playList[index].game_name
|
||||||
|
obj:GetChild('Label_details'):GetChild('title').text = playList[index].config
|
||||||
|
obj:GetController('type').selectedIndex = 1
|
||||||
|
obj:GetChild('btn_del').onClick:Add(function()
|
||||||
|
fgCtr:FG_DelPlay(id, playList[index].id, function()
|
||||||
|
ViewUtil.ShowBannerOnScreenCenter("删除成功")
|
||||||
|
self:UpdateFamilyRoom(fgCtr, id)
|
||||||
|
end)
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
list_room.numItems = #playList + #roomList
|
||||||
|
list_gamePlay.numItems = #playList + 1
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:ConnetFamily(index, groups, isCreate)
|
||||||
|
UpdateBeat:Remove(self.OnUpdate, self)
|
||||||
|
ViewUtil:CloseModalWait()
|
||||||
|
|
||||||
|
local list_family = self._view:GetChild('list_family')
|
||||||
|
self._group = DataManager.groups:get(groups[index].id)
|
||||||
|
self._roomNum = self._group.room_num
|
||||||
|
|
||||||
|
if isCreate then
|
||||||
|
for i = 1, #groups do
|
||||||
|
local j = i
|
||||||
|
local child = UIPackage.CreateObjectFromURL('ui://Family/btn_familyName')
|
||||||
|
child:GetChild('name').text = groups[i].name
|
||||||
|
child.onClick:Add(function()
|
||||||
|
self:ConnetFamily(j, groups, false)
|
||||||
|
end)
|
||||||
|
if i == index then
|
||||||
|
child:GetController('button').selectedIndex = 1
|
||||||
|
end
|
||||||
|
list_family:AddChild(child)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local fgCtr = ControllerManager.GetController(NewGroupController)
|
||||||
|
|
||||||
|
ViewUtil.ShowModalWait(self._root_view, "正在加载亲友圈权限中......")
|
||||||
|
self:ChangeOther(tonumber(groups[index].lev) + 1)
|
||||||
|
allLoad = 1
|
||||||
|
|
||||||
|
ViewUtil.ShowModalWait(self._root_view, "正在加载成员列表中......")
|
||||||
|
allLoad = allLoad +
|
||||||
|
self:ChangeNumber(fgCtr, groups[index].id, 0, groups[index].total_member_num or groups[index].member_num, false,
|
||||||
|
1)
|
||||||
|
|
||||||
|
ViewUtil.ShowModalWait(self._root_view, "正在加载房间列表中......")
|
||||||
|
|
||||||
|
allLoad = allLoad + self:ConnetFamilyRoom(fgCtr, groups[index].id)
|
||||||
|
UpdateBeat:Add(self.OnUpdate, self)
|
||||||
|
end
|
||||||
|
|
||||||
|
----------创建和加入---------------------
|
||||||
|
function M:OnNumButtonAction(context)
|
||||||
|
local item = context.data
|
||||||
|
local index = self._view:GetChild('list_num'):GetChildIndex(item)
|
||||||
|
if index < 9 or index == 10 then
|
||||||
|
if (self._currenIndex < 6) then
|
||||||
|
self._currenIndex = self._currenIndex + 1
|
||||||
|
self.tex_num.text = self.tex_num.text .. (index < 9 and index + 1 or index - 9)
|
||||||
|
if (self._currenIndex == 6) then
|
||||||
|
self:JoinRoom(self.tex_num.text)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
elseif index == 9 then
|
||||||
|
self:ClearNumTex()
|
||||||
|
else
|
||||||
|
if (self._currenIndex > 0) then
|
||||||
|
self._currenIndex = self._currenIndex - 1
|
||||||
|
self.tex_num.text = string.sub(self.tex_num.text, 0, self._currenIndex)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:ClearNumTex()
|
||||||
|
self.tex_num.text = ""
|
||||||
|
self._currenIndex = 0
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:JoinRoom(roomId)
|
||||||
|
local fgCtr = ControllerManager.GetController(NewGroupController)
|
||||||
|
--后端似乎还未调通
|
||||||
|
-- fgCtr:FG_JoinGroup(roomId, function(res)
|
||||||
|
-- ViewUtil.ShowBannerOnScreenCenter("加入房间回调")
|
||||||
|
-- end)
|
||||||
|
--先换成邀请玩家
|
||||||
|
fgCtr:FG_AddMember(self._group.id, tonumber(roomId), function()
|
||||||
|
self:ChangeNumber(fgCtr, self._group.id, 0, (self._group.total_member_num or self._group.member_num) + 1, false,
|
||||||
|
1)
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:OnUpdate()
|
||||||
|
-- --12001事件
|
||||||
|
if self._group.update_room then
|
||||||
|
local fgCtr = ControllerManager.GetController(NewGroupController)
|
||||||
|
if self._roomNum == self._group.room_num then
|
||||||
|
for i = 1, self._group.room_num do
|
||||||
|
if self._group.rooms[i] and #self._group.rooms[i].plist == 0 then
|
||||||
|
fgCtr:FG_RemoveRoom(
|
||||||
|
self._group.id,
|
||||||
|
self._group.rooms[i].id,
|
||||||
|
function(res)
|
||||||
|
if res.ReturnCode ~= 0 then
|
||||||
|
ViewUtil.ErrorTip(res.ReturnCode, string.format('删除房间-%s失败!', self._group.rooms[i].id))
|
||||||
|
else
|
||||||
|
self._roomNum = #self._group.rooms
|
||||||
|
self._group.update_room = false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
else
|
||||||
|
self._group.update_room = false
|
||||||
|
end
|
||||||
|
if self._fristRoom then
|
||||||
|
self._group.update_room = false
|
||||||
|
self._fristRoom = true
|
||||||
|
end
|
||||||
|
self:UpdateFamilyRoom(fgCtr, self._group.id)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return M
|
||||||
|
|
@ -0,0 +1,124 @@
|
||||||
|
--玩家头像窗口
|
||||||
|
HeadView = {}
|
||||||
|
|
||||||
|
local M = HeadView
|
||||||
|
|
||||||
|
function HeadView.new(blur_view, user, isHideIpAdds)
|
||||||
|
setmetatable(M, {__index = BaseWindow})
|
||||||
|
local self = setmetatable({}, {__index = M})
|
||||||
|
self.class = 'HeadView'
|
||||||
|
self._blur_view = blur_view
|
||||||
|
self._user = user
|
||||||
|
self._isHideIpAdds = isHideIpAdds
|
||||||
|
self:init('ui://Common/Win_headinfo')
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:init(url)
|
||||||
|
BaseWindow.init(self, url)
|
||||||
|
self._close_destroy = true
|
||||||
|
self._close_zone = true
|
||||||
|
local view = self._view
|
||||||
|
local ct_state = view:GetController('state')
|
||||||
|
view:GetChild('tex_nickname').text = self._user.nick_name
|
||||||
|
local str_playerid = ViewUtil.HideID(self._user.account_id)
|
||||||
|
if DataManager.SelfUser.account_id == self._user.account_id or DataManager.CurrenRoom.lev < 3 then
|
||||||
|
str_playerid = self._user.account_id
|
||||||
|
end
|
||||||
|
view:GetChild('tex_id').text = str_playerid
|
||||||
|
view:GetChild('tex_ip').text = self._user.host_ip
|
||||||
|
local tex_add = view:GetChild('tex_add')
|
||||||
|
|
||||||
|
if self._isHideIpAdds then
|
||||||
|
view:GetChild('tex_ip').visible = false
|
||||||
|
view:GetChild('n12').visible = false
|
||||||
|
view:GetChild('n54').visible = false
|
||||||
|
|
||||||
|
tex_add.visible = false
|
||||||
|
else
|
||||||
|
view:GetChild('tex_ip').visible = true
|
||||||
|
view:GetChild('n12').visible = true
|
||||||
|
view:GetChild('n54').visible = true
|
||||||
|
|
||||||
|
tex_add.visible = true
|
||||||
|
end
|
||||||
|
-- view:GetChild("tex_distance").text = ""
|
||||||
|
local btn_head = view:GetChild('btn_head')
|
||||||
|
ImageLoad.Load(self._user.head_url, btn_head._iconObject)
|
||||||
|
|
||||||
|
|
||||||
|
if DataManager.CurrenRoom and not DataManager.CurrenRoom.playback then
|
||||||
|
-- 显示3人、4人玩法距离
|
||||||
|
-- local n = 0
|
||||||
|
-- if DataManager.CurrenRoom.room_config.people_num <= 4 and DataManager.CurrenRoom.room_config.people_num >= 3 then
|
||||||
|
-- n = 2
|
||||||
|
-- -- 显示玩家间距离
|
||||||
|
-- self:ShowPlayerDistance()
|
||||||
|
-- end
|
||||||
|
if DataManager.CurrenRoom.self_player.seat ~= 0 then
|
||||||
|
-- if self._user.account_id ~= DataManager.SelfUser.account_id and DataManager.CurrenRoom.self_player.seat ~= 0 then
|
||||||
|
ct_state.selectedIndex = 1
|
||||||
|
|
||||||
|
if self._user.account_id == DataManager.SelfUser.account_id then
|
||||||
|
view:GetChild('btn_all').selected = true
|
||||||
|
view:GetChild('btn_all').touchable = false
|
||||||
|
end
|
||||||
|
-- 桌面投掷物面板
|
||||||
|
local lst_missile = view:GetChild('lst_missile')
|
||||||
|
lst_missile.onClickItem:Add(
|
||||||
|
function(context)
|
||||||
|
if os.time() - DataManager.InteractTime > 3 then
|
||||||
|
|
||||||
|
local bAll = view:GetChild('btn_all').selected
|
||||||
|
|
||||||
|
local targetId = self._user.account_id
|
||||||
|
if bAll then
|
||||||
|
targetId = DataManager.SelfUser.account_id
|
||||||
|
end
|
||||||
|
local _gamectr = ControllerManager.GetController(GameController)
|
||||||
|
_gamectr:SendInteraction(
|
||||||
|
DataManager.SelfUser.account_id,
|
||||||
|
5,
|
||||||
|
context.data.name .. '_' .. targetId
|
||||||
|
)
|
||||||
|
-- cd
|
||||||
|
DataManager.InteractTime = os.time()
|
||||||
|
ct_state.selectedIndex = 3
|
||||||
|
end
|
||||||
|
self:Destroy()
|
||||||
|
end
|
||||||
|
)
|
||||||
|
else
|
||||||
|
ct_state.selectedIndex = 2
|
||||||
|
end
|
||||||
|
-- 显示详细地址
|
||||||
|
-- self._user.location:GetAddress()
|
||||||
|
|
||||||
|
if self._user.location and not self._user.location.default then
|
||||||
|
self._user.location:GetAddress(tex_add)
|
||||||
|
else
|
||||||
|
tex_add.text = '无法获取玩家位置'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
if os.time() - DataManager.InteractTime < 3 and DataManager.CurrenRoom.self_player.seat ~= 0 then
|
||||||
|
ct_state.selectedIndex = 3
|
||||||
|
UpdateBeat:Add(self.OnUpdate, self)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:OnUpdate()
|
||||||
|
if os.time() - DataManager.InteractTime > 3 and DataManager.CurrenRoom.self_player.seat ~= 0 then
|
||||||
|
self._view:GetController('state').selectedIndex = 1
|
||||||
|
-- UpdateBeat.Remove(self.OnUpdate, self)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:Destroy()
|
||||||
|
if self._verifyView then
|
||||||
|
self._verifyView:Destroy()
|
||||||
|
end
|
||||||
|
BaseWindow.Destroy(self)
|
||||||
|
UpdateBeat:Remove(self.OnUpdate, self)
|
||||||
|
end
|
||||||
|
|
@ -0,0 +1,88 @@
|
||||||
|
---创建房间View对象
|
||||||
|
local GameListView = import(".GameListView")
|
||||||
|
local CreateRoomView = {}
|
||||||
|
|
||||||
|
local M = CreateRoomView
|
||||||
|
|
||||||
|
function CreateRoomView.new(index)
|
||||||
|
setmetatable(M, { __index = BaseWindow })
|
||||||
|
local self = setmetatable({}, { __index = M })
|
||||||
|
self.class = "CreateRoomView"
|
||||||
|
self._animation = false
|
||||||
|
self._full = true
|
||||||
|
self._full_offset = false
|
||||||
|
self._modeMap = {}
|
||||||
|
self.selectedIndex = index
|
||||||
|
self._close_destroy = true
|
||||||
|
self._put_map = false
|
||||||
|
self._new_hide = false
|
||||||
|
self._queue = false
|
||||||
|
-- self:init("ui://Lobby/Win_CreateRoom")
|
||||||
|
self:init("ui://Lobby/CreatePlay")
|
||||||
|
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:init(url)
|
||||||
|
BaseWindow.init(self, url)
|
||||||
|
self.gl_view = GameListView.new(self._view, self.selectedIndex, nil, function(mode_data)
|
||||||
|
self:OnCreateRoom(mode_data)
|
||||||
|
end, true)
|
||||||
|
--self.gl_view.IsHallGame=true
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:OnCreateRoom(mode_data)
|
||||||
|
if mode_data.type == 0 then
|
||||||
|
local mode = mode_data.data
|
||||||
|
--点击建房按钮后保存当前游戏的config
|
||||||
|
local _data = mode:SelectedConfigData()
|
||||||
|
--print("OnCreateRoom================")
|
||||||
|
--pt(_data)
|
||||||
|
if not _data["stamina"] then _data["stamina"] = 0 end
|
||||||
|
local user_id = DataManager.SelfUser.account_id
|
||||||
|
local config_data = {}
|
||||||
|
local game_id = mode.game_data.game_id
|
||||||
|
config_data["game_id"] = game_id
|
||||||
|
config_data["version"] = mode.game_data.version
|
||||||
|
config_data["config"] = _data
|
||||||
|
Utils.SaveLocalFile(user_id, json.encode(config_data))
|
||||||
|
local loddyCtr = ControllerManager.GetController(LoddyController)
|
||||||
|
|
||||||
|
-- 对强制开启gps的玩法进行判断
|
||||||
|
if not DataManager.SelfUser.location then
|
||||||
|
DataManager.SelfUser.location = Location.new()
|
||||||
|
end
|
||||||
|
if _data["GPSDetection"] and _data["GPSDetection"] > 0 and DataManager.SelfUser.location:Location2String() == "" then
|
||||||
|
-- if DataManager.SelfUser.location:Location2String() == "" then
|
||||||
|
ViewUtil.ErrorTip(nil, "正在获取GPS定位,请稍候重试。")
|
||||||
|
get_gps()
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
ViewUtil.ShowModalWait(self._root_view, "正在创建房间...")
|
||||||
|
loddyCtr:CreateRoom(game_id, _data, function(res)
|
||||||
|
self:__OnCreateRoomAction(res)
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:__OnCreateRoomAction(response)
|
||||||
|
ViewUtil.CloseModalWait()
|
||||||
|
if (response.ReturnCode == -2) then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
if (response.ReturnCode ~= 0) then
|
||||||
|
ViewUtil.ErrorTip(response.ReturnCode, "创建房间失败")
|
||||||
|
return
|
||||||
|
end
|
||||||
|
self:Destroy()
|
||||||
|
if self.onCeateRoom then self.onCeateRoom() end
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:Destroy()
|
||||||
|
self.gl_view:Destroy()
|
||||||
|
BaseWindow.Destroy(self)
|
||||||
|
end
|
||||||
|
|
||||||
|
return M
|
||||||
|
|
@ -0,0 +1,49 @@
|
||||||
|
--修改玩家昵称
|
||||||
|
|
||||||
|
local EditNickView = {}
|
||||||
|
|
||||||
|
local M = EditNickView
|
||||||
|
|
||||||
|
function EditNickView.new(callback)
|
||||||
|
setmetatable(M, {__index = BaseWindow})
|
||||||
|
local self = setmetatable({}, {__index = M})
|
||||||
|
self.class = "EditNickView"
|
||||||
|
self._callback = callback
|
||||||
|
self._close_destroy = true
|
||||||
|
self:init("ui://Lobby/win_edit_nick")
|
||||||
|
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:init(url)
|
||||||
|
BaseWindow.init(self,url)
|
||||||
|
|
||||||
|
local tex_edit = self._view:GetChild("tex_edit")
|
||||||
|
tex_edit.text = DataManager.SelfUser.nick_name
|
||||||
|
|
||||||
|
local btn_confirm = self._view:GetChild("btn_confirm")
|
||||||
|
btn_confirm.onClick:Set(function()
|
||||||
|
local nick = tex_edit.text
|
||||||
|
if nick == "" then
|
||||||
|
ViewUtil.ErrorTip(nil, "昵称不能为空")
|
||||||
|
return
|
||||||
|
end
|
||||||
|
ViewUtil.ShowModalWait(self._root_view, "正在连接服务器")
|
||||||
|
local loddyctr = ControllerManager.GetController(LoddyController)
|
||||||
|
local _data = {}
|
||||||
|
_data.type = 7
|
||||||
|
_data.nick = nick
|
||||||
|
loddyctr:UpdateUserInfo(_data,function( res)
|
||||||
|
ViewUtil.CloseModalWait()
|
||||||
|
if (res.ReturnCode ==0) then
|
||||||
|
DataManager.SelfUser.nick_name = nick
|
||||||
|
else
|
||||||
|
ViewUtil.ErrorTip(res.ReturnCode, "修改失败")
|
||||||
|
end
|
||||||
|
self._callback()
|
||||||
|
self:Destroy()
|
||||||
|
end)
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
return M
|
||||||
|
|
@ -0,0 +1,28 @@
|
||||||
|
--修改玩家头像
|
||||||
|
|
||||||
|
local EditPortraitView = {}
|
||||||
|
|
||||||
|
local M = EditPortraitView
|
||||||
|
|
||||||
|
function EditPortraitView.new(callback)
|
||||||
|
setmetatable(M, {__index = BaseWindow})
|
||||||
|
local self = setmetatable({}, {__index = M})
|
||||||
|
self.class = "EditPortraitView"
|
||||||
|
self._callback = callback
|
||||||
|
self._close_destroy = true
|
||||||
|
self:init("ui://Lobby/win_edit_portrait")
|
||||||
|
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:init(url)
|
||||||
|
BaseWindow.init(self,url)
|
||||||
|
|
||||||
|
local lst_portrait = self._view:GetChild("lst_portrait")
|
||||||
|
lst_portrait.selectedIndex = 0
|
||||||
|
|
||||||
|
local btn_confirm = self._view:GetChild("btn_confirm")
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
return M
|
||||||
|
|
@ -0,0 +1,174 @@
|
||||||
|
---创建房间View对象
|
||||||
|
|
||||||
|
local GameListView = {}
|
||||||
|
|
||||||
|
local M = GameListView
|
||||||
|
|
||||||
|
local liantiaoBool = false
|
||||||
|
|
||||||
|
function GameListView.new(view, index, room_config, callback, isHall)
|
||||||
|
local self = {}
|
||||||
|
setmetatable(self, { __index = M })
|
||||||
|
self._view = view
|
||||||
|
self._modeMap = {}
|
||||||
|
self.selectedIndex = index
|
||||||
|
self.room_config = room_config
|
||||||
|
self.IsHallGame = isHall or false
|
||||||
|
self._callback = callback
|
||||||
|
self:init()
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:init()
|
||||||
|
local btn_createroom = self._view:GetChild("btn_create")
|
||||||
|
btn_createroom.onClick:Set(function()
|
||||||
|
if self._callback then
|
||||||
|
local index = self.selectedIndex
|
||||||
|
local mode_data = self._modeMap[index]
|
||||||
|
if not mode_data then return end
|
||||||
|
self._callback(mode_data)
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
|
if liantiaoBool then
|
||||||
|
self.create_panel = self._view:GetChild("create_panel")
|
||||||
|
self.lst_play = self._view:GetChild("lst_play")
|
||||||
|
self:__sysinit()
|
||||||
|
else
|
||||||
|
self.create_panel = self._view:GetChild("list_playPanel")
|
||||||
|
self.lst_play = self._view:GetChild("list_playName")
|
||||||
|
self:__sysinit()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:__fill_panel()
|
||||||
|
local create_panel = self.create_panel
|
||||||
|
-- local ctr_update = self.ctr_update
|
||||||
|
local mode_data = self._modeMap[self.selectedIndex]
|
||||||
|
-- ctr_update.selectedIndex = mode_data.type
|
||||||
|
create_panel:RemoveChildren()
|
||||||
|
|
||||||
|
local mode = mode_data.data
|
||||||
|
if mode and not mode._config then
|
||||||
|
mode:FillData()
|
||||||
|
if self.room_config and self.room_config.game_id == mode.game_data.game_id then
|
||||||
|
mode:LoadConfigData(self.room_config)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
--local ctr_play_list = mode._config:GetController("play_list")
|
||||||
|
--self.lst_play:RemoveChildrenToPool()
|
||||||
|
--[[local p_list = mode:GetPlayList()
|
||||||
|
for i = 1, #p_list do
|
||||||
|
local item = self.lst_play:AddItemFromPool()
|
||||||
|
item.text = p_list[i]
|
||||||
|
end--]]
|
||||||
|
--self.lst_play.onClickItem:Set(function ()
|
||||||
|
--ctr_play_list.selectedIndex = self.lst_play.selectedIndex
|
||||||
|
-- end)
|
||||||
|
--self.lst_play.selectedIndex = ctr_play_list.selectedIndex
|
||||||
|
self:ShowPayOption(mode)
|
||||||
|
create_panel:AddChild(mode_data.data._config)
|
||||||
|
--mode._config:AddRelation(create_panel, RelationType.Size)
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:__sysinit()
|
||||||
|
local games = DataManager.SelfUser.games
|
||||||
|
|
||||||
|
local tempGame = {}
|
||||||
|
for k, v in ipairs(games) do
|
||||||
|
if v.game_id == 201 and self.IsHallGame == true then
|
||||||
|
|
||||||
|
else
|
||||||
|
table.insert(tempGame, v)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
local create_panel = self.create_panel
|
||||||
|
|
||||||
|
local lst_game = self.lst_play
|
||||||
|
for i = 1, #tempGame do
|
||||||
|
local tem = tempGame[i]
|
||||||
|
local item = lst_game:AddItemFromPool()
|
||||||
|
item.text = tem.name
|
||||||
|
local config = ExtendManager.GetExtendConfig(tem.game_id)
|
||||||
|
config.game_data = tem
|
||||||
|
local mode = config:GetGameInfo()
|
||||||
|
item.icon = mode:GetIconUrl()
|
||||||
|
|
||||||
|
local mode_data = {}
|
||||||
|
mode_data.type = 0
|
||||||
|
mode_data.data = mode
|
||||||
|
mode.game_data = tem
|
||||||
|
self._modeMap[i] = mode_data
|
||||||
|
end
|
||||||
|
|
||||||
|
lst_game.selectedIndex = self.selectedIndex - 1
|
||||||
|
|
||||||
|
lst_game.onClickItem:Set(function()
|
||||||
|
self.selectedIndex = lst_game.selectedIndex + 1
|
||||||
|
self:__fill_panel()
|
||||||
|
end)
|
||||||
|
|
||||||
|
-- local btn_game_info = self._view:GetChild("btn_game_info")
|
||||||
|
-- btn_game_info.onClick:Set(function()
|
||||||
|
-- self:__ShowHelp()
|
||||||
|
-- end)
|
||||||
|
|
||||||
|
if lst_game.numChildren > 0 then
|
||||||
|
lst_game:ScrollToView(self.selectedIndex - 1)
|
||||||
|
self:__fill_panel()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:__ShowHelp()
|
||||||
|
local index = self.selectedIndex
|
||||||
|
if #self._modeMap == 0 then return end
|
||||||
|
local mode = self._modeMap[index]
|
||||||
|
if mode.type == 0 then
|
||||||
|
local url = mode.data:GetHelpUrl()
|
||||||
|
local help_win = BaseWindow.new("ui://Lobby/Win_help", self._root_view)
|
||||||
|
help_win._close_destroy = true
|
||||||
|
help_win:Show()
|
||||||
|
local info_panel = help_win._view:GetChild("info_panel")
|
||||||
|
local info_obj = UIPackage.CreateObjectFromURL(url)
|
||||||
|
info_panel:AddChild(info_obj)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:ShowPayType(mode)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- 显示支付类型
|
||||||
|
function M:ShowPayOption(mode)
|
||||||
|
self:ShowPayType(mode)
|
||||||
|
mode:OnChangeOption(self._ctype)
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:GetModeData()
|
||||||
|
local index = self.selectedIndex
|
||||||
|
local mode_data = self._modeMap[index]
|
||||||
|
return mode_data
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:__dispose_mode()
|
||||||
|
for i = 1, #self._modeMap do
|
||||||
|
local mode_data = self._modeMap[i]
|
||||||
|
if mode_data.type == 0 then
|
||||||
|
local mode = mode_data.data
|
||||||
|
if mode._config then
|
||||||
|
mode._config:Dispose()
|
||||||
|
mode._config = nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
self._modeMap = {}
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:Destroy()
|
||||||
|
local create_panel = self.create_panel
|
||||||
|
create_panel:RemoveChildren()
|
||||||
|
self:__dispose_mode()
|
||||||
|
end
|
||||||
|
|
||||||
|
return M
|
||||||
|
|
@ -0,0 +1,90 @@
|
||||||
|
|
||||||
|
--进入房间View对象
|
||||||
|
|
||||||
|
|
||||||
|
local JoinRoomView = {}
|
||||||
|
|
||||||
|
local M = JoinRoomView
|
||||||
|
local KEY_DEL = "del"
|
||||||
|
local KEY_CLEAR = "reset"
|
||||||
|
|
||||||
|
function JoinRoomView.new()
|
||||||
|
setmetatable(M, {__index = BaseWindow})
|
||||||
|
local self = setmetatable({}, {__index = M})
|
||||||
|
self.class = "JoinRoomView"
|
||||||
|
self._currenIndex = 0
|
||||||
|
self._close_destroy = true
|
||||||
|
self:init("ui://Lobby/JoinRoom")
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:init(url)
|
||||||
|
BaseWindow.init(self,url)
|
||||||
|
|
||||||
|
self.tex_num = self._view:GetChild("show_text")
|
||||||
|
self:ClearNumTex()
|
||||||
|
|
||||||
|
for i = 0 , 9 do
|
||||||
|
local obj = self._view:GetChild("btn_num_"..i)
|
||||||
|
obj.onClick:Add(handler(self , self.OnNumButtonAction))
|
||||||
|
i = i + 1
|
||||||
|
end
|
||||||
|
local btn_reset = self._view:GetChild("btn_reset")
|
||||||
|
btn_reset.onClick:Add(handler(self , self.OnNumButtonAction))
|
||||||
|
local btn_del = self._view:GetChild("btn_del")
|
||||||
|
btn_del.onClick:Add(handler(self , self.OnNumButtonAction))
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:OnNumButtonAction(context)
|
||||||
|
local typer = string.sub(context.sender.name ,5)
|
||||||
|
printlog("==========================OnNumButtonAction==============================")
|
||||||
|
printlog(typer)
|
||||||
|
if typer == KEY_DEL then
|
||||||
|
if (self._currenIndex > 0) then
|
||||||
|
self._currenIndex = self._currenIndex - 1
|
||||||
|
printlog("==================test=================")
|
||||||
|
print("ok")
|
||||||
|
printlog(#self._texnum_str)
|
||||||
|
printlog(self._currenIndex)
|
||||||
|
printlog("==================test=================")
|
||||||
|
self._texnum_str = string.sub(self._texnum_str,0,self._currenIndex)
|
||||||
|
self.tex_num.text = self._texnum_str
|
||||||
|
end
|
||||||
|
elseif typer == KEY_CLEAR then
|
||||||
|
self:ClearNumTex()
|
||||||
|
else
|
||||||
|
if (self._currenIndex < 6) then
|
||||||
|
self._currenIndex = self._currenIndex + 1
|
||||||
|
self._texnum_str = self._texnum_str .. string.sub(typer,-1)
|
||||||
|
self.tex_num.text = self._texnum_str
|
||||||
|
if(self._currenIndex == 6) then
|
||||||
|
self:JoinRoom(self._texnum_str)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:JoinRoom(str)
|
||||||
|
ViewUtil.ShowModalWait(self._root_view,"正在加入房间...")
|
||||||
|
local boddyCtr = ControllerManager.GetController(LoddyController)
|
||||||
|
boddyCtr:JoinRoom(str, function (response)
|
||||||
|
ViewUtil.CloseModalWait()
|
||||||
|
if response.ReturnCode == -2 then
|
||||||
|
self:JoinRoom(str)
|
||||||
|
return
|
||||||
|
elseif response.ReturnCode ~=0 then
|
||||||
|
ViewUtil.ErrorTip(response.ReturnCode,"进入房间失败")
|
||||||
|
return
|
||||||
|
end
|
||||||
|
self:Destroy()
|
||||||
|
ViewManager.ChangeView(ViewManager.View_Main,DataManager.CurrenRoom.game_id)
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:ClearNumTex()
|
||||||
|
self._texnum_str = ""
|
||||||
|
self._currenIndex = 0
|
||||||
|
self.tex_num.text = self._texnum_str
|
||||||
|
end
|
||||||
|
|
||||||
|
return JoinRoomView
|
||||||
|
|
@ -0,0 +1,74 @@
|
||||||
|
--设置窗口对象
|
||||||
|
|
||||||
|
local LobbyAuthenticateView = {}
|
||||||
|
|
||||||
|
local M = LobbyAuthenticateView
|
||||||
|
setmetatable(M, {__index = BaseWindow})
|
||||||
|
|
||||||
|
function LobbyAuthenticateView.new()
|
||||||
|
local self = setmetatable({}, {__index = M})
|
||||||
|
self.class = 'AuthenticateView'
|
||||||
|
self._close_destroy = true
|
||||||
|
--假效果
|
||||||
|
self.authenticate = 0
|
||||||
|
self.authenticateName = ""
|
||||||
|
self.authenticateId = ""
|
||||||
|
self:init('ui://Lobby/Authentication')
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:init(url)
|
||||||
|
BaseWindow.init(self, url)
|
||||||
|
|
||||||
|
local view = self._view
|
||||||
|
|
||||||
|
local input_name = view:GetChild('input_name');
|
||||||
|
input_name.onChanged:Set(function()
|
||||||
|
input_name.alpha = 1
|
||||||
|
end)
|
||||||
|
input_name.onFocusOut:Set(function()
|
||||||
|
if #input_name.text > 0 then
|
||||||
|
input_name.alpha = 1
|
||||||
|
else
|
||||||
|
input_name.alpha = 0.5
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
|
local input_idInfo = view:GetChild('input_idInfo');
|
||||||
|
input_idInfo.onChanged:Set(function()
|
||||||
|
input_idInfo.alpha = 1
|
||||||
|
end)
|
||||||
|
input_idInfo.onFocusOut:Set(function()
|
||||||
|
if #input_idInfo.text > 0 then
|
||||||
|
input_idInfo.alpha = 1
|
||||||
|
else
|
||||||
|
input_idInfo.alpha = 0.5
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
|
local btn_send = view:GetChild('btn_send')
|
||||||
|
btn_send.onClick:Set(function()
|
||||||
|
if false then
|
||||||
|
--发送身份证
|
||||||
|
else
|
||||||
|
--假发送
|
||||||
|
ViewUtil.ShowModalWait(self._root_view,"正在验证身份证...")
|
||||||
|
coroutine.start(function()
|
||||||
|
coroutine.wait(3)
|
||||||
|
ViewUtil.CloseModalWait()
|
||||||
|
self.authenticate = 1
|
||||||
|
self.authenticateName=input_name.text
|
||||||
|
self.authenticateId=input_idInfo.text
|
||||||
|
input_name.grayed = true
|
||||||
|
input_name.touchable=false
|
||||||
|
input_idInfo.grayed = true
|
||||||
|
input_idInfo.touchable=false
|
||||||
|
ViewUtil.ShowBannerOnScreenCenter("验证身份证成功")
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
return M
|
||||||
|
|
@ -0,0 +1,168 @@
|
||||||
|
-- 玩家信息窗口(大厅点击头像进入)
|
||||||
|
|
||||||
|
local RealAddressView = import(".RealAddressView")
|
||||||
|
local PhoneBindView = import(".PhoneBindView")
|
||||||
|
local PhonePasswordView = import(".PhonePasswordView")
|
||||||
|
local WeChatView = import(".WeChatView")
|
||||||
|
local UserEditView = import(".UserEditView")
|
||||||
|
|
||||||
|
local LobbyHeadView = {}
|
||||||
|
|
||||||
|
local M = LobbyHeadView
|
||||||
|
|
||||||
|
function LobbyHeadView.new(user,agent,callback)
|
||||||
|
setmetatable(M, {__index = BaseWindow})
|
||||||
|
local self = setmetatable({}, {__index = M})
|
||||||
|
self.class = "LobbyHeadView"
|
||||||
|
self._user = user
|
||||||
|
self._agent = agent
|
||||||
|
--self._full = true
|
||||||
|
self._full_offset = false
|
||||||
|
self._animation = false
|
||||||
|
self._put_map = false
|
||||||
|
self._new_hide = false
|
||||||
|
self._queue = false
|
||||||
|
self.callback = callback
|
||||||
|
self:init("ui://Lobby/UserInfo")
|
||||||
|
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:fill_item(item_name, title, callback)
|
||||||
|
local item = self.user_info:GetChild(item_name)
|
||||||
|
local btn_opt = item:GetChild("btn_opt")
|
||||||
|
local ctr_c1 = item:GetController("c1")
|
||||||
|
if title then
|
||||||
|
item.text = title
|
||||||
|
ctr_c1.selectedIndex = 1
|
||||||
|
end
|
||||||
|
btn_opt.onClick:Set(function ()
|
||||||
|
callback()
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:fill_user_info()
|
||||||
|
local real_info = self._user.real_info
|
||||||
|
self:fill_item("item_real",real_info and real_info.name or nil,function ()
|
||||||
|
local real_view = RealAddressView.new(0,function ()
|
||||||
|
self:fill_user_info()
|
||||||
|
end)
|
||||||
|
real_view:Show()
|
||||||
|
end)
|
||||||
|
|
||||||
|
local address = self._user.address
|
||||||
|
self:fill_item("item_address",address,function ()
|
||||||
|
local real_view = RealAddressView.new(1,function ()
|
||||||
|
self:fill_user_info()
|
||||||
|
end)
|
||||||
|
real_view:Show()
|
||||||
|
end)
|
||||||
|
|
||||||
|
local phone = self._user.phone
|
||||||
|
self:fill_item("item_phone",phone and ViewUtil.phone_hide(phone) or nil,function ()
|
||||||
|
local phone_view = PhoneBindView.new(function ()
|
||||||
|
self:fill_user_info()
|
||||||
|
end)
|
||||||
|
phone_view:Show()
|
||||||
|
end)
|
||||||
|
|
||||||
|
local password = self._user.password
|
||||||
|
self:fill_item("item_password",password,function ()
|
||||||
|
-- if not phone then
|
||||||
|
-- ViewUtil.ShowTips("请绑定手机号")
|
||||||
|
-- return
|
||||||
|
-- end
|
||||||
|
local pw_view = PhonePasswordView.new(function()
|
||||||
|
self:fill_user_info()
|
||||||
|
end)
|
||||||
|
pw_view:Show()
|
||||||
|
end)
|
||||||
|
|
||||||
|
local invitation = self._user.invitation
|
||||||
|
local item_invte = self.user_info:GetChild("item_invte")
|
||||||
|
local ctr_invte = item_invte:GetController("c1")
|
||||||
|
ctr_invte.selectedIndex = invitation
|
||||||
|
ctr_invte.onChanged:Set(function ()
|
||||||
|
ViewUtil.ShowModalWait()
|
||||||
|
local loddyctr = ControllerManager.GetController(LoddyController)
|
||||||
|
local _data = {}
|
||||||
|
_data.type =5
|
||||||
|
_data.invitation = ctr_invte.selectedIndex
|
||||||
|
loddyctr:UpdateUserInfo(_data,function( res)
|
||||||
|
ViewUtil.CloseModalWait()
|
||||||
|
if (res.ReturnCode ==0) then
|
||||||
|
DataManager.SelfUser.invitation = ctr_invte.selectedIndex
|
||||||
|
else
|
||||||
|
ViewUtil.ErrorTip(res.ReturnCode,"提交失败")
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end)
|
||||||
|
|
||||||
|
local acc = self._user.acc
|
||||||
|
self:fill_item("item_wx",acc and "(绑定:"..self._user.nick_name..")" or "",function ()
|
||||||
|
local wx_view = WeChatView.new(function()
|
||||||
|
self:fill_user_info()
|
||||||
|
end)
|
||||||
|
wx_view:Show()
|
||||||
|
end)
|
||||||
|
|
||||||
|
local _btn_logout = self._view:GetChild('btn_logout')
|
||||||
|
_btn_logout.onClick:Set(function()
|
||||||
|
local _curren_msg = MsgWindow.new(self._root_view, '您是否退出当前账号?', MsgWindow.MsgMode.OkAndCancel)
|
||||||
|
_curren_msg.onOk:Add(function()
|
||||||
|
PlayerPrefs.DeleteKey('session_id')
|
||||||
|
PlayerPrefs.Save()
|
||||||
|
RestartGame()
|
||||||
|
end)
|
||||||
|
_curren_msg:Show()
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function M:ChangeToLogin()
|
||||||
|
local _curren_msg = MsgWindow.new(self._root_view, '您是否退出当前账号?', MsgWindow.MsgMode.OkAndCancel)
|
||||||
|
_curren_msg.onOk:Add(function()
|
||||||
|
PlayerPrefs.DeleteKey('session_id')
|
||||||
|
PlayerPrefs.Save()
|
||||||
|
RestartGame()
|
||||||
|
end)
|
||||||
|
_curren_msg:Show()
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:init(url)
|
||||||
|
BaseWindow.init(self,url)
|
||||||
|
self._close_destroy = true
|
||||||
|
self._close_zone = true
|
||||||
|
local view = self._view
|
||||||
|
|
||||||
|
local ctr_nav = view:GetController("nav")
|
||||||
|
--ctr_nav.selectedIndex = self._agent and 1 or 0
|
||||||
|
local ct_state = view:GetController("state")
|
||||||
|
view:GetChild("tex_nickname").text = self._user.nick_name
|
||||||
|
local str_playerid = self._user.account_id
|
||||||
|
view:GetChild("tex_id").text = "ID:"..str_playerid
|
||||||
|
|
||||||
|
|
||||||
|
local btn_head = view:GetChild("btn_head")
|
||||||
|
ImageLoad.Load(self._user.head_url, btn_head._iconObject)
|
||||||
|
btn_head.onClick:Set(function()
|
||||||
|
local user_edit_view = UserEditView.new(function()
|
||||||
|
view:GetChild("tex_nickname").text = self._user.nick_name
|
||||||
|
ImageLoad.Load(self._user.head_url, btn_head._iconObject)
|
||||||
|
self.callback()
|
||||||
|
end)
|
||||||
|
user_edit_view:Show()
|
||||||
|
end)
|
||||||
|
|
||||||
|
local ctr_load = view:GetController("load")
|
||||||
|
local loddyCtr1 = ControllerManager.GetController(LoddyController)
|
||||||
|
loddyCtr1:GetUserInfo(function(res)
|
||||||
|
if res.ReturnCode == 0 then
|
||||||
|
ctr_load.selectedIndex = 1
|
||||||
|
self:fill_user_info()
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
self.user_info = view:GetChild("user_info")
|
||||||
|
end
|
||||||
|
|
||||||
|
return M
|
||||||
|
|
@ -0,0 +1,27 @@
|
||||||
|
--设置窗口对象
|
||||||
|
|
||||||
|
local LobbyMessagesView = {}
|
||||||
|
|
||||||
|
local M = LobbyMessagesView
|
||||||
|
setmetatable(M, {__index = BaseWindow})
|
||||||
|
|
||||||
|
function LobbyMessagesView.new(Fct_UpdateDiamo)
|
||||||
|
local self = setmetatable({}, {__index = M})
|
||||||
|
self.class = 'LobbyMessagesView'
|
||||||
|
self._close_destroy = true
|
||||||
|
self:init('ui://Lobby/Messages')
|
||||||
|
self.UpdateDiamo = Fct_UpdateDiamo
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:init(url)
|
||||||
|
BaseWindow.init(self, url)
|
||||||
|
|
||||||
|
local view = self._view
|
||||||
|
local messageList = view:GetChild('main')
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
return M
|
||||||
|
|
@ -0,0 +1,86 @@
|
||||||
|
--设置窗口对象
|
||||||
|
|
||||||
|
local LobbyPlayerInfoView = {}
|
||||||
|
|
||||||
|
local M = LobbyPlayerInfoView
|
||||||
|
setmetatable(M, { __index = BaseWindow })
|
||||||
|
|
||||||
|
function LobbyPlayerInfoView.new(user, callback)
|
||||||
|
local self = setmetatable({}, { __index = M })
|
||||||
|
self.class = 'LobbyPlayerInfoView'
|
||||||
|
self._close_destroy = true
|
||||||
|
self.user = user
|
||||||
|
self._callback = callback
|
||||||
|
self:init('ui://Lobby/PlayerInfo')
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:init(url)
|
||||||
|
BaseWindow.init(self, url)
|
||||||
|
|
||||||
|
local view = self._view
|
||||||
|
local user = self.user;
|
||||||
|
|
||||||
|
print("================phone=====================")
|
||||||
|
for k, v in pairs(user) do
|
||||||
|
print(string.format("k:%s|v:%s", k, v))
|
||||||
|
end
|
||||||
|
|
||||||
|
--show
|
||||||
|
view:GetChild('name').text = user.nick_name
|
||||||
|
view:GetChild('phone').text = user.phone
|
||||||
|
view:GetChild('id').text = user.account_id
|
||||||
|
view:GetChild('diamo').text = user.diamo
|
||||||
|
view:GetChild('sex').text = user.sex and "男" or "女"
|
||||||
|
ImageLoad.Load(DataManager.SelfUser.head_url, view:GetChild("btn_PlayerHead")._iconObject)
|
||||||
|
|
||||||
|
--change
|
||||||
|
view:GetChild('choose_id').text = user.account_id
|
||||||
|
view:GetChild('choose_diamo').text = user.diamo
|
||||||
|
self.Lable_name = view:GetChild('Lable_name'):GetChild('text')
|
||||||
|
self.Lable_name.text = user.nick_name
|
||||||
|
self.group_sex = view:GetController('group_sex')
|
||||||
|
self.group_sex.selectedIndex = user.sex
|
||||||
|
self.Lable_phone = view:GetChild('Lable_phone'):GetChild('text')
|
||||||
|
local bind = view:GetController('bind')
|
||||||
|
if user.phone then
|
||||||
|
bind.selectedIndex = 1
|
||||||
|
self.Lable_phone.text = user.phone
|
||||||
|
else
|
||||||
|
bind.selectedIndex = 0
|
||||||
|
self.Lable_phone.text = ""
|
||||||
|
end
|
||||||
|
view:GetChild('btn_headChange').onClick:Add(function()
|
||||||
|
ViewUtil.ShowOneChooose("暂不支持更换头像", 1)
|
||||||
|
end)
|
||||||
|
view:GetChild('btn_changePhone').onClick:Add(function()
|
||||||
|
ViewUtil.ShowOneChooose("绑定页面正在优化中,请稍后绑定", 1)
|
||||||
|
end)
|
||||||
|
view:GetChild('btn_bindPhone').onClick:Add(function()
|
||||||
|
ViewUtil.ShowOneChooose("绑定页面正在优化中,请稍后绑定", 1, function()
|
||||||
|
bind.selectedIndex = 1
|
||||||
|
end)
|
||||||
|
end)
|
||||||
|
local type = view:GetController('type')
|
||||||
|
view:GetChild('btn_save').onClick:Add(function()
|
||||||
|
local cnt = 0
|
||||||
|
if self.Lable_name.text ~= user.nick_name then
|
||||||
|
cnt = 1
|
||||||
|
end
|
||||||
|
if self.group_sex.selectedIndex ~= tonumber(user.sex) then
|
||||||
|
cnt = cnt + 2
|
||||||
|
end
|
||||||
|
if cnt > 0 then
|
||||||
|
ViewUtil.ShowOneChooose(
|
||||||
|
string.format("确定要修改%s%s%s吗?", cnt % 2 == 1 and "昵称" or "", cnt == 3 and "、" or "",
|
||||||
|
cnt >= 2 and "性别" or ""),
|
||||||
|
1, function()
|
||||||
|
type.selectedIndex = 0
|
||||||
|
end)
|
||||||
|
else
|
||||||
|
type.selectedIndex = 0
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
return M
|
||||||
|
|
@ -0,0 +1,25 @@
|
||||||
|
--设置窗口对象
|
||||||
|
|
||||||
|
local LobbyRecordView = {}
|
||||||
|
|
||||||
|
local M = LobbyRecordView
|
||||||
|
setmetatable(M, { __index = BaseWindow })
|
||||||
|
|
||||||
|
function LobbyRecordView.new(Fct_UpdateDiamo)
|
||||||
|
local self = setmetatable({}, { __index = M })
|
||||||
|
self.class = 'LobbyRecordView'
|
||||||
|
self._close_destroy = true
|
||||||
|
self:init('ui://Lobby/Record')
|
||||||
|
self.UpdateDiamo = Fct_UpdateDiamo
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:init(url)
|
||||||
|
BaseWindow.init(self, url)
|
||||||
|
|
||||||
|
local view = self._view
|
||||||
|
|
||||||
|
local LbC = ControllerManager.GetCurrenController()
|
||||||
|
end
|
||||||
|
|
||||||
|
return M
|
||||||
|
|
@ -0,0 +1,89 @@
|
||||||
|
--设置窗口对象
|
||||||
|
|
||||||
|
local LobbySettingView = {}
|
||||||
|
|
||||||
|
local M = LobbySettingView
|
||||||
|
setmetatable(M, {__index = BaseWindow})
|
||||||
|
|
||||||
|
function LobbySettingView.new()
|
||||||
|
local self = setmetatable({}, {__index = M})
|
||||||
|
self.class = 'SettingView'
|
||||||
|
self._close_destroy = true
|
||||||
|
self:init('ui://Lobby/Setting')
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:init(url)
|
||||||
|
BaseWindow.init(self, url)
|
||||||
|
|
||||||
|
local view = self._view
|
||||||
|
local slider_sound = view:GetChild('slider_vedio_sound')
|
||||||
|
local slider_music = view:GetChild('slider_vedio_music')
|
||||||
|
local btn_music = view:GetChild('btn_vedio_music')
|
||||||
|
local btn_sound = view:GetChild('btn_vedio_sound')
|
||||||
|
print(GameApplication.Instance.MusicMute)
|
||||||
|
|
||||||
|
slider_sound.value = GameApplication.Instance.SoundValue
|
||||||
|
slider_music.value = GameApplication.Instance.MusicValue
|
||||||
|
|
||||||
|
slider_music.onChanged:Add(function()
|
||||||
|
GameApplication.Instance.MusicValue = slider_music.value
|
||||||
|
btn_music.selected = false
|
||||||
|
GameApplication.Instance.MusicMute = false;
|
||||||
|
end)
|
||||||
|
|
||||||
|
slider_sound.onChanged:Add(function()
|
||||||
|
GameApplication.Instance.SoundValue = slider_sound.value
|
||||||
|
btn_sound.selected = false
|
||||||
|
GameApplication.Instance.SoundMute = false;
|
||||||
|
end)
|
||||||
|
|
||||||
|
btn_sound.onClick:Add(function()
|
||||||
|
GameApplication.Instance.SoundMute = btn_sound.selected;
|
||||||
|
end)
|
||||||
|
|
||||||
|
btn_music.onClick:Add(function()
|
||||||
|
GameApplication.Instance.MusicMute = btn_music.selected;
|
||||||
|
end)
|
||||||
|
|
||||||
|
local _btn_logout = self._view:GetChild('btn_switchAccount')
|
||||||
|
_btn_logout.onClick:Set(function()
|
||||||
|
local _curren_msg = MsgWindow.new(self._root_view, '您是否退出当前账号?', MsgWindow.MsgMode.OkAndCancel)
|
||||||
|
_curren_msg.onOk:Add(function()
|
||||||
|
PlayerPrefs.DeleteKey('session_id')
|
||||||
|
PlayerPrefs.Save()
|
||||||
|
RestartGame()
|
||||||
|
end)
|
||||||
|
_curren_msg:Show()
|
||||||
|
end)
|
||||||
|
|
||||||
|
local btn_quit = view:GetChild('btn_exitAccount')
|
||||||
|
btn_quit.onClick:Set(
|
||||||
|
function()
|
||||||
|
GameApplication.Instance:QuitGameOnUnity();
|
||||||
|
end
|
||||||
|
)
|
||||||
|
--[[
|
||||||
|
|
||||||
|
local _btn_logout = self._view:GetChild('btn_del')
|
||||||
|
_btn_logout.onClick:Set(function()
|
||||||
|
local _curren_msg = MsgWindow.new(self._root_view, '您是否退出当前账号?', MsgWindow.MsgMode.OkAndCancel)
|
||||||
|
_curren_msg.onOk:Add(function()
|
||||||
|
PlayerPrefs.DeleteKey('session_id')
|
||||||
|
PlayerPrefs.Save()
|
||||||
|
RestartGame()
|
||||||
|
end)
|
||||||
|
_curren_msg:Show()
|
||||||
|
end)
|
||||||
|
|
||||||
|
--]]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
return M
|
||||||
|
|
@ -0,0 +1,64 @@
|
||||||
|
--设置窗口对象
|
||||||
|
|
||||||
|
local LobbyShopView = {}
|
||||||
|
|
||||||
|
local M = LobbyShopView
|
||||||
|
setmetatable(M, {__index = BaseWindow})
|
||||||
|
|
||||||
|
local SHOP_LIST = {
|
||||||
|
{
|
||||||
|
num=2000,
|
||||||
|
price=300
|
||||||
|
},
|
||||||
|
{
|
||||||
|
num=1000,
|
||||||
|
price=165
|
||||||
|
},
|
||||||
|
{
|
||||||
|
num=300,
|
||||||
|
price=50
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
function LobbyShopView.new(Fct_UpdateDiamo)
|
||||||
|
local self = setmetatable({}, {__index = M})
|
||||||
|
self.class = 'ShopView'
|
||||||
|
self._close_destroy = true
|
||||||
|
self:init('ui://Lobby/Shop')
|
||||||
|
self.UpdateDiamo = Fct_UpdateDiamo
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:init(url)
|
||||||
|
BaseWindow.init(self, url)
|
||||||
|
|
||||||
|
local view = self._view
|
||||||
|
local shopList = view:GetChild("main")
|
||||||
|
|
||||||
|
for i = 1, #SHOP_LIST do
|
||||||
|
local shopChild = UIPackage.CreateObjectFromURL('ui://Lobby/c_shop_child')
|
||||||
|
shopChild:GetChild('num').text = string.format("%s 张",SHOP_LIST[i].num)
|
||||||
|
local shopBuyBtn = shopChild:GetChild('btn_buy')
|
||||||
|
shopBuyBtn:GetChild('sprite').icon = string.format("ui://Lobby/shop_buy_%s",SHOP_LIST[i].price)
|
||||||
|
shopBuyBtn.onClick:Set(function()
|
||||||
|
local index = i;
|
||||||
|
if false then
|
||||||
|
--发送购买给后端
|
||||||
|
else
|
||||||
|
--假数据
|
||||||
|
print("===================shop====================")
|
||||||
|
print(SHOP_LIST[index].num)
|
||||||
|
print(DataManager.SelfUser.diamo)
|
||||||
|
DataManager.SelfUser.diamo = DataManager.SelfUser.diamo + SHOP_LIST[index].num
|
||||||
|
print(DataManager.SelfUser.diamo)
|
||||||
|
self.UpdateDiamo()
|
||||||
|
end
|
||||||
|
|
||||||
|
end)
|
||||||
|
shopList:AddChild(shopChild)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
return M
|
||||||
|
|
@ -0,0 +1,69 @@
|
||||||
|
local NoticeView = {}
|
||||||
|
local M = NoticeView
|
||||||
|
|
||||||
|
function NoticeView.new(blur_view)
|
||||||
|
setmetatable(M, {__index = BaseWindow})
|
||||||
|
local self = setmetatable({}, {__index = M})
|
||||||
|
self.class = "NoticeView"
|
||||||
|
-- self._blur_view = blur_view
|
||||||
|
self:init("ui://Lobby/pop_notice")
|
||||||
|
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:init(url)
|
||||||
|
BaseWindow.init(self,url)
|
||||||
|
self._close_destroy = true
|
||||||
|
self._close_zone = true
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:FillData(data)
|
||||||
|
if not data then return end
|
||||||
|
self._notices = data
|
||||||
|
local list = self._view:GetChild("list")
|
||||||
|
for i = 1, #data do
|
||||||
|
local info = data[i]
|
||||||
|
local item = list:AddItemFromPool()
|
||||||
|
item:GetChild("title").text = info.name
|
||||||
|
|
||||||
|
if info.type == "NEW" then
|
||||||
|
item:GetChild("icon").url = "ui://27vd145bildu7e"
|
||||||
|
elseif info.type == "ACTIVITY" then
|
||||||
|
item:GetChild("icon").url = "ui://27vd145bildu74"
|
||||||
|
else
|
||||||
|
item:GetChild("icon").url = ""
|
||||||
|
end
|
||||||
|
|
||||||
|
item.onClick:Add(function()
|
||||||
|
self:ShowIndex(i)
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
list.selectedIndex = 0
|
||||||
|
self:ShowIndex(1)
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:ShowIndex(index)
|
||||||
|
local title = self._view:GetChild("tex_title")
|
||||||
|
local pic = self._view:GetChild("img")
|
||||||
|
local content = self._view:GetChild("com_content"):GetChild("tex_content")
|
||||||
|
local notices = self._notices
|
||||||
|
|
||||||
|
if index <= #notices then
|
||||||
|
title.text = notices[index].title
|
||||||
|
content.text = notices[index].content
|
||||||
|
end
|
||||||
|
|
||||||
|
-- pic.text = "<img src=\""..notices[index].picture.."\"></img>"
|
||||||
|
-- pic.text = "<img src=\"".."http://www.w3school.com.cn/i/eg_tulip.jpg".."\"></img>"
|
||||||
|
-- print(pic.text)
|
||||||
|
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:Destroy(flag)
|
||||||
|
-- ImageLoad.Clear(self.class)
|
||||||
|
BaseWindow.Destroy(self, flag)
|
||||||
|
end
|
||||||
|
|
||||||
|
return M
|
||||||
|
|
@ -0,0 +1,119 @@
|
||||||
|
local PhoneBindView = {}
|
||||||
|
|
||||||
|
local M = PhoneBindView
|
||||||
|
|
||||||
|
function PhoneBindView.new(callback)
|
||||||
|
setmetatable(M, {__index = BaseWindow})
|
||||||
|
local self = setmetatable({}, {__index = M})
|
||||||
|
self.class = "PhoneBindView"
|
||||||
|
self._callback = callback
|
||||||
|
self._close_destroy = true
|
||||||
|
local url = "ui://Lobby/win_phone"
|
||||||
|
self:init(url)
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:init(url)
|
||||||
|
BaseWindow.init(self,url)
|
||||||
|
|
||||||
|
if DataManager.SelfUser.phone then
|
||||||
|
local ctr_update = self._view:GetController("update")
|
||||||
|
ctr_update.selectedIndex = 1
|
||||||
|
end
|
||||||
|
|
||||||
|
local btn_getCode = self._view:GetChild("btn_getCode")
|
||||||
|
btn_getCode.onClick:Set(function()
|
||||||
|
self:GetCode()
|
||||||
|
end)
|
||||||
|
|
||||||
|
local btn_ok = self._view:GetChild("btn_ok")
|
||||||
|
btn_ok.onClick:Set(function()
|
||||||
|
self:Bind()
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
--获取验证码
|
||||||
|
function M:GetCode()
|
||||||
|
local phone = self:CheckInputPhone()
|
||||||
|
if not phone then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
local loddyctr = ControllerManager.GetController(LoddyController)
|
||||||
|
loddyctr:GetPhoneCode(phone,function( res)
|
||||||
|
if res.ReturnCode == 0 then
|
||||||
|
self._view:GetController("code").selectedIndex = 1
|
||||||
|
self._left_time = 120
|
||||||
|
UpdateBeat:Add(self.OnUpdate, self)
|
||||||
|
else
|
||||||
|
ViewUtil.ErrorTip(res.ReturnCode, "请输入正确的手机号")
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:OnUpdate()
|
||||||
|
local deltaTime = Time.deltaTime
|
||||||
|
local _left_time = self._left_time
|
||||||
|
if (_left_time > 0) then
|
||||||
|
_left_time = _left_time - deltaTime
|
||||||
|
_left_time = math.max(0, _left_time)
|
||||||
|
local leftTime = math.floor(_left_time)
|
||||||
|
self._view:GetChild("tex_time").text = tostring(leftTime).."后重新发送"
|
||||||
|
self._left_time = _left_time
|
||||||
|
else
|
||||||
|
self._view:GetController("code").selectedIndex=0
|
||||||
|
UpdateBeat:Remove(self.OnUpdate, self)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:Destroy()
|
||||||
|
BaseWindow.Destroy(self)
|
||||||
|
UpdateBeat:Remove(self.OnUpdate, self)
|
||||||
|
end
|
||||||
|
|
||||||
|
--绑定
|
||||||
|
function M:Bind()
|
||||||
|
local phone = self:CheckInputPhone()
|
||||||
|
if not phone then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
local code = self:CheckInputCode()
|
||||||
|
if not code then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
ViewUtil.ShowModalWait(self._root_view,"正在提交...")
|
||||||
|
local loddyctr = ControllerManager.GetController(LoddyController)
|
||||||
|
local _data = {}
|
||||||
|
_data.type =4
|
||||||
|
_data.phone = phone
|
||||||
|
_data.code = code
|
||||||
|
loddyctr:UpdateUserInfo(_data,function( res)
|
||||||
|
ViewUtil.CloseModalWait()
|
||||||
|
if (res.ReturnCode ==0) then
|
||||||
|
DataManager.SelfUser.phone = phone
|
||||||
|
if self._callback then self._callback() end
|
||||||
|
else
|
||||||
|
ViewUtil.ErrorTip(res.ReturnCode,"提交失败")
|
||||||
|
end
|
||||||
|
self:Close()
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:CheckInputPhone()
|
||||||
|
local phone = self._view:GetChild("tex_phone").text
|
||||||
|
if not (string.len(phone) == 11 or string.len(phone) == 12) then
|
||||||
|
ViewUtil.ShowTips("请输入正确的手机号")
|
||||||
|
return
|
||||||
|
end
|
||||||
|
return phone
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:CheckInputCode()
|
||||||
|
local code = self._view:GetChild("tex_code").text
|
||||||
|
if not (string.len(code) == 6) then
|
||||||
|
ViewUtil.ShowTips("请输入正确的验证码")
|
||||||
|
return
|
||||||
|
end
|
||||||
|
return code
|
||||||
|
end
|
||||||
|
|
||||||
|
return M
|
||||||
|
|
@ -0,0 +1,123 @@
|
||||||
|
local PhonePasswordView = {}
|
||||||
|
|
||||||
|
local M = PhonePasswordView
|
||||||
|
|
||||||
|
function PhonePasswordView.new(callback)
|
||||||
|
setmetatable(M, {__index = BaseWindow})
|
||||||
|
local self = setmetatable({}, {__index = M})
|
||||||
|
self.class = "PhonePasswordView"
|
||||||
|
self._callback = callback
|
||||||
|
self._close_destroy = true
|
||||||
|
local url = "ui://Lobby/win_phone_password"
|
||||||
|
self:init(url)
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:init(url)
|
||||||
|
BaseWindow.init(self,url)
|
||||||
|
self.ctr_update = self._view:GetController("update")
|
||||||
|
if DataManager.SelfUser.password then
|
||||||
|
--self.ctr_update.selectedIndex = 1
|
||||||
|
--print("DataManager.SelfUser.account_idDataManager.SelfUser.account_idDataManager.SelfUser.account_id ",DataManager.SelfUser.account_id)
|
||||||
|
--self._view:GetChild("tex_phone").text = DataManager.SelfUser.account_id--ViewUtil.phone_hide(DataManager.SelfUser.phone)
|
||||||
|
end
|
||||||
|
|
||||||
|
self._view:GetChild("tex_phone").text = DataManager.SelfUser.account_id
|
||||||
|
|
||||||
|
local btn_getCode = self._view:GetChild("btn_getCode")
|
||||||
|
btn_getCode.onClick:Set(function()
|
||||||
|
self:GetCode()
|
||||||
|
end)
|
||||||
|
|
||||||
|
local btn_ok = self._view:GetChild("btn_ok")
|
||||||
|
btn_ok.onClick:Set(function()
|
||||||
|
self:Bind()
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
--获取验证码
|
||||||
|
function M:GetCode()
|
||||||
|
local phone = self:CheckInputPhone()
|
||||||
|
if not phone then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
local loddyctr = ControllerManager.GetController(LoddyController)
|
||||||
|
loddyctr:GetPhoneCode(phone,function( res)
|
||||||
|
if res.ReturnCode == 0 then
|
||||||
|
self._view:GetController("code").selectedIndex = 1
|
||||||
|
self._left_time = 120
|
||||||
|
UpdateBeat:Add(self.OnUpdate, self)
|
||||||
|
else
|
||||||
|
ViewUtil.ErrorTip(res.ReturnCode, "请输入正确的手机号")
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:OnUpdate()
|
||||||
|
local deltaTime = Time.deltaTime
|
||||||
|
local _left_time = self._left_time
|
||||||
|
if (_left_time > 0) then
|
||||||
|
_left_time = _left_time - deltaTime
|
||||||
|
_left_time = math.max(0, _left_time)
|
||||||
|
local leftTime = math.floor(_left_time)
|
||||||
|
self._view:GetChild("tex_time").text = tostring(leftTime).."后重新发送"
|
||||||
|
self._left_time = _left_time
|
||||||
|
else
|
||||||
|
self._view:GetController("code").selectedIndex=0
|
||||||
|
UpdateBeat:Remove(self.OnUpdate, self)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:Destroy()
|
||||||
|
BaseWindow.Destroy(self)
|
||||||
|
UpdateBeat:Remove(self.OnUpdate, self)
|
||||||
|
end
|
||||||
|
|
||||||
|
--绑定
|
||||||
|
function M:Bind()
|
||||||
|
|
||||||
|
local tex_passwd = self._view:GetChild("tex_passwd")
|
||||||
|
local password = tex_passwd.text
|
||||||
|
if string.len(password) <6 then
|
||||||
|
ViewUtil.ShowTips("请输入5位以上的密码")
|
||||||
|
return
|
||||||
|
end
|
||||||
|
local _data = {}
|
||||||
|
|
||||||
|
-- if self.ctr_update.selectedIndex == 1 then
|
||||||
|
|
||||||
|
-- local code = self:CheckInputCode()
|
||||||
|
-- if not code then
|
||||||
|
-- return
|
||||||
|
-- end
|
||||||
|
-- _data.phone = DataManager.SelfUser.phone
|
||||||
|
-- _data.code = code
|
||||||
|
-- end
|
||||||
|
ViewUtil.ShowModalWait(self._root_view,"正在提交...")
|
||||||
|
local loddyctr = ControllerManager.GetController(LoddyController)
|
||||||
|
_data.password = password
|
||||||
|
_data.type =3
|
||||||
|
|
||||||
|
loddyctr:UpdateUserInfo(_data,function( res)
|
||||||
|
ViewUtil.CloseModalWait()
|
||||||
|
if (res.ReturnCode ==0) then
|
||||||
|
DataManager.SelfUser.password = "123"
|
||||||
|
if self._callback then self._callback() end
|
||||||
|
else
|
||||||
|
ViewUtil.ErrorTip(res.ReturnCode,"提交失败")
|
||||||
|
end
|
||||||
|
self:Close()
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function M:CheckInputCode()
|
||||||
|
local code = self._view:GetChild("tex_code").text
|
||||||
|
if not (string.len(code) == 6) then
|
||||||
|
ViewUtil.ShowTips("请输入正确的验证码")
|
||||||
|
return
|
||||||
|
end
|
||||||
|
return code
|
||||||
|
end
|
||||||
|
|
||||||
|
return M
|
||||||
|
|
@ -0,0 +1,403 @@
|
||||||
|
-- 排行和战绩窗口
|
||||||
|
-- author:谌建军
|
||||||
|
|
||||||
|
RankView = {}
|
||||||
|
|
||||||
|
|
||||||
|
local M = RankView
|
||||||
|
|
||||||
|
function RankView.new( main_view,video )
|
||||||
|
UIPackage.AddPackage("base/rank/ui/Rank")
|
||||||
|
setmetatable(M, {__index = BaseWindow})
|
||||||
|
local self = setmetatable({}, {__index = M})
|
||||||
|
self.class = "RankView"
|
||||||
|
self._animation = false
|
||||||
|
self._full = true
|
||||||
|
self._full_offset = false
|
||||||
|
self._close_destroy = true
|
||||||
|
self._main_view = main_view
|
||||||
|
self._video = video
|
||||||
|
self._put_map = false
|
||||||
|
self._new_hide = false
|
||||||
|
self._queue = false
|
||||||
|
self:init("ui://Rank/Main")
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:init( url )
|
||||||
|
|
||||||
|
BaseWindow.init(self,url)
|
||||||
|
|
||||||
|
self._view:GetController("tab").selectedIndex = self._video and 1 or 0
|
||||||
|
self._curren_tex = ""
|
||||||
|
self._curren_len = 0
|
||||||
|
local develop_panel = self._view:GetChild("n70")
|
||||||
|
self.tex_roomid = develop_panel:GetChild("tex_roomid")
|
||||||
|
self.tex_roomid.text = ""
|
||||||
|
for i = 0, 9 do
|
||||||
|
local btn = develop_panel:GetChild("btn_" .. i)
|
||||||
|
btn.onClick:Add(function()
|
||||||
|
|
||||||
|
if self._curren_len < 6 then
|
||||||
|
|
||||||
|
self._curren_tex = self._curren_tex .. i
|
||||||
|
self._curren_len = self._curren_len + 1
|
||||||
|
self.tex_roomid.text = self._curren_tex
|
||||||
|
|
||||||
|
if self._curren_len == 6 then
|
||||||
|
|
||||||
|
ViewUtil.ShowModalWait(self._root_view)
|
||||||
|
local loddyCtr1 = ControllerManager.GetController(LoddyController)
|
||||||
|
loddyCtr1:RequestRecordList(function (result)
|
||||||
|
ViewUtil.CloseModalWait()
|
||||||
|
if self._is_destroy then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
if result == Table_Error_code.ERR_TIMEOUT then
|
||||||
|
self:readData()
|
||||||
|
return
|
||||||
|
end
|
||||||
|
if result == 0 then
|
||||||
|
self:InitRecord1(loddyCtr1.recordList, true)
|
||||||
|
end
|
||||||
|
end, self._curren_tex)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
develop_panel:GetChild("btn_del").onClick:Add(function()
|
||||||
|
if self._curren_len > 0 then
|
||||||
|
self._curren_len = self._curren_len - 1
|
||||||
|
self._curren_tex = string.sub(self._curren_tex, 0, self._curren_len)
|
||||||
|
self.tex_roomid.text = self._curren_tex
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
|
develop_panel:GetChild("btn_retype").onClick:Add(function()
|
||||||
|
self._curren_tex = ""
|
||||||
|
self._curren_len = 0
|
||||||
|
self.tex_roomid.text = self._curren_tex
|
||||||
|
end)
|
||||||
|
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:readData()
|
||||||
|
local view = self._view
|
||||||
|
|
||||||
|
local record_list_1 = view:GetChild("n26")
|
||||||
|
record_list_1:RemoveChildrenToPool()
|
||||||
|
|
||||||
|
local loddyCtr1 = ControllerManager.GetController(LoddyController)
|
||||||
|
loddyCtr1:RequestRecordList(function (result)
|
||||||
|
if self._is_destroy then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
if result == Table_Error_code.ERR_TIMEOUT then
|
||||||
|
self:readData()
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
self:InitRecord1(loddyCtr1.recordList)
|
||||||
|
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:Show()
|
||||||
|
BaseWindow.Show(self)
|
||||||
|
UpdateBeat:Remove(self._main_view.OnUpdate, self._main_view)
|
||||||
|
-- self:readData()
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:Destroy()
|
||||||
|
BaseWindow.Destroy(self)
|
||||||
|
UpdateBeat:Add(self._main_view.OnUpdate, self._main_view)
|
||||||
|
end
|
||||||
|
|
||||||
|
local load_head_num = 0
|
||||||
|
function M:InitRecord1(recordList, develop_tool)
|
||||||
|
|
||||||
|
--print("InitRecord1=========")
|
||||||
|
pt(recordList)
|
||||||
|
local main_view = self._view
|
||||||
|
-- 战绩 list
|
||||||
|
local record_list_1, ctr_recored, ctr_no_record
|
||||||
|
if develop_tool then
|
||||||
|
|
||||||
|
ctr_recored = main_view:GetController("developer")
|
||||||
|
ctr_recored.selectedIndex = 1
|
||||||
|
|
||||||
|
record_list_1 = main_view:GetChild("lst_record")
|
||||||
|
local btn_backto_search = main_view:GetChild("btn_backto_search")
|
||||||
|
btn_backto_search.onClick:Set(function()
|
||||||
|
|
||||||
|
ctr_recored.selectedIndex = 0
|
||||||
|
|
||||||
|
self._curren_tex = ""
|
||||||
|
self._curren_len = 0
|
||||||
|
self.tex_roomid.text = ""
|
||||||
|
end)
|
||||||
|
ctr_no_record = self._view:GetController("noRecordData2")
|
||||||
|
else
|
||||||
|
record_list_1 = main_view:GetChild("n26")
|
||||||
|
ctr_no_record = self._view:GetController("noRecordData")
|
||||||
|
end
|
||||||
|
record_list_1:RemoveChildrenToPool()
|
||||||
|
ctr_no_record.selectedIndex = #recordList == 0 and 1 or 0
|
||||||
|
for i=1, #recordList do
|
||||||
|
|
||||||
|
local record_list_item = recordList[i]
|
||||||
|
local total_score_list = record_list_item.TotalScoreList
|
||||||
|
local item = record_list_1:AddItemFromPool()
|
||||||
|
|
||||||
|
local player_item_list = item:GetChild("big_round")
|
||||||
|
local more_person = #total_score_list >= 6
|
||||||
|
if more_person then
|
||||||
|
item:GetController("person_num").selectedIndex = 1
|
||||||
|
else
|
||||||
|
item:GetController("person_num").selectedIndex = 0
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
local game_id = record_list_item.GameId
|
||||||
|
local game_data = ExtendManager.GetGameData(game_id)
|
||||||
|
local room_type_str = record_list_item.GameInfo.name
|
||||||
|
local room_id_str = record_list_item.RoomId
|
||||||
|
local time =tonumber(record_list_item.Time)
|
||||||
|
local room_time_str = os.date("%Y-%m-%d %H:%M", time)
|
||||||
|
local item_score_list = record_list_item.GameTimes
|
||||||
|
local play_back_id = record_list_item.PlayBackId
|
||||||
|
-- 显示 房间号 房间类型 时间
|
||||||
|
item:GetChild("RoomType").asTextField.text = room_type_str
|
||||||
|
item:GetChild("RoomID").asTextField.text = room_id_str
|
||||||
|
item:GetChild("Time").asTextField.text = room_time_str
|
||||||
|
if record_list_item.hp_times and record_list_item.hp_times ~= 0 then
|
||||||
|
item:GetChild("tex_times").text = record_list_item.hp_times .. "倍"
|
||||||
|
else
|
||||||
|
item:GetChild("tex_times").text = ""
|
||||||
|
end
|
||||||
|
player_item_list:RemoveChildrenToPool()
|
||||||
|
local hpOnOff = record_list_item.hpOnOff
|
||||||
|
local hpType = record_list_item.GameInfo.hpType
|
||||||
|
-- 显示 每个玩家的 名字和 分数
|
||||||
|
-- player_list 是聊天室数据
|
||||||
|
local player_list = {}
|
||||||
|
for j=1,#total_score_list do
|
||||||
|
local player_list_item = total_score_list[j]
|
||||||
|
local player_item = player_item_list:AddItemFromPool()
|
||||||
|
player_item:GetChild("n0").text = player_list_item.Name
|
||||||
|
local player_score = player_item:GetChild("n1")
|
||||||
|
local score = player_list_item.Score
|
||||||
|
if hpOnOff == 1 and hpType > 1 then
|
||||||
|
score = score / 10
|
||||||
|
end
|
||||||
|
if score < 0 then
|
||||||
|
player_item:GetController("num_color").selectedIndex = 1
|
||||||
|
else
|
||||||
|
player_item:GetController("num_color").selectedIndex = 0
|
||||||
|
end
|
||||||
|
|
||||||
|
player_score.text = score >= 0 and "+"..score or score
|
||||||
|
player_list[j] = {}
|
||||||
|
player_list[j].id = player_list_item.Id
|
||||||
|
player_list[j].score = score
|
||||||
|
player_list[j].house = 0
|
||||||
|
player_list[j].nick = player_list_item.Name
|
||||||
|
end
|
||||||
|
-- 点击事件
|
||||||
|
item.onClick:Add(function ()
|
||||||
|
|
||||||
|
self:ShowRecord2(play_back_id, room_type_str, room_id_str, room_time_str,item_score_list, game_id, develop_tool, record_list_item)
|
||||||
|
end)
|
||||||
|
-- 分享
|
||||||
|
item:GetChild("btn_screenshot").onClick:Set(function()
|
||||||
|
ViewUtil.ShowModalWait(self._view, "正在分享...")
|
||||||
|
local result_view = UIPackage.CreateObjectFromURL("ui://Rank/ResultView")
|
||||||
|
result_view.visible = false
|
||||||
|
self._view:AddChild(result_view)
|
||||||
|
result_view:GetChild("tex_roomnum").text = room_id_str .. " " .. room_type_str
|
||||||
|
result_view:GetChild("tex_data").text = room_time_str
|
||||||
|
result_view:GetChild("btn_confirm").onClick:Set(function() result_view:Dispose() end)
|
||||||
|
local lst_p = result_view:GetChild("list_result")
|
||||||
|
local lst_p2 = result_view:GetChild("list_result2")
|
||||||
|
load_head_num = #total_score_list
|
||||||
|
local count = #total_score_list
|
||||||
|
for j = 1, count do
|
||||||
|
local p = total_score_list[j]
|
||||||
|
local item = nil
|
||||||
|
if count < 6 or (count >= 6 and j <= math.ceil(count / 2)) then
|
||||||
|
item = lst_p:AddItemFromPool()
|
||||||
|
else
|
||||||
|
item = lst_p2:AddItemFromPool()
|
||||||
|
end
|
||||||
|
item:GetChild("name").text = p.Name
|
||||||
|
local score = p.Score
|
||||||
|
if hpOnOff == 1 and hpType > 1 then
|
||||||
|
score = score / 10
|
||||||
|
end
|
||||||
|
item:GetChild("score").text = score
|
||||||
|
if score < 0 then item:GetController("di").selectedIndex = 1 end
|
||||||
|
if p.Portrait and p.Portrait ~= "" then
|
||||||
|
ImageLoad.Load(p.Portrait, item:GetChild("n9")._iconObject, 1, function( ... )
|
||||||
|
load_head_num = load_head_num - 1
|
||||||
|
end)
|
||||||
|
else
|
||||||
|
load_head_num = load_head_num - 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
coroutine.start(function ( ... )
|
||||||
|
local left_time = 4
|
||||||
|
while (true) do
|
||||||
|
if load_head_num == 0 or left_time == 0 then
|
||||||
|
result_view.visible = true
|
||||||
|
coroutine.wait(0.2)
|
||||||
|
ShareScreenShotWithOption(function()
|
||||||
|
result_view:Dispose()
|
||||||
|
end)
|
||||||
|
ViewUtil.CloseModalWait()
|
||||||
|
break
|
||||||
|
end
|
||||||
|
coroutine.wait(1)
|
||||||
|
left_time = left_time - 1
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end)
|
||||||
|
item:GetChild("btn_link").onClick:Set(function()
|
||||||
|
local group_id = record_list_item.group_id and tonumber(record_list_item.group_id) or 0
|
||||||
|
ShareChatRoom(record_list_item.RoomId, tostring(os.time()), #item_score_list, room_type_str, group_id, player_list, self._root_view)
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:ShowRecord2(playback_id, room_type, room_id, room_time, item_score, game_id, develop_tool, record_item)
|
||||||
|
local record_list_2
|
||||||
|
if develop_tool then
|
||||||
|
record_list_2 = self._view:GetChild("lst_round")
|
||||||
|
self._view:GetController("developer").selectedIndex = 2
|
||||||
|
else
|
||||||
|
record_list_2 = self._view:GetChild("n29")
|
||||||
|
self._view:GetController("Record").selectedIndex = 1
|
||||||
|
end
|
||||||
|
|
||||||
|
local hpOnOff = record_item.hpOnOff
|
||||||
|
local hpType = record_item.GameInfo.hpType
|
||||||
|
|
||||||
|
record_list_2:RemoveChildrenToPool()
|
||||||
|
for i=1,#item_score do
|
||||||
|
local item_player_info = item_score[i]
|
||||||
|
local play_back_id = item_player_info.PlayBackId
|
||||||
|
local player_score = item_player_info.PlayerList
|
||||||
|
|
||||||
|
local record_item_2 = record_list_2:AddItemFromPool("ui://Rank/Record_Item_2")
|
||||||
|
local player_item_list = record_item_2:GetChild("List")
|
||||||
|
local more_person = #player_score >= 6
|
||||||
|
|
||||||
|
if more_person then
|
||||||
|
record_item_2:GetController("person_num").selectedIndex = 1
|
||||||
|
else
|
||||||
|
record_item_2:GetController("person_num").selectedIndex = 0
|
||||||
|
end
|
||||||
|
|
||||||
|
-- 设置房间信息
|
||||||
|
record_item_2:GetChild("RoomType").text = room_type
|
||||||
|
record_item_2:GetChild("RoomID").text = room_id
|
||||||
|
--record_item_2:GetChild("Time").text = room_time
|
||||||
|
record_item_2:GetChild("Number").text = tostring(i)
|
||||||
|
|
||||||
|
player_item_list:RemoveChildrenToPool()
|
||||||
|
for j=1,#player_score do
|
||||||
|
|
||||||
|
local player_item = player_item_list:AddItemFromPool()
|
||||||
|
player_item:GetChild("n0").text = player_score[j].Name
|
||||||
|
local player_score_text = player_item:GetChild("n1")
|
||||||
|
local score = player_score[j].Score
|
||||||
|
if hpOnOff == 1 and hpType > 1 then
|
||||||
|
score = score / 10
|
||||||
|
end
|
||||||
|
if score < 0 then
|
||||||
|
player_item:GetController("num_color").selectedIndex = 1
|
||||||
|
else
|
||||||
|
player_item:GetController("num_color").selectedIndex = 0
|
||||||
|
end
|
||||||
|
player_score_text.text = score >= 0 and "+"..score or score
|
||||||
|
|
||||||
|
end
|
||||||
|
local btn_play_back = record_item_2:GetChild("btn_play_back")
|
||||||
|
btn_play_back.onClick:Set(function()
|
||||||
|
--print("点击进入回放=====")
|
||||||
|
if DataManager.SelfUser.playback[playback_id] ~= nil and DataManager.SelfUser.playback[playback_id][i] ~= nil then
|
||||||
|
--print("1111111111111111")
|
||||||
|
local room = ExtendManager.GetExtendConfig(game_id):NewRoom()
|
||||||
|
DataManager.CurrenRoom = room
|
||||||
|
room.game_id = game_id
|
||||||
|
local extend = ExtendManager.GetExtendConfig(game_id)
|
||||||
|
extend:FillPlayBackData(DataManager.SelfUser.playback[playback_id][i])
|
||||||
|
if not room.self_player then
|
||||||
|
room.self_player = room:GetPlayerBySeat(1)
|
||||||
|
end
|
||||||
|
local main = self:GenaratePlayBack(ViewManager.View_PlayBack, game_id)
|
||||||
|
main._currentId = playback_id
|
||||||
|
main._currentRound = i
|
||||||
|
main._totalRound = #item_score
|
||||||
|
main:FillRoomData(DataManager.SelfUser.playback[playback_id][i])
|
||||||
|
else
|
||||||
|
--print("2222222222222")
|
||||||
|
ViewUtil.ShowModalWait(self._view)
|
||||||
|
local _data = {}
|
||||||
|
_data["military_id"] = playback_id
|
||||||
|
_data["round"] = tostring(i)
|
||||||
|
local loddyCtr1 = ControllerManager.GetController(LoddyController)
|
||||||
|
loddyCtr1:RequestPlayBack(_data,function(code,data)
|
||||||
|
ViewUtil.CloseModalWait()
|
||||||
|
if code == 0 then
|
||||||
|
if DataManager.SelfUser.playback[playback_id] ~= nil then
|
||||||
|
DataManager.SelfUser.playback[playback_id][i] = data
|
||||||
|
else
|
||||||
|
local playback_data = {}
|
||||||
|
playback_data[i] = data
|
||||||
|
DataManager.SelfUser.playback[playback_id] = playback_data
|
||||||
|
end
|
||||||
|
|
||||||
|
local main = self:GenaratePlayBack(ViewManager.View_PlayBack, game_id)
|
||||||
|
main._currentId = playback_id
|
||||||
|
main._currentRound = i
|
||||||
|
main._totalRound = #item_score
|
||||||
|
--print(main)
|
||||||
|
main:FillRoomData(data)
|
||||||
|
elseif code == 25 then
|
||||||
|
ViewUtil.ErrorTip(code, "回放未找到!")
|
||||||
|
btn_play_back.grayed = true
|
||||||
|
end
|
||||||
|
end, record_item.GameInfo)
|
||||||
|
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:GenaratePlayBack(id, game_id, ...)
|
||||||
|
local tem =nil
|
||||||
|
local dview_class = nil
|
||||||
|
if not dview_class then
|
||||||
|
local exconfig = ExtendManager.GetExtendConfig(game_id)
|
||||||
|
dview_class = exconfig:GetView(id)
|
||||||
|
--print(dview_class)
|
||||||
|
end
|
||||||
|
if not dview_class then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
local arg = {...}
|
||||||
|
tem = dview_class.new(...)
|
||||||
|
tem.Id = id
|
||||||
|
tem:Show()
|
||||||
|
return tem
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:Destroy()
|
||||||
|
BaseWindow.Destroy(self)
|
||||||
|
UIPackage.RemovePackage("base/rank/ui/Rank")
|
||||||
|
end
|
||||||
|
|
||||||
|
return M
|
||||||
|
|
@ -0,0 +1,143 @@
|
||||||
|
--实名认证窗口
|
||||||
|
|
||||||
|
local RealAddressView = {}
|
||||||
|
|
||||||
|
local M = RealAddressView
|
||||||
|
|
||||||
|
function RealAddressView.new(type,callback)
|
||||||
|
setmetatable(M, {__index = BaseWindow})
|
||||||
|
local self = setmetatable({}, {__index = M})
|
||||||
|
self.class = "RealAddressView"
|
||||||
|
self._type = type
|
||||||
|
self._callback = callback
|
||||||
|
self._close_destroy = true
|
||||||
|
self:init("ui://Lobby/win_real_address")
|
||||||
|
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:init(url)
|
||||||
|
BaseWindow.init(self,url)
|
||||||
|
local view = self._view
|
||||||
|
|
||||||
|
local btn_real = view:GetChild("btn_real")
|
||||||
|
btn_real.onClick:Set(function()
|
||||||
|
self:real_action()
|
||||||
|
end)
|
||||||
|
|
||||||
|
local btn_address = view:GetChild("btn_address")
|
||||||
|
btn_address.onClick:Set(function ()
|
||||||
|
self:address_action()
|
||||||
|
end)
|
||||||
|
|
||||||
|
self.ctr_update = view:GetController("update")
|
||||||
|
|
||||||
|
local ctr_nav = view:GetController("nav")
|
||||||
|
ctr_nav.onChanged:Set(function()
|
||||||
|
if ctr_nav.selectedIndex ==0 then
|
||||||
|
self:fill_real()
|
||||||
|
else
|
||||||
|
local user = DataManager.SelfUser
|
||||||
|
if user.address then
|
||||||
|
self._view:GetChild("tex_address").text = user.address
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
|
if self._type == 0 then
|
||||||
|
self:fill_real()
|
||||||
|
end
|
||||||
|
ctr_nav.selectedIndex = self._type
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:fill_real()
|
||||||
|
local user = DataManager.SelfUser
|
||||||
|
if user.real_info then
|
||||||
|
self.ctr_update.selectedIndex = 1
|
||||||
|
self._view:GetChild("tex_name1").text ="姓名:".. user.real_info.name
|
||||||
|
self._view:GetChild("tex_identity1").text = "身份证号:"..ViewUtil.identity_hide(user.real_info.identity)
|
||||||
|
else
|
||||||
|
self.ctr_update.selectedIndex = 0
|
||||||
|
end
|
||||||
|
end
|
||||||
|
function M:SetCallBack(callback)
|
||||||
|
self._CB = callback
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:real_action()
|
||||||
|
local check,str = self:CheckInputValidity()
|
||||||
|
if not check then
|
||||||
|
ViewUtil.ShowTips(str)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
ViewUtil.ShowModalWait(self._root_view,"正在提交认证...")
|
||||||
|
local loddyctr = ControllerManager.GetController(LoddyController)
|
||||||
|
local _data = {}
|
||||||
|
_data.type =1
|
||||||
|
local real_info = {}
|
||||||
|
real_info.name =self._view:GetChild("tex_name").text
|
||||||
|
real_info.identity = self._view:GetChild("tex_identity").text
|
||||||
|
_data.real_info = real_info
|
||||||
|
loddyctr:UpdateUserInfo(_data,function( res)
|
||||||
|
ViewUtil.CloseModalWait()
|
||||||
|
if (res.ReturnCode ==0) then
|
||||||
|
DataManager.SelfUser.real_info = real_info
|
||||||
|
if self._callback then self._callback() end
|
||||||
|
else
|
||||||
|
ViewUtil.ErrorTip(res.ReturnCode, "认证失败,请重试")
|
||||||
|
end
|
||||||
|
self:Close()
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:CheckInputValidity()
|
||||||
|
local name = self._view:GetChild("tex_name").text
|
||||||
|
local id = self._view:GetChild("tex_identity").text
|
||||||
|
|
||||||
|
if name then
|
||||||
|
local l = string.len(name)
|
||||||
|
if l == 0 then return false, "请输入名字" end
|
||||||
|
-- 中文长度是3
|
||||||
|
if l == 3 then return false, "名字过短" end
|
||||||
|
for i = 1, l do
|
||||||
|
local c = string.byte(string.sub(name, i, i))
|
||||||
|
--if not ((65 <= c and c <= 90) or (97 <= c and c <= 122) or c > 127) then
|
||||||
|
if not (c > 127) then
|
||||||
|
return false, "名字中不能包含英文、数字或特殊符号"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if id then
|
||||||
|
local l = string.len(id)
|
||||||
|
if l ~= 18 then return false, "请输入18位身份证号码" end
|
||||||
|
if not (tonumber(id) or string.sub(id,18,18) == "X") then
|
||||||
|
return false, "请输入正确的身份证号码"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:address_action()
|
||||||
|
local tex_address = self._view:GetChild("tex_address").text
|
||||||
|
if string.len(tex_address) <=0 then
|
||||||
|
ViewUtil.ShowTips("请输入详细地址")
|
||||||
|
return
|
||||||
|
end
|
||||||
|
ViewUtil.ShowModalWait(self._root_view,"正在提交...")
|
||||||
|
local loddyctr = ControllerManager.GetController(LoddyController)
|
||||||
|
local _data = {}
|
||||||
|
_data.type =2
|
||||||
|
_data.address = tex_address
|
||||||
|
loddyctr:UpdateUserInfo(_data,function( res)
|
||||||
|
ViewUtil.CloseModalWait()
|
||||||
|
if (res.ReturnCode ==0) then
|
||||||
|
DataManager.SelfUser.address = _data.address
|
||||||
|
if self._callback then self._callback() end
|
||||||
|
else
|
||||||
|
ViewUtil.ErrorTip(res.ReturnCode,"提示失败")
|
||||||
|
end
|
||||||
|
self:Close()
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
return M
|
||||||
|
|
@ -0,0 +1,52 @@
|
||||||
|
--修改玩家昵称头像
|
||||||
|
local EditPortraitView = import(".EditPortraitView")
|
||||||
|
local EditNickView = import(".EditNickView")
|
||||||
|
|
||||||
|
local UserEditView = {}
|
||||||
|
|
||||||
|
local M = UserEditView
|
||||||
|
|
||||||
|
function UserEditView.new(callback)
|
||||||
|
setmetatable(M, {__index = BaseWindow})
|
||||||
|
local self = setmetatable({}, {__index = M})
|
||||||
|
self.class = "UserEditView"
|
||||||
|
self._callback = callback
|
||||||
|
self._close_destroy = true
|
||||||
|
self:init("ui://Lobby/win_user_edit")
|
||||||
|
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:init(url)
|
||||||
|
BaseWindow.init(self,url)
|
||||||
|
|
||||||
|
local btn_head = self._view:GetChild("btn_head")
|
||||||
|
ImageLoad.Load(DataManager.SelfUser.head_url, btn_head._iconObject)
|
||||||
|
|
||||||
|
local tex_nick = self._view:GetChild("tex_nick")
|
||||||
|
tex_nick.text = DataManager.SelfUser.nick_name
|
||||||
|
|
||||||
|
local tex_id = self._view:GetChild("tex_id")
|
||||||
|
tex_id.text = string.format("玩家ID:%s", DataManager.SelfUser.account_id)
|
||||||
|
|
||||||
|
local btn_edit_nick = self._view:GetChild("btn_edit_nick")
|
||||||
|
btn_edit_nick.onClick:Set(function()
|
||||||
|
local edit_nick_view = EditNickView.new(function()
|
||||||
|
tex_nick.text = DataManager.SelfUser.nick_name
|
||||||
|
self._callback()
|
||||||
|
end)
|
||||||
|
edit_nick_view:Show()
|
||||||
|
end)
|
||||||
|
|
||||||
|
local btn_edit_portrait = self._view:GetChild("btn_edit_portrait")
|
||||||
|
btn_edit_portrait.onClick:Set(function()
|
||||||
|
-- local edit_portrait_view = EditPortraitView.new(function()
|
||||||
|
-- ImageLoad.Load(DataManager.SelfUser.head_url, btn_head._iconObject)
|
||||||
|
-- --print(DataManager.SelfUser.head_url)
|
||||||
|
-- self._callback()
|
||||||
|
-- end)
|
||||||
|
-- edit_portrait_view:Show()
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
return M
|
||||||
|
|
@ -0,0 +1,79 @@
|
||||||
|
-- 同步微信信息
|
||||||
|
|
||||||
|
local WeChatView = {}
|
||||||
|
|
||||||
|
local M = WeChatView
|
||||||
|
|
||||||
|
function WeChatView.new(callback)
|
||||||
|
setmetatable(M, {__index = BaseWindow})
|
||||||
|
local self = setmetatable({}, {__index = M})
|
||||||
|
self.class = "WeChatView"
|
||||||
|
self._close_destroy = true
|
||||||
|
self._close_zone = true
|
||||||
|
self._callback =callback
|
||||||
|
self:init("ui://Lobby/win_user_wx")
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:init(url)
|
||||||
|
BaseWindow.init(self,url)
|
||||||
|
|
||||||
|
local btn_ok = self._view:GetChild("btn_ok")
|
||||||
|
btn_ok.onClick:Set(function ()
|
||||||
|
ViewUtil.ShowModalWait(self._root_view,"正在同步数据...")
|
||||||
|
GameApplication.Instance:WXLogin(handler(self,self.WXCallBack))
|
||||||
|
end)
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:WXCallBack(result,data)
|
||||||
|
|
||||||
|
if (not result) or result ~= 0 then
|
||||||
|
if result == 10 then
|
||||||
|
ViewUtil.ShowModalWait(self._root_view)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
ViewUtil.CloseModalWait()
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
if not data then
|
||||||
|
ViewUtil.CloseModalWait()
|
||||||
|
return
|
||||||
|
end
|
||||||
|
local jd = json.decode(data)
|
||||||
|
local headurl = jd["headimgurl"]
|
||||||
|
local unionid = jd["unionid"]
|
||||||
|
local sex = jd["sex"]
|
||||||
|
if (sex == 0) then sex = 1 end
|
||||||
|
local nickname = jd["nickname"]
|
||||||
|
|
||||||
|
if not unionid or string.len(unionid)<1 then
|
||||||
|
ViewUtil.CloseModalWait()
|
||||||
|
return
|
||||||
|
end
|
||||||
|
local _data = {}
|
||||||
|
_data.type =6
|
||||||
|
_data["acc"] = unionid
|
||||||
|
_data["nick"] = nickname
|
||||||
|
_data["sex"] = sex
|
||||||
|
_data["portrait"] = headurl
|
||||||
|
local loddyctr = ControllerManager.GetController(LoddyController)
|
||||||
|
loddyctr:UpdateUserInfo(_data,function( res)
|
||||||
|
ViewUtil.CloseModalWait()
|
||||||
|
if (res.ReturnCode ==0) then
|
||||||
|
local user = DataManager.SelfUser
|
||||||
|
user.acc = unionid
|
||||||
|
user.nick_name = nickname
|
||||||
|
user.sex = sex
|
||||||
|
user.head_url = headurl
|
||||||
|
if self._callback then self._callback() end
|
||||||
|
else
|
||||||
|
ViewUtil.ErrorTip(res.ReturnCode, "同步失败,请重试")
|
||||||
|
end
|
||||||
|
self:Close()
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
return M
|
||||||
|
|
@ -0,0 +1,497 @@
|
||||||
|
--大厅View对象
|
||||||
|
--author:--
|
||||||
|
local JoinRoomView = import(".Lobby.JoinRoomView")
|
||||||
|
local LobbySettingView = import(".Lobby.LobbySettingView")
|
||||||
|
local LobbyShopView = import(".Lobby.LobbyShopView")
|
||||||
|
local LobbyAuthenticateView = import(".Lobby.LobbyAuthenticateView")
|
||||||
|
local LobbyMessagesView = import(".Lobby.LobbyMessagesView")
|
||||||
|
local LobbyRecordView = import(".Lobby.LobbyRecordView")
|
||||||
|
local LobbyPlayerInfoView = import(".Lobby.LobbyPlayerInfoView")
|
||||||
|
local CreatePlayView = import(".Family.CreatePlayView")
|
||||||
|
|
||||||
|
local CreateRoomView = import(".Lobby.CreateRoomView")
|
||||||
|
local RankView = import(".Lobby.RankView")
|
||||||
|
local GroupMainView = import(".NewGroup.GroupMainView")
|
||||||
|
local NoticeView = import(".Lobby.NoticeView")
|
||||||
|
local HeadView = import(".Lobby.LobbyHeadView")
|
||||||
|
local PhoneBindView = import(".Lobby.PhoneBindView")
|
||||||
|
local RealAddressView = import(".Lobby.RealAddressView")
|
||||||
|
local LobbyHeadView = import(".Lobby.LobbyHeadView")
|
||||||
|
|
||||||
|
LobbyView = {}
|
||||||
|
|
||||||
|
local M = {}
|
||||||
|
|
||||||
|
function LobbyView.new()
|
||||||
|
-- print("new lobbyView!!!!")
|
||||||
|
setmetatable(M, { __index = BaseView })
|
||||||
|
local self = setmetatable({}, { __index = M })
|
||||||
|
self.class = "LobbyView"
|
||||||
|
|
||||||
|
UIPackage.AddPackage("base/lobby/ui/Lobby")
|
||||||
|
self.lobby_pause_time = 0
|
||||||
|
self._full = true
|
||||||
|
self:InitView("ui://Lobby/Main_New")
|
||||||
|
-- self._close_destroy = false
|
||||||
|
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:InitView(url)
|
||||||
|
-- print("init lobbyView!!!!")
|
||||||
|
BaseView.InitView(self, url)
|
||||||
|
self._full_offset = false
|
||||||
|
local view = self._view
|
||||||
|
|
||||||
|
local btn_joinroom = self._view:GetChild("btn_join")
|
||||||
|
btn_joinroom.onClick:Add(handler(self, self.OnJoinRoomAction))
|
||||||
|
|
||||||
|
local btn_setting = self._view:GetChild("btn_setting")
|
||||||
|
btn_setting.onClick:Set(handler(self, function()
|
||||||
|
local settingView = LobbySettingView.new()
|
||||||
|
settingView:Show()
|
||||||
|
end))
|
||||||
|
|
||||||
|
local btn_shop = self._view:GetChild("btn_shop")
|
||||||
|
btn_shop.onClick:Add(handler(self, function()
|
||||||
|
local shopView = LobbyShopView.new(function()
|
||||||
|
ViewUtil.ShowBannerOnScreenCenter("该功能还会开放,敬请期待")
|
||||||
|
-- self:ShowPlayerInfo(1, DataManager.SelfUser.diamo, 1)
|
||||||
|
end)
|
||||||
|
shopView:Show()
|
||||||
|
end))
|
||||||
|
|
||||||
|
local btn_authenticate = self._view:GetChild("btn_authenticate")
|
||||||
|
btn_authenticate.onClick:Add(handler(self, function()
|
||||||
|
local authenticateView = LobbyAuthenticateView.new()
|
||||||
|
authenticateView:Show()
|
||||||
|
end))
|
||||||
|
|
||||||
|
local btn_notice = self._view:GetChild("btn_notice")
|
||||||
|
|
||||||
|
btn_notice.onClick:Set(function()
|
||||||
|
local noticeView = LobbyMessagesView.new(self._root_view)
|
||||||
|
-- noticeView:FillData(DataManager.SelfUser.notices.data)
|
||||||
|
noticeView:Show()
|
||||||
|
end)
|
||||||
|
|
||||||
|
local btn_record = self._view:GetChild("btn_record")
|
||||||
|
btn_record.onClick:Add(handler(self, function()
|
||||||
|
local lobbyRecordView = LobbyRecordView.new(self, true)
|
||||||
|
lobbyRecordView:Show()
|
||||||
|
end))
|
||||||
|
btn_record.displayObject.gameObject:SetActive(true)
|
||||||
|
|
||||||
|
local btn_gamePlay = self._view:GetChild("btn_gamePlay")
|
||||||
|
btn_gamePlay.onClick:Add(function()
|
||||||
|
ViewUtil.ErrorTip(self._view, "该功能还会开放,敬请期待")
|
||||||
|
end)
|
||||||
|
|
||||||
|
local btn_more = self._view:GetChild("btn_more")
|
||||||
|
btn_more.onClick:Add(function()
|
||||||
|
ViewUtil.ErrorTip(self._view, "该功能还会开放,敬请期待")
|
||||||
|
end)
|
||||||
|
|
||||||
|
local btn_family = self._view:GetChild("btn_family")
|
||||||
|
btn_family.onClick:Add(function()
|
||||||
|
ControllerManager.ChangeController(NewGroupController)
|
||||||
|
ViewManager.ChangeView(ViewManager.View_Family)
|
||||||
|
end)
|
||||||
|
|
||||||
|
-- local btn_createRoom = self._view:GetChild("btn_createRoom")
|
||||||
|
-- btn_createRoom.onClick:Add(function()
|
||||||
|
-- local createPlayView = CreatePlayView.new()
|
||||||
|
|
||||||
|
-- createPlayView:Show()
|
||||||
|
-- end)
|
||||||
|
|
||||||
|
local createRoomBtn = self._view:GetChild("btn_createRoom")
|
||||||
|
createRoomBtn.touchable = true
|
||||||
|
createRoomBtn.onClick:Set(function()
|
||||||
|
local _createRoomView = CreateRoomView.new(1)
|
||||||
|
_createRoomView.onCeateRoom = function()
|
||||||
|
ViewManager.ChangeView(ViewManager.View_Main, DataManager.CurrenRoom.game_id)
|
||||||
|
end
|
||||||
|
_createRoomView:Show()
|
||||||
|
end)
|
||||||
|
|
||||||
|
local btn_diamo = self._view:GetChild("btn_diamo")
|
||||||
|
btn_diamo.onClick:Add(function()
|
||||||
|
ViewUtil.ErrorTip(self._view, string.format("当前房卡一共%s张", DataManager.SelfUser.diamo))
|
||||||
|
end)
|
||||||
|
|
||||||
|
local btn_customerService = self._view:GetChild("btn_customerService")
|
||||||
|
btn_customerService.onClick:Add(function()
|
||||||
|
ViewUtil.ShowModalWait(self._root_view, "正在跳转微信中......")
|
||||||
|
coroutine.start(function()
|
||||||
|
coroutine.wait(3)
|
||||||
|
ViewUtil.CloseModalWait()
|
||||||
|
ViewUtil.ShowBannerOnScreenCenter("微信跳转失败")
|
||||||
|
end)
|
||||||
|
end)
|
||||||
|
|
||||||
|
local btn_invite = self._view:GetChild("btn_invite")
|
||||||
|
btn_invite.onClick:Add(function()
|
||||||
|
ViewUtil.ShowOneChooose("下载地址已复制,请到浏览器粘贴", 1)
|
||||||
|
end)
|
||||||
|
|
||||||
|
local btn_head = view:GetChild("btn_head")
|
||||||
|
ImageLoad.Load(DataManager.SelfUser.head_url, btn_head._iconObject)
|
||||||
|
btn_head.onClick:Set(function()
|
||||||
|
-- local headView = HeadView.new(DataManager.SelfUser, nil, function()
|
||||||
|
-- view:GetChild("tex_name").text = DataManager.SelfUser.nick_name
|
||||||
|
-- ImageLoad.Load(DataManager.SelfUser.head_url, btn_head._iconObject)
|
||||||
|
-- end)
|
||||||
|
-- headView:Show()
|
||||||
|
local lobbyPlayerInfoView = LobbyPlayerInfoView.new(DataManager.SelfUser, function()
|
||||||
|
ImageLoad.Load(DataManager.SelfUser.head_url, btn_head._iconObject)
|
||||||
|
end)
|
||||||
|
lobbyPlayerInfoView:Show()
|
||||||
|
end)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
local btn_teamwork = view:GetChild("btn_teamwork")
|
||||||
|
btn_teamwork.onClick:Set(function()
|
||||||
|
-- local headView = HeadView.new(DataManager.SelfUser, nil, function()
|
||||||
|
-- view:GetChild("tex_name").text = DataManager.SelfUser.nick_name
|
||||||
|
-- ImageLoad.Load(DataManager.SelfUser.head_url, btn_head._iconObject)
|
||||||
|
-- end)
|
||||||
|
-- headView:Show()
|
||||||
|
local lobbyHeadView = LobbyHeadView.new(DataManager.SelfUser, DataManager.SelfUser.agent, function()
|
||||||
|
ImageLoad.Load(DataManager.SelfUser.head_url, btn_head._iconObject)
|
||||||
|
end)
|
||||||
|
lobbyHeadView:Show()
|
||||||
|
end)
|
||||||
|
|
||||||
|
view:GetChild("tex_name").text = DataManager.SelfUser.nick_name
|
||||||
|
view:GetChild("tex_id").text = tostring(DataManager.SelfUser.account_id)
|
||||||
|
|
||||||
|
view:GetChild("btn_diamo"):GetChild("num").text = tostring(DataManager.SelfUser.diamo)
|
||||||
|
|
||||||
|
--btn_joinroom.displayObject.gameObject:SetActive(false)
|
||||||
|
|
||||||
|
--未知 ,原来未启用,未测试
|
||||||
|
-- local btn_record = self._view:GetChild("btn_record")
|
||||||
|
-- --[[ btn_record.onClick:Set(function()
|
||||||
|
-- local headView = HeadView.new(DataManager.SelfUser,true)
|
||||||
|
-- headView:Show()
|
||||||
|
-- end)--]]
|
||||||
|
-- btn_record.displayObject.gameObject:SetActive(false)
|
||||||
|
|
||||||
|
--录像,原来未启用,未测试
|
||||||
|
-- local btn_video = self._view:GetChild("btn_video")
|
||||||
|
-- --[[btn_video.onClick:Set(function ()
|
||||||
|
-- local _rankView = RankView.new(self,true)
|
||||||
|
-- _rankView:Show()
|
||||||
|
-- end)--]]
|
||||||
|
-- btn_video.displayObject.gameObject:SetActive(false)
|
||||||
|
|
||||||
|
local btn_exit = self._view:GetChild("btn_exit")
|
||||||
|
btn_exit.onClick:Set(handler(self, function()
|
||||||
|
local _curren_msg = MsgWindow.new(self._root_view, '确认退出游戏', MsgWindow.MsgMode.OkAndCancel)
|
||||||
|
_curren_msg.onOk:Add(function()
|
||||||
|
Application.Quit()
|
||||||
|
end)
|
||||||
|
_curren_msg:Show()
|
||||||
|
end))
|
||||||
|
|
||||||
|
--可能是我的好友,未调测
|
||||||
|
-- local lst_userBG = self._view:GetChild("n118")
|
||||||
|
-- lst_userBG.displayObject.gameObject:SetActive(false)
|
||||||
|
-- local lst_user = self._view:GetChild("lst_user")
|
||||||
|
-- lst_user.displayObject.gameObject:SetActive(false)
|
||||||
|
--[[ lst_user.onClickItem:Set(function (context)
|
||||||
|
if context.data.name == "real" then
|
||||||
|
local real_view = RealAddressView.new(0)
|
||||||
|
real_view:Show()
|
||||||
|
elseif context.data.name == "address" then
|
||||||
|
local real_view = RealAddressView.new(1)
|
||||||
|
real_view:Show()
|
||||||
|
elseif context.data.name == "phone" then
|
||||||
|
local phone_view = PhoneBindView.new()
|
||||||
|
phone_view:Show()
|
||||||
|
end
|
||||||
|
end)--]]
|
||||||
|
-- self:__ShowShare()
|
||||||
|
|
||||||
|
-- btn_notice.displayObject.gameObject:SetActive(false)
|
||||||
|
|
||||||
|
--可能未游戏服务客服,未调测
|
||||||
|
-- local btn_service = self._view:GetChild("btn_service")
|
||||||
|
--[[btn_service.onClick:Set(function()
|
||||||
|
self:__show_service()
|
||||||
|
end)--]]
|
||||||
|
-- btn_service.displayObject.gameObject:SetActive(false)
|
||||||
|
|
||||||
|
--联盟,未调测,原可以使用
|
||||||
|
-- self.groupMainView = GroupMainView.new(self._view:GetChild("group"),self._root_view,self._view)
|
||||||
|
--self.groupMainView:Show()
|
||||||
|
|
||||||
|
-- local btn_more_group = self._view:GetChild("btn_more_group")
|
||||||
|
-- btn_more_group.onClick:Set(function()
|
||||||
|
-- --self.groupMainView._view.visible = true
|
||||||
|
-- ViewUtil.ShowModalWait(self._root_view,"请稍等,获取牌友圈中...")
|
||||||
|
-- local enterGroupCallBackFunc=function (code)
|
||||||
|
-- ViewUtil.CloseModalWait()
|
||||||
|
-- if code==0 then
|
||||||
|
-- self.groupMainView._view.visible = true
|
||||||
|
-- else
|
||||||
|
-- ViewUtil.ErrorTip(10000000,"获取牌友圈失败,请检查网络设置!")
|
||||||
|
-- printlog("获取圈子数据失败=======>>>>")
|
||||||
|
-- end
|
||||||
|
-- end
|
||||||
|
-- self.groupMainView:Show(nil,enterGroupCallBackFunc)
|
||||||
|
-- end)
|
||||||
|
|
||||||
|
--================================================
|
||||||
|
|
||||||
|
|
||||||
|
---[[
|
||||||
|
-- self.btn_joingroup.onClick:Set(function()
|
||||||
|
-- local groups = DataManager.groups.groupList
|
||||||
|
-- if #groups == 0 then
|
||||||
|
-- local jgv = JoinGroupView.new(self._root_view)
|
||||||
|
-- jgv:Show()
|
||||||
|
-- else
|
||||||
|
-- local info = GroupInfoView.new(groups[1], self.fg_info)
|
||||||
|
-- self._groupInfoView = info
|
||||||
|
-- info:SetCallBack(function()
|
||||||
|
-- self._groupInfoView = nil
|
||||||
|
-- self:Show()
|
||||||
|
-- self._view.visible = true
|
||||||
|
-- end)
|
||||||
|
-- info:Show()
|
||||||
|
-- self._view.visible = false
|
||||||
|
-- end
|
||||||
|
-- if not DataManager.SelfUser.phone then
|
||||||
|
-- --local phone_view = PhoneBindView.new()
|
||||||
|
-- --phone_view:Show()
|
||||||
|
-- -- return
|
||||||
|
-- end
|
||||||
|
-- end)
|
||||||
|
-- self.btn_joingroup.touchable = true
|
||||||
|
--]]
|
||||||
|
|
||||||
|
--游戏列表,原有界面,未调测
|
||||||
|
-- local lst_game = self._view:GetChild("lst_game")
|
||||||
|
-- lst_game.displayObject.gameObject:SetActive(false)
|
||||||
|
--[[local games = DataManager.SelfUser.games
|
||||||
|
for i = 1, math.min( 4,#games ) do
|
||||||
|
local tem = games[i]
|
||||||
|
local item = lst_game:AddItemFromPool()
|
||||||
|
item.text = tem.name
|
||||||
|
local config = ExtendManager.GetExtendConfig(tem.game_id)
|
||||||
|
config.game_data = tem
|
||||||
|
local mode = config:GetGameInfo()
|
||||||
|
item.icon = mode:GetIconUrl()
|
||||||
|
item.onClick:Set(function ()
|
||||||
|
local _createRoomView = CreateRoomView.new(i)
|
||||||
|
_createRoomView.onCeateRoom = function ()
|
||||||
|
ViewManager.ChangeView(ViewManager.View_Main,DataManager.CurrenRoom.game_id)
|
||||||
|
end
|
||||||
|
_createRoomView:Show()
|
||||||
|
end)
|
||||||
|
end--]]
|
||||||
|
|
||||||
|
local message = self._view:GetChild("c_message")
|
||||||
|
--message.visible = true
|
||||||
|
self._message = message:GetChild("message")
|
||||||
|
self._tex_message = message:GetChild("text")
|
||||||
|
self:__GetMessage()
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:OnJoinRoomAction(context)
|
||||||
|
local joinRoomView = JoinRoomView.new(self._root_view)
|
||||||
|
joinRoomView:Show()
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:__show_service()
|
||||||
|
local _buy_win = BaseWindow.new("ui://Lobby/Win_service", self._root_view)
|
||||||
|
_buy_win._close_destroy = true
|
||||||
|
_buy_win:Show()
|
||||||
|
local sview = _buy_win._view
|
||||||
|
local btn_copy = sview:GetChild("btn_copy")
|
||||||
|
btn_copy.onClick:Set(function()
|
||||||
|
GameApplication.Instance:CopyToClipboard("xbkf888108") --湘北
|
||||||
|
-- GameApplication.Instance:CopyToClipboard("ttwmq008")--fb
|
||||||
|
_buy_win:Destroy()
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:__GetMessage(data)
|
||||||
|
-- print("on GetMessage~~~~~~~~~~~~~~~~~~~~~~~~~~~")
|
||||||
|
if not data or not data.notice_list then
|
||||||
|
self._mesList = ""
|
||||||
|
else
|
||||||
|
local message = self._view:GetChild("com_message")
|
||||||
|
message.visible = true
|
||||||
|
local mesl = {}
|
||||||
|
for i = 1, #data.notice_list do
|
||||||
|
mesl[i] = data.notice_list[i].informContent
|
||||||
|
end
|
||||||
|
self._mesList = mesl
|
||||||
|
end
|
||||||
|
|
||||||
|
self:__moveMsg(0)
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:__PopMsg(index)
|
||||||
|
local num = #self._mesList
|
||||||
|
index = index + 1
|
||||||
|
if index > num then index = 1 end
|
||||||
|
local str = tostring(self._mesList[index])
|
||||||
|
if str == nil or str == "nil" then str = "" end
|
||||||
|
return index, string.gsub(str, "\r", "")
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:__moveMsg(index)
|
||||||
|
-- print("on moveMsg!!!!!!!!!!!!!!!!!!!!!!!!!")
|
||||||
|
if not self._tex_message then return end
|
||||||
|
index, self._tex_message.text = self:__PopMsg(index)
|
||||||
|
self._tex_message.x = self._message.width
|
||||||
|
|
||||||
|
if self._mesTw then
|
||||||
|
TweenUtils.Kill(self._mesTw)
|
||||||
|
end
|
||||||
|
local change = -self._message.width * 2
|
||||||
|
local dd = self._tex_message.width / self._message.width
|
||||||
|
if dd < 1 then dd = 1 end
|
||||||
|
self._mesTw = TweenUtils.TweenFloat(0, 1 * dd, 10 * dd, function(value)
|
||||||
|
self._tex_message.x = self._message.width + (change * value)
|
||||||
|
end)
|
||||||
|
TweenUtils.OnComplete(self._mesTw, function()
|
||||||
|
self._mesTw = nil
|
||||||
|
if (#self._mesList == 0) then
|
||||||
|
self:__GetMessage()
|
||||||
|
else
|
||||||
|
self:__PopMsg(index)
|
||||||
|
self:__moveMsg(index)
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:__ShowShare()
|
||||||
|
local pop_share = self._view:GetChild("pop_share")
|
||||||
|
local shareUrl = GetGameInfo("invite_link") .. "?uid=" .. DataManager.SelfUser.account_id
|
||||||
|
--print("shareUrl=================")
|
||||||
|
--print(shareUrl)
|
||||||
|
local btn_wx_session = pop_share:GetChild("btn_wx_session")
|
||||||
|
btn_wx_session.onClick:Add(function()
|
||||||
|
shareQRCodePicture(shareUrl, 0)
|
||||||
|
end)
|
||||||
|
local btn_wx_line = pop_share:GetChild("btn_wx_line").asButton
|
||||||
|
btn_wx_line.onClick:Add(function()
|
||||||
|
shareQRCodePicture(shareUrl, 1)
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:OnUpdate()
|
||||||
|
local roomid = GameApplication.Instance:GetRoomID()
|
||||||
|
if roomid and string.len(roomid) > 1 then
|
||||||
|
ControllerManager.WebClient:clearActionQueue()
|
||||||
|
local joinRoomView = JoinRoomView.new(self._root_view)
|
||||||
|
joinRoomView:JoinRoom(roomid)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:Close()
|
||||||
|
BaseView.Close(self)
|
||||||
|
UpdateBeat:Remove(self.OnUpdate, self)
|
||||||
|
coroutine.stopAll()
|
||||||
|
if self._mesTw then
|
||||||
|
TweenUtils.Kill(self._mesTw)
|
||||||
|
end
|
||||||
|
BaseWindow.DestroyAll()
|
||||||
|
DSTweenManager.ClearTween()
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:Destroy()
|
||||||
|
UpdateBeat:Remove(self.OnUpdate, self)
|
||||||
|
if self._mesTw then
|
||||||
|
TweenUtils.Kill(self._mesTw)
|
||||||
|
end
|
||||||
|
self._tex_message = nil
|
||||||
|
coroutine.stopAll()
|
||||||
|
BaseView.Destroy(self)
|
||||||
|
BaseWindow.DestroyAll()
|
||||||
|
DSTweenManager.ClearTween()
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:Show()
|
||||||
|
--print("on lobbyView show~~~~~~")
|
||||||
|
BaseView.Show(self)
|
||||||
|
ViewUtil.PlaySoundBg()
|
||||||
|
UpdateBeat:Add(self.OnUpdate, self)
|
||||||
|
|
||||||
|
-- 如果在圈子内的房间,显示tip
|
||||||
|
local user = DataManager.SelfUser
|
||||||
|
local tem = user.notices
|
||||||
|
if user.group_id ~= 0 then
|
||||||
|
local msg_tip = MsgWindow.new(self._root_view, "还在圈子的房间中,现在重连吗?", MsgWindow.MsgMode.OkAndCancel)
|
||||||
|
msg_tip.onOk:Add(function()
|
||||||
|
if self.groupMainView ~= nil then
|
||||||
|
self.groupMainView:Show(user.group_id)
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
msg_tip:Show()
|
||||||
|
tem.auto_show = false
|
||||||
|
else
|
||||||
|
local lobbyCtr1 = ControllerManager.GetController(LoddyController)
|
||||||
|
lobbyCtr1:UpdateNotice(DataManager.SelfUser.account_id, function(result, data)
|
||||||
|
-- local data1 = {}
|
||||||
|
-- data1.notice_list = {}
|
||||||
|
-- data1.notice_list[1] = "ccccccccccccccccccccccccccc"
|
||||||
|
if result then
|
||||||
|
self:__GetMessage(data)
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
local loddyCtr1 = ControllerManager.GetController(LoddyController)
|
||||||
|
self:GetPlayerInfoData()
|
||||||
|
|
||||||
|
-- 获取GPS坐标
|
||||||
|
if not DataManager.SelfUser.location or DataManager.SelfUser.location:Location2String() == "" then
|
||||||
|
get_gps()
|
||||||
|
end
|
||||||
|
|
||||||
|
if self.groupMainView and self.groupMainView._groupInfoView then
|
||||||
|
self.groupMainView._groupInfoView:hidePipei()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:GetPlayerInfoData()
|
||||||
|
local loddyCtr1 = ControllerManager.GetController(LoddyController)
|
||||||
|
loddyCtr1:UpdatePlayerInfo(function(result, data)
|
||||||
|
if result then
|
||||||
|
self:ShowPlayerInfo(data.raffle, data.diamo, data.newMail)
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:ShowPlayerInfo(raffle, diamo, newMail)
|
||||||
|
self._view:GetChild("btn_diamo"):GetChild("num").text = diamo or 0
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:OnApplicationPause()
|
||||||
|
ControllerManager.WebClient:clearActionQueue()
|
||||||
|
-- 切后台时间
|
||||||
|
if DataManager.SelfUser.cur_group then
|
||||||
|
self.lobby_pause_time = os.time()
|
||||||
|
DataManager.SelfUser.cur_group.pause = true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:OnApplicationActive()
|
||||||
|
ControllerManager.WebClient:clearActionQueue()
|
||||||
|
self:GetPlayerInfoData()
|
||||||
|
-- 切后台太久牌友圈重连
|
||||||
|
if DataManager.SelfUser.cur_group then
|
||||||
|
DataManager.SelfUser.cur_group.pause = false
|
||||||
|
if os.time() - self.lobby_pause_time > 15 then
|
||||||
|
self.lobby_pause_time = os.time()
|
||||||
|
DataManager.SelfUser.cur_group:Reconnect()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
@ -0,0 +1,279 @@
|
||||||
|
local PhoneLoginView = import(".PhoneLoginView")
|
||||||
|
LoginView = {}
|
||||||
|
|
||||||
|
|
||||||
|
local M = {}
|
||||||
|
|
||||||
|
--- Create a new LoginView
|
||||||
|
function LoginView.new()
|
||||||
|
setmetatable(M, { __index = BaseView })
|
||||||
|
local self = setmetatable({}, { __index = M })
|
||||||
|
self.class = "LoginView"
|
||||||
|
self._full = true
|
||||||
|
self:init()
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
---
|
||||||
|
--@function [parent=#LoginView] init
|
||||||
|
--@param self
|
||||||
|
function M:init()
|
||||||
|
UIPackage.AddPackage("base/login/ui/Login")
|
||||||
|
|
||||||
|
--UIPackage.AddPackage("UI/Card")
|
||||||
|
ViewUtil.PlaySoundBg()
|
||||||
|
self:InitView("ui://Login/Main")
|
||||||
|
|
||||||
|
local view = self._view
|
||||||
|
-- view:GetChild("tex_version").text = "Version:" .. GetGameInfoPlatform("version")
|
||||||
|
-- print(GameApplication.Instance.accountTest and 1 or 0)
|
||||||
|
view:GetController("test").selectedIndex = GameApplication.Instance.accountTest and 1 or 0
|
||||||
|
self.agree = view:GetController("agree");
|
||||||
|
-- Utils.LoadBg("loginbg", view)
|
||||||
|
if GameApplication.Instance.accountTest then
|
||||||
|
local json_data = Utils.LoadLocalFile("userId")
|
||||||
|
if json_data then
|
||||||
|
local _data = json.decode(json_data)
|
||||||
|
view:GetChild("tex_unionid").text = _data.userId
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local _btn_login = view:GetChild("btn_wx")
|
||||||
|
|
||||||
|
_btn_login.onClick:Add(function()
|
||||||
|
if self.agree.selectedIndex == 0 then
|
||||||
|
ViewUtil.ErrorTip(self._root_view, "请勾选同意《用户协议》")
|
||||||
|
return
|
||||||
|
end
|
||||||
|
ViewUtil.ShowModalWait(self._root_view, "正在登录游戏...")
|
||||||
|
coroutine.start(function()
|
||||||
|
coroutine.wait(8)
|
||||||
|
if self.isWXCallBackMark then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
ViewUtil.CloseModalWait()
|
||||||
|
ViewUtil.ErrorTip(10000, "微信登录失败!")
|
||||||
|
end)
|
||||||
|
if (not GameApplication.Instance.accountTest) then
|
||||||
|
GameApplication.Instance:WXLogin(handler(self, self.LoginCallBack))
|
||||||
|
else
|
||||||
|
--local ctr_user = view:GetController("user")
|
||||||
|
|
||||||
|
local _tex_unionid = view:GetChild("tex_unionid")
|
||||||
|
|
||||||
|
local utez = _tex_unionid.text --.. (ctr_user.selectedIndex + 1)
|
||||||
|
|
||||||
|
local _data = {}
|
||||||
|
_data["userId"] = utez
|
||||||
|
local key = "userId"
|
||||||
|
local s, e = pcall(function()
|
||||||
|
Utils.SaveLocalFile(key, json.encode(_data))
|
||||||
|
end)
|
||||||
|
if not s then
|
||||||
|
print("Error:" .. e)
|
||||||
|
end
|
||||||
|
|
||||||
|
DataManager.SelfUser.acc = utez
|
||||||
|
DataManager.SelfUser.nick_name = utez
|
||||||
|
DataManager.SelfUser.sex = 1
|
||||||
|
DataManager.SelfUser.head_url = ""
|
||||||
|
self:LoginCallBack(0)
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
|
--按钮取消,功能暂时不用
|
||||||
|
-- local btn_passwrod = view:GetChild("btn_passwrod")
|
||||||
|
-- btn_passwrod.onClick:Set(function()
|
||||||
|
-- self:PhoneLogin()
|
||||||
|
-- end)
|
||||||
|
|
||||||
|
local btn_phone_code = view:GetChild("btn_phone_code")
|
||||||
|
btn_phone_code.onClick:Set(function()
|
||||||
|
if self.agree.selectedIndex == 0 then
|
||||||
|
ViewUtil.ErrorTip(self._root_view, "请勾选同意《用户协议》")
|
||||||
|
return
|
||||||
|
end
|
||||||
|
self:PhoneCodeLogin()
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:Destroy()
|
||||||
|
if self._agreement then
|
||||||
|
self._agreement:Destroy()
|
||||||
|
end
|
||||||
|
BaseView.Destroy(self)
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:Show()
|
||||||
|
BaseView.Show(self)
|
||||||
|
-- self:QuickLogin()
|
||||||
|
end
|
||||||
|
|
||||||
|
local function __goto_lobby(response)
|
||||||
|
if response.Data then
|
||||||
|
local notices = response.Data.notice_list
|
||||||
|
if notices and #notices > 0 then
|
||||||
|
local tem = {}
|
||||||
|
tem.data = notices
|
||||||
|
tem.auto_show = true
|
||||||
|
DataManager.SelfUser.notices = tem
|
||||||
|
end
|
||||||
|
end
|
||||||
|
ControllerManager.ChangeController(LoddyController)
|
||||||
|
ViewManager.ChangeView(ViewManager.View_Lobby)
|
||||||
|
end
|
||||||
|
|
||||||
|
local function __join_room(roomid, res)
|
||||||
|
local loddyctr = ControllerManager.GetController(LoddyController)
|
||||||
|
loddyctr:JoinRoom(roomid, function(res1)
|
||||||
|
ViewUtil.CloseModalWait()
|
||||||
|
if res1.ReturnCode == -2 then
|
||||||
|
__join_room(roomid, res)
|
||||||
|
elseif res1.ReturnCode == 0 then
|
||||||
|
ViewManager.ChangeView(ViewManager.View_Main, DataManager.CurrenRoom.game_id)
|
||||||
|
elseif res1.ReturnCode == 101 or res1.ReturnCode == 6 then
|
||||||
|
__goto_lobby(res)
|
||||||
|
else
|
||||||
|
ViewUtil.ErrorTip(res1.ReturnCode, "登录失败!")
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
local function __login_response(self, response)
|
||||||
|
ViewUtil.CloseModalWait()
|
||||||
|
local skey = "session_id"
|
||||||
|
if (response.ReturnCode == 0) then
|
||||||
|
local user = DataManager.SelfUser
|
||||||
|
-- if (user.guild) then
|
||||||
|
ExtendManager.Destroy()
|
||||||
|
|
||||||
|
local function f_enterLobby(...)
|
||||||
|
-- body
|
||||||
|
local _client = ControllerManager.WebClient
|
||||||
|
|
||||||
|
PlayerPrefs.SetString(skey, _client:getSession())
|
||||||
|
PlayerPrefs.Save()
|
||||||
|
|
||||||
|
ExtendManager.Init(user.games)
|
||||||
|
|
||||||
|
local roomid = user.room_id
|
||||||
|
if (string.len(roomid) > 1) then
|
||||||
|
if user.group_id == 0 then
|
||||||
|
ViewUtil.ShowModalWait(self._root_view, "正在加入房间...")
|
||||||
|
__join_room(roomid, response)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
end
|
||||||
|
__goto_lobby(response)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
if user.update ~= 0 then
|
||||||
|
ExtendHotupdate.UpdateGameList(user.games, f_enterLobby)
|
||||||
|
else
|
||||||
|
f_enterLobby()
|
||||||
|
end
|
||||||
|
else
|
||||||
|
if (response.ReturnCode == Table_Error_code.ERR_SERVER or response.ReturnCode == Table_Error_code.ERR_LOGOUT) then
|
||||||
|
PlayerPrefs.DeleteKey(skey)
|
||||||
|
PlayerPrefs.Save()
|
||||||
|
end
|
||||||
|
ViewUtil.ErrorTip(response.ReturnCode, "登录失败!")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:PhoneLogin()
|
||||||
|
local _phoneView = nil
|
||||||
|
_phoneView = PhoneLoginView.new(0, function(res)
|
||||||
|
if res.ReturnCode == 0 then
|
||||||
|
_phoneView:Destroy()
|
||||||
|
end
|
||||||
|
__login_response(self, res)
|
||||||
|
end)
|
||||||
|
_phoneView:Show()
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:PhoneCodeLogin()
|
||||||
|
local _phoneCodeView = nil
|
||||||
|
_phoneCodeView = PhoneLoginView.new(1, function(res)
|
||||||
|
if res.ReturnCode == 0 then
|
||||||
|
_phoneCodeView:Destroy()
|
||||||
|
end
|
||||||
|
__login_response(self, res)
|
||||||
|
end)
|
||||||
|
_phoneCodeView.agree = self.agree;
|
||||||
|
_phoneCodeView:Show()
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:IDLogin()
|
||||||
|
local _idView = nil
|
||||||
|
_idView = IDLoginView.new(function(res)
|
||||||
|
if res.ReturnCode == 0 then
|
||||||
|
_idView:Destroy()
|
||||||
|
end
|
||||||
|
__login_response(self, res)
|
||||||
|
end)
|
||||||
|
_idView:Show()
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:QuickLogin()
|
||||||
|
if (not GameApplication.Instance.accountTest) then
|
||||||
|
local session_id = PlayerPrefs.GetString("session_id")
|
||||||
|
print("session_id:" .. session_id)
|
||||||
|
if session_id and string.len(session_id) > 3 then
|
||||||
|
ViewUtil.ShowModalWait(self._root_view, "正在登录游戏...")
|
||||||
|
local loginCtr = ControllerManager.GetController(LoginController)
|
||||||
|
loginCtr:QuickLogin(session_id, function(response)
|
||||||
|
__login_response(self, response)
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:LoginCallBack(result, data)
|
||||||
|
self.isWXCallBackMark = true
|
||||||
|
--print("微信登录返回================================================================")
|
||||||
|
--print("result===>"..result)
|
||||||
|
--pt(data)
|
||||||
|
if (not result) or result ~= 0 then
|
||||||
|
if result == 10 then
|
||||||
|
ViewUtil.ShowModalWait(self._root_view)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
ViewUtil.CloseModalWait()
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
if data then
|
||||||
|
local jd = json.decode(data)
|
||||||
|
pt(jd)
|
||||||
|
local headurl = jd["headimgurl"]
|
||||||
|
local unionid = jd["unionid"]
|
||||||
|
local sex = jd["sex"]
|
||||||
|
if (sex == 0) then sex = 1 end
|
||||||
|
local nickname = jd["nickname"]
|
||||||
|
|
||||||
|
DataManager.SelfUser.acc = unionid
|
||||||
|
DataManager.SelfUser.nick_name = nickname
|
||||||
|
DataManager.SelfUser.sex = sex
|
||||||
|
DataManager.SelfUser.head_url = headurl
|
||||||
|
if not DataManager.SelfUser.acc or string.len(DataManager.SelfUser.acc) < 1 then
|
||||||
|
ViewUtil.CloseModalWait()
|
||||||
|
return
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
local loginCtr = ControllerManager.GetController(LoginController)
|
||||||
|
loginCtr:Login(function(response)
|
||||||
|
__login_response(self, response)
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:Destroy()
|
||||||
|
BaseView.Destroy(self)
|
||||||
|
-- UIPackage.RemovePackage("base/embed/ui/Hotupdate")
|
||||||
|
UIPackage.RemovePackage("base/login/ui/Login")
|
||||||
|
-- ResourcesManager.UnLoad("base/ui/Login.bytes")
|
||||||
|
end
|
||||||
|
|
@ -0,0 +1,127 @@
|
||||||
|
local MainRightPanelView = {
|
||||||
|
-- 查看记录
|
||||||
|
onLogCallback = nil
|
||||||
|
}
|
||||||
|
|
||||||
|
local M = MainRightPanelView
|
||||||
|
|
||||||
|
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 = mainView:NewSettingView()
|
||||||
|
_settingView.stateIndex = (mainView._room.curren_round >= 1 and mainView._allow_dissmiss) and 2 or 1
|
||||||
|
_settingView.cd_time = mainView.dismiss_room_cd_time
|
||||||
|
_settingView:Show()
|
||||||
|
|
||||||
|
local room = DataManager.CurrenRoom
|
||||||
|
_settingView.onCallback:Add(
|
||||||
|
function(context)
|
||||||
|
local _gamectr = ControllerManager.GetController(GameController)
|
||||||
|
if (room.CurnrenState == StateType.Ready) then
|
||||||
|
_gamectr:LevelRoom(
|
||||||
|
function(response)
|
||||||
|
if (response.ReturnCode == 0) then
|
||||||
|
ViewManager.ChangeView(ViewManager.View_Lobby)
|
||||||
|
GameApplication.Instance:ShowTips('房间已解散!')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
)
|
||||||
|
else
|
||||||
|
_gamectr:AskDismissRoom()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
)
|
||||||
|
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
|
||||||
|
|
||||||
|
--- Create a new MainRightPanelView
|
||||||
|
function MainRightPanelView.new(mainView, view)
|
||||||
|
local self = setmetatable({}, {__index = M})
|
||||||
|
self.class = 'MainRightPanelView'
|
||||||
|
-- 显示选项,1是正常,2的ping没有括号
|
||||||
|
self._opt = 1
|
||||||
|
__init(self, mainView, view)
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:__UpdateTime()
|
||||||
|
if self._total_time >= 10 then
|
||||||
|
self._total_time = 0
|
||||||
|
else
|
||||||
|
return
|
||||||
|
end
|
||||||
|
self:_ShowTime()
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:_ShowTime()
|
||||||
|
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
|
||||||
|
local str_ping = '(' .. ping .. 'ms)'
|
||||||
|
if self._opt == 2 then
|
||||||
|
str_ping = ping .. 'ms'
|
||||||
|
end
|
||||||
|
self._tex_ping.text = str_ping
|
||||||
|
end
|
||||||
|
--
|
||||||
|
function M:OnUpdate(deltaTime)
|
||||||
|
self:__UpdateTime()
|
||||||
|
self._total_time = self._total_time + deltaTime
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:Destroy()
|
||||||
|
-- self._timer:Stop()
|
||||||
|
end
|
||||||
|
|
||||||
|
return M
|
||||||
File diff suppressed because it is too large
Load Diff
|
|
@ -0,0 +1,70 @@
|
||||||
|
--创建牌友圈View对象
|
||||||
|
--author:--
|
||||||
|
|
||||||
|
local CreateGroupView = {}
|
||||||
|
|
||||||
|
|
||||||
|
local M = CreateGroupView
|
||||||
|
|
||||||
|
local url = {"ui://NewGroup/Win_CreateGroup","ui://NewGroup/Win_UpdateGroup"}
|
||||||
|
function CreateGroupView.new(blur_view,default_str)
|
||||||
|
setmetatable(M, {__index = BaseWindow})
|
||||||
|
local self = setmetatable({}, {__index = M})
|
||||||
|
self.class = "CreateGroupView"
|
||||||
|
self._close_destroy = true
|
||||||
|
self._close_zone = false
|
||||||
|
self._blur_view = blur_view
|
||||||
|
self.default_str = default_str
|
||||||
|
self:init(url[self.is_update and 2 or 1])
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:init(url)
|
||||||
|
BaseWindow.init(self,url)
|
||||||
|
local tex_name = self._view:GetChild("tex_name")
|
||||||
|
|
||||||
|
local ctr_agent = self._view:GetController("agent")
|
||||||
|
local user = DataManager.SelfUser
|
||||||
|
|
||||||
|
|
||||||
|
self._view:GetController("index").selectedIndex = 2
|
||||||
|
self._view:GetController("alliance").selectedIndex = 1
|
||||||
|
|
||||||
|
local btn_ok = self._view:GetChild("btn_ok")
|
||||||
|
btn_ok.onClick:Set(function()
|
||||||
|
if string.utf8len(tex_name.text) == 0 then
|
||||||
|
ViewUtil.ErrorTip(-12,"请输入圈子名称!")
|
||||||
|
return
|
||||||
|
end
|
||||||
|
if MsgParser:checkString(tex_name.text) then
|
||||||
|
ViewUtil.ErrorTip(-12,"您输入的名称存在敏感字!")
|
||||||
|
return
|
||||||
|
end
|
||||||
|
-- if not self.is_update and not self.config then
|
||||||
|
-- ViewUtil.ErrorTip(-12,"请选择玩法!")
|
||||||
|
-- return
|
||||||
|
-- end
|
||||||
|
if self.callback then
|
||||||
|
local ctr_index = self._view:GetController("index")
|
||||||
|
local index = ctr_index.selectedIndex + 1
|
||||||
|
local pay_type = index
|
||||||
|
local fg_type = 1
|
||||||
|
if index == 3 then
|
||||||
|
pay_type = 1
|
||||||
|
fg_type = 2
|
||||||
|
end
|
||||||
|
self.callback(tex_name.text, pay_type, fg_type)
|
||||||
|
end
|
||||||
|
self:Destroy()
|
||||||
|
end)
|
||||||
|
local btn_cal = self._view:GetChild("btn_cal")
|
||||||
|
btn_cal.onClick:Set(function()
|
||||||
|
self:Destroy()
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:SetCallback(callback)
|
||||||
|
self.callback = callback
|
||||||
|
end
|
||||||
|
|
||||||
|
return M
|
||||||
|
|
@ -0,0 +1,79 @@
|
||||||
|
-- 被邀请界面
|
||||||
|
local FGInvitedMsgView = {}
|
||||||
|
|
||||||
|
local M = FGInvitedMsgView
|
||||||
|
setmetatable(M, {__index = BaseWindow})
|
||||||
|
|
||||||
|
function FGInvitedMsgView.new(blur_view, group_id, callback)
|
||||||
|
|
||||||
|
local self = setmetatable({}, {__index = M})
|
||||||
|
self.class = "FGInvitedMsgView"
|
||||||
|
self._blur_view = blur_view
|
||||||
|
self._animation = true
|
||||||
|
self._close_destroy = true
|
||||||
|
self._close_time = 15
|
||||||
|
|
||||||
|
self.group_id = group_id
|
||||||
|
self.callback = callback
|
||||||
|
UIPackage.AddPackage("base/newgroup/ui/FGAssist")
|
||||||
|
self:init("ui://FGAssist/panel_invited")
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:FillData(data)
|
||||||
|
self._view:GetChild("tex_name").text = data.nick
|
||||||
|
self._view:GetChild("tex_id").text = "ID:" .. data.uid
|
||||||
|
local btn_head = self._view:GetChild("btn_head")
|
||||||
|
ImageLoad.Load(data.portrait, btn_head._iconObject)
|
||||||
|
|
||||||
|
local group = DataManager.groups:get(self.group_id)
|
||||||
|
local play = group:getPlay(data.pid)
|
||||||
|
self._view:GetChild("tex_play_name").text = play and play.name or pid
|
||||||
|
self._view:GetChild("tex_game_name").text = data.g_name
|
||||||
|
|
||||||
|
local btn_refuse = self._view:GetChild("btn_refuse")
|
||||||
|
local id = data.invi_id
|
||||||
|
local btn_yes = self._view:GetChild("btn_yes")
|
||||||
|
btn_yes.onClick:Set(function()
|
||||||
|
local refuse = btn_refuse.selected and 1 or 0
|
||||||
|
self:SendResponse(id, refuse)
|
||||||
|
self:Destroy()
|
||||||
|
if self.callback then
|
||||||
|
self.callback(data.roomid)
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
local btn_no = self._view:GetChild("btn_no")
|
||||||
|
btn_no.onClick:Set(function()
|
||||||
|
local refuse = btn_refuse.selected and 1 or 0
|
||||||
|
self:SendResponse(id, refuse)
|
||||||
|
self:Destroy()
|
||||||
|
end)
|
||||||
|
|
||||||
|
self._co = coroutine.start(function()
|
||||||
|
while self._close_time > 0 do
|
||||||
|
coroutine.wait(1)
|
||||||
|
self._close_time = self._close_time - 1
|
||||||
|
self:ShowLeftTime()
|
||||||
|
end
|
||||||
|
self:Destroy()
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:ShowLeftTime()
|
||||||
|
self._view:GetChild("tex_left_time").text = self._close_time .. "s"
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:SendResponse(id, refuse)
|
||||||
|
local mgr_ctr = ControllerManager.GetController(GroupMgrController)
|
||||||
|
mgr_ctr:FG_ResponseInvited(id, refuse)
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:Destroy()
|
||||||
|
if self._co then
|
||||||
|
coroutine.stop(self._co)
|
||||||
|
self._co = nil
|
||||||
|
end
|
||||||
|
BaseWindow.Destroy(self)
|
||||||
|
end
|
||||||
|
|
||||||
|
return M
|
||||||
File diff suppressed because it is too large
Load Diff
|
|
@ -0,0 +1,103 @@
|
||||||
|
--进入牌友圈View对象
|
||||||
|
--author:--
|
||||||
|
|
||||||
|
|
||||||
|
local GroupJoinsView = {}
|
||||||
|
|
||||||
|
local M = GroupJoinsView
|
||||||
|
|
||||||
|
function GroupJoinsView.new(blur_view)
|
||||||
|
setmetatable(M, {__index = BaseWindow})
|
||||||
|
local self = setmetatable({}, {__index = M})
|
||||||
|
self.class = "GroupJoinsView"
|
||||||
|
self._close_destroy = true
|
||||||
|
self._blur_view = blur_view
|
||||||
|
self:init("ui://NewGroup/Win_GroupJoins")
|
||||||
|
self.change = false
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
local function __fillJoins(self,curGroup,joins)
|
||||||
|
local lst_joins = self._view:GetChild("lst_joins")
|
||||||
|
lst_joins:RemoveChildrenToPool()
|
||||||
|
local fgCtr = ControllerManager.GetController(FriendGroupController)
|
||||||
|
|
||||||
|
for i=1,#joins do
|
||||||
|
local rdata = joins[i]
|
||||||
|
local item = lst_joins:AddItemFromPool()
|
||||||
|
item:GetChild("tex_name").text = rdata.nick
|
||||||
|
item:GetChild("tex_id").text = "ID:"..rdata.id
|
||||||
|
local btn_yes = item:GetChild("btn_yes")
|
||||||
|
btn_yes.data = rdata
|
||||||
|
btn_yes.onClick:Set(function(context)
|
||||||
|
local _rd = context.sender.data
|
||||||
|
ViewUtil.ShowModalWait(self._root_view)
|
||||||
|
fgCtr:FG_GroupVerifyJoin(curGroup.id,_rd.id,true,function(res1)
|
||||||
|
if self._is_destroy then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
ViewUtil.CloseModalWait()
|
||||||
|
if res1.ReturnCode == 0 then
|
||||||
|
curGroup.joins = #res1.Data.joins
|
||||||
|
self.change = true
|
||||||
|
__fillJoins(self,curGroup,res1.Data.joins)
|
||||||
|
else
|
||||||
|
ViewUtil.ErrorTip(res.ReturnCode,"邀请失败!")
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end)
|
||||||
|
local btn_del = item:GetChild("btn_del")
|
||||||
|
btn_del.data = rdata
|
||||||
|
btn_del.onClick:Set(function(context)
|
||||||
|
local _rd = context.sender.data
|
||||||
|
ViewUtil.ShowModalWait(self._root_view)
|
||||||
|
fgCtr:FG_GroupVerifyJoin(curGroup.id,_rd.id,false,function(res1)
|
||||||
|
if self._is_destroy then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
ViewUtil.CloseModalWait()
|
||||||
|
if res1.ReturnCode == 0 then
|
||||||
|
curGroup.joins = #res1.Data.joins
|
||||||
|
self.change = true
|
||||||
|
__fillJoins(self,curGroup,res1.Data.joins)
|
||||||
|
else
|
||||||
|
ViewUtil.ErrorTip(res.ReturnCode,"邀请失败!")
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end)
|
||||||
|
local btn_head = item:GetChild("btn_head")
|
||||||
|
ImageLoad.Load(rdata.portrait, btn_head._iconObject)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:FillData(curGroup)
|
||||||
|
local lst_joins = self._view:GetChild("lst_joins")
|
||||||
|
lst_joins:RemoveChildrenToPool()
|
||||||
|
|
||||||
|
local fgCtr = ControllerManager.GetController(FriendGroupController)
|
||||||
|
fgCtr:FG_GroupJoins(curGroup.id,function( res)
|
||||||
|
if self._is_destroy then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
if (res.ReturnCode == 0) then
|
||||||
|
__fillJoins(self,curGroup,res.Data.joins)
|
||||||
|
else
|
||||||
|
ViewUtil.ErrorTip(res.ReturnCode,"获取邀请列表失败!")
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:SetCallback(callback)
|
||||||
|
self.callback = callback
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- 销毁窗口
|
||||||
|
function M:Destroy(remove_map)
|
||||||
|
if self.change and self.callback then
|
||||||
|
self.callback()
|
||||||
|
end
|
||||||
|
BaseWindow.Destroy(self,remove_map)
|
||||||
|
end
|
||||||
|
|
||||||
|
return M
|
||||||
|
|
@ -0,0 +1,107 @@
|
||||||
|
--牌友圈邮件View
|
||||||
|
|
||||||
|
|
||||||
|
local GroupMailView = {}
|
||||||
|
|
||||||
|
local M = GroupMailView
|
||||||
|
|
||||||
|
function GroupMailView.new(blur_view, curGroup)
|
||||||
|
setmetatable(M, {__index = BaseWindow})
|
||||||
|
local self = setmetatable({}, {__index = M})
|
||||||
|
self.class = "GroupMailView"
|
||||||
|
self._close_destroy = true
|
||||||
|
self._blur_view = blur_view
|
||||||
|
self.curGroup = curGroup
|
||||||
|
self.mail_data = {}
|
||||||
|
self._full = true
|
||||||
|
self:init("ui://NewGroup/Win_Mail")
|
||||||
|
self:FillView()
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:FillView()
|
||||||
|
self.lst_mail = self._view:GetChild("lst_mail")
|
||||||
|
self.lst_mail:SetVirtual()
|
||||||
|
self.lst_mail.itemRenderer = function(index, obj)
|
||||||
|
self:OnRenderItem(index, obj)
|
||||||
|
end
|
||||||
|
self.lst_mail.scrollPane.onPullUpRelease:Set(function()
|
||||||
|
self:GetMailData(#self.mail_data)
|
||||||
|
end)
|
||||||
|
self:GetMailData(#self.mail_data)
|
||||||
|
|
||||||
|
local btn_delete = self._view:GetChild("btn_delete")
|
||||||
|
btn_delete.onClick:Set(function()
|
||||||
|
local msg_tip = MsgWindow.new(self._root_view, "确定要删除所有邮件吗?", MsgWindow.MsgMode.OkAndCancel)
|
||||||
|
msg_tip.onOk:Add(function()
|
||||||
|
self:DelAllMail()
|
||||||
|
end)
|
||||||
|
msg_tip:Show()
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:GetMailData(index)
|
||||||
|
ViewUtil.ShowModalWait(nil)
|
||||||
|
local fgCtr = ControllerManager.GetController(NewGroupController)
|
||||||
|
fgCtr:FG_GetMailList(self.curGroup.id, DataManager.SelfUser.account_id, index, 20, function(res)
|
||||||
|
ViewUtil.CloseModalWait()
|
||||||
|
if res.ReturnCode == 0 then
|
||||||
|
if #res.Data.mail_list > 0 then
|
||||||
|
list_concat(self.mail_data, res.Data.mail_list)
|
||||||
|
self.lst_mail.numItems = #self.mail_data
|
||||||
|
end
|
||||||
|
else
|
||||||
|
ViewUtil.ErrorTip(res.ReturnCode, "获取邮件列表失败")
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:DelAllMail()
|
||||||
|
ViewUtil.ShowModalWait(nil)
|
||||||
|
local fgCtr = ControllerManager.GetController(NewGroupController)
|
||||||
|
fgCtr:FG_DelAllMail(self.curGroup.id, DataManager.SelfUser.account_id, function(res)
|
||||||
|
ViewUtil.CloseModalWait()
|
||||||
|
if res.ReturnCode == 0 then
|
||||||
|
self.mail_data = {}
|
||||||
|
self.lst_mail.numItems = 0
|
||||||
|
else
|
||||||
|
ViewUtil.ErrorTip(res.ReturnCode, "删除邮件失败")
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:OnRenderItem(index, obj)
|
||||||
|
local tex_title = obj:GetChild("tex_title")
|
||||||
|
local tex_content = obj:GetChild("tex_content")
|
||||||
|
local data = json.decode(self.mail_data[index + 1])
|
||||||
|
ImageLoad.Load(data.headurl, obj:GetChild("btn_head")._iconObject, self.class)
|
||||||
|
local nick = data.nick
|
||||||
|
local id = data.mgr_id
|
||||||
|
local hp = d2ad(data.hp)
|
||||||
|
if data.type == 1 then
|
||||||
|
local str_lev = data.lev == 3 and "合伙人" or "管理员"
|
||||||
|
local act = hp >= 0 and "给您增加了" or "扣除了您"
|
||||||
|
tex_title.text = "消息内容为:"--string.format("%s(%s) %s%s积分", nick, id, act, math.abs(hp))
|
||||||
|
tex_content.text = string.format("%s [color=#08a446]%s[/color](%s) %s[color=#08a446] %s [/color]积分", str_lev, nick, id, act, math.abs(hp))
|
||||||
|
else
|
||||||
|
tex_title.text = "消息内容为:"--string.format("%s(%s) 转账给您%s积分", nick, id, math.abs(hp))
|
||||||
|
tex_content.text = string.format("[color=#08a446]%s[/color](%s) 转账给您[color=#08a446] %s [/color]积分", nick, id, math.abs(hp))
|
||||||
|
end
|
||||||
|
obj:GetChild("tex_data").text = os.date("%Y-%m-%d %H:%M", data.time)
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:SetCallback(callback)
|
||||||
|
self.callback = callback
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- 销毁窗口
|
||||||
|
function M:Destroy(remove_map)
|
||||||
|
if self.callback then
|
||||||
|
self.callback()
|
||||||
|
end
|
||||||
|
BaseWindow.Destroy(self,remove_map)
|
||||||
|
ImageLoad.Clear(self.class)
|
||||||
|
end
|
||||||
|
|
||||||
|
return M
|
||||||
|
|
@ -0,0 +1,314 @@
|
||||||
|
local JoinGroupView = import('.JoinGroupView')
|
||||||
|
local GroupSettingView = import('.GroupSettingView')
|
||||||
|
local CreateGroupView = import('.CreateGroupView')
|
||||||
|
local GroupInfoView = import('.GroupInfoView')
|
||||||
|
local PhoneBindView = import("Game.View.Lobby.PhoneBindView")
|
||||||
|
|
||||||
|
local GroupMainView = {}
|
||||||
|
|
||||||
|
local M = GroupMainView
|
||||||
|
|
||||||
|
function GroupMainView.new(main_view, root_view,par_veiw)
|
||||||
|
--print(debug.traceback())
|
||||||
|
local self = setmetatable({}, {__index = M})
|
||||||
|
self.class = 'GroupMainView'
|
||||||
|
UIPackage.AddPackage('base/newgroup/ui/NewGroup')
|
||||||
|
self._view = main_view
|
||||||
|
self._root_view = root_view
|
||||||
|
self._par_veiw = par_veiw
|
||||||
|
self:InitView()
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:InitView(url)
|
||||||
|
--print(url)
|
||||||
|
-- BlurView(self._view:GetChild("bg"),true)
|
||||||
|
if DataManager.SelfUser.agent > 0 then
|
||||||
|
self._view:GetController('agent').selectedIndex = 1
|
||||||
|
end
|
||||||
|
-- local btn_close = self._view:GetChild("btn_close")
|
||||||
|
-- btn_close.onClick:Set(function()
|
||||||
|
-- self:Destroy()
|
||||||
|
-- end)
|
||||||
|
local fgCtr = ControllerManager.GetController(NewGroupController)
|
||||||
|
local btn_creategroup = self._view:GetChild('btn_creategroup')
|
||||||
|
btn_creategroup.onClick:Set(function()
|
||||||
|
local cgv = CreateGroupView.new(self._root_view)
|
||||||
|
cgv:Show()
|
||||||
|
cgv:SetCallback(function(name, pay_type, fg_type)
|
||||||
|
ViewUtil.ShowModalWait(cgv._root_view)
|
||||||
|
fgCtr:FG_CreateGroup(name,pay_type,fg_type,function(res)
|
||||||
|
ViewUtil.CloseModalWait()
|
||||||
|
if self._is_destroy then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
if res.ReturnCode == 0 then
|
||||||
|
cgv:Destroy()
|
||||||
|
self:FillData()
|
||||||
|
else
|
||||||
|
ViewUtil.ErrorTip(res.ReturnCode, '创建大联盟失败!')
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end)
|
||||||
|
end)
|
||||||
|
|
||||||
|
self.btn_joingroup = self._par_veiw:GetChild('btn_join_group')
|
||||||
|
self.btn_joingroup.displayObject.gameObject:SetActive(false)
|
||||||
|
--[[self.btn_joingroup.onClick:Set(function()
|
||||||
|
local groups = DataManager.groups.groupList
|
||||||
|
if #groups == 0 then
|
||||||
|
local jgv = JoinGroupView.new(self._root_view)
|
||||||
|
jgv:Show()
|
||||||
|
else
|
||||||
|
local info = GroupInfoView.new(groups[1], self.fg_info)
|
||||||
|
self._groupInfoView = info
|
||||||
|
info:SetCallBack(function()
|
||||||
|
self._groupInfoView = nil
|
||||||
|
self:Show()
|
||||||
|
self._view.visible = true
|
||||||
|
end)
|
||||||
|
info:Show()
|
||||||
|
self._view.visible = false
|
||||||
|
end
|
||||||
|
if not DataManager.SelfUser.phone then
|
||||||
|
--local phone_view = PhoneBindView.new()
|
||||||
|
--phone_view:Show()
|
||||||
|
-- return
|
||||||
|
end
|
||||||
|
end)--]]
|
||||||
|
|
||||||
|
-- local btn_setting = self._view:GetChild('btn_setting')
|
||||||
|
-- btn_setting.onClick:Set(
|
||||||
|
-- function()
|
||||||
|
-- local gsv = GroupSettingView.new(self._root_view)
|
||||||
|
-- gsv:FillData()
|
||||||
|
-- gsv:SetCallback(
|
||||||
|
-- function()
|
||||||
|
-- self:FillData()
|
||||||
|
-- end
|
||||||
|
-- )
|
||||||
|
-- gsv:Show()
|
||||||
|
-- end
|
||||||
|
-- )
|
||||||
|
|
||||||
|
local btn_refresh = self._view:GetChild('btn_refresh')
|
||||||
|
btn_refresh.onClick:Set(function()
|
||||||
|
ViewUtil.ShowModalWait(self._root_view)
|
||||||
|
fgCtr:FG_GroupList(function(res)
|
||||||
|
ViewUtil.CloseModalWait()
|
||||||
|
if self._is_destroy then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
if res.ReturnCode == 0 then
|
||||||
|
-- self:__fillTopGroups(res.Data.groups,res.Data.stickGroups)
|
||||||
|
self:FillData(res.Data.groups)
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end)
|
||||||
|
|
||||||
|
local lst_group = self._view:GetChild('lst_group')
|
||||||
|
lst_group.onClickItem:Add(function(context)
|
||||||
|
local curGroup = context.data.data
|
||||||
|
local info = GroupInfoView.new(curGroup, self.fg_info)
|
||||||
|
self._groupInfoView = info
|
||||||
|
info:SetCallBack(function()
|
||||||
|
self._groupInfoView = nil
|
||||||
|
self:Show()
|
||||||
|
self._view.visible = true
|
||||||
|
end)
|
||||||
|
--info:Show()
|
||||||
|
--self._view.visible = false
|
||||||
|
end)
|
||||||
|
|
||||||
|
local ctr_empty_group = self._view:GetController('empty_group')
|
||||||
|
ctr_empty_group.selectedIndex = 1
|
||||||
|
|
||||||
|
local btn_close = self._view:GetChild("btn_close")
|
||||||
|
btn_close.onClick:Set(function()
|
||||||
|
self._view.visible = false
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:DEnterGroup()
|
||||||
|
local groups = DataManager.groups.groupList
|
||||||
|
if #groups == 0 then
|
||||||
|
--local jgv = JoinGroupView.new(self._root_view)
|
||||||
|
--jgv:Show()
|
||||||
|
else
|
||||||
|
local info = GroupInfoView.new(groups[1], self.fg_info)
|
||||||
|
self._groupInfoView = info
|
||||||
|
info:SetCallBack(function()
|
||||||
|
self._groupInfoView = nil
|
||||||
|
self:Show()
|
||||||
|
self._view.visible = true
|
||||||
|
end)
|
||||||
|
--info:Show()
|
||||||
|
--self._view.visible = false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
local function SortGroups(a, b)
|
||||||
|
local sort_a = 0
|
||||||
|
local sort_b = 0
|
||||||
|
sort_a = a.top and 2000 or 0
|
||||||
|
sort_b = b.top and 2000 or 0
|
||||||
|
|
||||||
|
return sort_a > sort_b
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:__fill_item(item,group)
|
||||||
|
item:GetChild('tex_name').text = group.name
|
||||||
|
item:GetChild('tex_id').text = "ID:".. group.id
|
||||||
|
local p_num = group.total_member_num
|
||||||
|
item:GetChild('tex_p_num').text = p_num > 99 and '99+' or p_num
|
||||||
|
|
||||||
|
if group.lev < 3 then
|
||||||
|
if group.lev == 1 then
|
||||||
|
item:GetChild('tex_room_num').text = group.room_num
|
||||||
|
else
|
||||||
|
item:GetChild('tex_room_num').text = group.room_num > 99 and '99+' or group.room_num
|
||||||
|
end
|
||||||
|
else
|
||||||
|
if group.show_num > 0 and group.room_num > group.show_num then
|
||||||
|
item:GetChild('tex_room_num').text = group.show_num > 99 and '99+' or group.show_num--group.show_num
|
||||||
|
else
|
||||||
|
item:GetChild('tex_room_num').text = group.room_num > 99 and '99+' or group.room_num
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local btn_head = item:GetChild('btn_head')
|
||||||
|
btn_head.icon = 'ui://Common/Head0'
|
||||||
|
ImageLoad.Load(group.o_portrait, btn_head._iconObject, self.class)
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:FillData()
|
||||||
|
local groups = DataManager.groups.groupList
|
||||||
|
-- 读取牌友圈信息
|
||||||
|
local filename = 'fginfo_' .. DataManager.SelfUser.account_id
|
||||||
|
local json_data = Utils.LoadLocalFile(filename)
|
||||||
|
local fg_info = not json_data and {} or json.decode(json_data)
|
||||||
|
local fg_info_changed = not json_data and true or (table.nums(fg_info) ~= #groups and true or false)
|
||||||
|
local new_info = {}
|
||||||
|
for i = 1, #groups do
|
||||||
|
local key = tostring(groups[i].id)
|
||||||
|
local key1 = tostring(groups[i].id).."vip"
|
||||||
|
if not fg_info[key] then
|
||||||
|
new_info[key] = 0
|
||||||
|
if not fg_info_changed then
|
||||||
|
fg_info_changed = true
|
||||||
|
end
|
||||||
|
else
|
||||||
|
new_info[key] = fg_info[key]
|
||||||
|
end
|
||||||
|
if not fg_info[key1] then
|
||||||
|
new_info[key1] = 0
|
||||||
|
else
|
||||||
|
new_info[key1] = fg_info[key1]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
self.fg_info = new_info
|
||||||
|
if fg_info_changed and table.nums(new_info) > 0 then
|
||||||
|
Utils.SaveLocalFile(filename, json.encode(new_info))
|
||||||
|
end
|
||||||
|
|
||||||
|
local ctr_empty_group = self._view:GetController('empty_group')
|
||||||
|
if #groups == 0 then
|
||||||
|
self.btn_joingroup:GetController("info").selectedIndex = 0
|
||||||
|
ctr_empty_group.selectedIndex = 1
|
||||||
|
return
|
||||||
|
else
|
||||||
|
self.btn_joingroup:GetController("info").selectedIndex = 1
|
||||||
|
ctr_empty_group.selectedIndex = 0
|
||||||
|
self:__fill_item(self.btn_joingroup,groups[1])
|
||||||
|
end
|
||||||
|
|
||||||
|
local lst_group = self._view:GetChild('lst_group')
|
||||||
|
lst_group:RemoveChildrenToPool()
|
||||||
|
for i = 1, #groups do
|
||||||
|
local group = groups[i]
|
||||||
|
|
||||||
|
local item = lst_group:AddItemFromPool()
|
||||||
|
item.data = group
|
||||||
|
self:__fill_item(item,group)
|
||||||
|
|
||||||
|
local btn_top = item:GetChild('btn_top')
|
||||||
|
local ctr_select = btn_top:GetController('select')
|
||||||
|
ctr_select.selectedIndex = group.top_time > 0 and 1 or 0
|
||||||
|
-- item:GetController('select_index').selectedIndex = group.top_time > 0 and 1 or 0
|
||||||
|
btn_top.onClick:Set(function(context)
|
||||||
|
context:StopPropagation()
|
||||||
|
local fgCtr = ControllerManager.GetController(NewGroupController)
|
||||||
|
ViewUtil.ShowModalWait(self._root_view)
|
||||||
|
fgCtr:FG_TopGroup(group.id,ctr_select.selectedIndex == 0,function(res)
|
||||||
|
ViewUtil.CloseModalWait()
|
||||||
|
if self._is_destroy then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
if res.ReturnCode == 0 then
|
||||||
|
ctr_select.selectedIndex = group.top_time > 0 and 1 or 0
|
||||||
|
self:FillData()
|
||||||
|
else
|
||||||
|
ViewUtil.ErrorTip(res.ReturnCode, '置顶大联盟失败!')
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
-- end
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:OnFGChanged(callback)
|
||||||
|
self._onFGChange = callback
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:EnterGroup(fg_id)
|
||||||
|
local curGroup = DataManager.groups:get(fg_id)
|
||||||
|
local info = GroupInfoView.new(curGroup, self.fg_info)
|
||||||
|
self._groupInfoView = info
|
||||||
|
info:SetCallBack(function()
|
||||||
|
self._groupInfoView = nil
|
||||||
|
self:FillData()
|
||||||
|
self._view.visible = true
|
||||||
|
end)
|
||||||
|
info:Show()
|
||||||
|
--self._view.visible = false
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:Show(fg_id,callback)
|
||||||
|
local fgCtr1 = ControllerManager.GetController(NewGroupController)
|
||||||
|
fgCtr1:FG_GroupList(function(res)
|
||||||
|
if self._is_destroy then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
if res.ReturnCode == 0 then
|
||||||
|
self:FillData()
|
||||||
|
if fg_id then
|
||||||
|
self:EnterGroup(fg_id)
|
||||||
|
else
|
||||||
|
if callback then
|
||||||
|
callback(0)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
else
|
||||||
|
if callback then
|
||||||
|
callback(-1)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:Destroy()
|
||||||
|
if self._onFGChange then
|
||||||
|
self._onFGChange()
|
||||||
|
end
|
||||||
|
ImageLoad.Clear(self.class)
|
||||||
|
UIPackage.RemovePackage('base/newgroup/ui/NewGroup')
|
||||||
|
local num = PlayerPrefs.GetInt('fgroup_bg')
|
||||||
|
if num == 0 then
|
||||||
|
num = 1
|
||||||
|
end
|
||||||
|
ResourcesManager.UnLoadGroup('base/newgroup/bg/bg0' .. num)
|
||||||
|
end
|
||||||
|
|
||||||
|
return M
|
||||||
|
|
@ -0,0 +1,249 @@
|
||||||
|
-- 牌友圈管理界面
|
||||||
|
local MngPageConfig = import(".MngView.MngPageConfig")
|
||||||
|
|
||||||
|
local GroupManagerView = {}
|
||||||
|
|
||||||
|
local M = GroupManagerView
|
||||||
|
|
||||||
|
function GroupManagerView.new(blur_view, gid, btn_type, callback)
|
||||||
|
setmetatable(M, {__index = BaseWindow})
|
||||||
|
local self = setmetatable({}, {__index = M})
|
||||||
|
self.class = "GroupManagerView"
|
||||||
|
-- self._close_destroy = true
|
||||||
|
self._put_map = false
|
||||||
|
self._new_hide = false
|
||||||
|
self._queue = false
|
||||||
|
self._full = true
|
||||||
|
self._animation = false
|
||||||
|
self._blur_view = blur_view
|
||||||
|
self.group_id = gid
|
||||||
|
self.partnerList = {}
|
||||||
|
self.callback = callback
|
||||||
|
self:init("ui://NewGroup/Win_ManagerView", btn_type)
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
-- 获取界面配置
|
||||||
|
local function getPageConfig(id)
|
||||||
|
--pt(MngPageConfig.PageList)
|
||||||
|
for i=1,#MngPageConfig.PageList do
|
||||||
|
local tem = MngPageConfig.PageList[i]
|
||||||
|
if tem.id == id then
|
||||||
|
return tem
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:init(url, btn_type)
|
||||||
|
BaseWindow.init(self,url)
|
||||||
|
self.titleTxt = self._view:GetChild("n79")
|
||||||
|
-- if btn_type == 2 then
|
||||||
|
-- self._view:GetChild("n0"):GetChild("icon").url = "ui://m7iejg46p41ohx8"
|
||||||
|
-- elseif btn_type == 3 then
|
||||||
|
-- self._view:GetChild("n0"):GetChild("icon").url = "ui://m7iejg46p41ohx7"
|
||||||
|
-- elseif btn_type == 4 then
|
||||||
|
-- self._view:GetChild("n0"):GetChild("icon").url = "ui://m7iejg46p41ohx9"
|
||||||
|
-- end
|
||||||
|
local lst_index = self._view:GetChild("lst_index")
|
||||||
|
lst_index:RemoveChildrenToPool()
|
||||||
|
local group = DataManager.groups:get(self.group_id)
|
||||||
|
--根据玩家权限,加载不同的界面配置
|
||||||
|
local lev = group.lev
|
||||||
|
if lev == 3 and group.partnerLev == 0 then
|
||||||
|
lev = 4
|
||||||
|
end
|
||||||
|
|
||||||
|
self.page_config = MngPageConfig.Config[btn_type][lev]
|
||||||
|
|
||||||
|
-- 初始化标题列表
|
||||||
|
for i = 1, #self.page_config do
|
||||||
|
-- print("page_config:"..self.page_config[i])
|
||||||
|
local page = getPageConfig(self.page_config[i])
|
||||||
|
--如果界面无show_key,或圈子中对应的key为true才显示界面
|
||||||
|
if not page.show_key or (page.show_key and group[page.show_key]) then
|
||||||
|
--如果allicance为ture,则只有大联盟才显示界面
|
||||||
|
if (page.alliance and group.type == 2) or not page.alliance then
|
||||||
|
local item = lst_index:AddItemFromPool()
|
||||||
|
local title = page.title
|
||||||
|
item:GetChild("title").text = title
|
||||||
|
if i == 1 then
|
||||||
|
item.selected = true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- coroutine.start(function()
|
||||||
|
-- coroutine.wait(0)
|
||||||
|
-- local anchor = self._view:GetChild("anchor")
|
||||||
|
-- -- 初始界面
|
||||||
|
-- local first_page_config = getPageConfig(self.page_config[1])
|
||||||
|
-- local gmsv = first_page_config.view.new(self.group_id, self._root_view)
|
||||||
|
-- self._view_map = {}
|
||||||
|
-- self._view_map[1] = gmsv
|
||||||
|
-- gmsv.id = first_page_config.id
|
||||||
|
-- anchor:AddChild(gmsv._view)
|
||||||
|
-- printlog("tttttttttttttttttttttt :" , gmsv._view.displayObject.gameObject.name," ",gmsv._view.parent.displayObject.gameObject.name)
|
||||||
|
-- -- gmsv._view:AddRelation(anchor, RelationType.Size)
|
||||||
|
-- local offset = get_offset(self._full_offset)
|
||||||
|
-- gmsv._view.width = GRoot.inst.width -300 - 2 * offset
|
||||||
|
-- gmsv._view.height = GRoot.inst.height
|
||||||
|
-- gmsv._view.x = offset
|
||||||
|
|
||||||
|
-- end)
|
||||||
|
-- 所有子界面加载点
|
||||||
|
local anchor = self._view:GetChild("anchor")
|
||||||
|
-- 初始界面
|
||||||
|
local first_page_config = getPageConfig(self.page_config[1])
|
||||||
|
local gmsv = first_page_config.view.new(self.group_id, self._root_view)
|
||||||
|
self._view_map = {}
|
||||||
|
self._view_map[1] = gmsv
|
||||||
|
gmsv.id = first_page_config.id
|
||||||
|
anchor:AddChild(gmsv._view)
|
||||||
|
--printlog("tttttttttttttttttttttt :" , gmsv._view.displayObject.gameObject.name," ",gmsv._view.parent.displayObject.gameObject.name)
|
||||||
|
--gmsv._view:AddRelation(anchor, RelationType.Size)
|
||||||
|
local offset = get_offset(self._full_offset)
|
||||||
|
gmsv._view.width = GRoot.inst.width - 2 * offset - first_page_config.anchorOffset
|
||||||
|
gmsv._view.height = GRoot.inst.height
|
||||||
|
gmsv._view.x = 0--offset
|
||||||
|
|
||||||
|
-- first_page_config = getPageConfig(self.page_config[2])
|
||||||
|
-- gmsv = first_page_config.view.new(self.group_id, self._root_view)
|
||||||
|
-- self._view_map[2] = gmsv
|
||||||
|
-- gmsv.id = first_page_config.id
|
||||||
|
-- gmsv._view.visible = false
|
||||||
|
|
||||||
|
-- anchor:AddChild(gmsv._view)
|
||||||
|
-- gmsv._view:AddRelation(anchor, RelationType.Size)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
-- if first_page_config.refresh then gmsv:initData() end
|
||||||
|
|
||||||
|
-- if #self.page_config == 1 then
|
||||||
|
-- self._view:GetController("single").selectedIndex = 1
|
||||||
|
-- lst_index.visible = false
|
||||||
|
-- self._view:GetChild("n0"):GetController("v_menu").selectedIndex = 1
|
||||||
|
-- end
|
||||||
|
|
||||||
|
|
||||||
|
-- 切换界面
|
||||||
|
self.ctr_index = self._view:GetController("index")
|
||||||
|
self.ctr_index.onChanged:Set(function(pas)
|
||||||
|
local anchor = self._view:GetChild("anchor")
|
||||||
|
anchor:RemoveChildren()
|
||||||
|
|
||||||
|
|
||||||
|
local index = self.ctr_index.selectedIndex
|
||||||
|
local page_info = getPageConfig(self.page_config[index + 1])
|
||||||
|
if not self._view_map[index + 1] then
|
||||||
|
|
||||||
|
local tem = page_info.view.new(self.group_id, self._root_view)
|
||||||
|
|
||||||
|
-- anchor:AddRelation(self._root_view, RelationType.Size,true)
|
||||||
|
--tem._view:Center(true)
|
||||||
|
|
||||||
|
--print("222222222222222",anchor._view)
|
||||||
|
anchor:AddChild(tem._view)
|
||||||
|
-- tem._view.parent = anchor
|
||||||
|
|
||||||
|
local offset = get_offset(self._full_offset)
|
||||||
|
tem._view.width = GRoot.inst.width - 2 * offset - page_info.anchorOffset
|
||||||
|
tem._view.height = GRoot.inst.height
|
||||||
|
tem._view.x = 0--offset
|
||||||
|
--tem._view:AddRelation(self._root_view, RelationType.Size)
|
||||||
|
-- tem._view:MakeFullScreen()
|
||||||
|
|
||||||
|
tem.id = page_info.id
|
||||||
|
self._view_map[index + 1] = tem
|
||||||
|
--
|
||||||
|
-- anchor:SetBoundsChangedFlag()
|
||||||
|
-- anchor:EnsureBoundsCorrect()
|
||||||
|
-- tem._view:RemoveRelation(anchor, RelationType.Size)
|
||||||
|
--tem._view:AddRelation(anchor, RelationType.Size)
|
||||||
|
else
|
||||||
|
--self._view_map[index + 1]._view:AddRelation(anchor, RelationType.Size)
|
||||||
|
anchor:AddChild(self._view_map[index + 1]._view)
|
||||||
|
end
|
||||||
|
|
||||||
|
--self._view:AddRelation(anchor, RelationType.Size)
|
||||||
|
-- 如果refresh为true,重新加载界面时执行初始化数据方法initData
|
||||||
|
if page_info.refresh then
|
||||||
|
self._view_map[index + 1]:initData()
|
||||||
|
end
|
||||||
|
self.titleTxt.text = page_info.title
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function M:SetCurrentGroupInfoViewIns(groupInfoViewCallBack)
|
||||||
|
self.groupInfoViewCallBack=groupInfoViewCallBack
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- 获取指定ID的页面
|
||||||
|
function M:GetPageByID(id)
|
||||||
|
for i, v in pairs(self._view_map) do
|
||||||
|
if v.id == id then
|
||||||
|
return v
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
|
||||||
|
-- 根据ID刷新页面
|
||||||
|
function M:RefreshPage(id)
|
||||||
|
local page = self:GetPageByID(id)
|
||||||
|
if not page then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
page:initData()
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:Close()
|
||||||
|
if self.callback then self.callback() end
|
||||||
|
BaseWindow.Close(self)
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:Destroy()
|
||||||
|
for i = 1, #self.page_config do
|
||||||
|
if self._view_map[i] then
|
||||||
|
self._view_map[i]._view:Dispose()
|
||||||
|
if self._view_map[i].clear_image then
|
||||||
|
ImageLoad.Clear(self._view_map[i].class)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
BaseWindow.Destroy(self)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- quick_access_id 是快速访问标志,打开对应id的页面
|
||||||
|
function M:Show(quick_access_id)
|
||||||
|
local index = self.ctr_index.selectedIndex
|
||||||
|
printlog("index+1index+1index+1index+1 ",index+1)
|
||||||
|
if not quick_access_id then
|
||||||
|
local page_info = getPageConfig(self.page_config[index + 1])
|
||||||
|
if page_info.refresh then self._view_map[index + 1]:initData() end
|
||||||
|
self.titleTxt.text = page_info.title
|
||||||
|
else
|
||||||
|
-- 如果是 快速访问
|
||||||
|
for i, v in pairs(self.page_config) do
|
||||||
|
if getPageConfig(v).id == quick_access_id then
|
||||||
|
self.ctr_index.selectedIndex = i - 1
|
||||||
|
if not self._view_map[i] then
|
||||||
|
local tem = page_info.view.new(self.group_id, self._root_view)
|
||||||
|
self._view_map[i] = tem
|
||||||
|
end
|
||||||
|
local anchor = self._view:GetChild("anchor")
|
||||||
|
anchor:AddChild(self._view_map[i]._view)
|
||||||
|
self._view_map[i]:navigation()
|
||||||
|
--self._view:AddRelation(anchor, RelationType.Size)
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
BaseWindow.Show(self)
|
||||||
|
end
|
||||||
|
|
||||||
|
return M
|
||||||
|
|
@ -0,0 +1,291 @@
|
||||||
|
-- 能量包
|
||||||
|
local GroupTakeLogView = import(".MngView.GroupTakeLogView")
|
||||||
|
local GroupRewardsLogView = import(".MngView.GroupRewardsLogView")
|
||||||
|
local GroupNumberInputView = import(".MngView.GroupNumberInputView")
|
||||||
|
local GroupBankLogView = import(".MngView.GroupBankLogView")
|
||||||
|
|
||||||
|
local GroupMngFagPackView = {}
|
||||||
|
|
||||||
|
local M = GroupMngFagPackView
|
||||||
|
|
||||||
|
function GroupMngFagPackView.new(gid, blur_view,ctrNum,uid)
|
||||||
|
setmetatable(M, {__index = BaseWindow})
|
||||||
|
local self = setmetatable({}, {__index = M})
|
||||||
|
|
||||||
|
self.class = "GroupMngFagPackView"
|
||||||
|
self._close_destroy = true
|
||||||
|
self.group_id = gid
|
||||||
|
self.blur_view = blur_view
|
||||||
|
self.ctrNum=ctrNum
|
||||||
|
self.shouyiData = {}
|
||||||
|
self.uid = uid
|
||||||
|
self:init("ui://NewGroup/Win_bxx")
|
||||||
|
self:FillView()
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:FillView()
|
||||||
|
|
||||||
|
self.Ctr=self._view:GetController("ctr")
|
||||||
|
self.Ctr.selectedIndex=1
|
||||||
|
|
||||||
|
self.lst_bxx = self._view:GetChild('bxx_list')
|
||||||
|
self.lst_bxx:SetVirtual()
|
||||||
|
self.lst_bxx.itemRenderer = function(index, item)
|
||||||
|
self:fillGameItem(index, item)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
self.lst_bxx.onClickItem:Add(
|
||||||
|
function(pas)
|
||||||
|
if self.currentSelectItem == pas.data then return end
|
||||||
|
local name=pas.data.icon
|
||||||
|
self.currentGameItemName=name
|
||||||
|
self.lst_bxx.numItems=self.ctrNum
|
||||||
|
end
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
self.playerJF=self._view:GetChild('tex_player')
|
||||||
|
self.bankJF=self._view:GetChild('tex_bank')
|
||||||
|
|
||||||
|
self.ctr_page = self._view:GetController("type")
|
||||||
|
self.ctr_page.onChanged:Set(function()
|
||||||
|
if self.ctr_page.selectedIndex == 0 then
|
||||||
|
if self.shouyiData.day_rewad then
|
||||||
|
self._view:GetChild("tex_total").text = d2ad(self.shouyiData.day_rewad)
|
||||||
|
end
|
||||||
|
elseif self.ctr_page.selectedIndex == 1 then
|
||||||
|
if self.shouyiData.day_rewad_1 then
|
||||||
|
self._view:GetChild("tex_total").text = d2ad(self.shouyiData.day_rewad_1)
|
||||||
|
end
|
||||||
|
elseif self.ctr_page.selectedIndex == 2 then
|
||||||
|
if self.shouyiData.day_rewad_2 then
|
||||||
|
self._view:GetChild("tex_total").text = d2ad(self.shouyiData.day_rewad_2)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
|
self._view:GetChild("btn_bankinfo").onClick:Set(function()
|
||||||
|
local gtlv = GroupBankLogView.new(self.blur_view, self.group_id,self.uid)
|
||||||
|
gtlv:Show()
|
||||||
|
end)
|
||||||
|
|
||||||
|
local btn_cr = self._view:GetChild('btn_qd')
|
||||||
|
btn_cr.onClick:Set(
|
||||||
|
function()
|
||||||
|
|
||||||
|
local gniv = GroupNumberInputView.new(nil, function(num)
|
||||||
|
|
||||||
|
local value = limit
|
||||||
|
if otype == 1 then
|
||||||
|
value = value + ad2d(num)
|
||||||
|
elseif otype == - 1 then
|
||||||
|
value = value - ad2d(num)
|
||||||
|
else
|
||||||
|
value = ad2d(num)
|
||||||
|
end
|
||||||
|
|
||||||
|
if value < 0 then
|
||||||
|
ViewUtil.ErrorTip(1,"输入数据异常!")
|
||||||
|
end
|
||||||
|
|
||||||
|
ViewUtil.ShowModalWait()
|
||||||
|
local fgCtr = ControllerManager.GetController(NewGroupController)
|
||||||
|
fgCtr:FG_SAVEBankInfo(self.group_id, value,self.uid ,function(res1)
|
||||||
|
ViewUtil.CloseModalWait()
|
||||||
|
pt(res1)
|
||||||
|
if (res1.ReturnCode == 0) then
|
||||||
|
self:SetBank(res1.Data.hp,res1.Data.b_hp)
|
||||||
|
ViewUtil.ErrorTip(100011000,"积分存取成功!")
|
||||||
|
else
|
||||||
|
ViewUtil.ErrorTip(res1.ReturnCode,"存取积分失败!")
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
|
end, 0, nil)
|
||||||
|
gniv:Show()
|
||||||
|
|
||||||
|
|
||||||
|
end
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
local btn_qc = self._view:GetChild('btn_qc')
|
||||||
|
btn_qc.onClick:Set(
|
||||||
|
function()
|
||||||
|
|
||||||
|
local gniv = GroupNumberInputView.new(nil, function(num)
|
||||||
|
|
||||||
|
local value = limit
|
||||||
|
if otype == 1 then
|
||||||
|
value = value + ad2d(num)
|
||||||
|
elseif otype == - 1 then
|
||||||
|
value = value - ad2d(num)
|
||||||
|
else
|
||||||
|
value = ad2d(num)
|
||||||
|
end
|
||||||
|
|
||||||
|
if value < 0 then
|
||||||
|
ViewUtil.ErrorTip(1,"输入数据异常!")
|
||||||
|
end
|
||||||
|
|
||||||
|
ViewUtil.ShowModalWait()
|
||||||
|
local fgCtr = ControllerManager.GetController(NewGroupController)
|
||||||
|
fgCtr:FG_TakeBankInfo(self.group_id, value,self.uid, function(res1)
|
||||||
|
ViewUtil.CloseModalWait()
|
||||||
|
pt(res1)
|
||||||
|
if (res1.ReturnCode == 0) then
|
||||||
|
self:SetBank(res1.Data.hp,res1.Data.b_hp)
|
||||||
|
ViewUtil.ErrorTip(100011000,"积分取出成功!")
|
||||||
|
else
|
||||||
|
ViewUtil.ErrorTip(res1.ReturnCode,"获取积分失败!")
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
|
end, 0, nil)
|
||||||
|
gniv:Show()
|
||||||
|
|
||||||
|
end
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
---------------------------
|
||||||
|
self._view:GetChild("btn_take_log").onClick:Set(function()
|
||||||
|
local gtlv = GroupTakeLogView.new(self.blur_view, self.group_id,self.uid)
|
||||||
|
gtlv:Show()
|
||||||
|
end)
|
||||||
|
self._view:GetChild("btn_hp_info").onClick:Set(function()
|
||||||
|
local grlv = GroupRewardsLogView.new(self.blur_view, self.group_id,self.uid)
|
||||||
|
grlv:Show()
|
||||||
|
end)
|
||||||
|
self._view:GetChild("btn_take").onClick:Set(function()
|
||||||
|
local gniv = GroupNumberInputView.new(self.blur_view, function(num)
|
||||||
|
if ad2d(num) > self._total_hp then
|
||||||
|
ViewUtil.ErrorTip(nil, "奖励池积分不足")
|
||||||
|
return
|
||||||
|
end
|
||||||
|
local fgCtr = ControllerManager.GetController(NewGroupController)
|
||||||
|
fgCtr:FG_TakeHp(self.group_id, ad2d(num), self.uid,function(res)
|
||||||
|
if num == 0 then
|
||||||
|
ViewUtil.ErrorTip(nil, "提取值必须大于0")
|
||||||
|
return
|
||||||
|
end
|
||||||
|
if res.ReturnCode ~= 0 then
|
||||||
|
ViewUtil.ErrorTip(res.ReturnCode, "提取能量包失败")
|
||||||
|
else
|
||||||
|
self._total_hp = res.Data.r_hp
|
||||||
|
self._view:GetChild("tex_left").text = d2ad(self._total_hp)
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end, 1, d2ad(self._total_hp), "ui://NewGroup/Win_TakeHp")
|
||||||
|
gniv:Show()
|
||||||
|
end)
|
||||||
|
|
||||||
|
--self:initBankData()
|
||||||
|
self:initShouyiData()
|
||||||
|
self.lst_bxx.numItems=self.ctrNum
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function M:initBankData()
|
||||||
|
ViewUtil.ShowModalWait()
|
||||||
|
local fgCtr = ControllerManager.GetController(NewGroupController)
|
||||||
|
fgCtr:FG_GetBankInfo(self.group_id, self.uid,function(res)
|
||||||
|
pt(res)
|
||||||
|
ViewUtil.CloseModalWait()
|
||||||
|
if res.ReturnCode ~= 0 then
|
||||||
|
ViewUtil.ErrorTip(res.ReturnCode, "获取银行数据失败")
|
||||||
|
else
|
||||||
|
self:SetBank(res.Data.total_hp,res.Data.bank_hp)
|
||||||
|
self.Ctr.selectedIndex=0
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function M:initShouyiData()
|
||||||
|
ViewUtil.ShowModalWait()
|
||||||
|
self.shouyiData = {}
|
||||||
|
self._view:GetChild("tex_total").text = 0
|
||||||
|
local fgCtr = ControllerManager.GetController(NewGroupController)
|
||||||
|
fgCtr:FG_GetTakeInfo(self.group_id,self.uid ,function(res)
|
||||||
|
ViewUtil.CloseModalWait()
|
||||||
|
if res.ReturnCode ~= 0 then
|
||||||
|
ViewUtil.ErrorTip(res.ReturnCode, "获取保险箱数据失败")
|
||||||
|
else
|
||||||
|
local data = res.Data
|
||||||
|
self.ctr_page.selectedIndex = 0
|
||||||
|
self.shouyiData = data
|
||||||
|
self._view:GetChild("tex_left").text = d2ad(data.total_hp)
|
||||||
|
self._view:GetChild("tex_total").text = d2ad(data.day_rewad)
|
||||||
|
--self._view:GetChild("tex_totalshouyi").text = 0
|
||||||
|
self._total_hp = data.total_hp
|
||||||
|
self.Ctr.selectedIndex=1
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:SetCallback(callback)
|
||||||
|
self.callback = callback
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function M:SetBank(totalHp,bankHp)
|
||||||
|
self.playerJF.text=totalHp/1000
|
||||||
|
self.bankJF.text=bankHp/1000
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function M:fillGameItem(index, item)
|
||||||
|
if index~=0 then
|
||||||
|
item.icon="ui://NewGroup/button_cqg"
|
||||||
|
if self.currentGameItemName==nil then
|
||||||
|
item.icon="ui://NewGroup/button_cqg_xz"
|
||||||
|
end
|
||||||
|
else
|
||||||
|
item.icon="ui://NewGroup/button_sjjl"
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if self.currentGameItemName==item.icon then
|
||||||
|
item.icon=item.icon.."_xz"
|
||||||
|
if index~=0 then
|
||||||
|
self:initBankData()
|
||||||
|
else
|
||||||
|
self:initShouyiData()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
-- 销毁窗口
|
||||||
|
function M:Destroy(remove_map)
|
||||||
|
if self.callback then
|
||||||
|
self.callback()
|
||||||
|
end
|
||||||
|
BaseWindow.Destroy(self,remove_map)
|
||||||
|
ImageLoad.Clear(self.class)
|
||||||
|
end
|
||||||
|
|
||||||
|
return M
|
||||||
|
|
@ -0,0 +1,125 @@
|
||||||
|
-- 牌友圈设置界面
|
||||||
|
local GroupMngSettingView = {}
|
||||||
|
|
||||||
|
local M = GroupMngSettingView
|
||||||
|
|
||||||
|
function GroupMngSettingView.new(gid)
|
||||||
|
setmetatable(M, {__index = BaseWindow})
|
||||||
|
local self = setmetatable({}, {__index = M})
|
||||||
|
self.class = "GroupMngSettingView"
|
||||||
|
self._close_destroy = true
|
||||||
|
self.group_id = gid
|
||||||
|
-- self._full = true
|
||||||
|
self:init("ui://NewGroup/Win_GroupSetting")
|
||||||
|
self:FillView()
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:initData()
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:FillView()
|
||||||
|
local tex_name = self._view:GetChild("tex_name")
|
||||||
|
local tex_notice = self._view:GetChild("tex_notice")
|
||||||
|
local ctr_ban = self._view:GetController("ban")
|
||||||
|
local ctr_dissolve_time = self._view:GetController("dissolve_time")
|
||||||
|
local ctr_kick_time = self._view:GetController("kick_time")
|
||||||
|
local ctr_apply = self._view:GetController("apply")
|
||||||
|
local ctr_alliance = self._view:GetController("alliance")
|
||||||
|
|
||||||
|
local ctr_pt = self._view:GetController("pt")
|
||||||
|
local ctr_wq = self._view:GetController("wq")
|
||||||
|
local ctr_es = self._view:GetController("es")
|
||||||
|
local ctr_ua = self._view:GetController("ua")
|
||||||
|
|
||||||
|
local ctl_show_num = self._view:GetController("showAll")
|
||||||
|
|
||||||
|
local btn_chat_input = self._view:GetChild("btn_chat_input")
|
||||||
|
local btn_chat_voice = self._view:GetChild("btn_chat_voice")
|
||||||
|
local group = DataManager.groups:get(self.group_id)
|
||||||
|
tex_name.text = group.name
|
||||||
|
tex_notice.text = group.notice
|
||||||
|
ctr_ban.selectedIndex = group.ban and 1 or 0
|
||||||
|
ctr_dissolve_time.selectedIndex = group.dissolve_opt - 1
|
||||||
|
ctr_kick_time.selectedIndex = group.kick_opt - 1
|
||||||
|
ctr_alliance.selectedIndex = group.type - 1
|
||||||
|
ctr_apply.selectedIndex = group.apply or 0
|
||||||
|
btn_chat_input.selected = not group.ban_chat1
|
||||||
|
btn_chat_voice.selected = not group.ban_chat2
|
||||||
|
|
||||||
|
if group.show_num == 0 then
|
||||||
|
ctl_show_num.selectedIndex = 0
|
||||||
|
else
|
||||||
|
ctl_show_num.selectedIndex = 1
|
||||||
|
self._view:GetChild("txt_show_num").text = tostring(group.show_num)
|
||||||
|
end
|
||||||
|
|
||||||
|
local option = group.option or 0
|
||||||
|
|
||||||
|
ctr_pt.selectedIndex = bit:_and(option,1) > 0 and 1 or 0
|
||||||
|
ctr_wq.selectedIndex = bit:_and(option,2) > 0 and 1 or 0
|
||||||
|
ctr_es.selectedIndex = bit:_and(option,4) > 0 and 1 or 0
|
||||||
|
ctr_ua.selectedIndex = bit:_and(option,8) > 0 and 1 or 0
|
||||||
|
|
||||||
|
self._view:GetChild("btn_ok").onClick:Set(function()
|
||||||
|
ViewUtil.ShowModalWait()
|
||||||
|
local gid = self.group_id
|
||||||
|
local name = tex_name.text
|
||||||
|
local notice = tex_notice.text
|
||||||
|
local ban = ctr_ban.selectedIndex == 1
|
||||||
|
local dissolve_opt = ctr_dissolve_time.selectedIndex + 1
|
||||||
|
local kick_opt = ctr_kick_time.selectedIndex + 1
|
||||||
|
local apply = ctr_alliance.selectedIndex == 1 and ctr_apply.selectedIndex or 0
|
||||||
|
local ban_chat1 = not btn_chat_input.selected
|
||||||
|
local ban_chat2 = not btn_chat_voice.selected
|
||||||
|
local fgCtr = ControllerManager.GetController(NewGroupController)
|
||||||
|
|
||||||
|
local pt = ctr_pt.selectedIndex
|
||||||
|
local wq = ctr_wq.selectedIndex
|
||||||
|
local es = ctr_es.selectedIndex
|
||||||
|
local ua = ctr_ua.selectedIndex
|
||||||
|
|
||||||
|
local option = 0
|
||||||
|
if ctr_pt.selectedIndex == 1 then
|
||||||
|
option = bit:_or(option,1)
|
||||||
|
end
|
||||||
|
if ctr_wq.selectedIndex == 1 then
|
||||||
|
option = bit:_or(option,2)
|
||||||
|
end
|
||||||
|
if ctr_es.selectedIndex == 1 then
|
||||||
|
option = bit:_or(option,4)
|
||||||
|
end
|
||||||
|
if ctr_ua.selectedIndex == 1 then
|
||||||
|
option = bit:_or(option,8)
|
||||||
|
end
|
||||||
|
|
||||||
|
local showNum = 0
|
||||||
|
if ctl_show_num.selectedIndex == 1 then
|
||||||
|
local strShowNum = self._view:GetChild("txt_show_num").text
|
||||||
|
if strShowNum ~= nil and strShowNum ~= "" then
|
||||||
|
showNum = tonumber(self._view:GetChild("txt_show_num").text)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
fgCtr:FG_UpdateGroupInfo(gid, name, notice, ban, dissolve_opt, kick_opt, apply, ban_chat1, ban_chat2, option,showNum, function(res)
|
||||||
|
ViewUtil.CloseModalWait()
|
||||||
|
if res.ReturnCode ~= 0 then
|
||||||
|
ViewUtil.ErrorTip(res.ReturnCode,"设置大联盟失败。")
|
||||||
|
else
|
||||||
|
ViewUtil.ShowBannerOnScreenCenter("设置成功")
|
||||||
|
group.name = name
|
||||||
|
group.notice = notice
|
||||||
|
group.ban = ban
|
||||||
|
group.ban_ip = ban_ip
|
||||||
|
group.ban_gps = ban_gps
|
||||||
|
group.apply = apply
|
||||||
|
group.option = option
|
||||||
|
group.ban_chat1 = ban_chat1
|
||||||
|
group.ban_chat2 = ban_chat2
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
return M
|
||||||
|
|
@ -0,0 +1,41 @@
|
||||||
|
-- 快速上桌
|
||||||
|
local GroupQuickStartView = {}
|
||||||
|
|
||||||
|
local M = GroupQuickStartView
|
||||||
|
|
||||||
|
function GroupQuickStartView.new(blur_view,callback)
|
||||||
|
setmetatable(M, {__index = BaseWindow})
|
||||||
|
local self = setmetatable({}, {__index = M})
|
||||||
|
self.class = "GroupQuickStartView"
|
||||||
|
self._close_destroy = true
|
||||||
|
self._blur_view = blur_view
|
||||||
|
self._callback = callback
|
||||||
|
local url = "ui://NewGroup/Win_QuickStart"
|
||||||
|
self:init(url)
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:init(url)
|
||||||
|
BaseWindow.init(self,url)
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:FillData(list, index)
|
||||||
|
self._index = index
|
||||||
|
local lst_game = self._view:GetChild("lst_game")
|
||||||
|
lst_game:RemoveChildrenToPool()
|
||||||
|
for i = 1, #list do
|
||||||
|
local tem = list[i]
|
||||||
|
local item = lst_game:AddItemFromPool()
|
||||||
|
item.title = tem.name
|
||||||
|
item.selected = index == i
|
||||||
|
end
|
||||||
|
local btn_confirm = self._view:GetChild("btn_confirm")
|
||||||
|
btn_confirm.onClick:Set(function()
|
||||||
|
if self._callback then
|
||||||
|
self._callback(lst_game.selectedIndex + 1)
|
||||||
|
end
|
||||||
|
self:Destroy()
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
return M
|
||||||
|
|
@ -0,0 +1,307 @@
|
||||||
|
--牌友圈选择玩法View
|
||||||
|
|
||||||
|
|
||||||
|
local GroupRecordView = {}
|
||||||
|
|
||||||
|
local M = GroupRecordView
|
||||||
|
|
||||||
|
function GroupRecordView.new(curGroup, qid, includeMembers, begin_time, end_time, time_type)
|
||||||
|
|
||||||
|
setmetatable(M, {__index = BaseWindow})
|
||||||
|
local self = setmetatable({}, {__index = M})
|
||||||
|
self.class = "GroupRecordView"
|
||||||
|
self._close_destroy = true
|
||||||
|
self.curGroup = curGroup
|
||||||
|
self.qid = qid
|
||||||
|
self.includeMembers = includeMembers
|
||||||
|
self.begin_time = begin_time
|
||||||
|
self.end_time = end_time
|
||||||
|
self.time_type = time_type
|
||||||
|
self:init("ui://NewGroup/View_GroupStatSpe")
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:init(url)
|
||||||
|
BaseWindow.init(self,url)
|
||||||
|
|
||||||
|
self.record_data = {} --回放数据
|
||||||
|
|
||||||
|
self.lst_record = self._view:GetChild("lst_record")
|
||||||
|
self.lst_record:SetVirtual()
|
||||||
|
self.lst_record.itemRenderer = function(index, obj)
|
||||||
|
self:OnRenderRecordItem(index, obj)
|
||||||
|
end
|
||||||
|
self.lst_record.scrollPane.onPullUpRelease:Set(function()
|
||||||
|
self:GetRecordData(self.lst_record.numItems)
|
||||||
|
end)
|
||||||
|
|
||||||
|
self:GetRecordData(0)
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:OnRenderRecordItem(index, obj)
|
||||||
|
local data = self.record_data[index + 1]
|
||||||
|
self:FillRecordItem(data, obj)
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:GetRecordData(index)
|
||||||
|
|
||||||
|
ViewUtil.ShowModalWait()
|
||||||
|
local fgCtr = ControllerManager.GetController(NewGroupController)
|
||||||
|
fgCtr:FG_GetGroupRecordSpe(self.curGroup, GetPlatform(), self.qid, self.includeMembers, index, 6, self.begin_time, self.end_time, self.time_type, function(res)
|
||||||
|
|
||||||
|
if self._is_destroy then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
ViewUtil.CloseModalWait()
|
||||||
|
|
||||||
|
if res.ReturnCode ~= 0 then
|
||||||
|
ViewUtil.ErrorTip(res.ReturnCode, "获取回放数据失败")
|
||||||
|
else
|
||||||
|
local records = res.Data.records
|
||||||
|
for i = 1, #records do
|
||||||
|
self.record_data[#self.record_data + 1] = records[i]
|
||||||
|
end
|
||||||
|
self.lst_record.numItems = #self.record_data
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:FillRecordItem(data, obj)
|
||||||
|
|
||||||
|
local game_id = data.game_id
|
||||||
|
local room_id = data.room_id
|
||||||
|
local create_time = data.create_time
|
||||||
|
local room_type_str = data.game_info.name
|
||||||
|
local time =tonumber(create_time)
|
||||||
|
local room_time_str = os.date("%Y-%m-%d\n%H:%M", time)
|
||||||
|
local totalScore = json.decode(data.totalScore)
|
||||||
|
local hpOnOff = data.hpOnOff
|
||||||
|
local hpType = data.game_info.hpType
|
||||||
|
local player_list = {}
|
||||||
|
for i = 1, #totalScore do
|
||||||
|
local p = totalScore[i]
|
||||||
|
player_list[i] = {}
|
||||||
|
player_list[i].id = p.accId
|
||||||
|
local score = p.score
|
||||||
|
if hpOnOff == 1 and hpType > 1 then
|
||||||
|
score = score / 10
|
||||||
|
end
|
||||||
|
player_list[i].score = score
|
||||||
|
player_list[i].house = 0
|
||||||
|
player_list[i].nick = p.nick
|
||||||
|
end
|
||||||
|
local play_name = DataManager.groups:get(self.curGroup):getPlayName(data.groupPid)
|
||||||
|
|
||||||
|
obj:GetChild("tex_time").text = room_time_str
|
||||||
|
obj:GetChild("tex_roomid").text = room_id
|
||||||
|
obj:GetChild("tex_times").text = d2ad(data.hp_times).."倍"
|
||||||
|
obj:GetChild("tex_game").text = play_name
|
||||||
|
local lst_total = obj:GetChild("lst_total")
|
||||||
|
lst_total:RemoveChildrenToPool()
|
||||||
|
for j=1,#totalScore do
|
||||||
|
local titem = lst_total:AddItemFromPool()
|
||||||
|
local trdata = totalScore[j]
|
||||||
|
titem:GetChild("tex_name").text = ViewUtil.stringEllipsis(trdata.nick)
|
||||||
|
titem:GetChild("tex_id").text = "ID:"..trdata.accId
|
||||||
|
local score = trdata.score
|
||||||
|
if trdata.hp == nil then
|
||||||
|
if hpOnOff == 1 and hpType > 1 then
|
||||||
|
score = score / 10
|
||||||
|
end
|
||||||
|
else
|
||||||
|
score = d2ad(trdata.hp)
|
||||||
|
end
|
||||||
|
|
||||||
|
titem:GetChild("tex_score").text = score
|
||||||
|
|
||||||
|
if score >= 0 then
|
||||||
|
titem:GetController("num_color").selectedIndex = 0
|
||||||
|
else
|
||||||
|
titem:GetController("num_color").selectedIndex = 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if #totalScore >= 6 then
|
||||||
|
obj:GetController("person_num").selectedIndex = 1
|
||||||
|
else
|
||||||
|
obj:GetController("person_num").selectedIndex = 0
|
||||||
|
end
|
||||||
|
|
||||||
|
obj:GetChild("btn_screenshot").onClick:Set(function()
|
||||||
|
self:OnShareScreenShot(room_id, room_type_str, room_time_str, totalScore, hpOnOff, hpType)
|
||||||
|
end)
|
||||||
|
|
||||||
|
obj:GetChild("btn_share").onClick:Set(function()
|
||||||
|
ShareChatRoom(room_id, tostring(os.time()), data.round, room_type_str, self.group_id, player_list)
|
||||||
|
end)
|
||||||
|
obj.onClick:Set(function()
|
||||||
|
self:OnShowRecordInfo(data)
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:OnShareScreenShot(room_id, room_type_str, room_time_str, totalScore, hpOnOff, hpType)
|
||||||
|
ViewUtil.ShowModalWait(self._view, "正在分享...")
|
||||||
|
UIPackage.AddPackage("base/rank/ui/Rank")
|
||||||
|
local result_view = UIPackage.CreateObjectFromURL("ui://Rank/ResultView")
|
||||||
|
result_view.visible = false
|
||||||
|
self._view:AddChild(result_view)
|
||||||
|
result_view.x = -308
|
||||||
|
result_view.y = -47
|
||||||
|
result_view:GetChild("tex_roomnum").text = "房间号:" .. room_id .. " " .. room_type_str
|
||||||
|
result_view:GetChild("tex_data").text = room_time_str
|
||||||
|
result_view:GetChild("btn_confirm").onClick:Set(function() result_view:Dispose() end)
|
||||||
|
local lst_p = result_view:GetChild("list_result")
|
||||||
|
local load_head_num = #totalScore
|
||||||
|
for j = 1, #totalScore do
|
||||||
|
local p = totalScore[j]
|
||||||
|
local item = lst_p:AddItemFromPool()
|
||||||
|
item:GetChild("name").text = p.nick
|
||||||
|
local score = p.score
|
||||||
|
if hpOnOff == 1 and hpType > 1 then
|
||||||
|
score = score / 10
|
||||||
|
end
|
||||||
|
item:GetChild("score").text = score
|
||||||
|
if score < 0 then item:GetController("di").selectedIndex = 1 end
|
||||||
|
if p.portrait and p.portrait ~= "" then
|
||||||
|
ImageLoad.Load(p.portrait, item:GetChild("n9")._iconObject, self.class, function( ... )
|
||||||
|
load_head_num = load_head_num - 1
|
||||||
|
end)
|
||||||
|
else
|
||||||
|
load_head_num = load_head_num - 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
coroutine.start(function ( ... )
|
||||||
|
local left_time = 4
|
||||||
|
while (true) do
|
||||||
|
if load_head_num == 0 or left_time == 0 then
|
||||||
|
result_view.visible = true
|
||||||
|
coroutine.wait(0.2)
|
||||||
|
ShareScreenShotWithOption(function()
|
||||||
|
result_view:Dispose()
|
||||||
|
end)
|
||||||
|
ViewUtil.CloseModalWait()
|
||||||
|
break
|
||||||
|
end
|
||||||
|
coroutine.wait(1)
|
||||||
|
left_time = left_time - 1
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:OnShowRecordInfo(rdata)
|
||||||
|
local ctr_record = self._view:GetController("record")
|
||||||
|
ctr_record.selectedIndex = 1
|
||||||
|
|
||||||
|
local lst_recordInfo = self._view:GetChild("lst_recordInfo")
|
||||||
|
lst_recordInfo:RemoveChildrenToPool()
|
||||||
|
-- lst_recordInfo.scrollPane.currentPageX = 0
|
||||||
|
local round_count = tonumber(rdata.round)
|
||||||
|
local game_id = rdata.game_info.game_id
|
||||||
|
local playback_id = rdata.military_id
|
||||||
|
local hpOnOff = rdata.hpOnOff
|
||||||
|
local hpType = rdata.game_info.hpType
|
||||||
|
local play_name = DataManager.groups:get(self.curGroup):getPlayName(rdata.groupPid)
|
||||||
|
for i = 1,round_count do
|
||||||
|
local item = lst_recordInfo:AddItemFromPool()
|
||||||
|
item:GetChild("tex_num").text = tostring(i)
|
||||||
|
item:GetChild("tex_game").text = play_name
|
||||||
|
item:GetChild("tex_times").text = d2ad(rdata.hp_times).."倍"
|
||||||
|
item:GetChild("tex_roomid").text = rdata.room_id
|
||||||
|
local round_score_str = rdata["round_"..i]
|
||||||
|
local round_score_item = json.decode(round_score_str)
|
||||||
|
local lst_total = item:GetChild("lst_total")
|
||||||
|
lst_total:RemoveChildrenToPool()
|
||||||
|
for k=1,#round_score_item do
|
||||||
|
local titem = lst_total:AddItemFromPool()
|
||||||
|
local trdata = round_score_item[k]
|
||||||
|
titem:GetChild("tex_name").text = ViewUtil.stringEllipsis(trdata.nick)
|
||||||
|
titem:GetChild("tex_id").text = trdata.accId and ("ID:"..trdata.accId) or ""
|
||||||
|
local score = trdata.score
|
||||||
|
if trdata.hp == nil then
|
||||||
|
if hpOnOff == 1 and hpType > 1 then
|
||||||
|
score = score / 10
|
||||||
|
end
|
||||||
|
else
|
||||||
|
score = d2ad(trdata.hp)
|
||||||
|
end
|
||||||
|
|
||||||
|
titem:GetChild("tex_score").text = score
|
||||||
|
end
|
||||||
|
|
||||||
|
if #round_score_item >= 6 then
|
||||||
|
item:GetController("person_num").selectedIndex = 1
|
||||||
|
else
|
||||||
|
item:GetController("person_num").selectedIndex = 0
|
||||||
|
end
|
||||||
|
|
||||||
|
local btn_play =item:GetChild("btn_play")
|
||||||
|
btn_play.onClick:Set(function()
|
||||||
|
local group = DataManager.groups:get(self.curGroup)
|
||||||
|
if DataManager.SelfUser.playback[playback_id] ~= nil and DataManager.SelfUser.playback[playback_id][i] ~= nil then
|
||||||
|
local room = ExtendManager.GetExtendConfig(game_id):NewRoom()
|
||||||
|
DataManager.CurrenRoom = room
|
||||||
|
room.lev = group.lev
|
||||||
|
room.game_id = game_id
|
||||||
|
local extend = ExtendManager.GetExtendConfig(game_id)
|
||||||
|
extend:FillPlayBackData(DataManager.SelfUser.playback[playback_id][i])
|
||||||
|
if not room.self_player then
|
||||||
|
room.self_player = room:GetPlayerBySeat(1)
|
||||||
|
end
|
||||||
|
local main = self:GenaratePlayBack(ViewManager.View_PlayBack, game_id)
|
||||||
|
main._currentId = playback_id
|
||||||
|
main._currentRound = i
|
||||||
|
main._totalRound = tonumber(rdata.round)
|
||||||
|
main:FillRoomData(DataManager.SelfUser.playback[playback_id][i])
|
||||||
|
else
|
||||||
|
ViewUtil.ShowModalWait(self._view)
|
||||||
|
local _data = {}
|
||||||
|
_data["military_id"] = playback_id
|
||||||
|
_data["round"] = tostring(i)
|
||||||
|
local loddyCtr1 = ControllerManager.GetController(LoddyController)
|
||||||
|
loddyCtr1:RequestPlayBack(_data,function(code,data)
|
||||||
|
ViewUtil.CloseModalWait()
|
||||||
|
if code == 0 then
|
||||||
|
if DataManager.SelfUser.playback[playback_id] ~= nil then
|
||||||
|
DataManager.SelfUser.playback[playback_id][i] = data
|
||||||
|
else
|
||||||
|
local playback_data = {}
|
||||||
|
playback_data[i] = data
|
||||||
|
DataManager.SelfUser.playback[playback_id] = playback_data
|
||||||
|
end
|
||||||
|
|
||||||
|
local main = self:GenaratePlayBack(ViewManager.View_PlayBack, game_id)
|
||||||
|
main._currentId = playback_id
|
||||||
|
main._currentRound = i
|
||||||
|
main._totalRound = tonumber(rdata.round)
|
||||||
|
main:FillRoomData(data)
|
||||||
|
main._room.lev = group.lev
|
||||||
|
elseif code == 25 then
|
||||||
|
ViewUtil.ErrorTip(-1, "回放未找到!")
|
||||||
|
-- btn_play_back.grayed = true
|
||||||
|
end
|
||||||
|
end, rdata.game_info)
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function M:GenaratePlayBack(id, game_id, ...)
|
||||||
|
local tem =nil
|
||||||
|
local dview_class = nil
|
||||||
|
if not dview_class then
|
||||||
|
local exconfig = ExtendManager.GetExtendConfig(game_id)
|
||||||
|
dview_class = exconfig:GetView(id)
|
||||||
|
end
|
||||||
|
if not dview_class then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
local arg = {...}
|
||||||
|
tem = dview_class.new(...)
|
||||||
|
tem.Id = id
|
||||||
|
tem:Show()
|
||||||
|
return tem
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
return M
|
||||||
|
|
@ -0,0 +1,124 @@
|
||||||
|
--牌友圈转让View
|
||||||
|
|
||||||
|
|
||||||
|
local GroupRemitView = {}
|
||||||
|
local GroupNumberInputView = import(".MngView.GroupNumberInputView")
|
||||||
|
|
||||||
|
local M = GroupRemitView
|
||||||
|
|
||||||
|
function GroupRemitView.new(blur_view, curGroup)
|
||||||
|
setmetatable(M, {__index = BaseWindow})
|
||||||
|
local self = setmetatable({}, {__index = M})
|
||||||
|
self.class = "GroupRemitView"
|
||||||
|
self._close_destroy = true
|
||||||
|
self._blur_view = blur_view
|
||||||
|
self.curGroup = curGroup
|
||||||
|
self:init("ui://NewGroup/Win_Remit")
|
||||||
|
self:FillView()
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:FillView()
|
||||||
|
local fgCtr = ControllerManager.GetController(NewGroupController)
|
||||||
|
self._ctr_result = self._view:GetController("result")
|
||||||
|
local remite_id, remite_num
|
||||||
|
|
||||||
|
local btn_id = self._view:GetChild("btn_id")
|
||||||
|
btn_id.onClick:Set(function()
|
||||||
|
local gfv = GroupNumberInputView.new(self._root_view, function(num)
|
||||||
|
remite_id = num
|
||||||
|
btn_id.title = num
|
||||||
|
self._ctr_result.selectedIndex = 0
|
||||||
|
end)
|
||||||
|
gfv:Show()
|
||||||
|
end)
|
||||||
|
|
||||||
|
local btn_num = self._view:GetChild("btn_num")
|
||||||
|
btn_num.onClick:Set(function()
|
||||||
|
local gfv = GroupNumberInputView.new(self._root_view, function(num)
|
||||||
|
remite_num = num
|
||||||
|
btn_num.title = num
|
||||||
|
end)
|
||||||
|
gfv:Show()
|
||||||
|
end)
|
||||||
|
|
||||||
|
local btn_search = self._view:GetChild("btn_search")
|
||||||
|
btn_search.onClick:Set(function()
|
||||||
|
self._ctr_result.selectedIndex = 0
|
||||||
|
if not remite_id then
|
||||||
|
ViewUtil.ErrorTip(nil, "请输入玩家ID")
|
||||||
|
return
|
||||||
|
end
|
||||||
|
ViewUtil.ShowModalWait(nil)
|
||||||
|
fgCtr:FG_RemitFindMember(self.curGroup.id, remite_id, function(res)
|
||||||
|
ViewUtil.CloseModalWait()
|
||||||
|
if self._is_destroy then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
if res.ReturnCode ~= 0 then
|
||||||
|
ViewUtil.ErrorTip(res.ReturnCode, "查询玩家失败")
|
||||||
|
return
|
||||||
|
else
|
||||||
|
if not res.Data.uid then
|
||||||
|
ViewUtil.ErrorTip(nil, "查询玩家失败")
|
||||||
|
return
|
||||||
|
end
|
||||||
|
self._ctr_result.selectedIndex = 1
|
||||||
|
self._view:GetChild("tex_id").text = res.Data.uid
|
||||||
|
self._view:GetChild("tex_name").text = res.Data.nick
|
||||||
|
if res.Data.portrait then
|
||||||
|
ImageLoad.Load(res.Data.portrait, self._view:GetChild("btn_head")._iconObject)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end)
|
||||||
|
|
||||||
|
local btn_ok = self._view:GetChild("btn_ok")
|
||||||
|
btn_ok.onClick:Set(function()
|
||||||
|
local msgbox = MsgWindow.new(self._root_view, "确定要转让积分吗?", MsgWindow.MsgMode.OkAndCancel)
|
||||||
|
msgbox.onOk:Add(function( ... )
|
||||||
|
if not remite_id then
|
||||||
|
ViewUtil.ErrorTip(nil, "请输入玩家ID")
|
||||||
|
return
|
||||||
|
end
|
||||||
|
if self._ctr_result.selectedIndex == 0 then
|
||||||
|
ViewUtil.ErrorTip(nil, "请先搜索玩家")
|
||||||
|
return
|
||||||
|
end
|
||||||
|
if not remite_num then
|
||||||
|
ViewUtil.ErrorTip(nil, "请输入转让数量")
|
||||||
|
return
|
||||||
|
end
|
||||||
|
ViewUtil.ShowModalWait(nil)
|
||||||
|
fgCtr:FG_FagRemit(self.curGroup.id, remite_id, ad2d(remite_num), function(res)
|
||||||
|
ViewUtil.CloseModalWait()
|
||||||
|
if self._is_destroy then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
if res.ReturnCode ~= 0 then
|
||||||
|
ViewUtil.ErrorTip(res.ReturnCode, "转让失败")
|
||||||
|
return
|
||||||
|
else
|
||||||
|
local msgbox2 = MsgWindow.new(self._root_view, "转让积分成功", MsgWindow.MsgMode.OnlyOk)
|
||||||
|
msgbox2:Show()
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end)
|
||||||
|
msgbox:Show()
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:SetCallback(callback)
|
||||||
|
self.callback = callback
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- 销毁窗口
|
||||||
|
function M:Destroy(remove_map)
|
||||||
|
if self.change and self.callback then
|
||||||
|
self.callback()
|
||||||
|
end
|
||||||
|
BaseWindow.Destroy(self,remove_map)
|
||||||
|
end
|
||||||
|
|
||||||
|
return M
|
||||||
|
|
@ -0,0 +1,60 @@
|
||||||
|
--牌友圈选择玩法View
|
||||||
|
|
||||||
|
|
||||||
|
local GroupSelectPlayView = {}
|
||||||
|
|
||||||
|
local M = GroupSelectPlayView
|
||||||
|
|
||||||
|
function GroupSelectPlayView.new(blur_view, curGroup, i)
|
||||||
|
setmetatable(M, {__index = BaseWindow})
|
||||||
|
local self = setmetatable({}, {__index = M})
|
||||||
|
self.class = "GroupSelectPlayView"
|
||||||
|
self._close_destroy = true
|
||||||
|
self._blur_view = blur_view
|
||||||
|
self.curGroup = curGroup
|
||||||
|
self:init("ui://NewGroup/Win_SelectGame")
|
||||||
|
self:FillView(i)
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:FillView(i)
|
||||||
|
self.lst_game = self._view:GetChild("lst_game")
|
||||||
|
self.lst_game:SetVirtual()
|
||||||
|
self.lst_game.itemRenderer = function(index, obj)
|
||||||
|
self:OnRenderItem(index, obj)
|
||||||
|
end
|
||||||
|
self.lst_game.numItems = #self.curGroup.playList + 1
|
||||||
|
self.lst_game.selectedIndex = i
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:OnRenderItem(index, obj)
|
||||||
|
if index == 0 then
|
||||||
|
obj.title = "全部"
|
||||||
|
else
|
||||||
|
local play = self.curGroup.playList[index]
|
||||||
|
obj.title = play.name
|
||||||
|
end
|
||||||
|
obj.onClick:Set(function()
|
||||||
|
if self.lst_game.selectedIndex ~= index then
|
||||||
|
self._update = index
|
||||||
|
end
|
||||||
|
self:Destroy()
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:SetCallback(callback)
|
||||||
|
self.callback = callback
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- 销毁窗口
|
||||||
|
function M:Destroy(remove_map)
|
||||||
|
if self._update then
|
||||||
|
self.callback(self._update)
|
||||||
|
else
|
||||||
|
self.callback()
|
||||||
|
end
|
||||||
|
BaseWindow.Destroy(self,remove_map)
|
||||||
|
end
|
||||||
|
|
||||||
|
return M
|
||||||
|
|
@ -0,0 +1,126 @@
|
||||||
|
-- 牌友圈默认玩法设置界面
|
||||||
|
local GroupSetDefaultGameView = {}
|
||||||
|
|
||||||
|
local M = GroupSetDefaultGameView
|
||||||
|
|
||||||
|
function GroupSetDefaultGameView.new(gid,blur_view,callback)
|
||||||
|
setmetatable(M, {__index = BaseWindow})
|
||||||
|
local self = setmetatable({}, {__index = M})
|
||||||
|
self.class = "GroupSetDefaultGameView"
|
||||||
|
self._close_destroy = true
|
||||||
|
self.group_id = gid
|
||||||
|
self._blur_view = blur_view
|
||||||
|
self._callback = callback
|
||||||
|
local url = "ui://NewGroup/Win_SetDefaultGame"
|
||||||
|
self:init(url)
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:init(url)
|
||||||
|
BaseWindow.init(self,url)
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:FillData(list, index,callbackFill)
|
||||||
|
self.callbackFill=callbackFill
|
||||||
|
self._index = index
|
||||||
|
local lst_game = self._view:GetChild("lst_game")
|
||||||
|
lst_game:RemoveChildrenToPool()
|
||||||
|
|
||||||
|
local playName="playfaconfig"..self.group_id
|
||||||
|
local json_data = Utils.LoadLocalFile(playName)
|
||||||
|
local localDataPlay=nil
|
||||||
|
if json_data then
|
||||||
|
localDataPlay = json.decode(json_data)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
for i = 1, #list do
|
||||||
|
local tem = list[i]
|
||||||
|
local item = lst_game:AddItemFromPool()
|
||||||
|
item.title = tem.name
|
||||||
|
item.selected = index == i
|
||||||
|
|
||||||
|
local group = DataManager.groups:get(self.group_id)
|
||||||
|
local MarkSelect=item:GetChild("btn_select")
|
||||||
|
|
||||||
|
--if group.lev==1 then
|
||||||
|
-- MarkSelect.visible=true
|
||||||
|
--else
|
||||||
|
-- MarkSelect.visible=false
|
||||||
|
--end
|
||||||
|
|
||||||
|
MarkSelect.visible=true
|
||||||
|
if localDataPlay and localDataPlay[tostring(tem.id)] then
|
||||||
|
MarkSelect.selected=localDataPlay[tostring(tem.id)]
|
||||||
|
else
|
||||||
|
MarkSelect.selected=false
|
||||||
|
end
|
||||||
|
|
||||||
|
MarkSelect.onClick:Set(function()
|
||||||
|
self:MarkPlay(MarkSelect,tem.id,MarkSelect.selected)
|
||||||
|
end)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
end
|
||||||
|
local btn_confirm = self._view:GetChild("btn_confirm")
|
||||||
|
btn_confirm.onClick:Set(function()
|
||||||
|
if self._callback then
|
||||||
|
self._callback(lst_game.selectedIndex + 1)
|
||||||
|
end
|
||||||
|
self:Destroy()
|
||||||
|
end)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function M:MarkPlay(markS,pid,isMark)
|
||||||
|
--[[local fgCtr = ControllerManager.GetController(NewGroupController)
|
||||||
|
ViewUtil.ShowModalWait()
|
||||||
|
fgCtr:FG_MarkPlay(self.group_id, pid, isMark, function(res)
|
||||||
|
if self._is_destroy then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
ViewUtil.CloseModalWait()
|
||||||
|
if res.ReturnCode == 0 then
|
||||||
|
local group = DataManager.groups:get(self.group_id)
|
||||||
|
group:markPlay(pid, isMark)
|
||||||
|
if self.callbackFill then
|
||||||
|
self.callbackFill()
|
||||||
|
end
|
||||||
|
else
|
||||||
|
markS.selected=not isMark
|
||||||
|
ViewUtil.ErrorTip(res.ReturnCode,"设置失败,或已达设置上限")
|
||||||
|
end
|
||||||
|
end)--]]
|
||||||
|
|
||||||
|
if DataManager.SelfUser.PlayLocalList==nil then
|
||||||
|
DataManager.SelfUser.PlayLocalList={}
|
||||||
|
end
|
||||||
|
|
||||||
|
DataManager.SelfUser.PlayLocalList[tostring(pid)]=isMark
|
||||||
|
--printlog("111111111122222222222223333333333333")
|
||||||
|
--pt(DataManager.SelfUser.PlayLocalList)
|
||||||
|
|
||||||
|
local playName="playfaconfig"..self.group_id
|
||||||
|
|
||||||
|
Utils.SaveLocalFile(playName, json.encode(DataManager.SelfUser.PlayLocalList))
|
||||||
|
|
||||||
|
if self.callbackFill then
|
||||||
|
self.callbackFill()
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
return M
|
||||||
|
|
@ -0,0 +1,45 @@
|
||||||
|
-- 备注界面
|
||||||
|
local GroupSetTagView = {}
|
||||||
|
|
||||||
|
local M = GroupSetTagView
|
||||||
|
|
||||||
|
function GroupSetTagView.new(group_id, member, callback)
|
||||||
|
setmetatable(M, {__index = BaseWindow})
|
||||||
|
local self = setmetatable({}, {__index = M})
|
||||||
|
self.class = "GroupSetTagView"
|
||||||
|
self._close_destroy = true
|
||||||
|
self.callback = callback
|
||||||
|
self.group_id = group_id
|
||||||
|
self:init("ui://NewGroup/Win_SetTag", member)
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:init(url, member)
|
||||||
|
BaseWindow.init(self,url)
|
||||||
|
|
||||||
|
local tex_tag = self._view:GetChild("tex_tag")
|
||||||
|
if tag ~= 0 then
|
||||||
|
tex_tag.text = member.score
|
||||||
|
end
|
||||||
|
self._view:GetChild("btn_ok").onClick:Set(function()
|
||||||
|
ViewUtil.ShowModalWait(nil)
|
||||||
|
local score = tonumber(tex_tag.text) or 0
|
||||||
|
local fgCtr = ControllerManager.GetController(NewGroupController)
|
||||||
|
fgCtr:FG_SetMemberTag(self.group_id, member.uid, score, function(res)
|
||||||
|
if self._is_destroy then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
ViewUtil.CloseModalWait()
|
||||||
|
if res.ReturnCode ~= 0 then
|
||||||
|
ViewUtil.ErrorTip(res.ReturnCode, "备注失败")
|
||||||
|
else
|
||||||
|
ViewUtil.ShowBannerOnScreenCenter("备注成功")
|
||||||
|
member.score = score
|
||||||
|
self:Destroy()
|
||||||
|
self.callback(true)
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
return M
|
||||||
|
|
@ -0,0 +1,132 @@
|
||||||
|
--牌友圈设置View对象
|
||||||
|
--author:--
|
||||||
|
|
||||||
|
local CreateGroupView = import(".CreateGroupView")
|
||||||
|
|
||||||
|
local GroupSettingView = {}
|
||||||
|
|
||||||
|
local M = GroupSettingView
|
||||||
|
|
||||||
|
function GroupSettingView.new(blur_view)
|
||||||
|
setmetatable(M, {__index = BaseWindow})
|
||||||
|
local self = setmetatable({}, {__index = M})
|
||||||
|
self.class = "GroupSettingView"
|
||||||
|
self._close_destroy = true
|
||||||
|
self._blur_view = blur_view
|
||||||
|
|
||||||
|
self:init("ui://NewGroup/Win_GroupSetting")
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
local function __removeGroup(self,msg,curData)
|
||||||
|
local fgCtr = ControllerManager.GetController(NewGroupController)
|
||||||
|
local _curren_msg = MsgWindow.new(self._root_view, msg, MsgWindow.MsgMode.OkAndCancel)
|
||||||
|
_curren_msg.onOk:Add(function()
|
||||||
|
ViewUtil.ShowModalWait(self._root_view)
|
||||||
|
local func = curData.owner == DataManager.SelfUser.account_id and fgCtr.FG_RemoveGroup or fgCtr.FG_ExitGroup
|
||||||
|
func(fgCtr, curData.id, function(res)
|
||||||
|
if self._is_destroy then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
ViewUtil.CloseModalWait()
|
||||||
|
if res.ReturnCode == 0 then
|
||||||
|
self.change = true
|
||||||
|
local groups = DataManager.groups.groupList
|
||||||
|
if #groups > 0 then
|
||||||
|
self:FillData()
|
||||||
|
else
|
||||||
|
self:Destroy()
|
||||||
|
end
|
||||||
|
else
|
||||||
|
ViewUtil.ErrorTip(res.ReturnCode,"删除大联盟失败!")
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end)
|
||||||
|
_curren_msg:Show()
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:init(url)
|
||||||
|
BaseWindow.init(self,url)
|
||||||
|
local lst_group = self._view:GetChild("lst_group")
|
||||||
|
|
||||||
|
local btn_remove = self._view:GetChild("btn_remove")
|
||||||
|
btn_remove.onClick:Set(function()
|
||||||
|
local group = lst_group:GetChildAt(lst_group.selectedIndex).data
|
||||||
|
__removeGroup(self,"您确定解散该大联盟吗?",group)
|
||||||
|
end)
|
||||||
|
local btn_exit = self._view:GetChild("btn_exit")
|
||||||
|
btn_exit.onClick:Set(function()
|
||||||
|
local group = lst_group:GetChildAt(lst_group.selectedIndex).data
|
||||||
|
__removeGroup(self,"您确定退出该大联盟吗?",group)
|
||||||
|
end)
|
||||||
|
lst_group.onClickItem:Add(function(context)
|
||||||
|
local group = context.data.data
|
||||||
|
|
||||||
|
if group.lev == 1 then
|
||||||
|
self._view:GetController("opt").selectedIndex = 2
|
||||||
|
else
|
||||||
|
local option = group.option or 0
|
||||||
|
if bit:_and(option,2) > 0 then
|
||||||
|
self._view:GetController("opt").selectedIndex = 1
|
||||||
|
|
||||||
|
else
|
||||||
|
self._view:GetController("opt").selectedIndex = 0
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:FillData()
|
||||||
|
local groups = DataManager.groups.groupList
|
||||||
|
local lst_group = self._view:GetChild("lst_group")
|
||||||
|
lst_group:RemoveChildrenToPool()
|
||||||
|
local fgCtr = ControllerManager.GetController(NewGroupController)
|
||||||
|
|
||||||
|
for i = 1, #groups do
|
||||||
|
local group = groups[i]
|
||||||
|
local item = lst_group:AddItemFromPool()
|
||||||
|
item:GetChild("tex_name").text = group.name
|
||||||
|
item:GetChild("tex_id").text = group.id
|
||||||
|
item:GetChild("tex_nick").text ="创建人:" .. group.o_nick
|
||||||
|
item.data = group
|
||||||
|
end
|
||||||
|
|
||||||
|
if #groups > 0 and lst_group.selectedIndex == -1 then
|
||||||
|
lst_group.selectedIndex = 0
|
||||||
|
|
||||||
|
if groups[1].lev == 1 then
|
||||||
|
self._view:GetController("opt").selectedIndex = 2
|
||||||
|
else
|
||||||
|
local option = groups[1].option or 0
|
||||||
|
if bit:_and(option,2) > 0 then
|
||||||
|
self._view:GetController("opt").selectedIndex = 1
|
||||||
|
else
|
||||||
|
self._view:GetController("opt").selectedIndex = 0
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if #groups == 0 then
|
||||||
|
self._view:GetController("opt").selectedIndex = 0
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:SetCallback(callback)
|
||||||
|
self.callback = callback
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- 销毁窗口
|
||||||
|
function M:Destroy(remove_map)
|
||||||
|
if self.change and self.callback then
|
||||||
|
self.callback()
|
||||||
|
end
|
||||||
|
BaseWindow.Destroy(self,remove_map)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
return M
|
||||||
|
|
@ -0,0 +1,84 @@
|
||||||
|
--进入牌友圈View对象
|
||||||
|
--author:--
|
||||||
|
|
||||||
|
|
||||||
|
local JoinGroupView = {}
|
||||||
|
|
||||||
|
local M = JoinGroupView
|
||||||
|
local KEY_DEL = "del"
|
||||||
|
local KEY_CLEAR = "c"
|
||||||
|
|
||||||
|
function JoinGroupView.new(blur_view)
|
||||||
|
setmetatable(M, {__index = BaseWindow})
|
||||||
|
local self = setmetatable({}, {__index = M})
|
||||||
|
self.class = "JoinGroupView"
|
||||||
|
self._currenIndex = 0
|
||||||
|
self._close_destroy = true
|
||||||
|
self._blur_view = blur_view
|
||||||
|
self:init("ui://NewGroup/Win_FGJoin")
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:init(url)
|
||||||
|
BaseWindow.init(self,url)
|
||||||
|
|
||||||
|
self.tex_num = self._view:GetChild("tex_num")
|
||||||
|
self:ClearNumTex()
|
||||||
|
|
||||||
|
local cnt = self._view.numChildren - 1
|
||||||
|
|
||||||
|
for i = 0 , 9 do
|
||||||
|
local obj = self._view:GetChild("btn_"..i)
|
||||||
|
obj.onClick:Add(handler(self , self.OnNumButtonAction))
|
||||||
|
i = i + 1
|
||||||
|
end
|
||||||
|
local btn_ok = self._view:GetChild("btn_ok")
|
||||||
|
btn_ok.onClick:Set(function()
|
||||||
|
if self._currenIndex <6 then
|
||||||
|
ViewUtil.ErrorTip(-12,"您输入的大联盟ID少于六位!")
|
||||||
|
return
|
||||||
|
end
|
||||||
|
ViewUtil.ShowModalWait(self._root_view)
|
||||||
|
local fgCtr = ControllerManager.GetController(NewGroupController)
|
||||||
|
fgCtr:FG_JoinGroup(tonumber(self._texnum_str),function(response)
|
||||||
|
ViewUtil.CloseModalWait()
|
||||||
|
if self._is_destroy then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
if (response.ReturnCode == 0) then
|
||||||
|
ViewUtil.ErrorTip("请等待盟主审核")
|
||||||
|
self:Destroy()
|
||||||
|
else
|
||||||
|
ViewUtil.ErrorTip(response.ReturnCode,"加入大联盟失败!")
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end)
|
||||||
|
local btn_del = self._view:GetChild("btn_del")
|
||||||
|
btn_del.onClick:Add(handler(self , self.OnNumButtonAction))
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:OnNumButtonAction(context)
|
||||||
|
local typer = string.sub(context.sender.name ,5)
|
||||||
|
if typer == KEY_DEL then
|
||||||
|
if (self._currenIndex > 0) then
|
||||||
|
self._currenIndex = self._currenIndex - 1
|
||||||
|
self._texnum_str = string.sub(self._texnum_str,0,self._currenIndex)
|
||||||
|
self.tex_num.text = self._texnum_str
|
||||||
|
end
|
||||||
|
else
|
||||||
|
if (self._currenIndex < 6) then
|
||||||
|
self._currenIndex = self._currenIndex + 1
|
||||||
|
self._texnum_str = self._texnum_str .. typer
|
||||||
|
self.tex_num.text = self._texnum_str
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:ClearNumTex()
|
||||||
|
self._texnum_str = ""
|
||||||
|
self._currenIndex = 0
|
||||||
|
self.tex_num.text = self._texnum_str
|
||||||
|
end
|
||||||
|
|
||||||
|
return M
|
||||||
|
|
@ -0,0 +1,60 @@
|
||||||
|
local GroupAddMemberInfoView = {}
|
||||||
|
|
||||||
|
local M = GroupAddMemberInfoView
|
||||||
|
|
||||||
|
function GroupAddMemberInfoView.new(group_id,member_id)
|
||||||
|
setmetatable(M, {__index = BaseView})
|
||||||
|
local self = setmetatable({}, {__index = M})
|
||||||
|
self.class = "GroupAddMemberInfoView"
|
||||||
|
self.group_id = group_id
|
||||||
|
self.member_id = member_id
|
||||||
|
self:init("ui://NewGroup/Win_PlayerInfoForAdd")
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:init(url)
|
||||||
|
BaseWindow.init(self,url)
|
||||||
|
self.Tx=self._view:GetChild("btn_head")
|
||||||
|
self.Name=self._view:GetChild("tex_name")
|
||||||
|
self.Id=self._view:GetChild("tex_id")
|
||||||
|
self._view:GetChild("btn_close").onClick:Set(
|
||||||
|
function ()
|
||||||
|
self:Destroy()
|
||||||
|
end
|
||||||
|
)
|
||||||
|
self._view:GetChild("btn_qc").onClick:Set(
|
||||||
|
function ()
|
||||||
|
self:Destroy()
|
||||||
|
end
|
||||||
|
)
|
||||||
|
self._view:GetChild("btn_qd").onClick:Set(
|
||||||
|
function ()
|
||||||
|
ViewUtil.ShowModalWait()
|
||||||
|
local fgCtr = ControllerManager.GetController(NewGroupController)
|
||||||
|
fgCtr:FG_AddMember(
|
||||||
|
self.group_id,
|
||||||
|
self.member_id,
|
||||||
|
function (response)
|
||||||
|
ViewUtil.CloseModalWait()
|
||||||
|
if (response.ReturnCode == 0) then
|
||||||
|
ViewUtil.ShowBannerOnScreenCenter('添加成功!', 1)
|
||||||
|
else
|
||||||
|
ViewUtil.ErrorTip(response.ReturnCode, '邀请玩家失败!')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
)
|
||||||
|
end
|
||||||
|
)
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function M:SetAddMember(data)
|
||||||
|
ImageLoad.Load(data.portrait, self.Tx._iconObject)
|
||||||
|
self.Name.text=data.nick
|
||||||
|
self.Id.text=data.uid
|
||||||
|
self:Show()
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
return M
|
||||||
|
|
@ -0,0 +1,232 @@
|
||||||
|
-- 禁止同桌界面
|
||||||
|
|
||||||
|
local GroupBanSameTableView = {}
|
||||||
|
|
||||||
|
local M = GroupBanSameTableView
|
||||||
|
|
||||||
|
function GroupBanSameTableView.new(blur_view, group_id, member_id, data)
|
||||||
|
setmetatable(M, {__index = BaseWindow})
|
||||||
|
local self = setmetatable({}, {__index = M})
|
||||||
|
self.class = "GroupBanSameTableView"
|
||||||
|
self._close_destroy = true
|
||||||
|
self._blur_view = blur_view
|
||||||
|
self.group_id = group_id
|
||||||
|
self.ori_ban = data.ban_list
|
||||||
|
self.ban_list = membe_deep_clone(data.ban_list)
|
||||||
|
self.member_id = member_id
|
||||||
|
self:init("ui://NewGroup/Win_BanSameTable")
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:init(url)
|
||||||
|
BaseWindow.init(self,url)
|
||||||
|
-- 搜索结果
|
||||||
|
self._search_member_data = {}
|
||||||
|
self._search_ban_data = {}
|
||||||
|
|
||||||
|
local group = DataManager.groups:get(self.group_id)
|
||||||
|
self.all_members = group.members
|
||||||
|
self.member_data = {}
|
||||||
|
self:getMemberData(#self.all_members)
|
||||||
|
|
||||||
|
self.ctr_search_m = self._view:GetController("search_m")
|
||||||
|
self.ctr_search_b = self._view:GetController("search_b")
|
||||||
|
|
||||||
|
self.lst_member = self._view:GetChild("lst_member")
|
||||||
|
self.lst_member:SetVirtual()
|
||||||
|
self.lst_member.itemRenderer = function(index, obj)
|
||||||
|
self:OnRenderMemberItem(index, obj)
|
||||||
|
end
|
||||||
|
self.lst_member.scrollPane.onPullUpRelease:Set(function()
|
||||||
|
self:getMemberData(#self.all_members)
|
||||||
|
end)
|
||||||
|
|
||||||
|
self.lst_ban = self._view:GetChild("lst_ban")
|
||||||
|
self.lst_ban:SetVirtual()
|
||||||
|
self.lst_ban.itemRenderer = function(index, obj)
|
||||||
|
self:OnRenderBanItem(index, obj)
|
||||||
|
end
|
||||||
|
self:refreshList()
|
||||||
|
|
||||||
|
self._view:GetChild("btn_back").onClick:Set(function()
|
||||||
|
self._search_member_data = {}
|
||||||
|
self.ctr_search_m.selectedIndex = 0
|
||||||
|
self:refreshList()
|
||||||
|
end)
|
||||||
|
|
||||||
|
self._view:GetChild("btn_back_ban").onClick:Set(function()
|
||||||
|
self._search_ban_data = {}
|
||||||
|
self.ctr_search_b.selectedIndex = 0
|
||||||
|
self:refreshList()
|
||||||
|
end)
|
||||||
|
|
||||||
|
local fgCtr = ControllerManager.GetController(NewGroupController)
|
||||||
|
self._view:GetChild("btn_search_member").onClick:Set(function()
|
||||||
|
ViewUtil.ShowModalWait(nil)
|
||||||
|
local qid = tonumber(self._view:GetChild("tex_find_memb").text)
|
||||||
|
if not qid then
|
||||||
|
ViewUtil.CloseModalWait()
|
||||||
|
ViewUtil.ErrorTip(nil, "输入ID进行搜索")
|
||||||
|
return
|
||||||
|
end
|
||||||
|
fgCtr:FG_FindMember(self.group_id, qid, function(res)
|
||||||
|
ViewUtil.CloseModalWait()
|
||||||
|
if self._is_destroy then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
if res.ReturnCode ~= 0 then
|
||||||
|
ViewUtil.ErrorTip(res.ReturnCode, "找不到成员")
|
||||||
|
self._search_member_data = {}
|
||||||
|
self:refreshList()
|
||||||
|
else
|
||||||
|
self.ctr_search_m.selectedIndex = 1
|
||||||
|
self._search_member_data[1] = res.Data.members[1]
|
||||||
|
self:refreshList()
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end)
|
||||||
|
|
||||||
|
self._view:GetChild("btn_search_ban").onClick:Set(function()
|
||||||
|
local qid = tonumber(self._view:GetChild("tex_find_ban").text)
|
||||||
|
if not qid then
|
||||||
|
ViewUtil.ErrorTip(nil, "输入ID进行搜索")
|
||||||
|
return
|
||||||
|
end
|
||||||
|
for i = 1, #self.ban_list do
|
||||||
|
local data = self.ban_list[i]
|
||||||
|
if data.uid == qid then
|
||||||
|
self.ctr_search_b.selectedIndex = 1
|
||||||
|
self._search_ban_data[1] = data
|
||||||
|
self:refreshList()
|
||||||
|
return
|
||||||
|
end
|
||||||
|
end
|
||||||
|
ViewUtil.ErrorTip(nil, "找不到成员")
|
||||||
|
self._search_ban_data = {}
|
||||||
|
self:refreshList()
|
||||||
|
end)
|
||||||
|
|
||||||
|
self._view:GetChild("btn_ok").onClick:Set(function()
|
||||||
|
local set_list = {}
|
||||||
|
local del_list = {}
|
||||||
|
for i = 1, #self.ban_list do
|
||||||
|
table.insert(set_list, self.ban_list[i].uid)
|
||||||
|
end
|
||||||
|
for i = 1, #self.ori_ban do
|
||||||
|
local tem = self.ori_ban[i]
|
||||||
|
if not list_check(set_list, tem.uid) then
|
||||||
|
table.insert(del_list, tem.uid)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
ViewUtil.ShowModalWait()
|
||||||
|
fgCtr:FG_SetBanTable(self.group_id, self.member_id, set_list, del_list, function(res)
|
||||||
|
ViewUtil.CloseModalWait()
|
||||||
|
if res.ReturnCode == 0 then
|
||||||
|
self:Destroy()
|
||||||
|
ViewUtil.ShowBannerOnScreenCenter("禁止同桌设置成功")
|
||||||
|
else
|
||||||
|
ViewUtil.ErrorTip(res.ReturnCode, "禁止同桌设置失败")
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
local function checkList(list, data)
|
||||||
|
for i = 1, #list do
|
||||||
|
if list[i].uid == data.uid then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
function M:refreshList()
|
||||||
|
local all_members = self.all_members
|
||||||
|
if #self._search_member_data > 0 then
|
||||||
|
all_members = self._search_member_data
|
||||||
|
end
|
||||||
|
self.member_data = {}
|
||||||
|
for i = 1, #all_members do
|
||||||
|
local data = all_members[i]
|
||||||
|
if not checkList(self.ban_list, data) and data.uid ~= DataManager.SelfUser.account_id and data.uid ~= self.member_id then
|
||||||
|
local mdata = {}
|
||||||
|
mdata.nick = data.nick
|
||||||
|
mdata.uid = data.uid
|
||||||
|
mdata.portrait = data.portrait
|
||||||
|
if not checkList(self.member_data, mdata) then
|
||||||
|
table.insert(self.member_data, mdata)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
self.lst_member.numItems = #self.member_data
|
||||||
|
|
||||||
|
if self.ctr_search_b.selectedIndex == 1 then
|
||||||
|
self.lst_ban.numItems = #self._search_ban_data
|
||||||
|
else
|
||||||
|
self.lst_ban.numItems = #self.ban_list
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:getMemberData(index)
|
||||||
|
local group = DataManager.groups:get(self.group_id)
|
||||||
|
-- if index == 0 then
|
||||||
|
-- group:clearMember()
|
||||||
|
-- end
|
||||||
|
ViewUtil.ShowModalWait(nil)
|
||||||
|
local fgCtr = ControllerManager.GetController(NewGroupController)
|
||||||
|
fgCtr:FG_GroupMembers(self.group_id, index, 10, false, 1, function(res)
|
||||||
|
ViewUtil.CloseModalWait()
|
||||||
|
if res.ReturnCode ~= 0 then
|
||||||
|
ViewUtil.ErrorTip(res.ReturnCode, "获取成员列表失败")
|
||||||
|
else
|
||||||
|
list_concat(self.all_members, res.Data.members)
|
||||||
|
self:refreshList()
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:OnRenderMemberItem(index, obj)
|
||||||
|
local data
|
||||||
|
if #self._search_member_data > 0 then
|
||||||
|
data = self._search_member_data[index + 1]
|
||||||
|
else
|
||||||
|
data = self.member_data[index + 1]
|
||||||
|
end
|
||||||
|
self:FillItem(data, obj, 0)
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:OnRenderBanItem(index, obj)
|
||||||
|
local data
|
||||||
|
if self.ctr_search_b.selectedIndex == 1 then
|
||||||
|
data = self._search_ban_data[index + 1]
|
||||||
|
else
|
||||||
|
data = self.ban_list[index + 1]
|
||||||
|
end
|
||||||
|
self:FillItem(data, obj, 1)
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:FillItem(data, item, act)
|
||||||
|
item:GetController("act").selectedIndex = act
|
||||||
|
item:GetChild("tex_name").text = ViewUtil.stringEllipsis(data.nick)
|
||||||
|
item:GetChild("tex_id").text = "ID:" .. data.uid
|
||||||
|
btn_head = item:GetChild("btn_head")
|
||||||
|
ImageLoad.Load(data.portrait, btn_head._iconObject)
|
||||||
|
item:GetChild("btn_del").onClick:Set(function()
|
||||||
|
if self.ctr_search_b.selectedIndex == 1 then
|
||||||
|
list_remove(self.ban_list, data)
|
||||||
|
list_remove(self._search_ban_data, data)
|
||||||
|
else
|
||||||
|
list_remove(self.ban_list, data)
|
||||||
|
end
|
||||||
|
self:refreshList()
|
||||||
|
end)
|
||||||
|
item:GetChild("btn_set").onClick:Set(function()
|
||||||
|
if #self.ban_list >= 20 then
|
||||||
|
ViewUtil.ErrorTip(nil, "最多添加20个禁止同桌对象")
|
||||||
|
return
|
||||||
|
end
|
||||||
|
table.insert(self.ban_list, data)
|
||||||
|
self:refreshList()
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
return M
|
||||||
|
|
@ -0,0 +1,67 @@
|
||||||
|
|
||||||
|
local TimeSettingPanel = import(".TimeSettingPanel")
|
||||||
|
|
||||||
|
local GroupBankLogView = {}
|
||||||
|
|
||||||
|
local M = GroupBankLogView
|
||||||
|
|
||||||
|
function GroupBankLogView.new(blur_view,group_id,uid)
|
||||||
|
setmetatable(M, {__index = BaseWindow})
|
||||||
|
local self = setmetatable({}, {__index = M})
|
||||||
|
self.class = "GroupBankLogView"
|
||||||
|
self._close_destroy = true
|
||||||
|
self.uid = uid
|
||||||
|
self._blur_view = blur_view
|
||||||
|
self.group_id = group_id
|
||||||
|
self:init("ui://NewGroup/Win_Banklog")
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:init(url)
|
||||||
|
BaseWindow.init(self,url)
|
||||||
|
self.take_log = {}
|
||||||
|
self.lst_log = self._view:GetChild("lst_log")
|
||||||
|
self.lst_log:SetVirtual()
|
||||||
|
self.lst_log.itemRenderer = function(index, obj)
|
||||||
|
self:OnRenderItem(index, obj)
|
||||||
|
end
|
||||||
|
self.lst_log.scrollPane.onPullUpRelease:Set(function()
|
||||||
|
self:getTakeLog(self.lst_log.numItems)
|
||||||
|
end)
|
||||||
|
|
||||||
|
self.time_panel = TimeSettingPanel.new(self._view, self._view:GetChild("btn_date1"), self._view:GetChild("btn_date2"), -308, 0)
|
||||||
|
self._view:GetChild("btn_search").onClick:Set(function()
|
||||||
|
self.take_log = {}
|
||||||
|
self:getTakeLog(0)
|
||||||
|
end)
|
||||||
|
|
||||||
|
self:getTakeLog(0)
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:getTakeLog(index)
|
||||||
|
local begin_time, end_time = self.time_panel:GetDate()
|
||||||
|
local fgCtr = ControllerManager.GetController(NewGroupController)
|
||||||
|
fgCtr:FG_GetBankLog(self.group_id, index, 6, begin_time, end_time, self.uid,function(res)
|
||||||
|
if res.ReturnCode ~= 0 then
|
||||||
|
ViewUtil.ErrorTip(res.ReturnCode, "获取提取详情失败")
|
||||||
|
else
|
||||||
|
local hp_logs = res.Data.hp_logs
|
||||||
|
if #hp_logs > 0 then
|
||||||
|
for i = 1, #hp_logs do
|
||||||
|
table.insert(self.take_log, hp_logs[i])
|
||||||
|
end
|
||||||
|
self.lst_log.numItems = #self.take_log
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:OnRenderItem(index, obj)
|
||||||
|
local data = self.take_log[index + 1]
|
||||||
|
obj:GetChild("tex_name").text = ViewUtil.stringEllipsis(DataManager.SelfUser.nick_name)
|
||||||
|
obj:GetChild("tex_id").text = DataManager.SelfUser.account_id
|
||||||
|
obj:GetChild("tex__hp").text = d2ad(data.hp)
|
||||||
|
obj:GetChild("tex_data").text = os.date("%Y-%m-%d\r%H:%M", data.time)
|
||||||
|
end
|
||||||
|
|
||||||
|
return M
|
||||||
|
|
@ -0,0 +1,824 @@
|
||||||
|
-- 牌友圈玩法设置
|
||||||
|
local GroupNumberInputView = import(".GroupNumberInputView")
|
||||||
|
local GroupRoomColorView = import(".GroupRoomColorView")
|
||||||
|
local GameListView = require "Game/View/Lobby/GameListView"
|
||||||
|
local GroupGameSettingView = {}
|
||||||
|
|
||||||
|
local M = GroupGameSettingView
|
||||||
|
|
||||||
|
function GroupGameSettingView.new(blur_view, gid, pid , room_config, callback)
|
||||||
|
setmetatable(M, {__index = BaseWindow})
|
||||||
|
local self = setmetatable({}, {__index = M})
|
||||||
|
self.class = "GroupGameSettingView"
|
||||||
|
self._animation = false
|
||||||
|
self._full = true
|
||||||
|
self._full_offset = false
|
||||||
|
self.selectedIndex = index
|
||||||
|
self._close_destroy = true
|
||||||
|
self._put_map = false
|
||||||
|
self._new_hide = false
|
||||||
|
self._queue = false
|
||||||
|
self.group_id = gid
|
||||||
|
self.play = DataManager.groups:get(gid):getPlay(pid)
|
||||||
|
self.table_color = self.play and self.play.deskId or 0
|
||||||
|
if room_config then
|
||||||
|
self.room_config = json.decode(room_config)
|
||||||
|
end
|
||||||
|
self.rewards_data = {}
|
||||||
|
self.callback = callback
|
||||||
|
self._full = true
|
||||||
|
self:init("ui://NewGroup/View_GroupGameSetting")
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:init(url)
|
||||||
|
BaseWindow.init(self,url)
|
||||||
|
self.hpData = {}
|
||||||
|
|
||||||
|
self:FillGameData()
|
||||||
|
|
||||||
|
self._view:GetChild("btn_next").onClick:Set(function()
|
||||||
|
if self._view:GetChild("tex_name").text == "" then
|
||||||
|
ViewUtil.ErrorTip(nil, "输入玩法名才能进入下一步")
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local game_data = self.gl_view:GetModeData().data.game_data
|
||||||
|
if not game_data then
|
||||||
|
ViewUtil.ErrorTip(nil, "请先下载游戏")
|
||||||
|
return
|
||||||
|
end
|
||||||
|
self.rewards_data = {}
|
||||||
|
self:FillFagData()
|
||||||
|
self._view:GetController("page").selectedIndex = 1
|
||||||
|
end)
|
||||||
|
|
||||||
|
self._view:GetChild("btn_color").onClick:Set(function()
|
||||||
|
local grcv = GroupRoomColorView.new(self._root_view, self.table_color, function(index)
|
||||||
|
self.table_color = index
|
||||||
|
end)
|
||||||
|
grcv:Show()
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- 显示游戏列表
|
||||||
|
function M:FillGameData()
|
||||||
|
local index = 1
|
||||||
|
-- 显示所有游戏
|
||||||
|
local games = DataManager.SelfUser.games
|
||||||
|
local lst_game = self._view:GetChild("lst_game")
|
||||||
|
-- local n65 = lst_game:GetChild("n65")
|
||||||
|
printlog("jefe all games")
|
||||||
|
pt(games)
|
||||||
|
-- n65.visible = false
|
||||||
|
for i = 1, #games do
|
||||||
|
local game = games[i]
|
||||||
|
if (self.room_config and self.room_config.game_id == game.game_id) or i == 1 then
|
||||||
|
index = i
|
||||||
|
end
|
||||||
|
end
|
||||||
|
self.gl_view = GameListView.new(lst_game,index,self.room_config)
|
||||||
|
local btn_close = lst_game:GetChild("btn_close")
|
||||||
|
btn_close.onClick:Set(function()
|
||||||
|
self:Destroy()
|
||||||
|
end)
|
||||||
|
-- 玩法名
|
||||||
|
if self.play then
|
||||||
|
local tex_name = self._view:GetChild("tex_name")
|
||||||
|
tex_name.text = self.play.name
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local tuoguanTimeList={10,30,60,120,180,240,300}
|
||||||
|
-- 显示玩法体力值配置
|
||||||
|
function M:FillFagData()
|
||||||
|
|
||||||
|
local mod = self.gl_view:GetModeData()
|
||||||
|
local game_id = mod.data.game_data.game_id
|
||||||
|
|
||||||
|
local panel_play_set = self._view:GetChild("panel_play_set")
|
||||||
|
local ctr_show_nonnegative = panel_play_set:GetController("show_nonnegative") --玩法不可负分开关
|
||||||
|
local btn_nonnegative = panel_play_set:GetChild("btn_nonnegative") --不可负分开关
|
||||||
|
local btn_no_upper = panel_play_set:GetChild("btn_no_upper") --没有上限
|
||||||
|
local btn_tuoguan = panel_play_set:GetChild("btn_tuoguan") --托管开关
|
||||||
|
btn_tuoguan.selected = true
|
||||||
|
|
||||||
|
local btn_BanDismiss = panel_play_set:GetChild("btn_BanDismiss")
|
||||||
|
local cb_tuoguan_time = panel_play_set:GetChild("comb_offline") --托管时间
|
||||||
|
local cb_tuoguan_type = panel_play_set:GetChild("comb_result") --托管结算类型
|
||||||
|
local btn_hidden = panel_play_set:GetChild("btn_hidden") --防作弊开关
|
||||||
|
local btn_vip = panel_play_set:GetChild("btn_vip") --vip房间开关
|
||||||
|
--根据hpType显示
|
||||||
|
local game_data = mod.data.game_data
|
||||||
|
panel_play_set:GetController("game_type").selectedIndex = game_data and game_data.hpType or 0
|
||||||
|
--体力值开关
|
||||||
|
local ctr_switch = panel_play_set:GetController("hp_switch")
|
||||||
|
local group = DataManager.groups:get(self.group_id)
|
||||||
|
if group.type == 2 then
|
||||||
|
ctr_switch.selectedIndex = 1
|
||||||
|
panel_play_set:GetController("type").selectedIndex = 1
|
||||||
|
end
|
||||||
|
local hpData
|
||||||
|
|
||||||
|
if self.play then
|
||||||
|
-- 如果有玩法信息,加载玩法的hpdata
|
||||||
|
if self.play.hpOnOff == 1 then
|
||||||
|
hpData = json.decode(self.play.hpData)
|
||||||
|
end
|
||||||
|
local config = json.decode(self.play.config)
|
||||||
|
ctr_switch.selectedIndex = self.play.hpOnOff
|
||||||
|
|
||||||
|
btn_BanDismiss.selected = (config.isBanDismiss and config.isBanDismiss ~= 0) and true or false
|
||||||
|
btn_tuoguan.selected = (config.tuoguan and config.tuoguan ~= 0) and true or false
|
||||||
|
if btn_tuoguan.selected then
|
||||||
|
cb_tuoguan_time.value = config.tuoguan_active_timeIndex or 1
|
||||||
|
cb_tuoguan_type.value = config.tuoguan_result_type
|
||||||
|
end
|
||||||
|
|
||||||
|
if btn_hidden then
|
||||||
|
btn_hidden.selected = (config.isHidden and config.isHidden ~= 0) and true or false
|
||||||
|
end
|
||||||
|
if btn_vip then
|
||||||
|
btn_vip.selected = (config.isvip and config.isvip ~= 0) and true or false
|
||||||
|
end
|
||||||
|
|
||||||
|
btn_nonnegative.selected = config.isNonnegative and config.isNonnegative == 1
|
||||||
|
btn_no_upper.selected = config.hp_no_limit and config.hp_no_limit == 1
|
||||||
|
end
|
||||||
|
local game = DataManager.SelfUser:getGameData(game_id)
|
||||||
|
ctr_show_nonnegative.selectedIndex = game.isNonnegative
|
||||||
|
if game.isNonnegative == 0 then
|
||||||
|
btn_nonnegative.selected = false
|
||||||
|
btn_no_upper.selected = false
|
||||||
|
else
|
||||||
|
btn_nonnegative.selected = true
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
local panel_fag = panel_play_set:GetChild("panel_fag")
|
||||||
|
-- 加入限制
|
||||||
|
local btn_join_limit = panel_play_set:GetChild("btn_join_limit")
|
||||||
|
local tex_join_limit = panel_play_set:GetChild("tex_join_limit")
|
||||||
|
tex_join_limit.text = hpData and d2ad(hpData.limitInRoom) or 0
|
||||||
|
btn_join_limit.onClick:Set(function()
|
||||||
|
self:__input_num(tex_join_limit,"limitInRoom")
|
||||||
|
end)
|
||||||
|
--机器人
|
||||||
|
local btn_robot_room = panel_fag:GetChild("robot_room")
|
||||||
|
local tex_robot_room = panel_fag:GetChild("tex_robot_room")
|
||||||
|
tex_robot_room.text = hpData and (hpData.robot_room and (hpData.robot_room) or 0) or 0
|
||||||
|
btn_robot_room.onClick:Set(function()
|
||||||
|
self:__input_num(tex_robot_room,"robot_room")
|
||||||
|
end)
|
||||||
|
|
||||||
|
--抢庄限制
|
||||||
|
-- local btn_bank_limit = panel_play_set:GetChild("btn_bank_limit")
|
||||||
|
--local tex_bank_limit = panel_play_set:GetChild("tex_bank_limit")
|
||||||
|
-- tex_bank_limit.text = hpData and hpData.limitloot and d2ad(hpData.limitloot) or 0
|
||||||
|
-- btn_bank_limit.onClick:Set(function()
|
||||||
|
-- self:__input_num(tex_bank_limit,"limitloot")
|
||||||
|
-- end)
|
||||||
|
|
||||||
|
-- 退出限制
|
||||||
|
local btn_exit_limit = panel_play_set:GetChild("btn_exit_limit")
|
||||||
|
local tex_exit_limit = panel_play_set:GetChild("tex_exit_limit")
|
||||||
|
tex_exit_limit.text = hpData and hpData.limitPlay and d2ad(hpData.limitPlay) or 1
|
||||||
|
btn_exit_limit.onClick:Set(function()
|
||||||
|
-- self:__input_num(tex_exit_limit, "limitPlay")
|
||||||
|
local gfiv = GroupNumberInputView.new(self._root_view,function(num)
|
||||||
|
if num == 0 then
|
||||||
|
ViewUtil.ErrorMsg(nil,-9,"不能输入0")
|
||||||
|
return
|
||||||
|
end
|
||||||
|
tex_exit_limit.text = num
|
||||||
|
end)
|
||||||
|
gfiv:Show()
|
||||||
|
end)
|
||||||
|
--体力值倍数
|
||||||
|
local tex_times = panel_play_set:GetChild("tex_times")
|
||||||
|
if game_id ~= 41 then
|
||||||
|
tex_times.text = hpData and d2ad(hpData.times) or 1
|
||||||
|
local btn_times_input = panel_play_set:GetChild("btn_times_input")
|
||||||
|
btn_times_input.onClick:Set(function()
|
||||||
|
self:__input_num(tex_times, "times", 3)
|
||||||
|
end)
|
||||||
|
else
|
||||||
|
tex_times.text = 1
|
||||||
|
end
|
||||||
|
|
||||||
|
local btn_sub = panel_play_set:GetChild("btn_sub")
|
||||||
|
btn_sub.onClick:Set(function()
|
||||||
|
local value = tonumber(tex_times.text)
|
||||||
|
if value > 1 then
|
||||||
|
value = value - 1
|
||||||
|
tex_times.text = tostring(value)
|
||||||
|
end
|
||||||
|
|
||||||
|
end)
|
||||||
|
|
||||||
|
local btn_add = panel_play_set:GetChild("btn_add")
|
||||||
|
btn_add.onClick:Set(function()
|
||||||
|
local value = tonumber(tex_times.text)
|
||||||
|
value = value + 1
|
||||||
|
tex_times.text = tostring(value)
|
||||||
|
end)
|
||||||
|
|
||||||
|
|
||||||
|
--显示创建空房间
|
||||||
|
local tex_times_room = panel_play_set:GetChild("tex_times_room")
|
||||||
|
|
||||||
|
if hpData and hpData.tex_times_room then
|
||||||
|
tex_times_room.text = hpData.tex_times_room/1000
|
||||||
|
else
|
||||||
|
tex_times_room.text = 1
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
local btn_sub_room = panel_play_set:GetChild("btn_sub_room")
|
||||||
|
btn_sub_room.onClick:Set(function()
|
||||||
|
local value = tonumber(tex_times_room.text)
|
||||||
|
if value > 1 then
|
||||||
|
value = value - 1
|
||||||
|
tex_times_room.text = tostring(value)
|
||||||
|
end
|
||||||
|
|
||||||
|
end)
|
||||||
|
|
||||||
|
local btn_add_room = panel_play_set:GetChild("btn_add_room")
|
||||||
|
btn_add_room.onClick:Set(function()
|
||||||
|
local value = tonumber(tex_times_room.text)
|
||||||
|
value = value + 1
|
||||||
|
tex_times_room.text = tostring(value)
|
||||||
|
end)
|
||||||
|
|
||||||
|
|
||||||
|
-- 显示抽水列表
|
||||||
|
if hpData and hpData.rewards_list then
|
||||||
|
self.rewards_data = hpData.rewards_list
|
||||||
|
else
|
||||||
|
local tem = {}
|
||||||
|
-- tem.limitPump = hpData and hpData.limitPump or 0
|
||||||
|
-- tem.type = hpData and hpData.type or 1
|
||||||
|
tem.pumpProportion = hpData and hpData.pumpProportion or 0
|
||||||
|
tem.UpperLimit = hpData and hpData.UpperLimit or 0
|
||||||
|
table.insert(self.rewards_data, tem)
|
||||||
|
end
|
||||||
|
self._type = hpData and hpData.type or 1
|
||||||
|
self._limitPump = hpData and tonumber(hpData.limitPump) or 0
|
||||||
|
self:UpdateRewards()
|
||||||
|
|
||||||
|
-- 编辑类型,0是全显示,1是显示百分比,2是显示人头制, 3是全民推广
|
||||||
|
local ctr_edit_type = panel_fag:GetController("edit_type")
|
||||||
|
local ctr_edit_value_type = panel_fag:GetController("edit_value_type")
|
||||||
|
if not self.play then
|
||||||
|
ctr_edit_type.selectedIndex = 0
|
||||||
|
ctr_edit_value_type.selectedIndex = 0
|
||||||
|
elseif hpData then
|
||||||
|
ctr_edit_type.selectedIndex = self.play.rewardType
|
||||||
|
ctr_edit_value_type.selectedIndex = self.play.rewardValueType or 1
|
||||||
|
end
|
||||||
|
|
||||||
|
local ctr_edit_type1 = panel_fag:GetController("edit_type1")
|
||||||
|
local ctr_edit_value_type1 = panel_fag:GetController("edit_value_type1")
|
||||||
|
if not self.play then
|
||||||
|
ctr_edit_type1.selectedIndex = 0
|
||||||
|
ctr_edit_value_type1.selectedIndex = 0
|
||||||
|
elseif hpData then
|
||||||
|
ctr_edit_type1.selectedIndex = self.play.xipai_rewardType
|
||||||
|
ctr_edit_value_type1.selectedIndex = self.play.xipai_rewardValueType or 1
|
||||||
|
end
|
||||||
|
|
||||||
|
local ctr_rewards1 = panel_fag:GetController("rewards1")
|
||||||
|
ctr_rewards1.selectedIndex = 2
|
||||||
|
local ctr_rewards_value1 = panel_fag:GetController("rewards_value1")
|
||||||
|
-- 奖励类型:0百分比 1人头制 2全民推广
|
||||||
|
if self.play then
|
||||||
|
ctr_rewards1.selectedIndex = self.play.xipai_rewardType - 1
|
||||||
|
ctr_rewards_value1.selectedIndex = (self.play.xipai_rewardValueType or 1) - 1
|
||||||
|
end
|
||||||
|
|
||||||
|
local ctr_rewards2 = panel_fag:GetController("rewards2")
|
||||||
|
ctr_rewards2.selectedIndex = 2
|
||||||
|
local ctr_rewards_value2 = panel_fag:GetController("rewards_value2")
|
||||||
|
-- 奖励类型:0百分比 1人头制 2全民推广
|
||||||
|
if self.play then
|
||||||
|
-- ctr_rewards1.selectedIndex = self.play.xipai_rewardType - 1
|
||||||
|
ctr_rewards_value2.selectedIndex = (self.play.anchou_rewardValueType or 1) - 1
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
local base_pump = 0
|
||||||
|
if hpData ~= nil and hpData.basePump ~= nil then
|
||||||
|
base_pump = d2ad(hpData.basePump)
|
||||||
|
end
|
||||||
|
local tex_base_pump = panel_fag:GetChild("tex_base_pump")
|
||||||
|
tex_base_pump.text = ""..base_pump
|
||||||
|
|
||||||
|
local btn_base_pump = panel_fag:GetChild("btn_base_pump")
|
||||||
|
btn_base_pump.onClick:Set(function()
|
||||||
|
self:__input_num(tex_base_pump, "basePump", 3)
|
||||||
|
end)
|
||||||
|
|
||||||
|
-- panel_fag:GetController("alliance").selectedIndex = group.type == 2 and 1 or 0
|
||||||
|
panel_fag:GetController("alliance").selectedIndex = 0
|
||||||
|
local ctr_rewards = panel_fag:GetController("rewards")
|
||||||
|
local ctr_rewards_value = panel_fag:GetController("rewards_value")
|
||||||
|
-- 奖励类型:0百分比 1人头制 2全民推广
|
||||||
|
if self.play then
|
||||||
|
ctr_rewards.selectedIndex = self.play.rewardType - 1
|
||||||
|
ctr_rewards_value.selectedIndex = (self.play.rewardValueType or 1) - 1
|
||||||
|
end
|
||||||
|
|
||||||
|
-- 点击确定按钮 更新玩法数据
|
||||||
|
local btn_ok = self._view:GetChild("btn_ok")
|
||||||
|
btn_ok.onClick:Set(function()
|
||||||
|
local _data = mod.data:SelectedConfigData()
|
||||||
|
_data.game_id = game_id
|
||||||
|
_data.isNonnegative = btn_nonnegative.selected and 1 or 0
|
||||||
|
_data.hp_no_limit = (btn_nonnegative.selected and btn_no_upper.selected) and 1 or 0
|
||||||
|
_data.tuoguan = btn_tuoguan.selected
|
||||||
|
|
||||||
|
_data.tuoguan_active_time = _data.tuoguan and tuoguanTimeList[(tonumber(cb_tuoguan_time.value))] or 0
|
||||||
|
_data.tuoguan_active_timeIndex=tonumber(cb_tuoguan_time.value)
|
||||||
|
_data.tuoguan_result_type = _data.tuoguan and tonumber(cb_tuoguan_type.value) or 0
|
||||||
|
if btn_BanDismiss.selected then
|
||||||
|
_data.isBanDismiss = 1
|
||||||
|
end
|
||||||
|
|
||||||
|
if btn_hidden then
|
||||||
|
_data.isHidden = btn_hidden.selected and 1 or 0
|
||||||
|
else
|
||||||
|
_data.isHidden=0
|
||||||
|
end
|
||||||
|
|
||||||
|
if btn_vip then
|
||||||
|
_data.isvip = btn_vip.selected and 1 or 0
|
||||||
|
else
|
||||||
|
_data.isvip=0
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
local hpType = mod.data.game_data.hpType
|
||||||
|
self.hpData.limitInRoom = ad2d(tonumber(panel_play_set:GetChild("tex_join_limit").text))
|
||||||
|
self.hpData.limitPlay = ad2d(tonumber(panel_play_set:GetChild("tex_exit_limit").text))
|
||||||
|
self.hpData.limitloot = 0-- ad2d(tonumber(panel_play_set:GetChild("tex_bank_limit").text))
|
||||||
|
self.hpData.robot_room = (tonumber(panel_fag:GetChild("tex_robot_room").text))
|
||||||
|
self.hpData.type = self._type
|
||||||
|
self.hpData.limitPump = self._limitPump
|
||||||
|
local hpOnOff = ctr_switch.selectedIndex
|
||||||
|
if game_id == 41 then
|
||||||
|
if self.hpData.limitloot < ad2d(_data.up_bank) then
|
||||||
|
ViewUtil.ErrorMsg(self._root_view,-9,"抢庄限制必须大于等于" .. _data.up_bank)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if hpType > 1 and hpOnOff == 1 then
|
||||||
|
if self.hpData.limitInRoom < self.hpData.limitPlay then
|
||||||
|
ViewUtil.ErrorMsg(self._root_view,-9,"进入限制必须大于等于退出限制")
|
||||||
|
return
|
||||||
|
end
|
||||||
|
if self.hpData.limitPlay == 0 then
|
||||||
|
ViewUtil.ErrorMsg(self._root_view,-9,"退出房间限制不能为0")
|
||||||
|
return
|
||||||
|
end
|
||||||
|
end
|
||||||
|
local times = tonumber(tex_times.text)
|
||||||
|
self.hpData.times = ad2d(tonumber(times))
|
||||||
|
|
||||||
|
local tex_times_room = tonumber(tex_times_room.text)
|
||||||
|
self.hpData.tex_times_room = ad2d(tonumber(tex_times_room))
|
||||||
|
|
||||||
|
|
||||||
|
local base_pump = tonumber(tex_base_pump.text)
|
||||||
|
self.hpData.basePump = ad2d(tonumber(base_pump))
|
||||||
|
|
||||||
|
self.hpData.rewards_list = {}
|
||||||
|
local lst_rewards = panel_fag:GetChild("lst_rewards")
|
||||||
|
for i = 1, lst_rewards.numItems do
|
||||||
|
local r_item = lst_rewards:GetChildAt(i - 1)
|
||||||
|
local tem = {}
|
||||||
|
-- 大赢家
|
||||||
|
-- self.hpData.limitPump = tonumber(cb_type.value)
|
||||||
|
-- tem.limitPump = tonumber(r_item:GetChild("cb_type").value)
|
||||||
|
-- 抽水次数 固定抽水要发小数
|
||||||
|
local cb_method = r_item:GetChild("cb_method")
|
||||||
|
local proportion = string.gsub(string.gsub(r_item:GetChild("cb_proportion" .. cb_method.value).title, "抽", ""), "次", "")
|
||||||
|
if cb_method.value == "1" then proportion = ad2d(proportion) end
|
||||||
|
-- 抽水分数
|
||||||
|
-- self.hpData.pumpProportion = tonumber(proportion)
|
||||||
|
tem.pumpProportion = tonumber(proportion)
|
||||||
|
if tonumber(cb_method.value) == 1 then
|
||||||
|
local v = string.gsub(r_item:GetChild("cb_min").title, "分", "")
|
||||||
|
-- self.hpData.UpperLimit = ad2d(tonumber(v))
|
||||||
|
tem.UpperLimit = ad2d(tonumber(v))
|
||||||
|
|
||||||
|
local vsend = string.gsub(r_item:GetChild("cb_min_send").title, "分", "")
|
||||||
|
tem.UpperLimitReward = ad2d(tonumber(vsend))
|
||||||
|
|
||||||
|
else
|
||||||
|
local v = string.gsub(r_item:GetChild("cb_max").title, "分", "")
|
||||||
|
-- self.hpData.UpperLimit = ad2d(tonumber(v))
|
||||||
|
tem.UpperLimit = ad2d(tonumber(v))
|
||||||
|
end
|
||||||
|
-- tem.type = cb_method.value
|
||||||
|
table.insert(self.hpData.rewards_list, tem)
|
||||||
|
end
|
||||||
|
|
||||||
|
self.hpData.rewards_type = ctr_rewards.selectedIndex + 1
|
||||||
|
self.hpData.rewardValueType = ctr_rewards_value.selectedIndex + 1
|
||||||
|
|
||||||
|
self.hpData.xipai_rewardType = ctr_rewards1.selectedIndex + 1
|
||||||
|
self.hpData.xipai_rewardValueType = ctr_rewards_value1.selectedIndex + 1
|
||||||
|
|
||||||
|
self.hpData.anchou_rewardType = ctr_rewards2.selectedIndex + 1
|
||||||
|
self.hpData.anchou_rewardValueType = ctr_rewards_value2.selectedIndex + 1
|
||||||
|
|
||||||
|
|
||||||
|
if self.hpData.rewardValueType == 1 then
|
||||||
|
self.hpData.rewards_val = 100
|
||||||
|
else
|
||||||
|
self.hpData.rewards_val = ad2d(10000)
|
||||||
|
end
|
||||||
|
|
||||||
|
if self.hpData.xipai_rewardValueType == 1 then
|
||||||
|
self.hpData.xipai_rewards_val = 100
|
||||||
|
else
|
||||||
|
self.hpData.xipai_rewards_val = ad2d(10000)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
if self.hpData.anchou_rewardValueType == 1 then
|
||||||
|
self.hpData.anchou_rewards_val = 100
|
||||||
|
else
|
||||||
|
self.hpData.anchou_rewards_val = ad2d(10000)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
local tex_name = self._view:GetChild("tex_name")
|
||||||
|
local name = tex_name.text
|
||||||
|
print("jefe:")
|
||||||
|
pt(self.hpData)
|
||||||
|
|
||||||
|
local fgCtr = ControllerManager.GetController(NewGroupController)
|
||||||
|
ViewUtil.ShowModalWait(self._root_view)
|
||||||
|
if not self.play then
|
||||||
|
-- 新增玩法
|
||||||
|
fgCtr:FG_AddPlay(self.group_id, game_id, _data, name, self.hpData, hpOnOff, group.type, self.table_color, function(res)
|
||||||
|
if self._is_destroy then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
ViewUtil.CloseModalWait()
|
||||||
|
--print("======新增玩法=============")
|
||||||
|
--pt(res)
|
||||||
|
if res.ReturnCode == 0 then
|
||||||
|
local play = {}
|
||||||
|
play.name = name
|
||||||
|
play.deskId = self.table_color
|
||||||
|
play.game_name = mod.data.game_data.name
|
||||||
|
play.gameId = game_id
|
||||||
|
play.hpOnOff = hpOnOff
|
||||||
|
play.hpData= json.encode(self.hpData)
|
||||||
|
play.id = res.Data.pid
|
||||||
|
play.xipai_rewards_val = self.hpData.xipairewards_val
|
||||||
|
play.anchou_rewards_val = self.hpData.anchou_rewards_val
|
||||||
|
play.reward = self.hpData.rewards_val
|
||||||
|
play.rewardType = self.hpData.rewards_type
|
||||||
|
play.rewardValueType = self.hpData.rewardValueType
|
||||||
|
play.xipai_rewardType = self.hpData.xipai_rewardType
|
||||||
|
play.anchou_rewardType = 3
|
||||||
|
play.xipai_rewardValueType = self.hpData.xipai_rewardValueType
|
||||||
|
play.anchou_rewardValueType = 1
|
||||||
|
_data.maxPlayers = res.Data.maxPlayers
|
||||||
|
play.config = json.encode(_data)
|
||||||
|
play.hp_times = self.hpData.times
|
||||||
|
play.maxPlayers = _data.maxPlayers
|
||||||
|
play.roomNum=self.hpData.tex_times_room/1000
|
||||||
|
play.maxRound=res.Data.maxRound
|
||||||
|
ViewUtil.ShowBannerOnScreenCenter("添加玩法成功")
|
||||||
|
self.callback(play)
|
||||||
|
self:Destroy()
|
||||||
|
else
|
||||||
|
ViewUtil.ErrorTip(res.ReturnCode,"添加玩法失败!")
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
else
|
||||||
|
-- 修改玩法
|
||||||
|
fgCtr:FG_UpdatePlay(self.group_id,game_id,_data,name,self.hpData,hpOnOff,self.play.id, group.type, self.table_color, function(res)
|
||||||
|
if self._is_destroy then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
ViewUtil.CloseModalWait()
|
||||||
|
--print("======修改玩法=============")
|
||||||
|
--pt(res)
|
||||||
|
if res.ReturnCode == 0 then
|
||||||
|
local play = {}
|
||||||
|
play.name = name
|
||||||
|
play.deskId = self.table_color
|
||||||
|
play.game_name = mod.data.game_data.name
|
||||||
|
play.gameId = game_id
|
||||||
|
play.id = self.play.id
|
||||||
|
play.hpOnOff = hpOnOff
|
||||||
|
play.hpData= json.encode(self.hpData)
|
||||||
|
play.xipai_rewards_val = self.hpData.xipairewards_val
|
||||||
|
play.anchou_rewards_val = self.hpData.anchou_rewards_val
|
||||||
|
play.reward = self.hpData.rewards_val
|
||||||
|
play.rewardType = self.hpData.rewards_type
|
||||||
|
play.rewardValueType = self.hpData.rewardValueType
|
||||||
|
play.xipai_rewardType = self.hpData.xipai_rewardType
|
||||||
|
play.anchou_rewardType = 3
|
||||||
|
play.xipai_rewardValueType = self.hpData.xipai_rewardValueType
|
||||||
|
play.anchou_rewardValueType = 1
|
||||||
|
_data.maxPlayers = res.Data.maxPlayers
|
||||||
|
play.config = json.encode(_data)
|
||||||
|
play.hp_times = self.hpData.times
|
||||||
|
play.maxPlayers = _data.maxPlayers
|
||||||
|
play.roomNum=self.hpData.tex_times_room/1000
|
||||||
|
play.maxRound=res.Data.maxRound
|
||||||
|
self.callback(play)
|
||||||
|
self:Destroy()
|
||||||
|
else
|
||||||
|
ViewUtil.ErrorTip(res.ReturnCode,"修改玩法失败!")
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:UpdateRewards()
|
||||||
|
local lst_rewards = self._view:GetChild("panel_play_set"):GetChild("panel_fag"):GetChild("lst_rewards")
|
||||||
|
lst_rewards:RemoveChildrenToPool()
|
||||||
|
for i = 1, #self.rewards_data do
|
||||||
|
local item = lst_rewards:AddItemFromPool()
|
||||||
|
self:OnRenderItem(i, item)
|
||||||
|
end
|
||||||
|
lst_rewards.height = 120 * #self.rewards_data
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:OnRenderItem(index, obj)
|
||||||
|
local data = self.rewards_data[index]
|
||||||
|
-- 抽水方法,固定、浮动
|
||||||
|
local cb_method = obj:GetChild("cb_method")
|
||||||
|
cb_method.value = tostring(self._type)
|
||||||
|
cb_method.onChanged:Set(function()
|
||||||
|
local tem = membe_clone(self.rewards_data[1])
|
||||||
|
tem.pumpProportion = 0
|
||||||
|
self._type = tonumber(cb_method.value)
|
||||||
|
self.rewards_data = {}
|
||||||
|
self.rewards_data[1] = tem
|
||||||
|
self:UpdateRewards()
|
||||||
|
end)
|
||||||
|
--大赢家
|
||||||
|
local tem = obj:GetController("c1").selectedIndex
|
||||||
|
for i = 1, 2 do
|
||||||
|
local cb_type = obj:GetChild("cb_type" .. i)
|
||||||
|
if self._limitPump <= 4 - tem then
|
||||||
|
cb_type.value = tostring(self._limitPump)
|
||||||
|
else
|
||||||
|
self._limitPump = tonumber(cb_type.value)
|
||||||
|
end
|
||||||
|
cb_type.onChanged:Set(function()
|
||||||
|
local limitPump = cb_type.value
|
||||||
|
self._limitPump = tonumber(limitPump)
|
||||||
|
self:UpdateRewards()
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
-- hptype控制器,根据不同的hptype显示
|
||||||
|
local ctr_type = obj:GetController("type")
|
||||||
|
ctr_type.selectedIndex = self.gl_view:GetModeData().data.game_data.hpType
|
||||||
|
self._type = tonumber(cb_method.value)
|
||||||
|
--抽水次数
|
||||||
|
local val = data.pumpProportion
|
||||||
|
if cb_method.value ~= tostring(self._type) then
|
||||||
|
val = 0
|
||||||
|
elseif cb_method.value == "1" then
|
||||||
|
val = d2ad(val)
|
||||||
|
end
|
||||||
|
local cb_proportion1 = obj:GetChild("cb_proportion1")
|
||||||
|
local cb_proportion2 = obj:GetChild("cb_proportion2")
|
||||||
|
obj:GetChild("cb_proportion" .. cb_method.value).title = "抽" .. val .. "次"
|
||||||
|
cb_proportion1.onChanged:Set(function()
|
||||||
|
data.pumpProportion = ad2d(string.gsub(string.gsub(cb_proportion1.title, "抽", ""), "次", ""))
|
||||||
|
end)
|
||||||
|
cb_proportion2.onChanged:Set(function()
|
||||||
|
local v = string.gsub(string.gsub(cb_proportion2.title, "抽", ""), "次", "")
|
||||||
|
data.pumpProportion = tonumber(v)
|
||||||
|
end)
|
||||||
|
--抽水上限
|
||||||
|
local cb_max = obj:GetChild("cb_max")
|
||||||
|
--抽水门槛
|
||||||
|
local cb_min = obj:GetChild("cb_min")
|
||||||
|
local cb_min_send = obj:GetChild("cb_min_send")
|
||||||
|
local UpperLimit = d2ad(data.UpperLimit)
|
||||||
|
local UpperLimitReward = d2ad(data.UpperLimitReward or 0)
|
||||||
|
if tonumber(cb_method.value) == 1 then
|
||||||
|
cb_min.title = UpperLimit .. "分" or "0分"
|
||||||
|
cb_min_send.title = UpperLimitReward .. "分" or "0分"
|
||||||
|
if UpperLimitReward == 0 then
|
||||||
|
obj:GetController("give_owner").selectedIndex = 0
|
||||||
|
else
|
||||||
|
obj:GetController("give_owner").selectedIndex = 1
|
||||||
|
end
|
||||||
|
else
|
||||||
|
cb_max.value = UpperLimit .. "分"
|
||||||
|
self:SetIndex(cb_max, d2ad(data.UpperLimit))
|
||||||
|
end
|
||||||
|
|
||||||
|
obj:GetController("give_owner").onChanged:Add(function()
|
||||||
|
|
||||||
|
if obj:GetController("give_owner").selectedIndex == 0 then
|
||||||
|
data.UpperLimitReward = 0
|
||||||
|
self:UpdateRewards()
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
|
if cb_max.selectedIndex == -1 then
|
||||||
|
cb_max.selectedIndex = 0
|
||||||
|
end
|
||||||
|
if cb_min.selectedIndex == -1 then
|
||||||
|
cb_min.selectedIndex = 0
|
||||||
|
end
|
||||||
|
|
||||||
|
if cb_min_send.selectedIndex == -1 then
|
||||||
|
cb_min_send.selectedIndex = 0
|
||||||
|
end
|
||||||
|
|
||||||
|
-- 显示备注
|
||||||
|
local str_min_tip, str_max_tip
|
||||||
|
if index == 1 then
|
||||||
|
local tem = ""
|
||||||
|
local next_data = self.rewards_data[index + 1]
|
||||||
|
if next_data then
|
||||||
|
tem = string.format("小于%s", d2ad(next_data.UpperLimit))
|
||||||
|
end
|
||||||
|
local tem1 =""
|
||||||
|
if UpperLimitReward ~= 0 then
|
||||||
|
tem1 = string.format(",每个玩家赠送盟主%s分",UpperLimitReward)
|
||||||
|
end
|
||||||
|
str_min_tip = string.format("(低于%s分不抽水%s)", UpperLimit,tem1)
|
||||||
|
-- str_max_tip = string.format("(低于%s按此设置抽水)", UpperLimit)
|
||||||
|
elseif index == #self.rewards_data then
|
||||||
|
str_min_tip = string.format("(大于等于%s按此设置抽水)", UpperLimit)
|
||||||
|
-- str_max_tip = string.format("(大于等于%s,小于%s按此设置抽水)", last_upper, UpperLimit)
|
||||||
|
else
|
||||||
|
local next_upper = d2ad(self.rewards_data[index + 1].UpperLimit)
|
||||||
|
str_min_tip = string.format("(大于等于%s,小于%s按此设置抽水)", UpperLimit, next_upper)
|
||||||
|
-- str_max_tip = string.format("(大于等于%s,小于%s按此设置抽水)", last_upper, UpperLimit)
|
||||||
|
end
|
||||||
|
obj:GetChild("tex_min_tip").text = str_min_tip
|
||||||
|
-- obj:GetChild("tex_max_tip").text = str_max_tip
|
||||||
|
|
||||||
|
|
||||||
|
local input_limit = 1000
|
||||||
|
local btn_input = obj:GetChild("btn_input")
|
||||||
|
btn_input.onClick:Set(function()
|
||||||
|
local gfiv = GroupNumberInputView.new(self._root_view,function(num)
|
||||||
|
if num > input_limit then
|
||||||
|
ViewUtil.ErrorMsg(self._root_view,-9,"输入最大不能超过" .. input_limit)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
cb_proportion1.title = "抽" .. num .. "次"
|
||||||
|
data.pumpProportion = ad2d(num)
|
||||||
|
end, 3)
|
||||||
|
gfiv:Show()
|
||||||
|
end)
|
||||||
|
|
||||||
|
local input_limit2 = 1000
|
||||||
|
local min_v, max_v = 0, input_limit2 + 1
|
||||||
|
if index > 1 then
|
||||||
|
local last_data = self.rewards_data[index - 1]
|
||||||
|
min_v = d2ad(last_data.UpperLimit)
|
||||||
|
end
|
||||||
|
if index < #self.rewards_data then
|
||||||
|
local next_data = self.rewards_data[index + 1]
|
||||||
|
max_v = d2ad(next_data.UpperLimit)
|
||||||
|
end
|
||||||
|
local btn_input2 = obj:GetChild("btn_input2")
|
||||||
|
btn_input2.onClick:Set(function()
|
||||||
|
local gfiv = GroupNumberInputView.new(self._root_view,function(num)
|
||||||
|
if num > input_limit2 then
|
||||||
|
ViewUtil.ErrorMsg(nil,-9,"输入值不能超过" .. input_limit2)
|
||||||
|
return
|
||||||
|
elseif num >= max_v then
|
||||||
|
ViewUtil.ErrorMsg(nil,-9,"输入值必须小于" .. max_v)
|
||||||
|
return
|
||||||
|
elseif num <= min_v then
|
||||||
|
ViewUtil.ErrorMsg(nil,-9,"输入值必须大于" .. min_v)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
-- cb_min.title = num .. "分"
|
||||||
|
data.UpperLimit = ad2d(num)
|
||||||
|
self:UpdateRewards()
|
||||||
|
end, 3)
|
||||||
|
gfiv:Show()
|
||||||
|
end)
|
||||||
|
|
||||||
|
local btn_input2_send = obj:GetChild("btn_input2_send")
|
||||||
|
btn_input2_send.onClick:Set(function()
|
||||||
|
local gfiv = GroupNumberInputView.new(self._root_view,function(num)
|
||||||
|
|
||||||
|
data.UpperLimitReward = ad2d(num)
|
||||||
|
self:UpdateRewards()
|
||||||
|
end, 3)
|
||||||
|
gfiv:Show()
|
||||||
|
end)
|
||||||
|
cb_min.onChanged:Set(function()
|
||||||
|
local tem = string.gsub(cb_min.title, "分", "")
|
||||||
|
local tem = tonumber(tem)
|
||||||
|
if tem > input_limit2 then
|
||||||
|
ViewUtil.ErrorMsg(nil,-9,"输入值不能超过" .. input_limit2)
|
||||||
|
return
|
||||||
|
elseif tem >= max_v then
|
||||||
|
cb_min.title = d2ad(data.UpperLimit) .. "分"
|
||||||
|
ViewUtil.ErrorMsg(nil,-9,"输入值必须小于" .. max_v)
|
||||||
|
return
|
||||||
|
elseif tem <= min_v then
|
||||||
|
cb_min.title = d2ad(data.UpperLimit) .. "分"
|
||||||
|
ViewUtil.ErrorMsg(nil,-9,"输入值必须大于" .. min_v)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
data.UpperLimit = ad2d(string.gsub(cb_min.title, "分", ""))
|
||||||
|
self:UpdateRewards()
|
||||||
|
end)
|
||||||
|
|
||||||
|
cb_min_send.onChanged:Set(function()
|
||||||
|
local tem = string.gsub(cb_min_send.title, "分", "")
|
||||||
|
local tem = tonumber(tem)
|
||||||
|
|
||||||
|
data.UpperLimitReward = ad2d(string.gsub(cb_min_send.title, "分", ""))
|
||||||
|
self:UpdateRewards()
|
||||||
|
end)
|
||||||
|
|
||||||
|
cb_max.onChanged:Set(function()
|
||||||
|
local tem = string.gsub(cb_max.title, "分", "")
|
||||||
|
local tem = tonumber(tem)
|
||||||
|
if tem > max_v then
|
||||||
|
self:SetIndex(cb_max, d2ad(data.UpperLimit))
|
||||||
|
ViewUtil.ErrorMsg(nil,-9,"输入值必须小于" .. max_v)
|
||||||
|
return
|
||||||
|
-- elseif tem <= min_v then
|
||||||
|
-- self:SetIndex(cb_max, d2ad(data.UpperLimit))
|
||||||
|
-- ViewUtil.ErrorMsg(nil,-9,"输入值必须大于" .. min_v)
|
||||||
|
-- return
|
||||||
|
end
|
||||||
|
data.UpperLimit = ad2d(tem)
|
||||||
|
self:UpdateRewards()
|
||||||
|
end)
|
||||||
|
|
||||||
|
obj:GetController("first").selectedIndex = self._type == 1 and #self.rewards_data ~= 1 and 1 or 0
|
||||||
|
obj:GetController("last").selectedIndex = self._type == 1 and index == #self.rewards_data and 1 or 0
|
||||||
|
local btn_add = obj:GetChild("btn_add")
|
||||||
|
btn_add.onClick:Set(function()
|
||||||
|
-- 如果UpperLimit达到最大值,无法再增加
|
||||||
|
if (cb_method.value == "1" and data.UpperLimit >= ad2d(input_limit2)) or (cb_method.value == "2" and cb_max.selectedIndex == cb_max.values.Length - 1) then
|
||||||
|
ViewUtil.ErrorTip(nil, "已达到上限,无法再增加")
|
||||||
|
return
|
||||||
|
end
|
||||||
|
local ul = cb_method.value == "1" and data.UpperLimit + 10 or ad2d(cb_max.values[cb_max.selectedIndex + 1])
|
||||||
|
local tem = {type = data.type, pumpProportion = data.pumpProportion, UpperLimit = ul}
|
||||||
|
table.insert(self.rewards_data, tem)
|
||||||
|
self:UpdateRewards()
|
||||||
|
end)
|
||||||
|
local btn_remove = obj:GetChild("btn_remove")
|
||||||
|
btn_remove.onClick:Set(function()
|
||||||
|
local msg_tip = MsgWindow.new(self._root_view, "确定删除该项吗?", MsgWindow.MsgMode.OkAndCancel)
|
||||||
|
msg_tip.onOk:Add(function()
|
||||||
|
table.remove(self.rewards_data, index)
|
||||||
|
self:UpdateRewards()
|
||||||
|
end)
|
||||||
|
msg_tip:Show()
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:SetIndex(cb, value)
|
||||||
|
local str = tostring(value)
|
||||||
|
for i = 1, cb.values.Length do
|
||||||
|
if cb.values[i - 1] == str then
|
||||||
|
cb.selectedIndex = i - 1
|
||||||
|
return
|
||||||
|
end
|
||||||
|
end
|
||||||
|
cb.selectedIndex = 0
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:__input_num(tex, filed, itype)
|
||||||
|
itype = itype or 0
|
||||||
|
local gfiv = GroupNumberInputView.new(self._root_view,function(num)
|
||||||
|
tex.text = num
|
||||||
|
if filed == "robot_room" then
|
||||||
|
--printlog("cccccccccccccccc ",num)
|
||||||
|
self.hpData[filed] = (num)
|
||||||
|
else
|
||||||
|
self.hpData[filed] = ad2d(num)
|
||||||
|
end
|
||||||
|
|
||||||
|
end, itype)
|
||||||
|
gfiv:Show()
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:Destroy()
|
||||||
|
BaseWindow.Destroy(self)
|
||||||
|
self.gl_view:Destroy()
|
||||||
|
end
|
||||||
|
|
||||||
|
return M
|
||||||
|
|
@ -0,0 +1,319 @@
|
||||||
|
-- 牌友圈成员体力值记录
|
||||||
|
local TimeSettingPanel = import("Game.View.NewGroup.MngView.TimeSettingPanel")
|
||||||
|
local GroupMemberFagLogView = {}
|
||||||
|
|
||||||
|
local M = GroupMemberFagLogView
|
||||||
|
|
||||||
|
function GroupMemberFagLogView.new(group_id, member, not_manager)
|
||||||
|
setmetatable(M, {__index = BaseWindow})
|
||||||
|
local self = setmetatable({}, {__index = M})
|
||||||
|
self.class = "GroupMemberFagLogView"
|
||||||
|
self._close_destroy = true
|
||||||
|
-- self._blur_view = blur_view
|
||||||
|
self.member = member
|
||||||
|
self.nick = nick
|
||||||
|
self._full = true
|
||||||
|
self._animation = false
|
||||||
|
self.group_id = group_id
|
||||||
|
self.hp_log = {}
|
||||||
|
self.daily_count = {}
|
||||||
|
self.not_manager = not_manager
|
||||||
|
self._full = true
|
||||||
|
self.m_index = 0
|
||||||
|
self:init("ui://NewGroup/Win_MemberFagLog")
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:init(url)
|
||||||
|
BaseWindow.init(self,url)
|
||||||
|
|
||||||
|
local btn_close = self._view:GetChild("btn_close")
|
||||||
|
btn_close.onClick:Set(function()
|
||||||
|
self:Destroy()
|
||||||
|
end)
|
||||||
|
|
||||||
|
for i = 1, 8 do
|
||||||
|
local tem = math.pow(2, i - 1)
|
||||||
|
local btn_filter = self._view:GetChild("btn_filter" .. tem)
|
||||||
|
if btn_filter then
|
||||||
|
btn_filter.onClick:Set(function()
|
||||||
|
self.hp_log = {}
|
||||||
|
self.m_index = 0
|
||||||
|
self.lst_fag.numItems = 0
|
||||||
|
self:GetData(0)
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
self.lst_fag = self._view:GetChild("lst_fag")
|
||||||
|
self.lst_fag:SetVirtual()
|
||||||
|
self.lst_fag.itemRenderer = function(index, obj)
|
||||||
|
self:OnRenderItem(index, obj)
|
||||||
|
end
|
||||||
|
self.lst_fag.scrollPane.onPullUpRelease:Set(function()
|
||||||
|
self:GetData(self.lst_fag.numItems+self.m_index)
|
||||||
|
|
||||||
|
end)
|
||||||
|
if not self.not_manager then
|
||||||
|
self._view:GetController("manager").selectedIndex = 1
|
||||||
|
else
|
||||||
|
self._view:GetChild("btn_filter1").selected = false
|
||||||
|
self._view:GetChild("btn_filter8").selected = false
|
||||||
|
self._view:GetChild("btn_filter16").selected = false
|
||||||
|
end
|
||||||
|
|
||||||
|
self.lst_daily_count = self._view:GetChild("lst_daily_count")
|
||||||
|
self.lst_daily_count:SetVirtual()
|
||||||
|
self.lst_daily_count.itemRenderer = function(index, obj)
|
||||||
|
self:OnRenderDailyItem(index, obj)
|
||||||
|
end
|
||||||
|
|
||||||
|
self.ctr_index = self._view:GetController("index")
|
||||||
|
self.ctr_index.onChanged:Set(function()
|
||||||
|
if self.ctr_index.selectedIndex == 1 then
|
||||||
|
self:GetDailyData()
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
|
self.time_panel = TimeSettingPanel.new(self._view, self._view:GetChild("btn_date1"), self._view:GetChild("btn_date2"), -308, 0)
|
||||||
|
self.begin_time, self.end_time = self.time_panel:GetDate()
|
||||||
|
|
||||||
|
self._view:GetChild("btn_search").onClick:Set(function()
|
||||||
|
self.hp_log = {}
|
||||||
|
self.lst_fag.numItems = 0
|
||||||
|
self.m_index = 0
|
||||||
|
self.begin_time, self.end_time = self.time_panel:GetDate()
|
||||||
|
self:GetData(0)
|
||||||
|
end)
|
||||||
|
self:GetData(0)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- 获取过滤值,根据多选框计算
|
||||||
|
function M:GetFilter()
|
||||||
|
local filter = 0
|
||||||
|
for i = 1, 8 do
|
||||||
|
local tem = math.pow(2, i - 1)
|
||||||
|
--print("aaaaaaaaaaaaaaaaaaaaaaaa ",tem)
|
||||||
|
local btn_filter = self._view:GetChild("btn_filter" .. tem)
|
||||||
|
if btn_filter and btn_filter.selected then
|
||||||
|
filter = filter + tem
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return filter
|
||||||
|
end
|
||||||
|
|
||||||
|
-- 显示原因文本
|
||||||
|
local function __getReason(data)
|
||||||
|
-- return "玩家操作"
|
||||||
|
local s_nick = string.utf8sub(data.m_nick, 6)
|
||||||
|
if data.reason == 6 then
|
||||||
|
return data.info
|
||||||
|
elseif data.reason == 7 then
|
||||||
|
return string.format("系统衰减(%s)", data.roomid)
|
||||||
|
elseif data.reason == 8 then
|
||||||
|
return string.format("[color=#FF6600]%s[/color](%s) %s", s_nick, data.mgr_id, "操作增加")
|
||||||
|
elseif data.reason == 9 then
|
||||||
|
return string.format("[color=#FF6600]%s[/color](%s) %s", s_nick, data.mgr_id, "操作减少")
|
||||||
|
-- return "退出圈子"
|
||||||
|
elseif data.reason == 10 then
|
||||||
|
return string.format("[color=#FF6600]%s[/color](%s) %s", s_nick, data.mgr_id, "操作增加")
|
||||||
|
elseif data.reason == 11 then
|
||||||
|
return string.format("[color=#FF6600]%s[/color](%s) %s", s_nick, data.mgr_id, "操作减少")
|
||||||
|
-- return "每日提取"
|
||||||
|
elseif data.reason == 12 then
|
||||||
|
return "推广奖励"
|
||||||
|
elseif data.reason == 13 then
|
||||||
|
if data.hp < 0 then
|
||||||
|
return string.format("转账给 [color=#FF6600]%s(%s)[/color]", s_nick, data.mgr_id)
|
||||||
|
else
|
||||||
|
return string.format("收到 [color=#FF6600]%s(%s)[/color] 转账", s_nick, data.mgr_id)
|
||||||
|
end
|
||||||
|
elseif data.reason == 14 then
|
||||||
|
return "提取能量包"
|
||||||
|
elseif data.reason == 15 then
|
||||||
|
return ""
|
||||||
|
elseif data.reason == 20 then
|
||||||
|
return "洗牌"
|
||||||
|
elseif data.reason == 21 then
|
||||||
|
return "洗牌奖励"
|
||||||
|
elseif data.reason == 22 then
|
||||||
|
return "暗抽奖励"
|
||||||
|
elseif data.reason == 23 then
|
||||||
|
return string.format("系统衰减ac(%s)", data.roomid)
|
||||||
|
--return "管理费"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- 获取体力值详情数据
|
||||||
|
function M:GetData(index)
|
||||||
|
local filter = self:GetFilter()
|
||||||
|
if filter == 0 then return end
|
||||||
|
ViewUtil.ShowModalWait()
|
||||||
|
local fgCtr = ControllerManager.GetController(NewGroupController)
|
||||||
|
fgCtr:FG_GetMemberHpLog(self.group_id, self.member.uid, index, 6, filter, self.begin_time, self.end_time, function(res)
|
||||||
|
if self._is_destroy then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
ViewUtil.CloseModalWait()
|
||||||
|
if res.ReturnCode ~= 0 then
|
||||||
|
ViewUtil.ErrorTip(res.ReturnCode, "获取积分详情失败")
|
||||||
|
else
|
||||||
|
local data = res.Data.hp_logs
|
||||||
|
if #data == 0 then return end
|
||||||
|
-- print("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
|
||||||
|
-- pt(data)
|
||||||
|
-- pt(self.member)
|
||||||
|
for i = 1, #data do
|
||||||
|
self.hp_log[#self.hp_log + 1] = data[i]
|
||||||
|
end
|
||||||
|
--self:GuoLv(data)
|
||||||
|
|
||||||
|
self.lst_fag.numItems = #self.hp_log
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:GuoLv(data)
|
||||||
|
if self.member.lev == 1 then
|
||||||
|
local m_data_other = {}
|
||||||
|
local m_data_my = {}
|
||||||
|
for i=1,#data do
|
||||||
|
if self.member.uid ~= data[i].mgr_id then
|
||||||
|
table.insert(m_data_other,data[i])
|
||||||
|
else
|
||||||
|
table.insert(m_data_my,data[i])
|
||||||
|
end
|
||||||
|
end
|
||||||
|
-- printlog("比较计算=========m_data_my>>>",#m_data_my)
|
||||||
|
-- printlog("比较计算=========m_data_other>>>",#m_data_other)
|
||||||
|
|
||||||
|
|
||||||
|
if #m_data_my>0 and #m_data_other==0 then
|
||||||
|
for i = 1, #m_data_my do
|
||||||
|
self.hp_log[#self.hp_log + 1] = m_data_my[i]
|
||||||
|
end
|
||||||
|
self.m_index = #data - #m_data_my + self.m_index
|
||||||
|
else
|
||||||
|
for i = 1, #m_data_other do
|
||||||
|
self.hp_log[#self.hp_log + 1] = m_data_other[i]
|
||||||
|
end
|
||||||
|
self.m_index = #data - #m_data_other + self.m_index
|
||||||
|
end
|
||||||
|
else
|
||||||
|
local m_data_other = {}
|
||||||
|
local m_data_my = {}
|
||||||
|
|
||||||
|
for i=1,#data do
|
||||||
|
if self.member.uid ~= data[i].mgr_id then
|
||||||
|
table.insert(m_data_other,data[i])
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- printlog("比较计算11=========m_data_my>>>",#m_data_my)
|
||||||
|
-- printlog("比较计算11=========m_data_other>>>",#m_data_other)
|
||||||
|
|
||||||
|
for i = 1, #m_data_other do
|
||||||
|
self.hp_log[#self.hp_log + 1] = m_data_other[i]
|
||||||
|
end
|
||||||
|
self.m_index = #data - #m_data_other + self.m_index
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
local function fillItem(data, obj)
|
||||||
|
local num = d2ad(data.hp)
|
||||||
|
obj:GetChild("tex_num").text = num >= 0 and ('+' .. num) or num
|
||||||
|
obj:GetChild("tex_time").text = os.date("%Y-%m-%d\n%H:%M",data.time)
|
||||||
|
obj:GetChild("tex_reason").text = __getReason(data)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- 填充体力值详情对象
|
||||||
|
function M:OnRenderItem(index, obj)
|
||||||
|
local data = self.hp_log[index + 1]
|
||||||
|
obj:GetChild("tex_name").text = ViewUtil.stringEllipsis(self.member.nick)
|
||||||
|
local num = d2ad(data.hp)
|
||||||
|
obj:GetChild("tex_num").text = num >= 0 and ('+' .. num) or num
|
||||||
|
obj:GetController("add").selectedIndex = num >= 0 and 1 or 0
|
||||||
|
obj:GetChild("tex_fag").text = d2ad(data.cur_hp)
|
||||||
|
obj:GetChild("tex_reason").text = __getReason(data)
|
||||||
|
obj:GetChild("tex_time").text = os.date("%Y-%m-%d\n%H:%M",data.time)
|
||||||
|
local btn_head = obj:GetChild("btn_head")
|
||||||
|
btn_head.icon = "ui://Common/Head0"
|
||||||
|
ImageLoad.Load(self.member.portrait, btn_head._iconObject)
|
||||||
|
obj:GetController("show_check").selectedIndex = data.reason == 15 and 1 or 0
|
||||||
|
local btn_check = obj:GetChild("btn_check")
|
||||||
|
if data.reason ~= 15 or not data.detail then
|
||||||
|
btn_check.selected = false
|
||||||
|
obj:GetController("c1").selectedIndex = 0
|
||||||
|
obj.height = 94
|
||||||
|
end
|
||||||
|
btn_check.onClick:Set(function()
|
||||||
|
local lst = obj:GetChild("lst")
|
||||||
|
lst:RemoveChildrenToPool()
|
||||||
|
if not btn_check.selected then
|
||||||
|
obj.height = 94
|
||||||
|
self.lst_fag:RefreshVirtualList()
|
||||||
|
return
|
||||||
|
end
|
||||||
|
if data.detail then
|
||||||
|
lst:RemoveChildrenToPool()
|
||||||
|
for i = 1, #data.detail do
|
||||||
|
local item = lst:AddItemFromPool()
|
||||||
|
fillItem(data.detail[i], item)
|
||||||
|
end
|
||||||
|
obj.height =95 * (#data.detail+1)
|
||||||
|
self.lst_fag:RefreshVirtualList()
|
||||||
|
self.lst_fag:ScrollToView(index)
|
||||||
|
else
|
||||||
|
ViewUtil.ShowModalWait()
|
||||||
|
local fgCtr = ControllerManager.GetController(NewGroupController)
|
||||||
|
fgCtr:FG_GetHpLogDetail(self.group_id, self.member.uid, data.roomid, data.time, function(res)
|
||||||
|
if self._is_destroy then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
ViewUtil.CloseModalWait()
|
||||||
|
if res.ReturnCode ~= 0 then
|
||||||
|
ViewUtil.ErrorTip(res.ReturnCode, "获取积分详情失败")
|
||||||
|
else
|
||||||
|
data.detail = res.Data.hp_logs
|
||||||
|
lst:RemoveChildrenToPool()
|
||||||
|
for i = 1, #data.detail do
|
||||||
|
local item = lst:AddItemFromPool()
|
||||||
|
fillItem(data.detail[i], item)
|
||||||
|
end
|
||||||
|
obj.height =95 * (#data.detail+1)
|
||||||
|
self.lst_fag:RefreshVirtualList()
|
||||||
|
self.lst_fag:ScrollToView(index)
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- 获取日统计数据
|
||||||
|
function M:GetDailyData()
|
||||||
|
ViewUtil.ShowModalWait()
|
||||||
|
local fgCtr = ControllerManager.GetController(NewGroupController)
|
||||||
|
fgCtr:FG_GetPlayerDailyHPCount(self.group_id, self.member.uid, function(res)
|
||||||
|
if self._is_destroy then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
ViewUtil.CloseModalWait()
|
||||||
|
if res.ReturnCode ~= 0 then
|
||||||
|
ViewUtil.ErrorTip(res.ReturnCode, "获取积分详情失败")
|
||||||
|
else
|
||||||
|
self.daily_count = res.Data.list
|
||||||
|
self.lst_daily_count.numItems = #self.daily_count
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- 填充日统计对象
|
||||||
|
function M:OnRenderDailyItem(index, obj)
|
||||||
|
local data = self.daily_count[#self.daily_count - index]
|
||||||
|
obj:GetChild("tex_date").text = os.date("%Y-%m-%d",data.time)
|
||||||
|
local num = d2ad(data.num)
|
||||||
|
obj:GetChild("tex_num").text = num >= 0 and ('+' .. num) or num
|
||||||
|
end
|
||||||
|
|
||||||
|
return M
|
||||||
|
|
@ -0,0 +1,508 @@
|
||||||
|
local GroupNumberInputView = import(".GroupNumberInputView")
|
||||||
|
local GroupMemberFagLogView = import(".GroupMemberFagLogView")
|
||||||
|
local GroupSetPermissionView = import(".GroupSetPermissionView")
|
||||||
|
local GroupBanSameTableView = import(".GroupBanSameTableView")
|
||||||
|
local MngPermission = import(".MngPermission")
|
||||||
|
local GroupSetTagView = import("../GroupSetTagView")
|
||||||
|
local GroupSetMemberInfoDiaoduView=import('.GroupSetMemberInfoDiaoduView')
|
||||||
|
local GroupPartnerBanPlaysView = import(".GroupPartnerBanPlaysView")
|
||||||
|
|
||||||
|
-- 牌友圈成员体力值记录
|
||||||
|
local GroupMemberOperateView = {}
|
||||||
|
|
||||||
|
local M = GroupMemberOperateView
|
||||||
|
|
||||||
|
function GroupMemberOperateView.new(group_id, member, callBack,callBack1)
|
||||||
|
setmetatable(M, {__index = BaseWindow})
|
||||||
|
local self = setmetatable({}, {__index = M})
|
||||||
|
self.class = "GroupMemberOperateView"
|
||||||
|
self._close_destroy = true
|
||||||
|
-- self._blur_view = blur_view
|
||||||
|
--print("GroupMemberOperateView==============")
|
||||||
|
--pt(member)
|
||||||
|
self.member = member
|
||||||
|
self.group_id = group_id
|
||||||
|
self.callBack = callBack
|
||||||
|
self.callBack1 = callBack1
|
||||||
|
self:init("ui://NewGroup/Win_PlayerInfo")
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
-- 管理员权限
|
||||||
|
local MngPermissionList = {
|
||||||
|
DeleteMember = 1,-- 删除成员
|
||||||
|
AddMember = 2,--添加成员
|
||||||
|
SetFag = 3,--设置体力值
|
||||||
|
BanPlaying = 4,--禁止游戏
|
||||||
|
BanSameTable = 5--禁止同桌
|
||||||
|
}
|
||||||
|
|
||||||
|
local function CheckPermission(lev, permission)
|
||||||
|
if lev == 2 and not permission then
|
||||||
|
ViewUtil.ErrorTip(nil, "您无权操作!如有需要请联系盟主。", 1)
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:init(url)
|
||||||
|
BaseWindow.init(self,url)
|
||||||
|
|
||||||
|
local member = self.member
|
||||||
|
local group = DataManager.groups:get(self.group_id)
|
||||||
|
--print("DataManager.groups:get(self.group_id)")
|
||||||
|
--pt(group)
|
||||||
|
local perm_array = MngPermission.getPermData(group.permission)
|
||||||
|
|
||||||
|
local btn_close = self._view:GetChild("btn_close")
|
||||||
|
btn_close.onClick:Set(function()
|
||||||
|
self:Destroy()
|
||||||
|
end)
|
||||||
|
|
||||||
|
self._view:GetChild("tex_id").text = "ID:" .. member.uid
|
||||||
|
|
||||||
|
self._view:GetChild("tex_name").text = ViewUtil.stringEllipsis(member.nick)
|
||||||
|
self._view:GetChild("btn_head").icon = "ui://Common/Head0"
|
||||||
|
ImageLoad.Load(member.portrait, self._view:GetChild("btn_head")._iconObject, self.class)
|
||||||
|
|
||||||
|
-- obj.data = member.id
|
||||||
|
-- 显示玩家标签,合伙人、管理员
|
||||||
|
local ctr_type = self._view:GetController("type")
|
||||||
|
if member.lev < 3 then
|
||||||
|
ctr_type.selectedIndex = member.lev
|
||||||
|
elseif member.partnerLev ~= 0 then
|
||||||
|
ctr_type.selectedIndex = 3
|
||||||
|
else
|
||||||
|
ctr_type.selectedIndex = 0
|
||||||
|
end
|
||||||
|
|
||||||
|
local ctr_superior = self._view:GetController("show_superior")
|
||||||
|
if member.superior then
|
||||||
|
ctr_superior.selectedIndex = 2
|
||||||
|
if #member.superior > 0 then
|
||||||
|
local lst_superior = self._view:GetChild("lst_superior")
|
||||||
|
lst_superior:RemoveChildrenToPool()
|
||||||
|
for i = 1, #member.superior do
|
||||||
|
local item = lst_superior:AddItemFromPool()
|
||||||
|
item:GetChild("tex_id").text = member.superior[i]
|
||||||
|
-- item:GetChild("tex_num").text = tostring(#member.superior - i + 1) .. "级"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
elseif member.parentId ~= 0 then
|
||||||
|
self._view:GetChild("tex_superior_id").text = member.parentId
|
||||||
|
if group.owner == member.parentId or member.uid == DataManager.SelfUser.account_id then
|
||||||
|
ctr_superior.selectedIndex = 0
|
||||||
|
else
|
||||||
|
ctr_superior.selectedIndex = 1
|
||||||
|
end
|
||||||
|
elseif member.lev == 3 then
|
||||||
|
self._view:GetChild("tex_superior_id").text = ""
|
||||||
|
ctr_superior.selectedIndex = 3
|
||||||
|
else
|
||||||
|
ctr_superior.selectedIndex = 0
|
||||||
|
self._view:GetChild("tex_superior_id").text = ""
|
||||||
|
end
|
||||||
|
|
||||||
|
local fgCtr = ControllerManager.GetController(NewGroupController)
|
||||||
|
self._view:GetChild("btn_deploy").onClick:Set(function()
|
||||||
|
|
||||||
|
local gniv = GroupNumberInputView.new(nil, function(num)
|
||||||
|
ViewUtil.ShowModalWait()
|
||||||
|
local parent_id = tonumber(num)
|
||||||
|
fgCtr:FG_FindMember(self.group_id, parent_id, function(res)
|
||||||
|
if self._is_destroy then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
if res.ReturnCode ~= 0 then
|
||||||
|
ViewUtil.CloseModalWait()
|
||||||
|
ViewUtil.ErrorTip(res.ReturnCode, "找不到成员")
|
||||||
|
elseif res.Data.partnerLev == 0 then
|
||||||
|
ViewUtil.CloseModalWait()
|
||||||
|
ViewUtil.ErrorTip(res.ReturnCode, "目标不是合伙人")
|
||||||
|
else
|
||||||
|
fgCtr:FG_DeployMember(self.group_id, member.uid, parent_id, function(res1)
|
||||||
|
ViewUtil.CloseModalWait()
|
||||||
|
if (res1.ReturnCode == 0) then
|
||||||
|
member.parentId = parent_id
|
||||||
|
self._view:GetChild("tex_superior_id").text = parent_id
|
||||||
|
ctr_superior.selectedIndex = 1
|
||||||
|
ViewUtil.ShowBannerOnScreenCenter("调配玩家成功")
|
||||||
|
else
|
||||||
|
ViewUtil.ErrorTip(res1.ReturnCode,"调配玩家失败")
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end, 0, nil, "ui://NewGroup/Win_AddFriend")
|
||||||
|
gniv:Show()
|
||||||
|
end)
|
||||||
|
local vipbtn = self._view:GetChild("btn_vip")
|
||||||
|
if vipbtn ~= nil then
|
||||||
|
if (group.lev < member.lev) or (group.lev == 3 and group.partnerLev > 0 and member.uid ~= DataManager.SelfUser.account_id) or (group.lev < 3 and member.uid == DataManager.SelfUser.account_id ) then
|
||||||
|
vipbtn.visible = true
|
||||||
|
vipbtn.selected = member.isvip == 1 and true or false
|
||||||
|
vipbtn.onClick:Set(function()
|
||||||
|
local selected = vipbtn.selected and 1 or 0
|
||||||
|
fgCtr:FG_GroupSetVip(self.group_id, member.uid, selected, function(res1)
|
||||||
|
if self._is_destroy then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
ViewUtil.CloseModalWait()
|
||||||
|
if res1.ReturnCode == 0 then
|
||||||
|
member.isvip = selected
|
||||||
|
self.callBack()
|
||||||
|
else
|
||||||
|
vipbtn.selected = not vipbtn.selected
|
||||||
|
ViewUtil.ErrorTip(res1.ReturnCode,"设置vip失败")
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end)
|
||||||
|
else
|
||||||
|
vipbtn.visible = false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- 管理功能列表
|
||||||
|
local lst_mng = self._view:GetChild("lst_mng")
|
||||||
|
lst_mng:RemoveChildrenToPool()
|
||||||
|
-- 删除按钮
|
||||||
|
local option = group.option or 0
|
||||||
|
if (group.partnerLev > 0 and member.uid ~= DataManager.SelfUser.account_id and bit:_and(option,1) == 1) or group.lev < member.lev then
|
||||||
|
local btn_del = lst_mng:AddItemFromPool()
|
||||||
|
btn_del.icon = "ui://NewGroup/mng_del"
|
||||||
|
btn_del.onClick:Set(function()
|
||||||
|
if not CheckPermission(group.lev, perm_array[MngPermissionList.DeleteMember]) then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
local _curren_msg = MsgWindow.new(nil, "确定删除该成员吗?", MsgWindow.MsgMode.OkAndCancel)
|
||||||
|
_curren_msg.onOk:Add(function()
|
||||||
|
ViewUtil.ShowModalWait()
|
||||||
|
fgCtr:FG_GroupRemoveMember(self.group_id, member.uid, function(res1)
|
||||||
|
if self._is_destroy then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
ViewUtil.CloseModalWait()
|
||||||
|
if res1.ReturnCode == 0 then
|
||||||
|
self.callBack(true)
|
||||||
|
ViewUtil.ShowBannerOnScreenCenter("已成功删除玩家")
|
||||||
|
self:Destroy()
|
||||||
|
else
|
||||||
|
ViewUtil.ErrorTip(res1.ReturnCode,"删除成员失败")
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end)
|
||||||
|
_curren_msg:Show()
|
||||||
|
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- 禁止游戏
|
||||||
|
--
|
||||||
|
if (group.lev < member.lev) or (group.lev == 3 and group.partnerLev > 0 and member.uid ~= DataManager.SelfUser.account_id) then
|
||||||
|
--if group.lev == 1 and member.lev > 1 and member.partnerLev >0 and member.uid ~= DataManager.SelfUser.account_id then
|
||||||
|
local btn_ban = lst_mng:AddItemFromPool()
|
||||||
|
local pic = member.ban == 1 and "mng_del_ban" or "mng_ban"
|
||||||
|
btn_ban.icon = "ui://NewGroup/" .. pic
|
||||||
|
btn_ban.onClick:Set(function()
|
||||||
|
if not CheckPermission(group.lev, perm_array[MngPermissionList.BanPlaying]) then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local str = member.ban == 1 and "确定恢复娱乐吗?" or "确定禁止娱乐吗?"
|
||||||
|
local _curren_msg = MsgWindow.new(nil, str, MsgWindow.MsgMode.OkAndCancel)
|
||||||
|
_curren_msg.onOk:Add(function()
|
||||||
|
ViewUtil.ShowModalWait()
|
||||||
|
local val = 1 - member.ban
|
||||||
|
fgCtr:FG_BanMember(self.group_id, member.uid, val, 1, function(res1)
|
||||||
|
if self._is_destroy then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
ViewUtil.CloseModalWait()
|
||||||
|
if res1.ReturnCode == 0 then
|
||||||
|
member.ban = val
|
||||||
|
pic = member.ban == 1 and "mng_del_ban" or "mng_ban"
|
||||||
|
btn_ban.icon = "ui://NewGroup/" .. pic
|
||||||
|
self.callBack()
|
||||||
|
else
|
||||||
|
ViewUtil.ErrorTip(res1.ReturnCode,"禁止娱乐失败!")
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end)
|
||||||
|
_curren_msg:Show()
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
--print("group.type=====================")
|
||||||
|
--print(group.type)
|
||||||
|
--pt(group)
|
||||||
|
if member.partnerLev > 0 and group.type == 2 and member.uid ~= DataManager.SelfUser.account_id then
|
||||||
|
local btn_ban = lst_mng:AddItemFromPool()
|
||||||
|
local pic = member.group_ban == 1 and "mng_del_ban_group" or "mng_ban_group"
|
||||||
|
btn_ban.icon = "ui://NewGroup/" .. pic
|
||||||
|
--printlog("jefe member.partnerLev",member.partnerLev)
|
||||||
|
--if member.partnerLev==1 then
|
||||||
|
btn_ban.onClick:Set(function()
|
||||||
|
-- if not CheckPermission(group.lev, perm_array[MngPermissionList.BanPlaying]) then
|
||||||
|
-- return
|
||||||
|
-- end
|
||||||
|
|
||||||
|
|
||||||
|
local str = member.group_ban == 1 and "确定恢复该合伙人整组娱乐吗?" or "确定禁止该合伙人整组娱乐吗?"
|
||||||
|
local _curren_msg = MsgWindow.new(nil, str, MsgWindow.MsgMode.OkAndCancel)
|
||||||
|
_curren_msg.onOk:Add(function()
|
||||||
|
ViewUtil.ShowModalWait()
|
||||||
|
local val = member.group_ban == 1 and 0 or 1
|
||||||
|
fgCtr:FG_BanMember(self.group_id, member.uid, val, 2, function(res1)
|
||||||
|
if self._is_destroy then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
ViewUtil.CloseModalWait()
|
||||||
|
if res1.ReturnCode == 0 then
|
||||||
|
member.group_ban = val
|
||||||
|
pic = member.group_ban == 1 and "mng_del_ban_group" or "mng_ban_group"
|
||||||
|
btn_ban.icon = "ui://NewGroup/" .. pic
|
||||||
|
self.callBack()
|
||||||
|
else
|
||||||
|
ViewUtil.ErrorTip(res1.ReturnCode,val == 1 and "禁止整组娱乐失败!" or "恢复整组娱乐失败!")
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end)
|
||||||
|
_curren_msg:Show()
|
||||||
|
end)
|
||||||
|
-- end
|
||||||
|
end
|
||||||
|
-- 禁止同桌
|
||||||
|
if group.lev < 3 then
|
||||||
|
local btn_ban_table = lst_mng:AddItemFromPool()
|
||||||
|
btn_ban_table.icon = "ui://NewGroup/mng_ban_table"
|
||||||
|
btn_ban_table.onClick:Set(function()
|
||||||
|
if not CheckPermission(group.lev, perm_array[MngPermissionList.BanSameTable]) then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
ViewUtil.ShowModalWait()
|
||||||
|
fgCtr:FG_GetBanTable(self.group_id, member.uid, function(res)
|
||||||
|
ViewUtil.CloseModalWait()
|
||||||
|
if res.ReturnCode == 0 then
|
||||||
|
local btv = GroupBanSameTableView.new(self.blur_view, self.group_id, member.uid, res.Data)
|
||||||
|
btv:Show()
|
||||||
|
else
|
||||||
|
ViewUtil.ErrorTip(res.ReturnCode,"获取禁止同桌列表失败!")
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
if group.lev == 1 and member.lev > 1 and member.partnerLev >0 and member.uid ~= DataManager.SelfUser.account_id then
|
||||||
|
--if false then
|
||||||
|
local btn_set_mng = lst_mng:AddItemFromPool()
|
||||||
|
btn_set_mng.icon = "ui://NewGroup/zhengzu"
|
||||||
|
btn_set_mng.onClick:Set(
|
||||||
|
function()
|
||||||
|
ViewUtil.ShowModalWait()
|
||||||
|
fgCtr:FG_GetBanMemberHB(self.group_id, member.uid, function(res)
|
||||||
|
ViewUtil.CloseModalWait()
|
||||||
|
--pt(res)
|
||||||
|
if res.ReturnCode == 0 then
|
||||||
|
local diaoduView=GroupSetMemberInfoDiaoduView.new(self.group_id, member.uid)
|
||||||
|
diaoduView:SetCurrentState(res.Data.group_black+1,res.Data)
|
||||||
|
else
|
||||||
|
ViewUtil.ErrorTip(res.ReturnCode,"获取整组调度失败!")
|
||||||
|
end
|
||||||
|
|
||||||
|
end)
|
||||||
|
|
||||||
|
end)
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
-- 设置管理员
|
||||||
|
if group.lev == 1 and member.lev > 1 and member.partnerLev >= 0 then
|
||||||
|
local btn_set_mng = lst_mng:AddItemFromPool()
|
||||||
|
local pic = member.lev == 2 and "mng_del_mng" or "mng_set_mng"
|
||||||
|
btn_set_mng.icon = "ui://NewGroup/" .. pic
|
||||||
|
btn_set_mng.onClick:Set(function()
|
||||||
|
local str = member.lev == 3 and "确定设置玩家为副盟主吗?" or "确定取消玩家副盟主身份吗?"
|
||||||
|
local _curren_msg = MsgWindow.new(nil, str, MsgWindow.MsgMode.OkAndCancel)
|
||||||
|
_curren_msg.onOk:Add(function()
|
||||||
|
ViewUtil.ShowModalWait()
|
||||||
|
local val = 4 - member.lev
|
||||||
|
fgCtr:FG_SetManager(self.group_id, member.uid, val, function(res1)
|
||||||
|
if self._is_destroy then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
ViewUtil.CloseModalWait()
|
||||||
|
if res1.ReturnCode == 0 then
|
||||||
|
member.lev = val + 1
|
||||||
|
self.callBack()
|
||||||
|
if val == 1 then
|
||||||
|
ctr_superior.selectedIndex = 0
|
||||||
|
else
|
||||||
|
ctr_superior.selectedIndex = 3
|
||||||
|
end
|
||||||
|
self:Destroy()
|
||||||
|
else
|
||||||
|
ViewUtil.ErrorTip(res1.ReturnCode,"设置副群主失败!")
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end)
|
||||||
|
_curren_msg:Show()
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
if ((group.lev < 3 and member.parentId == 0) or (group.type == 2 and member.parentId == DataManager.SelfUser.account_id)) and member.partnerLev == 0 and member.lev == 3 then
|
||||||
|
local btn_set_partner = lst_mng:AddItemFromPool()
|
||||||
|
local pic = member.partnerLev == 0 and "mng_set_partner" or "mng_del_partner"
|
||||||
|
btn_set_partner.icon = "ui://NewGroup/" .. pic
|
||||||
|
btn_set_partner.onClick:Set(function()
|
||||||
|
local str = member.partnerLev == 0 and "确定设置玩家为合伙人吗?" or "确定取消玩家合伙人身份吗?"
|
||||||
|
local _curren_msg = MsgWindow.new(nil, str, MsgWindow.MsgMode.OkAndCancel)
|
||||||
|
_curren_msg.onOk:Add(function()
|
||||||
|
ViewUtil.ShowModalWait()
|
||||||
|
local val = member.partnerLev > 0 and 2 or 1
|
||||||
|
fgCtr:FG_SetPartner(self.group_id, member.uid, val, function(res1)
|
||||||
|
if self._is_destroy then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
ViewUtil.CloseModalWait()
|
||||||
|
if res1.ReturnCode == 0 then
|
||||||
|
member.parentId = res1.Data.parentId
|
||||||
|
member.partnerLev = res1.Data.partnerLev
|
||||||
|
self.callBack()
|
||||||
|
ctr_superior.selectedIndex = 1
|
||||||
|
|
||||||
|
self:Destroy()
|
||||||
|
else
|
||||||
|
ViewUtil.ErrorTip(res1.ReturnCode,"设置合伙人失败失败!")
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end)
|
||||||
|
_curren_msg:Show()
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
if ((group.lev < 3 and member.parentId == 0) or (group.type == 2 and member.parentId == DataManager.SelfUser.account_id)) and member.partnerLev == 0 and member.lev == 2 then
|
||||||
|
local btn_set_permission = lst_mng:AddItemFromPool()
|
||||||
|
btn_set_permission.icon = "ui://NewGroup/mng_set_permission"
|
||||||
|
btn_set_permission.onClick:Set(function()
|
||||||
|
local gspv = GroupSetPermissionView.new(self.blur_view, self.group_id, member)
|
||||||
|
gspv:Show()
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
local btn_fag_info = lst_mng:AddItemFromPool()
|
||||||
|
btn_fag_info.icon = "ui://NewGroup/mng_fag"
|
||||||
|
btn_fag_info.onClick:Set(function()
|
||||||
|
local mflv = GroupMemberFagLogView.new(self.group_id, member)
|
||||||
|
mflv:Show()
|
||||||
|
end)
|
||||||
|
|
||||||
|
if group.lev == 1 and member.partnerLev > 0 and group.type == 2 then
|
||||||
|
local btn_move = lst_mng:AddItemFromPool()
|
||||||
|
btn_move.icon = "ui://NewGroup/mng_move"
|
||||||
|
btn_move.onClick:Set(function()
|
||||||
|
local gniv = GroupNumberInputView.new(nil, function(num)
|
||||||
|
local parent_id = tonumber(num)
|
||||||
|
if parent_id == member.parentId then
|
||||||
|
ViewUtil.ErrorTip(nil, "已经在该合伙人名下")
|
||||||
|
return
|
||||||
|
elseif parent_id == member.id then
|
||||||
|
ViewUtil.ErrorTip(nil, "目标的上级不能是自己")
|
||||||
|
return
|
||||||
|
elseif parent_id == DataManager.SelfUser.account_id then
|
||||||
|
self:MovePartner(parent_id, member, self._view)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
ViewUtil.ShowModalWait()
|
||||||
|
local fgCtr = ControllerManager.GetController(NewGroupController)
|
||||||
|
fgCtr:FG_FindMember(self.group_id, parent_id, function(res)
|
||||||
|
if self._is_destroy then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
if res.ReturnCode ~= 0 then
|
||||||
|
ViewUtil.CloseModalWait()
|
||||||
|
ViewUtil.ErrorTip(res.ReturnCode, "找不到成员")
|
||||||
|
elseif res.Data.partnerLev == 0 then
|
||||||
|
ViewUtil.CloseModalWait()
|
||||||
|
ViewUtil.ErrorTip(res.ReturnCode, "目标不是合伙人")
|
||||||
|
else
|
||||||
|
self:MovePartner(parent_id, member, self._view)
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end, 0, nil, "ui://NewGroup/Win_AddFriend")
|
||||||
|
gniv:Show()
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
if member.parentId == DataManager.SelfUser.account_id then
|
||||||
|
local btn_set_tag = lst_mng:AddItemFromPool()
|
||||||
|
btn_set_tag.icon = "ui://NewGroup/mng_set_tag"
|
||||||
|
btn_set_tag.onClick:Set(function()
|
||||||
|
local stv = GroupSetTagView.new(self.group_id, member, function(refresh)
|
||||||
|
if refresh then
|
||||||
|
self.callBack()
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
stv:Show()
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
if group.lev == 1 then
|
||||||
|
local btn_banplays = lst_mng:AddItemFromPool()
|
||||||
|
btn_banplays.icon = "ui://NewGroup/mng_ban_plays"
|
||||||
|
btn_banplays.onClick:Set(function()
|
||||||
|
local banplays = GroupPartnerBanPlaysView.new(self.group_id,member.uid)
|
||||||
|
banplays:Show()
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
if group.lev == 1 then
|
||||||
|
local btn_qiangzhi = lst_mng:AddItemFromPool()
|
||||||
|
btn_qiangzhi.icon = "ui://NewGroup/mng_qiangzhi"
|
||||||
|
btn_qiangzhi.onClick:Set(function()
|
||||||
|
local msg_tip = MsgWindow.new(self._root_view,"确定全部提取吗?", MsgWindow.MsgMode.OnlyOk)
|
||||||
|
msg_tip.onOk:Add(function( ... )
|
||||||
|
ViewUtil.ShowModalWait()
|
||||||
|
fgCtr:FG_TakeHp1(self.group_id, member.uid, function(res)
|
||||||
|
ViewUtil.CloseModalWait()
|
||||||
|
if self._is_destroy then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
if res.ReturnCode ~= 0 then
|
||||||
|
ViewUtil.ErrorTip(res.ReturnCode, "提取失败")
|
||||||
|
else
|
||||||
|
ViewUtil.ErrorTip(res.ReturnCode, "提取成功")
|
||||||
|
self:Destroy()
|
||||||
|
if self.callBack1 then
|
||||||
|
self.callBack1()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
msg_tip:Close()
|
||||||
|
end)
|
||||||
|
msg_tip:Show()
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function M:MovePartner(parent_id, member, obj)
|
||||||
|
local fgCtr = ControllerManager.GetController(NewGroupController)
|
||||||
|
fgCtr:FG_MovePartner(self.group_id, member.uid, parent_id, function(res1)
|
||||||
|
ViewUtil.CloseModalWait()
|
||||||
|
if (res1.ReturnCode == 0) then
|
||||||
|
member.parentId = parent_id
|
||||||
|
member.partnerLev = res1.Data.partnerLev
|
||||||
|
obj:GetChild("tex_superior_id").text = parent_id
|
||||||
|
obj:GetController("show_superior").selectedIndex = 1
|
||||||
|
ViewUtil.ShowBannerOnScreenCenter("转移成功")
|
||||||
|
else
|
||||||
|
ViewUtil.ErrorTip(res1.ReturnCode,"转移失败")
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
return M
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue