Ejemplo n.º 1
0
        public void Main(string[] args)
        {
            try
            {
                _config = new Config();

                AppDomain.CurrentDomain.AssemblyResolve += delegate(object sender, ResolveEventArgs sargs)
                {
                    var asm = typeof(Terraria.Program).Assembly;

                    var resourceName = new AssemblyName(sargs.Name).Name + ".dll";
                    var text         = Array.Find(asm.GetManifestResourceNames(), (string element) => element.EndsWith(resourceName));
                    if (text == null)
                    {
                        return(null);
                    }

                    using (Stream manifestResourceStream = asm.GetManifestResourceStream(text))
                    {
                        var array = new byte[manifestResourceStream.Length];
                        manifestResourceStream.Read(array, 0, array.Length);
                        return(Assembly.Load(array));
                    }
                };

                Console.BackgroundColor = ConsoleColor.White;
                Console.ForegroundColor = ConsoleColor.DarkCyan;
                Console.Clear();

                Console.WriteLine("OTAPI Test Launcher.");

                var options = new NDesk.Options.OptionSet()
                              .Add("as:|auto-start:", x => _config.AutoStart = true);
                options.Parse(args);

                //AttachHooks();
                PreStart?.Invoke(this, EventArgs.Empty);

                if (_config.AutoStart)
                {
                    StartGame(args);
                }
                else
                {
                    Menu(args);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
                Console.ReadKey(true);
            }
        }
Ejemplo n.º 2
0
 protected bool Equals(PreStart other)
 {
     return(Equals(Source, other.Source));
 }
Ejemplo n.º 3
0
        //private Config _config;

        public void Main(string[] args)
        {
            try
            {
                //_config = new Config();

                AppDomain.CurrentDomain.AssemblyResolve += delegate(object sender, ResolveEventArgs sargs)
                {
                    var asm = typeof(Terraria.Program).Assembly;

                    var resourceName = new AssemblyName(sargs.Name).Name + ".dll";
                    var text         = Array.Find(asm.GetManifestResourceNames(), (string element) => element.EndsWith(resourceName));
                    if (text == null)
                    {
                        return(null);
                    }

                    using (Stream manifestResourceStream = asm.GetManifestResourceStream(text))
                    {
                        var array = new byte[manifestResourceStream.Length];
                        manifestResourceStream.Read(array, 0, array.Length);
                        return(Assembly.Load(array));
                    }
                };

                Console.BackgroundColor = ConsoleColor.White;
                Console.ForegroundColor = ConsoleColor.DarkCyan;
                Console.Clear();

                Console.WriteLine("OTAPI Test Launcher.");

                //var options = new NDesk.Options.OptionSet()
                //		.Add("as:|auto-start:", x => _config.AutoStart = true);
                //options.Parse(args);

                //AttachHooks();
                PreStart?.Invoke(this, EventArgs.Empty);

                /*if (_config.AutoStart)
                 *                      StartGame(args);
                 *              else */
                Menu(args);
            }
            catch (Exception ex)
            {
                try
                {
                    StackTrace st         = new System.Diagnostics.StackTrace(ex);
                    string     stackTrace = "";
                    foreach (StackFrame frame in st.GetFrames())
                    {
                        stackTrace = "at " + frame.GetMethod().Module.Name + "." +
                                     frame.GetMethod().ReflectedType.Name + "."
                                     + frame.GetMethod().Name
                                     + "  (IL offset: 0x" + frame.GetILOffset().ToString("x") + ")\n" + stackTrace;
                    }
                    Console.Write(stackTrace);
                    Console.WriteLine(ex);
                }
                catch
                {
                    Console.Write("");
                    Console.WriteLine(ex);
                }
                Console.ReadKey(true);
            }
        }