示例#1
0
        protected override void OnLoad()
        {
            base.OnLoad();

            Layer = LayerUI;

            MMW.FindGameComponent <BackgroundScript>().Trans(new OpenTK.Graphics.Color4(148, 212, 222, 255), 0.25);

            transit = new TransitControl();
            transit.LocalLocation = new Vector2(MMW.ClientSize.Width * 2.0f, 0);
            transit.Size          = new Vector2(MMW.ClientSize.Width, MMW.ClientSize.Height);
            transit.Target        = Vector2.Zero;

            input = new MenuInputResolver();

            var label = new Label()
            {
                Parent        = transit,
                Alignment     = ContentAlignment.TopCenter,
                Text          = "OPTION",
                Font          = new Font("Yu Gothic UI Light", 40.0f),
                LocalLocation = new Vector2(0.0f, 32.0f),
            };

            controls.Add(label);

            userData = MMW.GetAsset <UserData>();

            var labelName = new Label(transit, "User Name", new Vector2(200.0f, 160.0f));

            labelName.Font = Control.DefaultFontB;
            controls.Add(labelName);
            var textBoxName = new TextBox2(labelName, userData.UserName, new Vector2(200.0f, 0.0f), new Vector2(300.0f, 32.0f));

            textBoxName.MaxLength    = 16;
            textBoxName.TextChanged += (s, e) => { userData.UserName = textBoxName.Text; };
            controls.Add(textBoxName);

            var labelArchive = new Label(transit, "Display Achivement", new Vector2(200.0f, 200.0f));

            labelArchive.Font = Control.DefaultFontB;
            controls.Add(labelArchive);
            var comboArchive = new ComboBox(labelArchive, new Vector2(200.0f, 0.0f), new Vector2(300.0f, 32.0f));

            if (userData.Achivements.Count > 0)
            {
                comboArchive.Items                 = userData.Achivements.ToArray();
                comboArchive.SelectedIndex         = userData.ArchiveIndex;
                comboArchive.DisplayMember         = "Name";
                comboArchive.SelectedIndexChanged += (s, e) => { userData.ArchiveIndex = e; };
            }
            else
            {
                comboArchive.Enabled = false;
            }
            controls.Add(comboArchive);
        }
        protected override void OnLoad()
        {
            base.OnLoad();

            SelectedStage = null;

            input       = new MenuInputResolver();
            input.Up    = Key.W;
            input.Down  = Key.S;
            input.Right = Key.D;
            input.Left  = Key.A;

            load = MMW.FindGameComponent <InitLoading>();
            if (load.State != InitLoading.LoadingState.Finished)
            {
                load.LoadCompleted += Load_LoadCompleted;
            }

            transit = new TransitControl();
            transit.LocalLocation = new Vector2(MMW.ClientSize.Width * 2.0f, 0);
            transit.Size          = new Vector2(MMW.ClientSize.Width, MMW.ClientSize.Height);
            transit.Target        = Vector2.Zero;

            tabCtr = new TabControl()
            {
                Parent        = transit,
                LocalLocation = new Vector2(100, 164),
                Size          = new Vector2((MMW.ClientSize.Width / 2) - 100 - 64, MMW.ClientSize.Height - 164 - 48),
                Tabs          = new Tab[]
                {
                    new Tab()
                    {
                        Name = "PRESET", Items = load.PresetStages,
                    },
                    new Tab()
                    {
                        Name = "FREE", Items = load.FreeStages,
                    },
                },
                Focus = true,
            };

            label = new Label()
            {
                Parent        = transit,
                Alignment     = ContentAlignment.TopCenter,
                Text          = "STAGE SELECT",
                Font          = new Font("Yu Gothic UI Light", 40.0f),
                LocalLocation = new Vector2(0.0f, 32.0f),
            };
        }
示例#3
0
        //public TitleScript(int modeSelectIndex)
        //{
        //    this.modeSelectIndex = modeSelectIndex;
        //}

        protected override void OnLoad()
        {
            base.OnLoad();

            Layer = LayerUI;

            MMW.FindGameComponent <BackgroundScript>().Trans(new Color4(148, 212, 222, 255), 0.25);

            transit = new TransitControl();
            transit.LocalLocation = new Vector2(0.0f, 0);
            transit.Size          = new Vector2(MMW.ClientSize.Width, MMW.ClientSize.Height);
            transit.Target        = Vector2.Zero;

            //input = new MenuInputResolver();
            //input.Up = Key.W;
            //input.Down = Key.S;
            //input.Right = Key.D;
            //input.Left = Key.A;

            //texStar = new Texture2D(Resources.star);
            //texStar.Load();

            font  = new Font("Yu Gothic UI Light", 20.0f);
            fontB = new Font("Yu Gothic UI Light", 20.0f, FontStyle.Bold);
            fontL = new Font("Yu Gothic UI Light", 60.0f);

            texTitle    = Drawer.CreateStringTexture("MIKU MIKU WORLD", fontL);
            texSubTitle = Drawer.CreateStringTexture("WALKER", fontL);

            var btnExit = new Button(transit, "Exit", new Vector2(60.0f, MMW.Height - 132.0f), new Vector2(140.0f, 32.0f), "click");

            btnExit.Clicked += (s, e) =>
            {
                MMW.Window.Close();
            };
            controls.Add(btnExit);

            var btnSingle = new Button(btnExit, "Single Play", new Vector2(0.0f, -120.0f), new Vector2(140.0f, 32.0f), "click");

            btnSingle.Clicked += (s, e) =>
            {
            };
            controls.Add(btnSingle);

            var btnMulti = new Button(btnExit, "Multi Play", new Vector2(0.0f, -80.0f), new Vector2(140.0f, 32.0f), "click");

            btnMulti.Clicked += (s, e) =>
            {
                trans          = true;
                transit.Target = new Vector2(-MMW.ClientSize.Width * 2.0f, 0.0f);
                GameObject.AddComponent <ServerSelectScript>();
            };
            controls.Add(btnMulti);

            var btnOption = new Button(btnExit, "Option", new Vector2(0.0f, -40.0f), new Vector2(140.0f, 32.0f), "click");

            btnOption.Clicked += (s, e) =>
            {
                trans          = true;
                transit.Target = new Vector2(-MMW.ClientSize.Width * 2.0f, 0.0f);
                GameObject.AddComponent <OptionScript>();
            };
            controls.Add(btnOption);

            /*
             * var ts = new string[]
             * {
             *  "SINGLE PLAY",
             *  "MULTI PLAY",
             *  "OPTION",
             *  "EXIT",
             * };
             * texModes = new Texture2D[4];
             * for (var i = 0; i < 4; i++) texModes[i] = Drawer.CreateStringTexture(ts[i], fontB);
             */

            soundSelect = MMW.GetAsset <Sound>("select");
            soundClick  = MMW.GetAsset <Sound>("click");
        }
示例#4
0
        protected override void OnLoad()
        {
            base.OnLoad();

            MMW.FindGameComponent <BackgroundScript>().Trans(new Color4(148, 222, 148, 255), 0.25);

            input       = new MenuInputResolver();
            input.Up    = Key.W;
            input.Down  = Key.S;
            input.Right = Key.D;
            input.Left  = Key.A;

            transit = new TransitControl();
            transit.LocalLocation = new Vector2(MMW.ClientSize.Width * 2.0f, 0);
            transit.Size          = new Vector2(MMW.ClientSize.Width, MMW.ClientSize.Height);
            transit.Target        = Vector2.Zero;

            var label = new Label()
            {
                Parent        = transit,
                Alignment     = ContentAlignment.TopCenter,
                Text          = "WORLD EDIT",
                Font          = new Font("Yu Gothic UI Light", 40.0f),
                LocalLocation = new Vector2(0.0f, 32.0f),
            };

            Controls.Add(label);

            var labelHost = new Label(transit, "Host", new Vector2(MMW.Width * 0.5f - 160.0f, 300.0f + 2.0f));

            Controls.Add(labelHost);
            var labelPort = new Label(transit, "Port", new Vector2(MMW.Width * 0.5f - 160.0f, 350.0f + 2.0f));

            Controls.Add(labelPort);

            var textBoxHost = new TextBox2(transit, info.HostName, new Vector2(MMW.Width * 0.5f - 100.0f, 300.0f), new Vector2(360.0f, 32.0f));

            textBoxHost.MaxLength = 64;
            Controls.Add(textBoxHost);

            var textBoxPort = new TextBox2(transit, info.Port.ToString(), new Vector2(MMW.Width * 0.5f - 100.0f, 350.0f), new Vector2(72.0f, 32.0f));

            textBoxPort.MaxLength = 5;
            Controls.Add(textBoxPort);

            var backBtn = new Button(transit, "Back", new Vector2(-70.0f - 20.0f, 440.0f), "back");

            backBtn.Alignment = ContentAlignment.TopCenter;
            backBtn.Clicked  += (s, e) =>
            {
                trans          = true;
                transit.Target = new Vector2(-MMW.ClientSize.Width * 2.0f, 0.0f);
                GameObject.AddComponent <ServerSelectScript>();
            };
            Controls.Add(backBtn);

            var connectBtn = new Button(transit, "OK", new Vector2(70.0f + 20.0f, 440.0f), "click");

            connectBtn.Alignment = ContentAlignment.TopCenter;
            connectBtn.Clicked  += (s, e) =>
            {
                info.HostName = textBoxHost.Text;
                try
                {
                    info.Port = int.Parse(textBoxPort.Text);
                }
                catch { info.Port = 39393; }

                trans          = true;
                transit.Target = new Vector2(-MMW.ClientSize.Width * 2.0f, 0.0f);
                GameObject.AddComponent <ServerSelectScript>();
            };
            Controls.Add(connectBtn);

            var labelInfo = new Label(transit, "", new Vector2(0.0f, 500.0f));

            labelInfo.Alignment = ContentAlignment.TopCenter;
            Controls.Add(labelInfo);
        }
        protected override void OnLoad()
        {
            base.OnLoad();

            MMW.FindGameComponent <BackgroundScript>().Trans(new Color4(148, 222, 148, 255), 0.25);

            input       = new MenuInputResolver();
            input.Up    = Key.W;
            input.Down  = Key.S;
            input.Right = Key.D;
            input.Left  = Key.A;

            transit = new TransitControl();
            transit.LocalLocation = new Vector2(MMW.ClientSize.Width * 2.0f, 0);
            transit.Size          = new Vector2(MMW.ClientSize.Width, MMW.ClientSize.Height);
            transit.Target        = Vector2.Zero;

            var label = new Label()
            {
                Parent        = transit,
                Alignment     = ContentAlignment.TopCenter,
                Text          = "WORLD SELECT",
                Font          = new Font("Yu Gothic UI Light", 40.0f),
                LocalLocation = new Vector2(0.0f, 32.0f),
            };

            Controls.Add(label);

            var frame = new SelectWorldFrame(transit, MMW.ClientSize.Height - 120 - 100, new Vector2((MMW.ClientSize.Width - 760) * 0.5f, 120));

            Controls.Add(frame);
            foreach (var desc in MMW.GetAsset <UserData>().SignupServers)
            {
                frame.AddWorld(desc);
            }

            var signupBtn = new Button(frame, "SignUp World", new Vector2(70, MMW.ClientSize.Height - 120 - 100 + 20), new Vector2(140, 32), "click");

            Controls.Add(signupBtn);

            var editBtn = new Button(signupBtn, "Edit", new Vector2(160, 0), new Vector2(140, 32), "click");

            editBtn.Enabled = false;
            Controls.Add(editBtn);

            var delBtn = new Button(editBtn, "Delete", new Vector2(160, 0), new Vector2(140, 32), "click");

            delBtn.Enabled = false;
            Controls.Add(delBtn);

            var directBtn = new Button(delBtn, "Direct Connect", new Vector2(160, 0), new Vector2(140, 32), "click");

            Controls.Add(directBtn);

            signupBtn.Clicked += (s, b) =>
            {
                if (!signupBtn.Enabled)
                {
                    return;
                }
                trans          = true;
                transit.Target = new Vector2(-MMW.ClientSize.Width * 2.0f, 0.0f);
                GameObject.AddComponent <SignUpServerScript>();
            };

            editBtn.Clicked += (s, b) =>
            {
                if (!editBtn.Enabled)
                {
                    return;
                }
                trans          = true;
                transit.Target = new Vector2(-MMW.ClientSize.Width * 2.0f, 0.0f);
                GameObject.AddComponent <ServerEditScript>(frame.WorldInfo);
            };

            delBtn.Clicked += (s, b) =>
            {
                if (!delBtn.Enabled)
                {
                    return;
                }
                var res = System.Windows.Forms.MessageBox.Show(System.Windows.Forms.NativeWindow.FromHandle(MMW.Window.WindowInfo.Handle), "よろしいですか?\n(サーバ元のワールドは削除されません)", "ワールドを削除", System.Windows.Forms.MessageBoxButtons.OKCancel);
                if (res == System.Windows.Forms.DialogResult.OK)
                {
                    MMW.GetAsset <UserData>().SignupServers.Remove(frame.WorldInfo);
                    frame.RemoveWorld(frame.WorldInfo);
                    frame.WorldInfo = null;
                    editBtn.Enabled = false;
                    delBtn.Enabled  = false;
                }
            };

            directBtn.Clicked += (s, b) =>
            {
                if (!directBtn.Enabled)
                {
                    return;
                }
                trans          = true;
                transit.Target = new Vector2(-MMW.ClientSize.Width * 2.0f, 0.0f);
                GameObject.AddComponent <DirectConnectScript>();
            };

            frame.ServerClicked += (s, e) =>
            {
                editBtn.Enabled = true;
                delBtn.Enabled  = true;
            };
            frame.ServerSelected += (s, e) =>
            {
                MMW.GetAsset <Sound>("click").Play();
                var desc = frame.WorldInfo;
                Task.Factory.StartNew(() =>
                {
                    AcceptInput = false;
                    Thread.Sleep(100);

                    var server = NetworkUtil.Connect(desc.HostName, desc.Port);
                    if (server == null)
                    {
                        return;
                    }

                    server.Load();

                    var info = server.RequestJson <WorldInfo>(DataType.RequestWorldInfo, 1, DataType.ResponseWorldInfo, 3000);

                    if (info == null || info.GameType != 1 || (int)info.Version != (int)MMW.GetAsset <GameData>().Version)
                    {
                        AcceptInput = true;
                    }
                    else
                    {
                        MMW.Invoke(() =>
                        {
                            MMW.RegistAsset(server);
                            trans          = true;
                            transit.Target = new Vector2(-MMW.ClientSize.Width * 2.0f, 0.0f);
                            GameObject.AddComponent <ServerInfoScript>(info);
                        });
                    }
                });
            };
        }
示例#6
0
        protected override void OnLoad()
        {
            base.OnLoad();

            MMW.FindGameComponent <BackgroundScript>().Trans(new Color4(222, 216, 148, 255), 0.25);

            SelectedPlayer = null;

            input       = new MenuInputResolver();
            input.Up    = Key.W;
            input.Down  = Key.S;
            input.Right = Key.D;
            input.Left  = Key.A;

            transit = new TransitControl();
            transit.LocalLocation = new Vector2(MMW.ClientSize.Width * 2.0f, 0);
            transit.Size          = new Vector2(MMW.ClientSize.Width, MMW.ClientSize.Height);
            transit.Target        = Vector2.Zero;

            load = MMW.FindGameComponent <InitLoading>();

            tabCtr = new TabControl()
            {
                Parent        = transit,
                LocalLocation = new Vector2(100, 164),
                Size          = new Vector2((MMW.ClientSize.Width / 2) - 100 - 64, MMW.ClientSize.Height - 164 - 48),
                Tabs          = new Tab[]
                {
                    new Tab()
                    {
                        Name = "PRESET", Items = load.PresetCharacters,
                    },
                    new Tab()
                    {
                        Name = "FREE", Items = load.FreeCharacters,
                    },
                },
                Focus = true,
            };

            label = new Label()
            {
                Parent        = transit,
                Alignment     = ContentAlignment.TopCenter,
                Text          = "PLAYER SELECT",
                Font          = new Font("Yu Gothic UI Light", 40.0f),
                LocalLocation = new Vector2(0.0f, 32.0f),
            };

            MMW.MainCamera.GameObject.Transform.Position = new Vector3(0.6f, 1.1f, -1.7f);
            //MMW.MainCamera.GameObject.Transform.Position = new Vector3(0.3f, 1.4f, -0.6f);
            MMW.MainCamera.ShadowMapping = false;

            MMW.GlobalAmbient = new Color4(0.8f, 0.8f, 0.8f, 0.0f);
            //MMW.DirectionalLight.Transform.Rotate.Y = (float)Math.PI;
            MMW.DirectionalLight.Transform.Rotate = new Vector3(-MathHelper.PiOver3, 0.0f, 0.0f);
            MMW.DirectionalLight.Intensity        = 1.0f;
            MMW.IBLIntensity = 0.0f;


            if (load.State != InitLoading.LoadingState.Finished)
            {
                load.LoadCompleted += Load_LoadCompleted;
            }
        }
        protected override void OnLoad()
        {
            base.OnLoad();

            MMW.FindGameComponent <BackgroundScript>().Trans(new Color4(148, 222, 148, 255), 0.25);

            input       = new MenuInputResolver();
            input.Up    = Key.W;
            input.Down  = Key.S;
            input.Right = Key.D;
            input.Left  = Key.A;

            transit = new TransitControl();
            transit.LocalLocation = new Vector2(MMW.ClientSize.Width * 2.0f, 0);
            transit.Size          = new Vector2(MMW.ClientSize.Width, MMW.ClientSize.Height);
            transit.Target        = Vector2.Zero;

            var labelTitle = new Label()
            {
                Parent        = transit,
                Alignment     = ContentAlignment.TopCenter,
                Text          = "WORLD INFO",
                Font          = new Font("Yu Gothic UI Light", 40.0f),
                LocalLocation = new Vector2(0.0f, 32.0f),
            };

            Controls.Add(labelTitle);

            var imgWorld = new PictureBox()
            {
                Parent        = transit,
                Image         = Util.FromBitmapString(Info.WorldImage),
                LocalLocation = new Vector2(100.0f, 0.0f),
                Size          = new Vector2((MMW.Width * 0.5f) - 200.0f, MMW.Height - 280.0f),
                Alignment     = ContentAlignment.MiddleLeft,
                SizeMode      = SizeMode.Zoom,
            };

            Controls.Add(imgWorld);

            var labelWorldNameTitle = new Label()
            {
                Parent        = transit,
                Text          = "World Name",
                LocalLocation = new Vector2(MMW.Width * 0.5f, 146.0f),
                Font          = new Font("Yu Gothic UI", 14.0f, FontStyle.Bold),
            };

            Controls.Add(labelWorldNameTitle);

            var textWorldName = new TextBox(transit, Info.WorldName, new Vector2(MMW.Width * 0.5f, 175.0f), new Vector2(MMW.Width * 0.5f - 100.0f, 32.0f));

            textWorldName.Readonly = true;
            Controls.Add(textWorldName);

            var labelWorldDescTitle = new Label()
            {
                Parent        = transit,
                Text          = "World Desc",
                LocalLocation = new Vector2(MMW.Width * 0.5f, 216.0f),
                Font          = new Font("Yu Gothic UI", 14.0f, FontStyle.Bold),
            };

            Controls.Add(labelWorldDescTitle);

            var textWorldDesc = new TextBox(transit, Info.WorldDesc, new Vector2(MMW.Width * 0.5f, 245.0f), new Vector2(MMW.Width * 0.5f - 100.0f, MMW.Height - 420.0f));

            textWorldDesc.Readonly = true;
            Controls.Add(textWorldDesc);

            TextBox2 textboxPass = null;

            if (Info.WorldPass)
            {
                var labelPass = new Label(textWorldDesc, "Password", new Vector2(0.0f, MMW.Height - 420.0f + 10.0f));
                Controls.Add(labelPass);

                textboxPass = new TextBox2(labelPass, "", new Vector2(100.0f, 0.0f), new Vector2(200.0f, 32.0f));
                Controls.Add(textboxPass);
            }


            var btnJoin = new Button(textWorldDesc, "Join", new Vector2(MMW.Width * 0.5f - 200.0f, MMW.Height - 420.0f + 10.0f), new Vector2(100.0f, 32.0f), "click");

            Controls.Add(btnJoin);

            labelInfo = new Label(btnJoin, "", new Vector2(0.0f, 30.0f));
            Controls.Add(labelInfo);

            btnJoin.Clicked += (s, e) =>
            {
                AcceptInput = false;

                var loginDesc = new LoginDesc()
                {
                    UserName  = "******",
                    UserColor = new Color4f()
                    {
                    },
                };
                if (Info.WorldPass)
                {
                    loginDesc.Password = textboxPass.Text;
                }

                //Server.LoginResultReceived += Server_LoginResultReceived;

                var json = Util.SerializeJson(loginDesc);
                Server.SendTcp(Walker.DataType.Login, json);
                //Server.ReceiveTimeout = 5 * 1000;

                labelInfo.Text  = "Logging In...";
                labelInfo.Brush = Brushes.White;
            };
        }
示例#8
0
        protected override void OnLoad()
        {
            base.OnLoad();

            MMW.FindGameComponent <BackgroundScript>().Trans(new Color4(148, 222, 148, 255), 0.25);

            input       = new MenuInputResolver();
            input.Up    = Key.W;
            input.Down  = Key.S;
            input.Right = Key.D;
            input.Left  = Key.A;

            transit = new TransitControl();
            transit.LocalLocation = new Vector2(MMW.ClientSize.Width * 2.0f, 0);
            transit.Size          = new Vector2(MMW.ClientSize.Width, MMW.ClientSize.Height);
            transit.Target        = Vector2.Zero;

            var label = new Label()
            {
                Parent        = transit,
                Alignment     = ContentAlignment.TopCenter,
                Text          = "SIGN UP WORLD",
                Font          = new Font("Yu Gothic UI Light", 40.0f),
                LocalLocation = new Vector2(0.0f, 32.0f),
            };

            Controls.Add(label);

            var labelHost = new Label(transit, "Host", new Vector2(MMW.Width * 0.5f - 160.0f, 300.0f + 2.0f));

            Controls.Add(labelHost);

            var labelPort = new Label(transit, "Port", new Vector2(MMW.Width * 0.5f - 160.0f, 350.0f + 2.0f));

            Controls.Add(labelPort);

            var textBoxHost = new TextBox2(transit, "localhost", new Vector2(MMW.Width * 0.5f - 100.0f, 300.0f), new Vector2(360.0f, 32.0f));

            textBoxHost.MaxLength = 64;
            Controls.Add(textBoxHost);

            var textBoxPort = new TextBox2(transit, "39393", new Vector2(MMW.Width * 0.5f - 100.0f, 350.0f), new Vector2(72.0f, 32.0f));

            textBoxPort.MaxLength = 5;
            Controls.Add(textBoxPort);

            var backBtn = new Button(transit, "Back", new Vector2(-70.0f - 20.0f, 440.0f), "back");

            backBtn.Alignment = ContentAlignment.TopCenter;
            backBtn.Clicked  += (s, e) =>
            {
                trans          = true;
                transit.Target = new Vector2(-MMW.ClientSize.Width * 2.0f, 0.0f);
                GameObject.AddComponent <ServerSelectScript>();
            };
            Controls.Add(backBtn);

            var connectBtn = new Button(transit, "Sign Up", new Vector2(70.0f + 20.0f, 440.0f), "click");

            connectBtn.Alignment = ContentAlignment.TopCenter;
            connectBtn.Clicked  += (s, e) =>
            {
                var ss = MMW.GetAsset <UserData>().SignupServers;
                if (!ss.Exists(d => d.HostName == textBoxHost.Text && d.Port == int.Parse(textBoxPort.Text)))
                {
                    ss.Add(new Walker.WorldInfo()
                    {
                        HostName = textBoxHost.Text,
                        Port     = int.Parse(textBoxPort.Text),
                    });
                }

                trans          = true;
                transit.Target = new Vector2(-MMW.ClientSize.Width * 2.0f, 0.0f);
                GameObject.AddComponent <ServerSelectScript>();
            };
            Controls.Add(connectBtn);

            var labelInfo = new Label(transit, "", new Vector2(0.0f, 500.0f));

            labelInfo.Alignment = ContentAlignment.TopCenter;
            Controls.Add(labelInfo);
        }
示例#9
0
        protected override void OnLoad()
        {
            base.OnLoad();

            MMW.FindGameComponent <BackgroundScript>().Trans(new Color4(148, 222, 148, 255), 0.25);

            input       = new MenuInputResolver();
            input.Up    = Key.W;
            input.Down  = Key.S;
            input.Right = Key.D;
            input.Left  = Key.A;

            transit = new TransitControl();
            transit.LocalLocation = new Vector2(MMW.ClientSize.Width * 2.0f, 0);
            transit.Size          = new Vector2(MMW.ClientSize.Width, MMW.ClientSize.Height);
            transit.Target        = Vector2.Zero;

            var label = new Label()
            {
                Parent        = transit,
                Alignment     = ContentAlignment.TopCenter,
                Text          = "DIRECT CONNECT",
                Font          = new Font("Yu Gothic UI Light", 40.0f),
                LocalLocation = new Vector2(0.0f, 32.0f),
            };

            Controls.Add(label);

            var labelHost = new Label(transit, "Host", new Vector2(MMW.Width * 0.5f - 160.0f, 300.0f + 2.0f));

            Controls.Add(labelHost);
            var labelPort = new Label(labelHost, "Port", new Vector2(0, 50.0f));

            Controls.Add(labelPort);

            var textBoxHost = new TextBox2(transit, "localhost", new Vector2(MMW.Width * 0.5f - 100.0f, 300.0f), new Vector2(360.0f, 32.0f));

            textBoxHost.MaxLength = 64;
            Controls.Add(textBoxHost);

            var textBoxPort = new TextBox2(textBoxHost, "39393", new Vector2(0, 50.0f), new Vector2(72.0f, 32.0f));

            textBoxPort.MaxLength = 5;
            Controls.Add(textBoxPort);

            var backBtn = new Button(transit, "Back", new Vector2(-70.0f - 20.0f, 440.0f), "back");

            backBtn.Alignment = ContentAlignment.TopCenter;
            backBtn.Clicked  += (s, e) =>
            {
                trans          = true;
                transit.Target = new Vector2(-MMW.ClientSize.Width * 2.0f, 0.0f);
                GameObject.AddComponent <ServerSelectScript>();
            };
            Controls.Add(backBtn);

            var labelInfo = new Label(transit, "", new Vector2(0.0f, 500.0f));

            labelInfo.Alignment = ContentAlignment.TopCenter;
            Controls.Add(labelInfo);

            var connectBtn = new Button(transit, "Connect", new Vector2(70.0f + 20.0f, 440.0f), "click");

            connectBtn.Alignment = ContentAlignment.TopCenter;
            connectBtn.Clicked  += (s, e) =>
            {
                AcceptInput = false;

                labelInfo.Brush = Brushes.White;
                labelInfo.Text  = "Connecting...";

                var host = textBoxHost.Text;
                var port = int.Parse(textBoxPort.Text);

                Task.Factory.StartNew(() =>
                {
                    Thread.Sleep(100);
                    var server = NetworkUtil.Connect(host, port);

                    if (server == null)
                    {
                        labelInfo.Brush = Brushes.Red;
                        labelInfo.Text  = "Host not Found.";
                        AcceptInput     = true;
                    }
                    else
                    {
                        labelInfo.Text = "Downloading World info...";

                        var info = server.RequestJson <WorldInfo>(DataType.RequestWorldInfo, 1, DataType.ResponseWorldInfo, 5000);

                        if (info.GameType != 1)
                        {
                            labelInfo.Brush = Brushes.Red;
                            labelInfo.Text  = "Host not Found.";
                            AcceptInput     = true;
                        }
                        else if ((int)info.Version != (int)MMW.GetAsset <GameData>().Version)
                        {
                            labelInfo.Brush = Brushes.Red;
                            labelInfo.Text  = $"Wrong version. Host ver.{info.Version:0.0}";
                            AcceptInput     = true;
                        }
                        else
                        {
                            MMW.Invoke(() =>
                            {
                                trans          = true;
                                transit.Target = new Vector2(-MMW.ClientSize.Width * 2.0f, 0.0f);
                                GameObject.AddComponent <ServerInfoScript>(server, info);
                            });
                        }
                    }
                });
            };
            Controls.Add(connectBtn);
        }