using System;
using Microsoft.Xna.Framework.Graphics;
using TomShane.Neoforce.Controls;
using Omnion.SquadOmega.Shared.Secruity;
using Omnion.SquadOmega.Shared.Diagnostic;
using Omnion.SquadOmega.Shared.IO;
using Omnion.SquadOmega.Shared.Networking;
using Omnion.SquadOmegaClient.Networking;
namespace Omnion.SquadOmegaClient.MainMenuScreen
{
public class RegisterWindow : Window
{
public const int UsernameMin = 4, UsernameMax = 20,
PasswordMin = 6, PasswordMax = 20,
PlayerNameMin = 4, PlayerNameMax = 20;
public const string UserTooSmall = "Username must be at least 4 characters long.",
UserTooLarge = "Username can't be larger than 20 characters.",
PassTooSmall = "Password must be at least 6 characters long.",
PassTooLarge = "Password can't be larger than 20 characters.",
NonConformingPass = "Password confirmation doesn't match password.",
PlayerSmall = "Player name must be at least 4 characters long.",
PlayerLarge = "Player name can't be larger than 20 characters.";
FlexLabel userL, passL, confirmPassL, playerNameL;
TextBox userTB, passTB, confirmPassTB, playerNameTB;
Label errorL;
Button registerB, cancelB;
Window mainMenu;
SocketManager sockets;
public RegisterWindow(Manager manager, Window mainMenu)
: base(manager)
{
this.mainMenu = mainMenu;
this.sockets = SocketManager.GetSockets(manager.Game);
}
public override void Init()
{
base.Init();
this.Text = "Register";
this.Width = 500;
this.Height = 400;
this.Resizable = false;
this.Movable = false;
this.CloseButtonVisible = false;
this.Center();
this.InitControls();
}
private void InitControls()
{
this.userL = new FlexLabel(this.Manager);
this.userL.Text = "Username : ";
this.userL.Left = Layout.LargeSpace;
this.userL.Top = Layout.LargeSpace;
this.userL.Ellipsis = false;
this.userL.Parent = this;
this.userTB = new TextBox(this.Manager);
this.userTB.Left = this.userL.Left + this.userL.Width + Layout.SmallSpace;
this.userTB.Top = this.userL.Top;
this.userTB.Width = this.ClientWidth - (Layout.LargeSpace + this.userTB.Left);
this.userTB.Parent = this;
this.passL = new FlexLabel(this.Manager);
this.passL.Text = "Password : ";
this.passL.Left = this.userL.Left;
this.passL.Top = this.userTB.Top + this.userTB.Height + Layout.SmallSpace;
this.passL.Ellipsis = false;
this.passL.Parent = this;
this.passTB = new TextBox(this.Manager);
this.passTB.Left = this.passL.Left + this.passL.Width + Layout.SmallSpace;
this.passTB.Top = this.passL.Top;
this.passTB.Width = this.ClientWidth - (Layout.LargeSpace + this.passTB.Left);
this.passTB.Mode = TextBoxMode.Password;
this.passTB.Parent = this;
this.confirmPassL = new FlexLabel(this.Manager);
this.confirmPassL.Text = "Confirm Password : ";
this.confirmPassL.Left = this.userL.Left;
this.confirmPassL.Top = this.passTB.Top + this.passTB.Height + Layout.SmallSpace;
this.confirmPassL.Ellipsis = false;
this.confirmPassL.Parent = this;
this.confirmPassTB = new TextBox(this.Manager);
this.confirmPassTB.Left = this.confirmPassL.Left + this.confirmPassL.Width + Layout.SmallSpace;
this.confirmPassTB.Top = this.confirmPassL.Top;
this.confirmPassTB.Width = this.ClientWidth - (Layout.LargeSpace + this.confirmPassTB.Left);
this.confirmPassTB.Mode = TextBoxMode.Password;
this.confirmPassTB.Parent = this;
this.playerNameL = new FlexLabel(this.Manager);
this.playerNameL.Text = "Player Name : ";
this.playerNameL.Left = this.userL.Left;
this.playerNameL.Top = this.confirmPassTB.Top + this.confirmPassTB.Height + Layout.SmallSpace;
this.playerNameL.Ellipsis = false;
this.playerNameL.Parent = this;
this.playerNameTB = new TextBox(this.Manager);
this.playerNameTB.Left = this.playerNameL.Left + this.playerNameL.Width + Layout.SmallSpace;
this.playerNameTB.Top = this.playerNameL.Top;
this.playerNameTB.Width = this.ClientWidth - (Layout.LargeSpace + this.playerNameTB.Left);
this.playerNameTB.Parent = this;
this.userTB.Left = this.passTB.Left = this.playerNameTB.Left = this.confirmPassTB.Left;
this.userTB.Width = this.passTB.Width = this.playerNameTB.Width = this.confirmPassTB.Width;
this.userL.Width = this.passL.Width = this.playerNameL.Width = this.confirmPassL.Width;
this.userL.Alignment = this.passL.Alignment = this.confirmPassL.Alignment = this.playerNameL.Alignment
= Alignment.MiddleRight;
this.userL.TextColor = this.passL.TextColor = this.confirmPassL.TextColor = this.playerNameL.TextColor =
Color.Silver;
this.errorL = new Label(this.Manager);
this.errorL.Left = this.userL.Left;
this.errorL.Top = this.playerNameTB.Top + this.playerNameTB.Height + Layout.SmallSpace;
this.errorL.Width = this.ClientWidth - (Layout.LargeSpace * 2);
this.errorL.Alignment = Alignment.BottomCenter;
this.errorL.Parent = this;
this.errorL.Hide();
this.registerB = new Button(this.Manager);
this.registerB.Text = "Register";
this.registerB.Left = this.errorL.Left;
this.registerB.Top = this.errorL.Top + this.errorL.Height + Layout.SmallSpace;
this.registerB.Width = (this.ClientWidth - (Layout.SmallSpace + (Layout.LargeSpace * 2))) / 2;
this.registerB.Parent = this;
this.cancelB = new Button(this.Manager);
this.cancelB.Text = "Cancel";
this.cancelB.Left = this.registerB.Left + this.registerB.Width + Layout.SmallSpace;
this.cancelB.Top = this.registerB.Top;
this.cancelB.Width = this.registerB.Width;
this.cancelB.Parent = this;
this.ClientHeight = this.cancelB.Top + this.cancelB.Height + Layout.LargeSpace;
this.Center();
}
}
}