Beispiel #1
0
 public EditNotesDialog(Instance inst, Window parent = null)
     : base("", parent, DialogFlags.Modal)
 {
     this.Build();
     this.Inst = inst;
     notesTextView.Buffer.Text = inst.Notes;
 }
Beispiel #2
0
 public GameUpdater(Instance inst, 
     string latestVersion,
     string mainGameUrl,
     bool forceUpdate = false)
 {
     this.Inst = inst;
     this.latestVersion = latestVersion;
     this.mainGameUrl = mainGameUrl;
     this.forceUpdate = forceUpdate;
 }
Beispiel #3
0
        public EditModsDialog(Instance inst, Gtk.Window parent = null)
            : base("Edit Mods", parent, DialogFlags.Modal)
        {
            Inst = inst;

            this.Build();

            #region We have to make the treeview ourselves since monodevelop is absolute shit...
            this.editModScroll = new ScrolledWindow();
            this.editModScroll.HscrollbarPolicy = PolicyType.Never;
            this.modView = new Gtk.TreeView();
            this.modView.CanFocus = true;
            this.modView.Name = "modView";
            this.editModScroll.Add(this.modView);
            this.VBox.Add(this.editModScroll);
            Gtk.Box.BoxChild w3 = ((Gtk.Box.BoxChild)(this.VBox[this.editModScroll]));
            w3.Position = 0;
            this.ShowAll();
            #endregion

            modList = new ListStore(typeof(string), typeof(string), typeof(bool), typeof(DateTime));
            modView.Model = modList;
            modView.AppendColumn("File", new CellRendererText(), "text", 0);
            modView.AppendColumn("Install Date", new CellRendererText(), "text", 1);

            CellRendererToggle toggleRenderer = new CellRendererToggle();
            toggleRenderer.Activatable = true;
            toggleRenderer.Sensitive = true;
            toggleRenderer.Toggled += (object o, ToggledArgs args) =>
            {
                TreeIter iter;
                if (modList.GetIter(out iter, new TreePath(args.Path)))
                    modList.SetValue(iter, 2, !(bool)modList.GetValue(iter, 2));
            };
            modView.AppendColumn("Delete?", toggleRenderer, "active", 2);

            modView.Columns[0].Alignment = 0.0f;
            modView.Columns[0].Expand = true;
            modView.Columns[1].Alignment = 1.0f;
            modView.Columns[2].Alignment = 1.0f;

            LoadMods();
        }
Beispiel #4
0
        public ChangeIconDialog(Instance inst, Gtk.Window parent)
            : base("Change Icon", parent, Gtk.DialogFlags.Modal)
        {
            Inst = inst;

            this.Build();

            iconList = new ListStore(typeof(string), typeof(Pixbuf));

            iconView.Model = iconList;
            iconView.TextColumn = 0;
            iconView.PixbufColumn = 1;
            iconView.Cells[0] = new CellRendererText();

            CellRendererText textCell = (iconView.Cells[0] as CellRendererText);
            textCell.Editable = true;
            textCell.Width = 64;

            LoadIcons();
        }
        public EditModsDialog(Instance inst, Gtk.Window parent = null)
            : base("Edit Mods", parent, DialogFlags.Modal)
        {
            Inst = inst;

            using (Button buttonRefresh = new Button("gtk-refresh"))
            {
                buttonRefresh.Clicked += (sender, e) =>
                {
                    LoadMods();
                };
                ActionArea.Homogeneous = false;
                ActionArea.PackEnd(buttonRefresh, false, true, 0);
                buttonRefresh.Visible = true;
            }

            this.Build();

            #region We have to make the treeview ourselves since monodevelop is absolute shit...
            this.editModScroll = new ScrolledWindow();
            this.editModScroll.HscrollbarPolicy = PolicyType.Never;
            this.modView = new Gtk.TreeView();
            this.modView.CanFocus = true;
            this.modView.Name = "modView";
            this.editModScroll.Add(this.modView);
            this.VBox.Add(this.editModScroll);
            Gtk.Box.BoxChild w3 = ((Gtk.Box.BoxChild)(this.VBox[this.editModScroll]));
            w3.Position = 0;
            this.ShowAll();
            #endregion

            modList = new ListStore(typeof(string), typeof(int), typeof(bool));
            modView.Model = modList;
            using (CellRendererText cr = new CellRendererText())
                modView.AppendColumn("Index", cr, "text", 1);
            using (CellRendererText cr = new CellRendererText())
                modView.AppendColumn("File", cr, "text", 0);

            CellRendererToggle toggleRenderer = new CellRendererToggle();
            toggleRenderer.Activatable = true;
            toggleRenderer.Sensitive = true;
            toggleRenderer.Toggled += (object o, ToggledArgs args) =>
            {
                TreeIter iter;
                using (TreePath tp = new TreePath(args.Path))
                    if (modList.GetIter(out iter, tp))
                        modList.SetValue(iter, 2, !(bool) modList.GetValue(iter, 2));
            };
            modView.AppendColumn("Delete?", toggleRenderer, "active", 2);

            modView.Columns[0].Alignment = 0.0f;
            modView.Columns[1].Alignment = 0.0f;
            modView.Columns[1].Expand = true;
            modView.Columns[2].Alignment = 1.0f;

            modView.Reorderable = true;

            LoadMods();

            // Auto-refresh
            Inst.InstMods.ModFileChanged += (sender, e) =>
                Application.Invoke((sender2, e2) => LoadMods());
        }
Beispiel #6
0
 public Modder(Instance target)
 {
     this._Target = target;
 }
Beispiel #7
0
 /// <summary>
 /// Rebuilds the given instance's minecraft.jar
 /// </summary>
 private Modder RebuildMCJar(Instance inst)
 {
     if (!File.Exists(SelectedInst.MCJar))
     {
         MessageUtils.ShowMessageBox(MessageType.Warning,
                                     "You must run the " +
                                     "instance at least " +
                                     "once before installing mods.");
         return null;
     }
     Modder modder = new Modder(inst);
     modder.Completed += (sender, e) => inst.NeedsRebuild = false;
     StartTask(modder);
     return modder;
 }
Beispiel #8
0
        protected void OnNewClicked(object sender, System.EventArgs e)
        {
            using (NewInstanceDialog newDlg = new NewInstanceDialog(this))
            {
                newDlg.ParentWindow = this.GdkWindow;
                newDlg.Response += (sender1, e1) =>
                {
                    if (e1.ResponseId == ResponseType.Ok)
                    {
                        Console.WriteLine("Adding inst " + newDlg.InstDir);
                        using (Instance inst = new Instance(newDlg.InstName, newDlg.InstDir, true))
                        {
                            instList.AppendValues(inst.Name, inst);
                            LoadInstances();
                        }
                    }

                    newDlg.Destroy();
                };
                newDlg.Run();
            }
        }
Beispiel #9
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);
        }
Beispiel #10
0
 /// <summary>
 /// Rebuilds the given instance's minecraft.jar
 /// </summary>
 private void RebuildMCJar(Instance inst)
 {
     if (!File.Exists(SelectedInst.MCJar))
     {
         MessageUtils.ShowMessageBox(MessageType.Warning,
                                     "You must run the " +
                                     "instance at least " +
                                     "once before installing mods.");
         return;
     }
     Modder modder = new Modder(SelectedInst);
     instIconView.Sensitive = false;
     modder.Completed += (sender2, e2) => instIconView.Sensitive = true;
     StartTask(modder);
 }
Beispiel #11
0
 protected void OnNewClicked(object sender, System.EventArgs e)
 {
     NewInstanceDialog newDlg = new NewInstanceDialog(this);
     newDlg.ParentWindow = this.GdkWindow;
     newDlg.Show();
     newDlg.OKClicked += (sender1, e1) =>
     {
         Console.WriteLine("Adding inst " + newDlg.InstDir);
         Instance inst = new Instance(newDlg.InstName, newDlg.InstDir, true);
         instList.AppendValues(inst.Name, inst);
     };
 }
Beispiel #12
0
        //        ConsoleWindow consoleWindow;
        public void StartInstance(Instance inst)
        {
            //			inst.InstQuit += (sender, e) =>
            //			{
            //				if (!cwin.Visible)
            //					Visible = true;
            //			};

            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);
                    updater.Completed += (sender, e) => Application.Invoke((sender2, e2) =>
                    {
                        Visible = false;
                        UIEnabled = true;
                        inst.Launch();
                        ConsoleWindow cwin = new ConsoleWindow(inst);
                        cwin.ConsoleClosed += (sender3, e3) =>
                        {
                            Visible = true;
                        };
                    });
                    StartTask(updater);
                }
                else
                    UIEnabled = true;
            }, message);
            //			GameUpdater updater = new GameUpdater(inst,
            //			                                      loginInfo.,
            //			                                      "minecraft.jar?user="******"&ticket=" +
            //			                                      downloadTicket,
            //			                                      true);
        }
Beispiel #13
0
        public ConsoleWindow(Instance inst)
            : base(Gtk.WindowType.Toplevel)
        {
            // Build the GUI
            this.Build();
            this.Deletable = false;

            // If the user has show console on, show the window
            this.Visible = AppSettings.Main.ShowConsole;

            // Add a listener for when the instance quits
            Inst = inst;
            Inst.InstQuit += OnInstQuit;

            // Add formatting tags to the text buffer
            // Base tag
            TextTag baseTag = new TextTag("base");
            baseTag.Font = "Courier New";
            ConsoleView.Buffer.TagTable.Add(baseTag);

            // Standard output tag
            TextTag stdoutTag = new TextTag("std");
            ConsoleView.Buffer.TagTable.Add(stdoutTag);

            // Error message tag
            TextTag errorTag = new TextTag("err");
            errorTag.ForegroundGdk = new Gdk.Color(255, 0, 0);
            ConsoleView.Buffer.TagTable.Add(errorTag);

            // Misc message tag
            TextTag miscTag = new TextTag("etc");
            miscTag.ForegroundGdk = new Gdk.Color(0, 0, 255);
            ConsoleView.Buffer.TagTable.Add(miscTag);

            // Listen for output from the instance
            if (Inst.Running)
            {
                AttachOutputListeners();
            }
            else
            {
                Inst.InstLaunch += (sender, e) =>
                {
                    AttachOutputListeners();
                    Message("Instance started");
                };
            }

            // Add the tray icon
            statusIcon = new StatusIcon(Pixbuf.LoadFromResource("MainIcon"));
            statusIcon.Tooltip = "MultiMC Console";
            statusIcon.Activate += (sender, e) => ShowConsole = !ShowConsole;

            // Make a context menu for the icon
            Menu trayMenu = new Menu();

            // Show / hide console
            MenuItem showMenuItem = new MenuItem((ShowConsole ? "Hide Console" : "Show Console"));
            showMenuItem.Activated += (sender, e) =>
            {
                ShowConsole = !ShowConsole;
                (showMenuItem.Child as Label).Text =
                    (ShowConsole ? "Hide Console" : "Show Console");
            };
            trayMenu.Add(showMenuItem);

            // Kill Minecraft
            MenuItem killMenuItem = new MenuItem("Kill Minecraft");
            killMenuItem.Activated += (sender, e) =>
            {
                MessageDialog confirmDlg = new MessageDialog(this,
                                                             DialogFlags.Modal,
                                                             MessageType.Warning,
                                                             ButtonsType.OkCancel,
                                                             "Killing Minecraft can " +
                                                             "cause you to lose saves " +
                                                             "and other things. " +
                                                             "Are you sure?");
                confirmDlg.Title = "Warning";
                confirmDlg.Response += (object o, ResponseArgs args) =>
                {
                    if (args.ResponseId == ResponseType.Ok)
                    {
                        Inst.InstProcess.Kill();
                    }
                    confirmDlg.Destroy();
                };
                confirmDlg.Run();
            };
            trayMenu.Add(killMenuItem);

            if (OSUtils.Windows)
                StyleUtils.DeuglifyMenu(trayMenu);

            trayMenu.ShowAll();
            statusIcon.PopupMenu += (object o, PopupMenuArgs args) =>
                statusIcon.PresentMenu(trayMenu, (uint)args.Args[0], (uint)args.Args[1]);

            Message("Instance started with command: " +
                    inst.InstProcess.StartInfo.FileName +
                    " " + inst.InstProcess.StartInfo.Arguments.ToString());
        }