コード例 #1
0
ファイル: MainWindow.cs プロジェクト: rezonant/craftalyst
    public void Launch()
    {
        playButton.Sensitive = false;
        var monitor = new MainWindowGameMonitor(this);

        var installDialog = new InstallationDialog();
        installDialog.Parent = this;
        installDialog.Show();
        installDialog.GdkWindow.Raise();

        // Run syncing in installation dialog as a separate thread,
        // and wait until it is done while processing UI events for it

        var thread = new Thread(delegate() {
            var listener = new InstallationDialogStatusListener(installDialog);
            Instance.Sync(listener);
            var mc = Instance.CreateMinecraft();
            mc.Setup(listener);
        });
        thread.IsBackground = true;
        thread.Name = "GameSync";
        thread.Start();
        GLib.Timeout.Add(100, delegate() {
            if (!thread.IsAlive) {
                Application.Quit();
                return false;
            }

            return true;
        });
        Gtk.Application.Run();

        // Run the game

        installDialog.Log ("");
        installDialog.Log ("Getting ready to start Minecraft!");
        installDialog.Status = "All updates completed!";
        installDialog.Title = "All updates completed!";
        installDialog.Destroy ();

        monitor.OutputLine(GameMessageType.Output, "");
        monitor.OutputLine(GameMessageType.Output, "Starting Minecraft...");

        playButton.Sensitive = true;
        GameIsActive = true;
        thread = new Thread(delegate() {
            var mc = Instance.CreateMinecraft();
            GameProcess = mc.Start(Session, monitor);

            DedicatedLauncher.Singleton.EnqueueUxJob(delegate() {
                this.minecraftStatus.Text = string.Format("Minecraft is running (Process #{0})", GameProcess.Id);
            });

            Console.WriteLine("Game launched from seperate thread!");
        });
        thread.IsBackground = true;
        thread.Name = "GameLauncher";
        thread.Start();

        Console.WriteLine("Control returned.");
    }
コード例 #2
0
        public void RunInstance()
        {
            //Login ();

            var installDialog = new InstallationDialog ();
            installDialog.Show ();
            installDialog.ShowAll();

            ControlThread = new Thread(delegate() {
                if (Instance.IsNewInstance) {
                    Install(installDialog);
                }

                EnqueueUxJob(delegate() {
                    installDialog.Destroy();
                    Launch();
                });
            });

            ControlThread.Start();

            Function delly;

            Console.WriteLine("Registering GTK event sweeper");

            RunUx();
        }