示例#1
0
        public SingleplayerMenuScreen(Client tclient) : base(tclient)
        {
            ResetOnRender = false;
            AddChild(new UIButton("ui/menus/buttons/basic", "Back", TheClient.FontSets.SlightlyBigger, () => TheClient.ShowMainMenu(), UIAnchor.BOTTOM_LEFT, () => 350, () => 70, () => 10, () => - 100));
            int start = 150;
            IEnumerable <string> found    = Directory.EnumerateDirectories(Environment.CurrentDirectory);
            HashSet <string>     fullList = new HashSet <string>();

            foreach (string fnd in found)
            {
                string str = fnd.Substring(Environment.CurrentDirectory.Length).Replace('\\', '/').Replace("/", "");
                fullList.Add(str);
            }
            fullList.Add("server_default");
            fullList.Remove("server_menu");
            foreach (string fnd in fullList)
            {
                string str  = fnd;
                int    curr = start;
                if (str.StartsWith("server_"))
                {
                    str = str.Substring("server_".Length);
                    AddChild(new UIButton("ui/menus/buttons/sp", "== " + str + " ==", TheClient.FontSets.Standard, () =>
                    {
                        UIConsole.WriteLine("Opening singleplayer game: " + str);
                        TheClient.Network.Disconnect(TheClient.Network.ConnectionThread, TheClient.Network.ConnectionSocket, TheClient.Network.ChunkSocket);
                        if (TheClient.LocalServer != null)
                        {
                            UIConsole.WriteLine("Shutting down pre-existing server.");
                            TheClient.LocalServer.ShutDown();
                            TheClient.LocalServer = null;
                        }
                        TheClient.LocalServer = new Server(28010);
                        Server.Central        = TheClient.LocalServer;
                        TheClient.ShowLoading();
                        TheClient.Schedule.StartAsyncTask(() =>
                        {
                            try
                            {
                                TheClient.LocalServer.StartUp(str, () =>
                                {
                                    TheClient.Schedule.ScheduleSyncTask(() =>
                                    {
                                        TheClient.Network.Connect("localhost", "28010", false, str);
                                    }, 1.0);
                                });
                            }
                            catch (Exception ex)
                            {
                                Utilities.CheckException(ex);
                                SysConsole.Output("Running singleplayer game server", ex);
                            }
                        });
                    }, UIAnchor.TOP_LEFT, () => 600, () => 70, () => 10, () => curr));
                    start += 100;
                }
            }
            AddChild(new UILabel("^!^e^0  Voxalia\nSingleplayer", TheClient.FontSets.SlightlyBigger, UIAnchor.TOP_CENTER, () => 0, () => 0));
        }
        public SingleplayerMenuScreen(Client tclient) : base(tclient)
        {
            AddChild(new UIButton("ui/menus/buttons/basic", "Back", TheClient.FontSets.SlightlyBigger, () => TheClient.ShowMainMenu(), UIAnchor.BOTTOM_LEFT, () => 350, () => 70, () => 10, () => - 100));
            int           start = 150;
            List <string> found = TheClient.Files.ListFolders("saves");

            foreach (string str in found)
            {
                if (str.LastIndexOf('/') == "/saves/".Length - 1)
                {
                    AddChild(new UIButton("ui/menus/buttons/sp", "== " + str.Substring("/saves/".Length) + " ==", TheClient.FontSets.Standard, () => UIConsole.WriteLine("OPEN " + str), UIAnchor.TOP_LEFT, () => 600, () => 70, () => 10, () => start));
                    start += 100;
                }
            }
            AddChild(new UILabel("^!^e^0  Voxalia\nSingleplayer", TheClient.FontSets.SlightlyBigger, UIAnchor.TOP_CENTER, () => 0, () => 0));
        }
示例#3
0
        public SingleplayerMenuScreen(Client tclient) : base(tclient)
        {
            ResetOnRender = false;
            AddChild(new UIButton("ui/menus/buttons/basic", "Back", TheClient.FontSets.SlightlyBigger, () => TheClient.ShowMainMenu(), new UIPositionHelper(Client.MainUI).Anchor(UIAnchor.BOTTOM_LEFT).ConstantXY(10, -100).ConstantWidthHeight(350, 70)));
            AddChild(new UIButton("ui/menus/buttons/basic", "New Game", TheClient.FontSets.SlightlyBigger, () =>
            {
                AddGame("g" + Utilities.UtilRandom.Next(10000));
            }, new UIPositionHelper(Client.MainUI).Anchor(UIAnchor.BOTTOM_LEFT).ConstantXY(10, -200).ConstantWidthHeight(350, 70)));
            CurrentY = 150;
            IEnumerable <string> found    = Directory.EnumerateDirectories(Environment.CurrentDirectory);
            HashSet <string>     fullList = new HashSet <string>();

            foreach (string fnd in found)
            {
                string str = fnd.Substring(Environment.CurrentDirectory.Length).Replace('\\', '/').Replace("/", "");
                fullList.Add(str);
            }
            fullList.Add("server_default");
            fullList.Remove("server_menu");
            foreach (string fnd in fullList)
            {
                string str = fnd;
                if (str.StartsWith("server_"))
                {
                    str = str.Substring("server_".Length);
                    AddGame(str);
                }
            }
            AddChild(new UILabel("^!^e^0  Voxalia\nSingleplayer", TheClient.FontSets.SlightlyBigger, new UIPositionHelper(Client.MainUI).Anchor(UIAnchor.TOP_CENTER).ConstantXY(0, 0)));
        }