FormMainMenu() public method

public FormMainMenu ( ) : void
return void
Example #1
0
        public void Initialize()
        {
            widgets.Clear();
            worldbuttons.Clear();
            menu.AddBackground(widgets);
            menu.AddCaption(this, "Select world");
            string[] w = new List <string>(game.GetWorlds()).ToArray();
            for (int i = 0; i < w.Length; i++)
            {
                if (string.IsNullOrEmpty(w[i]))
                {
                    w[i] = "Empty";
                }
            }
            for (int i = 0; i < 8; i++)
            {
                int ii     = i;//closure
                var widget = new Widget()
                {
                    BackgroundImage         = menu.button4,
                    BackgroundImageSelected = menu.button4sel,
                    Rect     = new RectangleF(350 + (i % 2) * 500, 300 + (i / 2) * 150, 400, 128),
                    Text     = w[i],
                    Click    = delegate { selectedWorld = ii; },
                    selected = selectedWorld == i,
                };
                worldbuttons.Add(widget);
                widgets.Add(widget);
            }

            widgets.Add(new Widget()
            {
                BackgroundImage         = menu.button4,
                BackgroundImageSelected = menu.button4sel,
                Rect  = new RectangleF(650, 900, 300, 90),//500
                Text  = "Delete",
                Click = delegate
                {
                    string name = game.GetWorlds()[selectedWorld.Value];
                    if (!string.IsNullOrEmpty(name))
                    {
                        menu.MessageBoxYesNo(string.Format("Are you sure you want to delete world \"{0}\"?", name)
                                             , delegate { game.DeleteWorld(selectedWorld.Value); Initialize(); }, delegate { });
                    }
                },
                FontSize = 20,
            });/*
                * widgets.Add(new Widget()
                * {
                * BackgroundImage = "button4.png",
                * BackgroundImageSelected = "button4_sel.png",
                * Rect = new RectangleF(800, 900, 300, 90),
                * Text = "Options",
                * Click = delegate { },
                * FontSize = 20,
                * });*/

            menu.AddOkCancel(this, delegate { menu.afterSelectWorld(); }, delegate { menu.FormMainMenu(); });
        }
Example #2
0
        public void Initialize()
        {
            widgets.Clear();
            menu.AddBackground(widgets);
            menu.AddCaption(this, "Start server");
            selectedWorldWidget = new Widget()
            {
                BackgroundImage         = null,
                BackgroundImageSelected = null,
                Rect     = new RectangleF(200, 200, 400, 90),
                Text     = "",//Render()
                Click    = delegate { menu.FormSelectWorld(menu.FormStartServer); },
                FontSize = 20,
            };
            widgets.Add(selectedWorldWidget);
            widgets.Add(new Widget()
            {
                BackgroundImage         = menu.button4,
                BackgroundImageSelected = menu.button4sel,
                Rect     = new RectangleF(500, 200, 300, 90),
                Text     = "Select",
                Click    = delegate { menu.FormSelectWorld(delegate { menu.FormStartServer(); }); },
                FontSize = 20,
            });

            //Connection options
            widgets.Add(new Widget()
            {
                BackgroundImage         = null,
                BackgroundImageSelected = null,
                Rect     = new RectangleF(200, 300, 400, 90),
                Text     = "Server name: ",
                Click    = delegate { },
                FontSize = 20,
            });
            widgets.Add(new Widget()
            {
                BackgroundImage         = menu.button4,
                BackgroundImageSelected = menu.button4sel,
                Rect      = new RectangleF(500, 300, 600, 90),
                IsTextbox = true,
                FontSize  = 20,
                Text      = "My server",
            });
            widgets.Add(new Widget()
            {
                BackgroundImage         = null,
                BackgroundImageSelected = null,
                Rect     = new RectangleF(200, 400, 400, 90),
                Text     = "Max players: ",
                Click    = delegate { },
                FontSize = 20,
            });
            widgets.Add(new Widget()
            {
                BackgroundImage         = menu.button4,
                BackgroundImageSelected = menu.button4sel,
                Rect      = new RectangleF(500, 400, 600, 90),
                IsTextbox = true,
                IsNumeric = true,
                FontSize  = 20,
                Text      = "16",
            });
            widgets.Add(new Widget()
            {
                BackgroundImage         = null,
                BackgroundImageSelected = null,
                Rect     = new RectangleF(200, 500, 400, 90),
                Text     = "Password: "******"Public: ",
                Click    = delegate { },
                FontSize = 20,
            });
            publicWidget = new Widget()
            {
                BackgroundImage         = menu.button4,
                BackgroundImageSelected = menu.button4sel,
                Rect     = new RectangleF(500, 600, 200, 90),
                Text     = "",//Render()
                Click    = delegate { serverpublic = !serverpublic; },
                FontSize = 20,
            };
            widgets.Add(publicWidget);

            widgets.Add(new Widget()
            {
                BackgroundImage         = menu.button4,
                BackgroundImageSelected = menu.button4sel,
                Rect     = new RectangleF(1200, 200, 300, 90),
                Text     = "Show my IP",
                Click    = delegate { },
                FontSize = 20,
            });

            //Bottom buttons
            widgets.Add(new Widget()
            {
                BackgroundImage         = menu.button4,
                BackgroundImageSelected = menu.button4sel,
                Rect = new RectangleF(200, 1000, 400, 128),
                Text = serverstarted ? "Stop" : "Start",
                //Click = delegate { serverstarted = !serverstarted; FormStartMultiplayerServer(); },
                Click = delegate { game.StartAndJoinLocalServer(menu.d_FormSelectWorld.selectedWorld.Value); }
            });
            //widgets.Add(new Button()
            //{
            //    BackgroundImage = "button4.png",
            //    BackgroundImageSelected = "button4_sel.png",
            //    Rect = new RectangleF(600, 1000, 400, 128),
            //    Text = "Play",
            //    Click = delegate { FormGame(); },
            //});
            widgets.Add(new Widget()
            {
                BackgroundImage         = menu.button4,
                BackgroundImageSelected = menu.button4sel,
                Rect  = new RectangleF(1000, 1000, 400, 128),
                Text  = "Cancel",
                Click = delegate { menu.FormMainMenu(); }
            });
        }