namespace Assets.src.screen
{
	public class RegisterScreen : CScreen, IActionListener
	{
		public TField tfUser;

		public TField tfNgay;

		public TField tfThang;

		public TField tfNam;

		public TField tfDiachi;

		public TField tfCMND;

		public TField tfNgayCap;

		public TField tfNoiCap;

		public TField tfSodt;

		public static bool isContinueToLogin = false;

		private int focus;

		private int wC;

		private int yL;

		private int defYL;

		public bool isCheck;

		public bool isRes;

		private Command cmdLogin;

		private Command cmdCheck;

		private Command cmdExit;

		private Command cmdRes;

		private Command cmdMenu;

		private Command cmdBackFromRegister;

		public string listFAQ = string.Empty;

		public string titleFAQ;

		public string subtitleFAQ;

		private string numSupport = string.Empty;

		private string strUser;

		private string strPass;

		public static bool isLocal = false;

		public static bool isUpdateAll;

		public static bool isUpdateData;

		public static bool isUpdateMap;

		public static bool isUpdateSkill;

		public static bool isUpdateItem;

		public static string serverName;

		public static Image imgTitle;

		public int plX;

		public int plY;

		public int lY;

		public int lX;

		public int logoDes;

		public int lineX;

		public int lineY;

		public static int[] bgId = new int[5] { 0, 8, 2, 6, 9 };

		public static bool isTryGetIPFromWap;

		public static short timeLogin;

		public static long lastTimeLogin;

		public static long currTimeLogin;

		private int yt;

		private Command cmdSelect;

		private Command cmdOK;

		private int xLog;

		private int yLog;

		private int xP;

		private int yP;

		private int wP;

		private int hP;

		private string passRe = string.Empty;

		public bool isFAQ;

		private int tipid = -1;

		public bool isLogin2;

		private int v = 2;

		private int g;

		private int ylogo = -40;

		private int dir = 1;

		public static bool isLoggingIn;

		public RegisterScreen(sbyte haveName)
		{
			yLog = 130;
			if (CCanvas.h > 200)
			{
				defYL = CCanvas.hh - 80;
			}
			else
			{
				defYL = CCanvas.hh - 65;
			}
			resetLogo();
			wC = ((CCanvas.w < 200) ? 140 : 160);
			yt = CCanvas.hh - CScreen.ITEM_HEIGHT - 5;
			if (CCanvas.h <= 160)
			{
				yt = 20;
			}
			tfSodt = new TField();
			tfSodt.setIputType(TField.INPUT_TYPE_NUMERIC);
			tfSodt.width = 220;
			tfSodt.height = CScreen.ITEM_HEIGHT + 2;
			tfSodt.name = "Số điện thoại/ địa chỉ email";
			if (haveName == 1)
			{
				tfSodt.setText("01234567890");
			}
			tfUser = new TField();
			tfUser.width = 220;
			tfUser.height = CScreen.ITEM_HEIGHT + 2;
			tfUser.isFocus = true;
			tfUser.name = "Họ và tên";
			if (haveName == 1)
			{
				tfUser.setText("Nguyễn Văn A");
			}
			tfUser.setIputType(TField.INPUT_TYPE_ANY);
			tfNgay = new TField();
			tfNgay.setIputType(TField.INPUT_TYPE_NUMERIC);
			tfNgay.width = 70;
			tfNgay.height = CScreen.ITEM_HEIGHT + 2;
			tfNgay.name = "Ngày sinh";
			if (haveName == 1)
			{
				tfNgay.setText("01");
			}
			tfThang = new TField();
			tfThang.setIputType(TField.INPUT_TYPE_NUMERIC);
			tfThang.width = 70;
			tfThang.height = CScreen.ITEM_HEIGHT + 2;
			tfThang.name = "Tháng sinh";
			if (haveName == 1)
			{
				tfThang.setText("01");
			}
			tfNam = new TField();
			tfNam.setIputType(TField.INPUT_TYPE_NUMERIC);
			tfNam.width = 70;
			tfNam.height = CScreen.ITEM_HEIGHT + 2;
			tfNam.name = "Năm sinh";
			if (haveName == 1)
			{
				tfNam.setText("1990");
			}
			tfDiachi = new TField();
			tfDiachi.setIputType(TField.INPUT_TYPE_ANY);
			tfDiachi.width = 220;
			tfDiachi.height = CScreen.ITEM_HEIGHT + 2;
			tfDiachi.name = "Địa chỉ đăng ký thường trú";
			if (haveName == 1)
			{
				tfDiachi.setText("123 đường số 1, Quận 1, TP.HCM");
			}
			tfCMND = new TField();
			tfCMND.setIputType(TField.INPUT_TYPE_NUMERIC);
			tfCMND.width = 220;
			tfCMND.height = CScreen.ITEM_HEIGHT + 2;
			tfCMND.name = "Số Chứng minh nhân dân hoặc số hộ chiếu";
			if (haveName == 1)
			{
				tfCMND.setText("123456789");
			}
			tfNgayCap = new TField();
			tfNgayCap.setIputType(TField.INPUT_TYPE_NUMERIC);
			tfNgayCap.width = 220;
			tfNgayCap.height = CScreen.ITEM_HEIGHT + 2;
			tfNgayCap.name = "Ngày cấp";
			if (haveName == 1)
			{
				tfNgayCap.setText("01/01/2005");
			}
			tfNoiCap = new TField();
			tfNoiCap.setIputType(TField.INPUT_TYPE_ANY);
			tfNoiCap.width = 220;
			tfNoiCap.height = CScreen.ITEM_HEIGHT + 2;
			tfNoiCap.name = "Nơi cấp";
			if (haveName == 1)
			{
				tfNoiCap.setText("TP.HCM");
			}
			yt += 35;
			isCheck = true;
			focus = 0;
			wP = 170;
			hP = ((!isRes) ? 100 : 110);
			xP = CCanvas.hw - wP / 2;
			yP = tfUser.y - 15;
			int num = 4;
			int num2 = num * 32 + 23 + 33;
			if (num2 >= CCanvas.w)
			{
				num--;
				num2 = num * 32 + 23 + 33;
			}
			xLog = CCanvas.w / 2 - num2 / 2;
			yLog = 5;
			lY = ((CCanvas.w < 200) ? (tfUser.y - 30) : (yLog - 30));
			tfUser.x = xLog + 10;
			tfUser.y = yLog + 20;
			cmdOK = new Command(L.ok(), this, 1, null);
			cmdOK.x = 260;
			cmdOK.y = CCanvas.h - 60;
			cmdExit = new Command("Thoát", this, 2, null);
			cmdExit.x = 260;
			cmdExit.y = CCanvas.h - 30;
			if (CCanvas.w < 250)
			{
				cmdOK.x = CCanvas.w / 2 - 80;
				cmdExit.x = CCanvas.w / 2 + 10;
				cmdExit.y = (cmdOK.y = CCanvas.h - 25);
			}
			center = cmdOK;
			left = cmdExit;
		}

		public override void show()
		{
			if (CCanvas.isTouch)
			{
				focus = -1;
			}
			else
			{
				focus = 0;
				processFocus();
			}
			SoundMn.gI().stopAll();
			base.show();
		}

		protected void doMenu()
		{
		}

		protected void doRegister()
		{
		}

		protected void doRegister(string user)
		{
		}

		public void doViewFAQ()
		{
			if (!listFAQ.Equals(string.Empty) || !listFAQ.Equals(string.Empty))
			{
			}
			if (!Session_ME.connected)
			{
				isFAQ = true;
				LoginScr.connect();
			}
			CCanvas.startWaitDlgWithoutCancel(L.pleaseWait());
		}

		protected void saveIndexServer(int index)
		{
			Rms.saveRMSInt("indServer", index);
		}

		protected int loadIndexServer()
		{
			return Rms.loadRMSInt("indServer");
		}

		public void doLogin()
		{
		}

		public void savePass()
		{
		}

		public override void update()
		{
			tfUser.update();
			tfNgay.update();
			tfThang.update();
			tfNam.update();
			tfDiachi.update();
			tfCMND.update();
			tfNoiCap.update();
			tfSodt.update();
			tfNgayCap.update();
			if (CCanvas.isTouch)
			{
				if (isRes)
				{
					center = cmdRes;
					left = cmdBackFromRegister;
				}
				else
				{
					center = cmdOK;
					left = cmdExit;
				}
			}
			else if (isRes)
			{
				center = cmdRes;
				left = cmdBackFromRegister;
			}
			else
			{
				center = cmdOK;
				left = cmdExit;
			}
		}

		public void updateLogo()
		{
			if (defYL != yL)
			{
				yL += defYL - yL >> 1;
			}
		}

		public override void paint(mGraphics g)
		{
			BackgroundNew.paintBGGameScr(g);
			int num = tfUser.y - 50;
			if (CCanvas.h <= 220)
			{
				num += 5;
			}
			if (ChatPopupNR.currChatPopup != null || ChatPopupNR.serverChatPopUp != null)
			{
				return;
			}
			if (CCanvas.currentDialog == null)
			{
				xLog = 5;
				int num2 = 233;
				if (CCanvas.w < 260)
				{
					xLog = (CCanvas.w - 240) / 2;
				}
				yLog = (CCanvas.h - num2) / 2;
				int num3 = ((CCanvas.w < 200) ? 160 : 180);
				CScreen.paintBorderRect(g, xLog, yLog, 240, num2);
				if (CCanvas.h > 160 && imgTitle != null)
				{
					g.drawImage(imgTitle, CCanvas.hw, num, 3, false);
				}
				int num4 = 4;
				int num5 = num4 * 32 + 23 + 33;
				if (num5 >= CCanvas.w)
				{
					num4--;
					num5 = num4 * 32 + 23 + 33;
				}
				tfSodt.x = xLog + 10;
				tfSodt.y = yLog + 15;
				tfUser.x = tfSodt.x;
				tfUser.y = tfSodt.y + 30;
				tfNgay.x = xLog + 10;
				tfNgay.y = tfUser.y + 30;
				tfThang.x = tfNgay.x + 75;
				tfThang.y = tfNgay.y;
				tfNam.x = tfThang.x + 75;
				tfNam.y = tfThang.y;
				tfDiachi.x = tfUser.x;
				tfDiachi.y = tfNgay.y + 30;
				tfCMND.x = tfUser.x;
				tfCMND.y = tfDiachi.y + 30;
				tfNgayCap.x = tfUser.x;
				tfNgayCap.y = tfCMND.y + 30;
				tfNoiCap.x = tfUser.x;
				tfNoiCap.y = tfNgayCap.y + 30;
				tfUser.paint(g);
				tfNgay.paint(g);
				tfThang.paint(g);
				tfNam.paint(g);
				tfDiachi.paint(g);
				tfCMND.paint(g);
				tfNgayCap.paint(g);
				tfNoiCap.paint(g);
				tfSodt.paint(g);
				int num6 = 0;
				if (CCanvas.w >= 176)
				{
					num6 = 50;
				}
				else
				{
					mFont.tahoma_7b_green2.drawString(g, L.account() + ":", tfUser.x - 35, tfUser.y + 7, 0);
					mFont.tahoma_7b_green2.drawString(g, L.pass() + ":", tfNgay.x - 35, tfNgay.y + 7, 0);
					mFont.tahoma_7b_green2.drawString(g, "Máy chủ: " + serverName, CCanvas.w / 2, tfNgay.y + 32, 2);
					if (isRes)
					{
					}
					num6 = 0;
				}
			}
			string version = MyMidlet.version;
			g.setColor(8567981);
			g.fillRect(CCanvas.w - 40, 4, 36, 11, false);
			mFont.tahoma_7_grey.drawString(g, version, CCanvas.w - 22, 4, mFont.CENTER);
			CCanvas.resetTrans(g);
			if (CCanvas.w > 250)
			{
				mFont.tahoma_7b_white.drawString(g, "Dưới 18 tuổi", 260, 10, 0, mFont.tahoma_7b_dark);
				mFont.tahoma_7b_white.drawString(g, "chỉ có thể chơi", 260, 25, 0, mFont.tahoma_7b_dark);
				mFont.tahoma_7b_white.drawString(g, "180 phút 1 ngày", 260, 40, 0, mFont.tahoma_7b_dark);
			}
			else
			{
				mFont.tahoma_7b_white.drawString(g, "Dưới 18 tuổi chỉ có thể chơi", CCanvas.w / 2, 5, 2, mFont.tahoma_7b_dark);
				mFont.tahoma_7b_white.drawString(g, "180 phút 1 ngày", CCanvas.w / 2, 15, 2, mFont.tahoma_7b_dark);
			}
			base.paint(g);
		}

		private void turnOffFocus()
		{
			tfUser.isFocus = false;
			tfNgay.isFocus = false;
			tfThang.isFocus = false;
			tfNam.isFocus = false;
			tfDiachi.isFocus = false;
			tfCMND.isFocus = false;
			tfNgayCap.isFocus = false;
			tfNoiCap.isFocus = false;
			tfSodt.isFocus = false;
		}

		private void processFocus()
		{
			turnOffFocus();
			switch (focus)
			{
			case 0:
				tfUser.isFocus = true;
				break;
			case 1:
				tfNgay.isFocus = true;
				break;
			case 2:
				tfThang.isFocus = true;
				break;
			case 3:
				tfNam.isFocus = true;
				break;
			case 4:
				tfDiachi.isFocus = true;
				break;
			case 5:
				tfCMND.isFocus = true;
				break;
			case 6:
				tfNgayCap.isFocus = true;
				break;
			case 7:
				tfNoiCap.isFocus = true;
				break;
			case 8:
				tfSodt.isFocus = true;
				break;
			}
		}

		public override void input()
		{
			if (isContinueToLogin)
			{
				return;
			}
			if (!CCanvas.isTouch)
			{
				if (tfUser.isFocus)
				{
					right = tfUser.cmdClear;
				}
				else if (tfNgay.isFocus)
				{
					right = tfNgay.cmdClear;
				}
				else if (tfThang.isFocus)
				{
					right = tfThang.cmdClear;
				}
				else if (tfNam.isFocus)
				{
					right = tfNam.cmdClear;
				}
				else if (tfDiachi.isFocus)
				{
					right = tfDiachi.cmdClear;
				}
				else if (tfCMND.isFocus)
				{
					right = tfCMND.cmdClear;
				}
				else if (tfNgayCap.isFocus)
				{
					right = tfNgayCap.cmdClear;
				}
				else if (tfNoiCap.isFocus)
				{
					right = tfNoiCap.cmdClear;
				}
				else if (tfSodt.isFocus)
				{
					right = tfSodt.cmdClear;
				}
			}
			if (CCanvas.keyPressed[2])
			{
				focus--;
				if (focus < 0)
				{
					focus = 8;
				}
				processFocus();
			}
			else if (CCanvas.keyPressed[8])
			{
				focus++;
				if (focus > 8)
				{
					focus = 0;
				}
				processFocus();
			}
			if (CCanvas.keyPressed[2] || CCanvas.keyPressed[8])
			{
				CCanvas.clearKeyPressed();
			}
			if (CCanvas.isPointerJustRelease)
			{
				if (CCanvas.isPointerHoldIn(tfUser.x, tfUser.y, tfUser.width, tfUser.height))
				{
					focus = 0;
					processFocus();
				}
				else if (CCanvas.isPointerHoldIn(tfNgay.x, tfNgay.y, tfNgay.width, tfNgay.height))
				{
					focus = 1;
					processFocus();
				}
				else if (CCanvas.isPointerHoldIn(tfThang.x, tfThang.y, tfThang.width, tfThang.height))
				{
					focus = 2;
					processFocus();
				}
				else if (CCanvas.isPointerHoldIn(tfNam.x, tfNam.y, tfNam.width, tfNam.height))
				{
					focus = 3;
					processFocus();
				}
				else if (CCanvas.isPointerHoldIn(tfDiachi.x, tfDiachi.y, tfDiachi.width, tfDiachi.height))
				{
					focus = 4;
					processFocus();
				}
				else if (CCanvas.isPointerHoldIn(tfCMND.x, tfCMND.y, tfCMND.width, tfCMND.height))
				{
					focus = 5;
					processFocus();
				}
				else if (CCanvas.isPointerHoldIn(tfNgayCap.x, tfNgayCap.y, tfNgayCap.width, tfNgayCap.height))
				{
					focus = 6;
					processFocus();
				}
				else if (CCanvas.isPointerHoldIn(tfNoiCap.x, tfNoiCap.y, tfNoiCap.width, tfNoiCap.height))
				{
					focus = 7;
					processFocus();
				}
				else if (CCanvas.isPointerHoldIn(tfSodt.x, tfSodt.y, tfSodt.width, tfSodt.height))
				{
					focus = 8;
					processFocus();
				}
			}
			base.input();
		}

		public void resetLogo()
		{
			yL = -50;
		}

		public void perform(int idAction, object p)
		{
			switch (idAction)
			{
			case 1:
				if (tfNgay.getText().Equals(string.Empty) || tfThang.getText().Equals(string.Empty) || tfNam.getText().Equals(string.Empty) || tfDiachi.getText().Equals(string.Empty) || tfCMND.getText().Equals(string.Empty) || tfNgayCap.getText().Equals(string.Empty) || tfNoiCap.getText().Equals(string.Empty) || tfSodt.getText().Equals(string.Empty) || tfUser.getText().Equals(string.Empty))
				{
					CCanvas.startOKDlg("Vui lòng điền đầy đủ thông tin");
					break;
				}
				CCanvas.startWaitDlgWithoutCancel(L.pleaseWait());
				GameService.gI().charInfo(tfNgay.getText(), tfThang.getText(), tfNam.getText(), tfDiachi.getText(), tfCMND.getText(), tfNgayCap.getText(), tfNoiCap.getText(), tfSodt.getText(), tfUser.getText());
				break;
			case 2:
				Session_ME.gI().close();
				CCanvas.serverScreen.show();
				break;
			}
		}

		public override void keyPressed(int keyCode)
		{
			if (tfUser.isFocus)
			{
				tfUser.keyPressed(keyCode);
			}
			else if (tfNgay.isFocus)
			{
				tfNgay.keyPressed(keyCode);
			}
			else if (tfThang.isFocus)
			{
				tfThang.keyPressed(keyCode);
			}
			else if (tfNam.isFocus)
			{
				tfNam.keyPressed(keyCode);
			}
			else if (tfDiachi.isFocus)
			{
				tfDiachi.keyPressed(keyCode);
			}
			else if (tfCMND.isFocus)
			{
				tfCMND.keyPressed(keyCode);
			}
			else if (tfNoiCap.isFocus)
			{
				tfNoiCap.keyPressed(keyCode);
			}
			else if (tfSodt.isFocus)
			{
				tfSodt.keyPressed(keyCode);
			}
			else if (tfNgayCap.isFocus)
			{
				tfNgayCap.keyPressed(keyCode);
			}
			base.keyPressed(keyCode);
		}
	}
}
