From b95a75310c78e856b09d27d8bc53e63aea67c609 Mon Sep 17 00:00:00 2001 From: gaoxin Date: Sat, 10 Oct 2020 09:55:15 +0800 Subject: [PATCH] =?UTF-8?q?=E5=86=8D=E6=AC=A1=E4=BF=AE=E5=A4=8D=E7=99=BB?= =?UTF-8?q?=E5=BD=95=E6=97=B6=E5=8C=BA=E6=9C=8D=E6=98=BE=E7=A4=BA=E9=94=99?= =?UTF-8?q?=E8=AF=AF=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../~Lua/Modules/Login/LoginPanel.lua | 36 +++++++++---------- 1 file changed, 16 insertions(+), 20 deletions(-) diff --git a/Assets/ManagedResources/~Lua/Modules/Login/LoginPanel.lua b/Assets/ManagedResources/~Lua/Modules/Login/LoginPanel.lua index 94e88dbcc8..b8189fe898 100644 --- a/Assets/ManagedResources/~Lua/Modules/Login/LoginPanel.lua +++ b/Assets/ManagedResources/~Lua/Modules/Login/LoginPanel.lua @@ -13,7 +13,6 @@ local IsDevelopLogin = true local openIdkey = "openIdkey" local openIdPw = "openIdPw" -local lastServerIndex = "lastServerIndex" local defaultOpenIdkey = Language[11118] local defaultOpenIdPw = "" local LoginRoot_Url = VersionManager:GetVersionInfo("serverUrl") @@ -96,7 +95,6 @@ function this:BindEvent() recommend = this.recommend, callback = function(index) local list = this.serverList[index] - PlayerPrefs.SetInt(lastServerIndex, index) PlayerManager.serverInfo = list LoginManager.SocketAddress = list.ip LoginManager.SocketPort = list.port @@ -348,28 +346,26 @@ end function this.SetServerList(data) this.CacheLoginData(data) + -- 默认选择第一个服务器 + local lastIndex = 1 + -- 判断要显示的服务器 + local showServer - local lastIndex = PlayerPrefs.GetInt(lastServerIndex, 1) - if this.lastServer then --有最近登录显示最近登录,没有显示推荐,否则显示第一个服 - --for i = 1, #this.serverList do - -- if this.serverList[i].server_id == this.lastServer.serverid then - -- lastIndex = i - -- break - -- end - --end + if this.lastServer then --有最近登录显示最近登录,没有显示推荐,否则显示第一个服 + showServer = this.lastServer.serverid else - if this.recommend then - for i = 1, #this.serverList do - if this.serverList[i].server_id == this.recommend then - lastIndex = i - break - end - end + if this.recommend then + showServer = this.recommend end end - if not this.serverList[lastIndex] then - lastIndex = 1 - PlayerPrefs.SetInt(lastServerIndex, 1) + -- 如果有要显示的服务器判断位置 + if showServer then + for i = 1, #this.serverList do + if this.serverList[i].server_id == showServer then + lastIndex = i + break + end + end end PlayerManager.serverInfo = this.serverList[lastIndex] LoginManager.SocketAddress = this.serverList[lastIndex].ip