Example #1
0
        public override void FinishedLaunching(MonoMac.Foundation.NSObject notification)
        {
            Directory.SetCurrentDirectory(NSBundle.MainBundle.ResourcePath);

            if (getMaxfiles() < 512)
            {
                runCommand("launchctl", "limit maxfiles 512 4096");

                string execPath  = NSBundle.MainBundle.BundlePath;
                int    processId = NSProcessInfo.ProcessInfo.ProcessIdentifier;
                NSTask.LaunchFromPath("relaunch", new string[] { execPath, processId.ToString() });

                Environment.Exit(0);
            }

            WebClient updateClient = new WebClient();

            updateClient.DownloadStringCompleted += UpdateCheckCompleted;
            updateClient.DownloadStringAsync(new Uri("http://dl.dropbox.com/u/76985/MacTerraria_update.txt"));

            patchTerraria(Path.Combine(NSBundle.MainBundle.ResourcePath, "exes", "Terraria.exe"),
                          Path.Combine(NSBundle.MainBundle.ResourcePath, "Terraria.exe"));

            string savePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), "My Games", "Terraria");

            Directory.CreateDirectory(savePath);



            Assembly assembly = Assembly.LoadFrom(Path.Combine(NSBundle.MainBundle.ResourcePath, "Terraria.exe"));
            Type     mainType = assembly.GetType("Terraria.Main");
            object   game     = Activator.CreateInstance(mainType);

            mainType.InvokeMember("Run", BindingFlags.Default | BindingFlags.InvokeMethod, null, game, null);
        }
Example #2
0
        public static void Relaunch(this NSApplication self)
        {
            var pid    = NSProcessInfo.ProcessInfo.ProcessIdentifier;
            var script = string.Format(@"
                while [ `ps -p {0} | wc -l` -gt 1 ]; do sleep 0.1; done; open '{1}'
            ", pid, NSBundle.MainBundle.BundlePath);

            NSTask.LaunchFromPath("/bin/sh", new [] { "-c", script });
            self.Terminate(self);
        }
Example #3
0
        static void restart_WillTerminate(object sender, EventArgs e)
        {
            // re-open after we terminate
            var args = new string[] {
                "-c",
                "open \"$1\"",
                string.Empty,
                NSBundle.MainBundle.BundlePath
            };

            NSTask.LaunchFromPath("/bin/sh", args);
        }