Example #1
0
        //        ConsoleWindow consoleWindow;
        public void StartInstance(Instance inst)
        {
            //			inst.InstQuit += (sender, e) =>
            //			{
            //				if (!cwin.Visible)
            //					Visible = true;
            //			};

            //			Console.WriteLine("Offline allowed: " + inst.CanPlayOffline);

            string message = "";
            UIEnabled = false;
            DoLogin(
                (LoginInfo info) =>
                {
                    string mainGameUrl = "minecraft.jar";
                    if (!info.Cancelled)
                    {
                        Console.WriteLine(info.ForceUpdate);
                        GameUpdater updater =
                                new GameUpdater(inst,
                                                info.LatestVersion,
                                                mainGameUrl,
                                                info.ForceUpdate);

                        EventHandler startDelegate = new EventHandler(
                                (e, args) =>
                                {
                                    Visible = false;
                                    UIEnabled = true;
                                    inst.Launch(info.Username, info.SessionID);
                                    ConsoleWindow cwin = new ConsoleWindow(inst);
                                    cwin.ConsoleClosed += (sender3, e3) =>
                                    {
                                        Visible = true;
                                        cwin.Dispose();
                                    };
                                });

                        updater.Completed += (sender, e) =>
                        {
                            if (inst.NeedsRebuild)
                            {
                                Application.Invoke(
                                        (sender2, e2) =>
                                        {
                                            RebuildMCJar(inst).Completed += (sender3, e3) =>
                                                        Application.Invoke(sender3, e3, startDelegate);
                                        });
                            }
                            else
                                Application.Invoke(sender, e, startDelegate);
                        };

                        Application.Invoke((sender, e) => StartTask(updater));
                    }
                    else
                        UIEnabled = true;
                }, message, inst.CanPlayOffline);
            //			GameUpdater updater = new GameUpdater(inst,
            //			                                      loginInfo.,
            //			                                      "minecraft.jar?user="******"&ticket=" +
            //			                                      downloadTicket,
            //			                                      true);
        }