白日门UI修改,一个复古的服务器选择界面,看上去非常不错

这是关于白日门UI修改,一个复古的服务器选择界面,看上去非常不错,最近工作非常忙,没有时间,这个界面断断续续搞了几天,记录一下心得,以便以后自己可以很快的修改其他UI。

 

cfd7d82744163039

有时间还需要处理一下背景图片底部,有XXX信息。

还是老规矩,直接附上完整代码。

LUA_RET = {
	{
		n = "SceneSelectServer",
		parent = 0,
		v = true,
		type = 0,
		id = 1,
		w = 1136,
		h = 640
	},
	{
		n = "imgSceneBg",
		tag = 23,
		h = 640,
		type = 1,
		w = 1136,
		ax = 0.5,
		color = "255|255|255",
		parent = 1,
		v = true,
		y = 320,
		id = 2,
		ay = 0.5,
		x = 568
	},
	{
		tag = 136,
		n = "ZhuxijingimgSceneBg",
		h = 640,
		type = 1,
		w = 1136,
		ax = 0.5,
		color = "255|255|255",
		parent = 1,
		v = true,
		y = 317.1907,
		id = 311,
		ay = 0.5,
		x = 569.3109
	},
	{
		tag = 136,
		n = "panelBg",
		h = 640,
		type = 1,
		w = 1136,
		ax = 0.5,
		color = "255|255|255",
		parent = 1,
		v = false,
		y = 317.1907,
		id = 3,
		ay = 0.5,
		x = 569.3109
	},
	{
		tag = 116,
		c = false,
		h = 640,
		type = 0,
		w = 1136,
		n = "panelServerList",
		ax = 0.5,
		color = "255|255|255",
		parent = 1,
		v = false,
		y = 320,
		id = 4,
		ay = 0.5,
		x = 568,
		t = true
	},
	{
		sy = -15,
		tag = 23,
		h = 528,
		type = 1,
		w = 630,
		ss = true,
		color = "255|255|255",
		sx = -107,
		n = "serverListBg",
		ay = 0.5,
		sw = 260,
		ax = 0.5,
		parent = 4,
		v = true,
		y = 318,
		id = 5,
		sh = 76,
		x = 538
	},
	{
		sy = 15,
		tag = 98,
		h = 497,
		type = 1,
		w = 794,
		ss = true,
		color = "255|255|255",
		sx = 15,
		n = "serverBg",----添加的复古背景
		ay = 0.5,
		sw = 15,
		ax = 0.5,
		parent = 5,
		v = true,
		y = 284,
		id = 6,
		sh = 15,
		x = 255
	},
	{
		tag = 30,
		color = "255|255|255",
		h = 20,
		type = 3,
		w = 180,
		ht = 1,
		text = "最近登录",
		n = "Text_1",
		ay = 0.5,
		fs = 20,
		ax = 0.5,
		parent = 5,
		v = true,
		y = 451.2147,
		id = 7,
		x = 203.9086,
		vt = 1
	},
	{
		n = "Text_1_0",
		tag = 42,
		fs = 20,
		type = 3,
		w = 120,
		h = 20,
		ax = 0.5,
		color = "255|255|255",
		text = "服务器列表:",
		parent = 5,
		v = true,
		y = 351.2719,
		id = 8,
		ay = 0.5,
		x = 193.7019,
		vt = 1
	},
	{
		tag = 309,
		color = "255|217|156",
		h = 20,
		type = 3,
		w = 180,
		ht = 1,
		text = "推荐服务器",
		n = "Text_1_1",
		ay = 0.5,
		fs = 20,
		ax = 0.5,
		parent = 5,
		v = true,
		y = 451.21,
		id = 9,
		x = 472.0631,
		vt = 1
	},
	{
		n = "hint_0",
		tag = 40,
		h = 30,
		type = 1,
		w = 29,
		ax = 0.5,
		color = "255|255|255",
		res = "img_svr_status0",
		parent = 5,
		v = true,
		y = 64.6735,-------底部流畅 之类的图标
		id = 10,
		ay = 0.5,
		x = 86.99
	},
	{
		n = "Text_2_10",
		tag = 41,
		fs = 18,
		type = 3,
		w = 66,
		h = 18,
		color = "255|217|156",
		text = "维护",-------底部流畅 之类的图标
		parent = 10,
		v = true,
		y = 17.6412,
		id = 11,
		ay = 0.5,
		x = 35.2269,
		vt = 1
	},
	{
		n = "hint_1",
		tag = 32,
		h = 30,
		type = 1,
		w = 29,
		ax = 0.5,
		color = "255|255|255",
		res = "img_svr_status1",-------底部流畅 之类的图标
		parent = 5,
		v = true,
		y = 64.6735,
		id = 12,
		ay = 0.5,
		x = 229.9899
	},
	{
		n = "Text_2",
		tag = 33,
		fs = 18,
		type = 3,
		w = 66,
		h = 18,
		color = "255|217|156",-------底部流畅 之类的图标
		text = "流畅",
		parent = 12,
		v = true,
		y = 17.6413,
		id = 13,
		ay = 0.5,
		x = 35.2269,
		vt = 1
	},
	{
		tag = 38,
		sy = 9,
		h = 30,
		type = 1,
		w = 29,
		color = "255|255|255",
		res = "img_svr_status3",-------底部流畅 之类的图标
		sx = 9,
		n = "hint_2",
		ay = 0.5,
		sw = 9,
		ax = 0.5,
		parent = 5,
		v = true,
		y = 64.6735,
		id = 14,
		sh = 9,
		x = 371.9899
	},
	{
		n = "Text_2_8",
		tag = 39,
		fs = 18,
		type = 3,
		w = 66,
		h = 18,
		color = "255|217|156",-------底部流畅 之类的图标
		text = "火爆",
		parent = 14,
		v = true,
		y = 17.6413,
		id = 15,
		ay = 0.5,
		x = 35.2282,
		vt = 1
	},
	{
		tag = 31,
		d = 1,
		h = 230,
		type = 9,
		w = 550,
		parent = 5,
		id = 16,
		color = "255|255|255",
		ud = "2|4|10|25",
		c = false,
		v = true,
		y = 98.8813,
		n = "listServer",---------服务器列表 整体
		x = 122.7779,
		t = true
	},
	{
		ss = true,
		sy = 11,
		h = 45,
		type = 2,
		w = 258,
		tag = 37,
		color = "255|255|255",
		res = "SceneSelectServer_btn_gate_sel",
		sx = 15,
		n = "render",
		ay = 0.5,
		sw = 154,
		t = true,
		fs = 20,
		ax = 0.5,
		tcolor = "0|128|0",
		parent = 16,
		v = true,
		y = 250.5,
		id = 17,
		sh = 28,
		x = -99
	},
	{
		tag = 38,
		id = 18,
		fs = 16,
		type = 3,
		w = 174,
		ht = 1,
		h = 20,
		color = "255|255|255",
		text = "本地测试",--服务器列表那个名字
		parent = 17,
		v = true,
		y = 18,
		n = "lblSVRName",
		ay = 0.5,
		x = 40.8914,
		vt = 1
	},
	{
		n = "imgSVRStatus",
		tag = 39,
		h = 30,
		type = 1,
		w = 29,
		ax = 0.5,
		color = "255|255|255",
		res = "img_svr_status1",--服务器列表前面 那个状态图片。
		parent = 17,
		v = true,
		y = 16.68,
		id = 19,
		ay = 0.5,
		x = 24
	},
	{
		n = "imgSVRTag",
		tag = 466,
		h = 87,
		type = 1,
		w = 41,
		ax = 0.5,
		color = "255|255|255",
		res = "img_svr_tag1",--服务器列表 后面 那个状态图片。
		parent = 17,
		v = true,
		y = 20,
		id = 20,
		ay = 0.5,
		x = 211.7503
	},
	{
		tag = 79,
		n = "img_role_num_bg",
		h = 28,
		type = 1,
		w = 28,
		ax = 0.5,
		color = "255|255|255",
		parent = 17,
		v = false,
		y = 20.3498,
		id = 21,
		ay = 0.5,
		x = 178.2534
	},
	{
		tag = 80,
		color = "255|255|255",
		h = 16,
		type = 3,
		w = 8,
		ht = 1,
		text = "1",
		n = "lbl_role_num",
		ay = 0.5,
		fs = 16,
		ax = 0.5,
		parent = 21,
		v = true,
		y = 14,
		id = 22,
		x = 13,
		vt = 1
	},
	{
		ss = true,
		sy = 11,
		h = 35,
		type = 2,
		w = 230,
		tag = 28,
		color = "255|255|255",
		res = "lastbg",
		sx = 15,
		n = "btnLastServer",
		ay = 0.5,
		sw = 154,
		t = true,
		fs = 20,
		ax = 0.5,
		tcolor = "255|0|0",
		parent = 5,
		v = true,
		y = 409.5612,--最近登录 这个框
		id = 23,
		sh = 11,
		x = 234.3595
	},
	{
		n = "lblSVRLast",--最近登录 这个 服务器的名字
		tag = 30,
		fs = 20,
		type = 3,
		color = "255|0|0",
		text = "",
		parent = 23,
		v = true,
		y = 20,
		id = 24,
		ay = 0.5,
		x = 70,
		vt = 1
	},
	{
		n = "imgSVRStatus",--最近登录 这个 服务器的状态
		tag = 31,
		h = 30,
		type = 1,
		w = 29,
		ax = 0.5,
		color = "255|255|255",
		res = "img_svr_status1",
		parent = 23,
		v = true,
		y = 14.6794,
		id = 25,
		ay = 0.5,
		x = 24.0002
	},
	{
		ss = true,
		sy = 11,
		h = 35,
		type = 2,
		w = 230,
		tag = 310,
		color = "255|255|255",
		res = "lastbg",
		sx = 15,
		n = "btnRecommandServer",--推荐服务器 这个框
		ay = 0.5,
		sw = 154,
		t = true,
		fs = 20,
		ax = 0.5,
		tcolor = "255|200|94",
		parent = 5,
		v = true,
		y = 409.56,
		id = 26,
		sh = 11,
		x = 477.767
	},
	{
		n = "lblSVRName",--推荐服务器 这个服务器的名字
		tag = 311,
		fs = 20,
		type = 3,
		color = "218|112|214",
		text = "",
		parent = 26,
		v = true,
		y = 20,
		id = 27,
		ay = 0.5,
		x = 70,
		vt = 1
	},
	{
		n = "imgSVRStatus",--推荐服务器 这个服务器的状态
		tag = 312,
		h = 30,
		type = 1,
		w = 29,
		ax = 0.5,
		color = "255|255|255",
		res = "img_svr_status1",
		parent = 26,
		v = true,
		y = 14.6793,
		id = 28,
		ay = 0.5,
		x = 24.0001
	},
	{
		tag = 313,
		d = 1,
		h = 420,
		type = 9,
		w = 190,
		parent = 5,
		id = 29,
		color = "255|255|255",
		ud = "1|4|10|18",
		c = false,
		v = true,
		y = 40.4208,
		n = "listServerqu",
		x = -87.8781,--控制了整个左侧列表,只显示半截
		t = true
	},
	{
		ss = true,
		sy = 11,
		h = 55,
		type = 2,
		w = 200,
		tag = 314,
		color = "255|255|255",
		sx = 44,
		n = "render",--左侧列表
		ay = 0.5,
		sw = 44,
		t = true,
		fs = 20,
		ax = 0.5,
		tcolor = "255|255|255",
		parent = 29,
		v = true,
		y = 397.5,
		id = 30,
		sh = 28,
		x = 0
	},
	{
		tag = 438,
		sy = 14,
		h = 55,
		type = 1,
		w = 175,
		color = "255|255|255",
		res = "btn_gate",
		sx = 44,
		n = "btnServerBg",--左侧列表
		ay = 0.5,
		sw = 44,
		ax = 0.5,
		parent = 30,
		v = true,
		y = 20.05,
		id = 31,
		sh = 14,
		x = 46.48
	},
	{
		id = 32,
		tag = 315,
		h = 25,
		type = 3,
		w = 150,
		ht = 1,
		text = "1-100服",
		n = "lblSVRName",--左侧列表
		ay = 0.5,
		fs = 18,
		fr = "DFYuan.ttf",
		parent = 30,
		v = true,
		y = 22.6365,
		color = "255|51|51",
		x = -6.7837,
		vt = 1
	},
	{
		n = "panelLogin",
		c = false,
		h = 640,
		type = 0,
		w = 1136,
		tag = 58,
		ax = 0.5,
		color = "255|255|255",
		parent = 1,
		v = true,
		y = 320,
		id = 33,
		ay = 0.5,
		x = 568,
		t = true
	},
	{
		sy = 21,
		tag = 57,
		h = 50,
		type = 1,
		w = 289,
		ss = true,
		color = "255|255|255",
		res = "SceneSelectServer_img_xfdc",--点击选服 的 背景图
		sx = 82,
		n = "btnServerBg",
		ay = 0.5,
		sw = 330,
		ax = 0.5,
		parent = 33,
		v = true,
		y = 175.7103,
		id = 34,
		sh = 24,
		x = 574.465
	},
	{
		ss = true,
		sy = 10,
		h = 36,
		type = 2,
		w = 111,
		tag = 39,
		color = "255|255|255",
		res = "img_select_server",--点击选服
		sx = 15,
		n = "btnSelectServer",
		ay = 0.5,
		sw = 84,
		t = true,
		fs = 14,
		ax = 0.5,
		tcolor = "65|65|70",
		parent = 34,
		v = true,
		y = 24.6983,
		id = 35,
		sh = 12,
		x = 207.1288
	},
	{
		id = 36,
		n = "lblServerName",
		fs = 22,
		type = 3,
		ax = 1,
		color = "255|255|255",
		text = "",
		parent = 35,
		v = true,
		y = 20,
		tag = 40,
		ay = 0.5,
		x = -11
	},
	{
		type = 2,
		tag = 42,
		h = 89,
		sy = 11,
		w = 232,
		color = "255|255|255",
		res = "zhuxijing_img_login_48",
		sx = 32,
		n = "btnEnterGame",
		ay = 0.5,
		sw = 32,
		t = true,
		fs = 24,
		ax = 0.5,
		tcolor = "255|165|0",
		parent = 33,
		v = true,
		y = 79.9461,
		id = 37,
		sh = 11,
		x = 572.942
	},
	{
		type = 2,
		tag = 33,
		h = 67,
		sy = 11,
		w = 55,
		color = "255|255|255",
		res = "changeBtn",
		sx = 18,
		n = "btnLogout",
		ay = 0.5,
		sw = 18,
		t = true,
		fs = 24,
		ax = 0.5,
		tcolor = "255|165|0",
		parent = 33,
		v = true,
		y = 563.7584,
		id = 38,
		sh = 11,
		x = 1013.0172
	},
	{
		type = 2,
		n = "btnNotice",
		h = 32,
		sy = 11,
		w = 95,
		color = "255|255|255",
		res = "back",
		text = "公告",
		sx = 32,
		tag = 308,
		ay = 0.5,
		sw = 32,
		t = true,
		fs = 24,
		ax = 0.5,
		tcolor = "255|165|0",
		parent = 33,
		v = false,
		y = 563.756,
		id = 39,
		sh = 11,
		x = 1012.0351
	},
	{
		tag = 137,
		n = "img_open_door",
		h = 560,
		type = 1,
		w = 290,
		ax = 0.5,
		color = "255|255|255",
		parent = 1,
		v = false,
		y = 320.4008,
		id = 40,
		ay = 0.5,
		x = 567.9996
	},
	{
		tag = 37,
		c = false,
		h = 640,
		type = 0,
		w = 1136,
		n = "Panel_Connect",
		ax = 0.5,
		color = "255|255|255",
		parent = 1,
		v = false,
		y = 319.9999,
		id = 41,
		ay = 0.5,
		x = 564.8538,
		t = true
	},
	{
		n = "Image_Connect",
		tag = 41,
		h = 46,
		type = 1,
		w = 46,
		ax = 0.5,
		color = "255|255|255",
		parent = 41,
		v = true,
		y = 320,
		id = 42,
		ay = 0.5,
		x = 568
	},
	{
		id = 43,
		n = "Text_Connect",
		fs = 18,
		type = 3,
		ax = 0.5,
		color = "255|165|0",
		text = "",
		parent = 41,
		v = true,
		y = 320,
		tag = 39,
		ay = 0.5,
		x = 568
	}
}

功能层的

-- 选择服务器界面

SceneSelectServer = class("SceneSelectServer", function()
    return display.newScene("SceneSelectServer")
end)

local needloadImg = {
	-- ["imgSceneBg"] = {res = "img_battle.jpg", needscale = true, posX = display.cx, posY = display.cy, anchor = display.CENTER},
	["serverBg"] = {res = "zhuxijing_img_login_30", posX = display.cx-300, posY = display.cy-40, anchor = display.CENTER}
}

local buttonTable = {"btnLogout", "btnEnterGame", "btnSelectServer", "btnLastServer"}

function SceneSelectServer:ctor()
	self.m_serverUI = nil
	self.panelLogin = nil
	self.panelServerList = nil
	self.zhuxijing_img = nil
	self.zhuxijing_img2 = false
	self.zhuxijing_img3 = nil
	self.curPanel = nil
	self.loginManager = nil
	self.serverList = {}
	self.serverId = 1
	self.curTag = 1		-- 当前选的大区
	self.svrpath = cc.FileUtils:getInstance():getWritablePath().."serverList.json"
	self.directEnter = false
end

local serverNum = 20

-- -- 人物大图动画
function SceneSelectServer:playBgAnim(ui)
-- 	local startNum = 1
-- 	local doorNum = 20
 	local imgSceneBg = self.m_serverUI:getWidgetByName("imgSceneBg"):align(display.CENTER, display.cx, display.cy):scale(cc.MAX_SCALE)
-- 	local function startAnim()
 		asyncload_callback("needload/mp_xfjm_nztl.png", imgSceneBg, function (filepath, texture)
			if util.isObjectExist(imgSceneBg) then
				imgSceneBg:loadTexture(filepath)
			end
 		end)
-- 		startNum = startNum + 1
-- 		if startNum >= 21 then
-- 			startNum = 1
-- 		end
-- 	end
	
-- 	ui:runAction(cca.repeatForever(cca.seq({cca.delay(0.1),cca.cb(startAnim)}),tonumber(20)))

	if not self.zhuxijing_img then
		local ZhuxijingimgSceneBg = self.m_serverUI:getChildByName("ZhuxijingimgSceneBg")
	
		self.zhuxijing_img = ccui.ImageView:create("zhuxijing_img_login_29",ccui.TextureResType.plistType)
			:setContentSize(cc.size(467,313))
			:addTo(ZhuxijingimgSceneBg)
			:align(display.CENTER, display.cx, display.cy+200)
			:setVisible(true);
	end	
			
end

function SceneSelectServer:onEnter()
	if PlayAudio.musicName~="sound/login.mp3" then
		PlayAudio.music("sound/login.mp3")
	end

	self.m_serverUI = UILuaLoader.load("uilayout/SceneSelectServer.uif")
	if self.m_serverUI then
		self.m_serverUI:size(cc.size(display.width, display.height)):align(display.CENTER, display.cx, display.cy):addTo(self,2)
		local sceneScale = display.height / 640
		for k,v in pairs(needloadImg) do
			local imgNeedLoad = self.m_serverUI:getWidgetByName(k):loadTexture(v.res, ccui.TextureResType.plistType):setTouchEnabled(true)
			--local imgNeedLoad = self.m_serverUI:getWidgetByName(k):loadTexture("needload/"..v.res):setTouchEnabled(true):show()
			-- if v.needscale then imgNeedLoad:setScale(sceneScale) end
			-- if v.posX then imgNeedLoad:align(v.anchor, v.posX, v.posY) end
		end
		-- local img_left = self.m_serverUI:getWidgetByName("img_left")
		-- local img_right = self.m_serverUI:getWidgetByName("img_right")

		-- img_left:setPositionX(display.cx)
		-- img_right:setPositionX(display.cx)

		-- asyncload_callback("needload/OpenDoor/img_login_open.jpg", img_left, function (filepath, texture)
		-- 	if util.isObjectExist(img_left) then
		-- 		img_left:loadTexture(filepath):scale(cc.MAX_SCALE)
		-- 	end
		-- 	if util.isObjectExist(img_right) then
		-- 		img_right:loadTexture(filepath):scale(cc.MAX_SCALE)
		-- 	end
		-- end)
		-- img_right:setFlippedX(true)

		-- local panelBg = self.m_serverUI:getWidgetByName("imgSceneBg")
		-- --加载背景
		-- asyncload_callback("needload/2.png", panelBg, function (filepath, texture)
		-- 	if util.isObjectExist(panelBg) then
		-- 		panelBg:loadTexture(filepath):scale(cc.MAX_SCALE)
		-- 	end
		-- end)

		self:playBgAnim(self.m_serverUI)
		--util.asyncload(self.m_serverUI, "panelBg", "needload/2.png")

		--self:openDoor(self.m_serverUI)
		-- asyncload_callback("needload/tip_chenmi.png", self, function (filepath, texture)
		-- 	if util.isObjectExist(self) then
		-- 		self.tip_chenmi = ccui.ImageView:create(filepath):align(display.BOTTOM_CENTER, display.cx, 0):addTo(self,3):hide()
		-- 	end
		-- end)

		if device.platform ~= "windows" then
			local assetsCode = PlatformTool.getConfigString("assets_code")
			local version = PlatformTool.getConfigString("version")
			if not assetsCode or assetsCode=="" or assetsCode=="0" then
				assetsCode = version
			end

			local lblAssetsCode = util.newUILabel({
				text = lan.Com_Resource..":"..assetsCode,
				font = FONT_NAME,
				fontSize = 24,
				color = cc.c3b(255, 165, 0),
			}):addTo(self,11):align(display.RIGHT_TOP, display.right - 10, display.top - 10):enableOutline(cc.c4b(24,19,11,200),1)

			local lblAssetsCode = util.newUILabel({
				text = lan.Com_Game..":"..version,
				font = FONT_NAME,
				fontSize = 24,
				color = cc.c3b(255, 165, 0),
			}):addTo(self,11):align(display.LEFT_TOP, display.left + 10, display.top - 10):enableOutline(cc.c4b(24,19,11,200),1)
		end

		self.panelLogin = self.m_serverUI:getWidgetByName("panelLogin"):align(display.CENTER, display.cx, display.cy):hide()

		self.panelServerList = self.m_serverUI:getWidgetByName("panelServerList"):align(display.CENTER, display.cx, display.cy):hide()
			:setContentSize(cc.size(display.width, display.height)):setTouchEnabled(true)
		self.curPanel = self.panelLogin

		local imgSelectBg = self.panelLogin:getChildByName("Image_1")
		-- imgSelectBg:pos(display.cx, display.cy)

		local btnSelectServer = self.m_serverUI:getWidgetByName("btnSelectServer")
		local btnServerBg = self.m_serverUI:getWidgetByName("btnServerBg")
		btnServerBg:pos(display.cx, 180)
		--btnSelectServer:pos(display.cx + btnSelectServer:getContentSize().width/2, display.cy)
		btnSelectServer:addClickEventListener(function ()
			
			self:onSelectServer()
		end)


		self.panelConnect = self.m_serverUI:getWidgetByName("Panel_Connect")
		self.panelConnect:setContentSize(cc.size(display.width, display.height)):align(display.CENTER, display.cx, display.cy)
		self.panelConnect:setTouchEnabled(true)
		self.panelConnect:setVisible(false)

		--固定屏幕位置
		-- self.panelLogin:getWidgetByName("btnLogout"):pos(104,45)
		-- self.panelLogin:getWidgetByName("btnEnterGame"):pos(978,45)
		local btnLogout = self.panelLogin:getWidgetByName("btnLogout");
		local btnEnterGame = self.panelLogin:getWidgetByName("btnEnterGame");
		btnEnterGame:align(display.CENTER, display.cx-80, display.cy-200)--:pos(display.cx, 90)
		
		local btnLogoutSize = btnLogout:getContentSize();
		-- btnLogout:pos(display.left+btnLogoutSize.width/2+20, 45)

		local btnEnterGameSize = btnEnterGame:getContentSize();
		-- btnEnterGame:pos(display.right-btnEnterGameSize.width/2-20, 45)

		self.panelLogin:setContentSize(display.width, display.height)

		-- 公告
		self.panelLogin:getWidgetByName("btnNotice"):addClickEventListener(function ()
			-- asyncload_frames("uipic/SceneNotice",".png",function ()
			-- 	display.replaceScene(SceneNotice.new())
			-- end)
		end)

		for i,v in ipairs(buttonTable) do
			local btnScence = self.m_serverUI:getWidgetByName(v)
			if v == "btnLogout" then
				-- btnScence:align(display.LEFT_TOP, display.left + 10, display.height - 10)
			elseif v == "btnAnnounceMent" then
				btnScence:align(display.RIGHT_TOP, display.right - 10, display.height - 10)
			end
			UIRedPoint.addUIPoint(btnScence, handler(self, self.pushSceneButtons))
		end
		UIRedPoint.addUIPoint(self.panelServerList, handler(self, self.pushSceneButtons))
	end

	cc.EventProxy.new(NetClient,self)
		:addEventListener(Notify.EVENT_LOADCHAR_LIST, handler(self, self.handleCharLoaded))
		:addEventListener(Notify.EVENT_KEYBOARD_PASSED, handler(self, self.onKeyboard))

	self.loginManager = LoginManager:new()
	self:handleScenePartVisible(false)
	self:updateServerInfo()

end

function SceneSelectServer:openDoor(ui)
	--我家大门常打开
	local startNum = 1
	local doorNum = 7
	local img_left = ui:getWidgetByName("img_leftdoor")
	local img_right = ui:getWidgetByName("img_rightdoor")
	local function startOpen()
		asyncload_callback("needload/OpenDoor/img_door"..startNum..".jpg", img_left, function (filepath, texture)
			if util.isObjectExist(img_left) then
				img_left:loadTexture(filepath):scale(display.height/640)
			end
			if util.isObjectExist(img_right) then
				img_right:loadTexture(filepath):scale(display.height/640)
			end
		end)
		startNum = startNum + 1
		if startNum >= 8 then
			-- img_left:hide()
			-- img_right:hide()
			img_left:runAction(cca.fadeOut(0.5))
			img_right:runAction(cca.fadeOut(0.5))
			self:handleScenePartVisible(false)
		end
	end
	img_right:setFlippedX(true)
	ui:runAction(cca.rep(cca.seq({cca.delay(0.25),cca.cb(startOpen)}),tonumber(7)))
end
function SceneSelectServer:onKeyboard(event)
	if event.key=="back" then
		-- game.ShowExit()
	end
end

function SceneSelectServer:onSelectServer(  ) --选择服务器
	self:hideAndShowPanel(self.panelServerList)
end

function SceneSelectServer:updateServerInfo(showPanel)
	self.serverList = self.loginManager:getServers()
	print("--------------serverList = "..json.encode(self.serverList))
	
	self.serverId=UserConfig.Data["LastServerId"]


	local recommendId = self.loginManager:getRecommendServer()
	local btnRecommandServer = self.m_serverUI:getWidgetByName("btnRecommandServer")
	if recommendId then
		btnRecommandServer.tag = recommendId
		btnRecommandServer:getChildByName("lblSVRName"):setString(self.serverList[recommendId].name)
		print("------zhuxijing recommendId = "..recommendId..",name = "..self.serverList[recommendId].name)
		btnRecommandServer:getChildByName("imgSVRStatus"):loadTexture("img_svr_status"..self.serverList[recommendId].status, ccui.TextureResType.plistType)
		btnRecommandServer:show()
	else
		btnRecommandServer:hide()
	end
	UIRedPoint.addUIPoint(btnRecommandServer, handler(self, self.pushServerButton))
	if self.serverId == nil or self.serverId == "" then
		self.serverId = self.serverList[recommendId].serverId
	end

	local list = self.m_serverUI:getWidgetByName("listServer")
	list:reloadData(#self.serverList, handler(self, self.updateServerList))

	local quList = self.m_serverUI:getWidgetByName("listServerqu")
	quList:reloadData((#self.serverList - 1) / serverNum + 1, handler(self, self.updateServerQuList))

	local info = self.loginManager:getServerById(self.serverId)
	if info then
		self.m_serverUI:getWidgetByName("btnSelectServer"):getChildByName("lblServerName"):setString(info.name)
		--print("info.name",info.name)--第一界面的最新记录
		local btnLastServer = self.m_serverUI:getWidgetByName("btnLastServer")
		btnLastServer.tag = self.serverId
		btnLastServer:getChildByName("lblSVRLast"):setString(info.name)
		local status = info.status
		if tonumber(info.status) > 2 then
			status = 1
		end

		btnLastServer:getChildByName("imgSVRStatus"):loadTexture("img_svr_status"..status, ccui.TextureResType.plistType)
		UIRedPoint.addUIPoint(btnLastServer, handler(self, self.pushServerButton))

		if self.directEnter and info.socket and info.socket ~= "" then
			self:pushLoginButton()
			PlatformTool.showMsg(lan.Com_Loading, 1)
		end
	end
	self.directEnter = false
end

function SceneSelectServer:pushSceneButtons(pSender)
	local btnName = pSender:getName()
	if btnName == "btnEnterGame" then 
		self:pushLoginButton()
	elseif btnName == "btnLogout" and not game.disEnterButton then
		util.showAlert(lan.Com_Tip,"要退出当前账号吗?",{lan.Com_Confirm, lan.Com_Cancel},function (event)
			if event.buttonIndex == 1 then
				self:handleScenePartVisible(true)
				game.ExitToRelogin()
		    end
		end, self)
	elseif btnName == "btnLastServer" or btnName == "panelServerList" then 
		self:hideAndShowPanel()
	end
end

function SceneSelectServer:showRelatePanel(panel)
	self.curPanel = panel
	if panel then
		--self.tip_chenmi:setVisible(self.curPanel == self.panelServerList)
		self.curPanel:pos(display.cx, display.cy):show()
	end
end

function SceneSelectServer:hideAndShowPanel(panel)
	if not self.zhuxijing_img2 then
		print(11)
		self.zhuxijing_img:setVisible(false)
		self.zhuxijing_img2 = true;
		
		
		-- if not self.zhuxijing_img3 then
			-- self.zhuxijing_img3 = self.panelServerList:getChildByName("serverListBg")
					-- :loadTexture("zhuxijing_img_login_30", ccui.TextureResType.plistType)
					-- :setVisible(true);
			-- -- self.zhuxijing_img3 = ccui.ImageView:create("zhuxijing_img_login_30",ccui.TextureResType.plistType)
				-- -- :setContentSize(cc.size(819,523))
				-- -- :addTo(serverListBg)
				-- -- :align(display.CENTER, display.cx-250, display.cy-60)
				-- -- :setVisible(true);
		-- else
			-- self.zhuxijing_img3:setVisible(false);
		-- end	
		
	else
		print(12)
		self.zhuxijing_img:setVisible(true)
		self.zhuxijing_img2 = false;
		if self.zhuxijing_img3 then
			self.zhuxijing_img3:setVisible(false);
		end	
		
	end
	local tempPanel = panel or self.panelLogin
	if self.curPanel == tempPanel then return end

	self.curPanel:hide()
	self:showRelatePanel(tempPanel)
end

function SceneSelectServer:pushServerQuBtn(cell)
	print("www.aliuyun.cn 打开了")
	self.curTag = cell.tag
	local col = math.floor(#self.serverList / serverNum)
	local row = #self.serverList % serverNum
	local list = self.m_serverUI:getWidgetByName("listServer")
	list:reloadData((self.curTag - 1) < col and serverNum or row, handler(self, self.updateServerList))
	if self.curBtn then
		self.curBtn:loadTexture("zhuxijing_img_login_31", ccui.TextureResType.plistType)
	end
	self.curBtn = cell
	self.curBtn:loadTexture("zhuxijing_img_login_32", ccui.TextureResType.plistType)
end

-- 更新左边服务器区服列表
function SceneSelectServer:updateServerQuList(item)
	print("我不知道。");
	item:setTouchEnabled(true)
	local sBtn = item:getWidgetByName("btnServerBg")
	:setScale(0.9)
	:setContentSize(cc.size(172,55))
	:setAnchorPoint(cc.p(0,0))
	:setPosition(cc.p(0,0))
	
	
	
	
	item:getWidgetByName("lblSVRName"):setString("统战 "..tonumber(item.tag).." 区")
	if not sBtn.cellCallBack then
		sBtn.cellCallBack = true
		sBtn.tag = item.tag
		-- UIRedPoint.addUIPoint(sBtn, handler(self, self.pushServerQuBtn))
		item:addClickEventListener(function()
			self:pushServerQuBtn(sBtn)
		end)

		if item.tag == 1 then
			sBtn:loadTexture("zhuxijing_img_login_32", ccui.TextureResType.plistType)
			self:pushServerQuBtn(sBtn)
			self.curBtn = sBtn
		end
	end
end

--服务器列表。
function SceneSelectServer:updateServerList(item)
	item.tag = (self.curTag - 1) * serverNum + item.tag
	print("----------SceneSelectServer:updateServerList---------item.tag="..item.tag)
	local svrData = self.loginManager:getServerById(item.tag)
	item:hide()--:setTouchEnabled(false)
	if svrData then
		item:getWidgetByName("lblSVRName"):setString(svrData.name)-----.."gege"--服务器列表的名字
		item:getWidgetByName("img_role_num_bg"):hide()
		item:getWidgetByName("imgSVRStatus"):loadTexture("img_svr_status0", ccui.TextureResType.plistType)
		if svrData.socket and svrData.socket ~= ""  then
			print("zhuxijing 0");
			local status = svrData.status
			if tonumber(svrData.status) > 3 then
			print("zhuxijing 111111");
				status = 1
			end
			-- 0 维护 1 流畅  2 爆满
			item:getWidgetByName("imgSVRStatus"):loadTexture("img_svr_status"..status, ccui.TextureResType.plistType)
		end
		if game.svrRole and type(game.svrRole)=="table" then
			print("zhuxijing 2");
			if game.svrRole[svrData.serverId] and tonumber(game.svrRole[svrData.serverId])>0 then
				--print("aaaaaaa",tonumber(game.svrRole[svrData.serverId]))
				item:getWidgetByName("img_role_num_bg"):show()
				item:getWidgetByName("img_role_num_bg"):getWidgetByName("lbl_role_num"):setString(tostring(game.svrRole[svrData.serverId]))
			end
		end
		if svrData.role and tonumber(svrData.role)>0 then
			print("zhuxijing 3");
			item:getWidgetByName("img_role_num_bg"):show()
			item:getWidgetByName("img_role_num_bg"):getWidgetByName("lbl_role_num"):setString(tostring(svrData.role))
		end
		item.socket = svrData.socket
		if not item.cellCallBack then
			print("zhuxijing item.cellCallBack");
			item.cellCallBack = true
			UIRedPoint.addUIPoint(item, handler(self, self.pushServerButton))
		end
		local imgSVRTag = item:getChildByName("imgSVRTag")
		if svrData.isNew and tonumber(svrData.isNew) == 1 then
			print("zhuxijing isNew",tonumber(svrData.isNew));
			if not imgSVRTag then
			print("zhuxijing imgSVRTag");
				imgSVRTag = ccui.ImageView:create("img_svr_tag1", ccui.TextureResType.plistType):setName("imgSVRTag")
					:align(display.CENTER, 210, 35)
					:setScale(0.68)
					:addTo(item)
			end
			imgSVRTag:show():setScale(0.68)		
		elseif imgSVRTag then
			print("zhuxijing else imgSVRTag");
			imgSVRTag:hide()
		end
		item:show()
	end
end

function SceneSelectServer:pushServerButton(cell)
	print("------pushServerButton-----")
	print("---------cell.tag = "..cell.tag)

	local svrData = self.loginManager:getServerById(cell.tag)
	if (cell.tag ~= nil) and (svrData ~= nil) then
		local info = svrData

		if info and info.status then
			self.serverId = cell.tag
			self.m_serverUI:getWidgetByName("btnSelectServer"):getChildByName("lblServerName"):setString(info.name)
			
			self:hideAndShowPanel()
		-- elseif info and info.status and tonumber(info.status) == 0 then
		-- 	util.showAlert("", lan.SceneSelectServer_Server_Weihu.."!", "")
		-- elseif info and info.status and tonumber(info.status) == 6 then
		-- 	util.showAlert("", "尚未到开区时间,请稍后进入".."!", "")
		end
	end
end

function SceneSelectServer:onExit()
	print("www.aliuyun.cn")
	-- loginScene和SceneSelectServer 都用的同一个合图, 所以这里不能removeFramesByFile
	-- cc.SpriteManager:getInstance():removeFramesByFile("uipic/SceneSelectServer")
	cc.CacheManager:getInstance():releaseUnused(false)
	
	game.disEnterButton = false
end

function SceneSelectServer:pushLoginButton(pSender)
	if not game.disEnterButton then
		local svrData = self.loginManager:getServerById(self.serverId)--game.lastSvr
		game.lastSvr = svrData
		if svrData == nil then
			svrData = self.serverList[1]
		end

		if svrData.socket and svrData.socket ~= "" then
			local errorFun= function (code, msg)
				util.showAlert(lan.Com_Tip,msg,{lan.Com_Confirm},function (event)

				end, self)
			end
			local progressFun=function (code,msg)
				--game.showConnecting(self.connectBox,true,msg)
				self.panelConnect:setVisible(true)
				self.panelConnect:getChildByName("Text_Connect"):setString(msg):align(display.CENTER, display.cx, display.cy + 80)
								:setLocalZOrder(2)

				local sprite = ccui.ImageView:create()
    						:align(display.CENTER, display.cx, display.cy + 0)
							:addTo(self.panelConnect)

				if not sprite then return end
				sprite:stopAllActions()
				--cc.Director:getInstance():getActionManager():removeAllActionsFromTarget(sprite)
				
				-- local frames = display.newFrames("loadingtips%d", 1, 10)
				-- local animation = display.newAnimation(frames, 0.1)
				-- sprite:playAnimationForever(animation)
				-- sprite:setScale(1.5)
				local curNum = 1
				sprite:runAction(cca.loop(
					cca.seq({
						cca.delay(0.15),
						cca.cb(function ()
							if curNum < 7 then
								curNum = curNum + 1
							else
								curNum = 1
							end
							asyncload_callback("needload/login/"..curNum..".png", sprite, function(filepath, texture) 
								sprite:loadTexture(filepath)
							end)
						end)
					})
				))
				
			end
			local successFun=function()
				NetClient:ListCharacter()
			end
			self.loginManager:selectServer(svrData.serverId,errorFun,progressFun,successFun)
    		return
		else
			util.showAlert(lan.Com_Not_Open, lan.Com_Open_Zone_Time..":"..svrData.openDateTime..","..lan.SceneSelectServer_Refresh_List.."?" ,{lan.Com_Confirm, lan.Com_Cancel}, function (event)
				if event.buttonIndex == 1 then
					self.directEnter = true
					self:requestServerList()
				end
			end)
			-- util.showAlert("尚未开启", "开区时间:"..svrData.openDateTime, "确定")
			return
		end
		util.showAlert("", lan.SceneSelectServer_ServerData_YiChang, lan.Com_Confirm)
	end
end

function SceneSelectServer:handleCharLoaded(event)
	cc.SpriteManager:getInstance():removeFramesByFile("uipic/SceneSelectServer")
	
	if #NetClient._netChars > 0 then
		asyncload_frames("uipic/SceneSelectRole",".png",function ()
			display.replaceScene(SceneSelectRole.new())
	    end,self)
	else
		asyncload_frames("uipic/SceneCreateRole",".png",function ()
			display.replaceScene(SceneCreateRole.new())
		end,self)
	end
end

function SceneSelectServer:handleScenePartVisible(isAccount)
	if isAccount then
		print("====>SceneSelectServer.isAccount = true")
	else
		print("====>SceneSelectServer.isAccount = false")
	end

	self.m_serverUI:getWidgetByName("btnLogout"):setVisible(not isAccount)
	if isAccount then
		self.curPanel:setVisible(false)
	end

	self.curPanel = self.panelLogin:setVisible(not isAccount)
	if not isAccount then self.curPanel:pos(display.cx, display.cy) end
end

return SceneSelectServer

 

请登录后发表评论

    没有回复内容