Esempio n. 1
0
        public static TerrariaWrapper Initialize()
        {
            Thread.CurrentThread.Name = "Main Thread";

            // Program.LaunchParameters = Utils.ParseArguements(args);
            //ThreadPool.SetMinThreads(8, 8);
            LanguageManager.Instance.SetLanguage(GameCulture.DefaultCulture);
            //Program.InitializeConsoleOutput();
            //Program.SetupLogging();
            //Platform.Get<IWindowService>().SetQuickEditEnabled(false);
            var main = new TerrariaWrapper();

            try
            {
                Lang.InitializeLegacyLocalization();
                SocialAPI.Initialize(null);
                LaunchInitializer.LoadParameters(main);
                Task.Factory.StartNew(() => main.DedServ());
                //main.Run();
                return(main);
            }
            catch (Exception exception)
            {
            }
            return(null);
        }
Esempio n. 2
0
 public static void LaunchGame(string[] args, bool monoArgs = false)
 {
     Thread.CurrentThread.Name = "Main Thread";
     if (monoArgs)
     {
         args = Utils.ConvertMonoArgsToDotNet(args);
     }
     if (false)
     {
         Main.OnEngineLoad += delegate
         {
             Main.instance.IsMouseVisible = false;
         };
     }
     LaunchParameters = Utils.ParseArguements(args);
     ThreadPool.SetMinThreads(8, 8);
     LanguageManager.Instance.SetLanguage(GameCulture.DefaultCulture);
     InitializeConsoleOutput();
     SetupLogging();
     //Platform.Get<IWindowService>().SetQuickEditEnabled(false);
     using Main main = new Main();
     try
     {
         Lang.InitializeLegacyLocalization();
         //SocialAPI.Initialize();
         LaunchInitializer.LoadParameters(main);
         Main.OnEnginePreload += StartForceLoad;
         main.Run();
     }
     catch (Exception e)
     {
         DisplayException(e);
     }
 }
Esempio n. 3
0
 public static void LaunchGame(string[] args, bool monoArgs = false)
 {
     if (monoArgs)
     {
         args = Utils.ConvertMonoArgsToDotNet(args);
     }
     if (Platform.get_IsOSX())
     {
         Main.OnEngineLoad += (Action)(() => Main.instance.set_IsMouseVisible(false));
     }
     Program.LaunchParameters = Utils.ParseArguements(args);
     ThreadPool.SetMinThreads(8, 8);
     LanguageManager.Instance.SetLanguage(GameCulture.English);
     Program.SetupLogging();
     using (Main game = new Main())
     {
         try
         {
             Program.InitializeConsoleOutput();
             Lang.InitializeLegacyLocalization();
             SocialAPI.Initialize(new SocialMode?());
             LaunchInitializer.LoadParameters(game);
             Main.OnEnginePreload += new Action(Program.StartForceLoad);
             game.Run();
         }
         catch (Exception ex)
         {
             Program.DisplayException(ex);
         }
     }
 }
Esempio n. 4
0
        public static TerrariaWrapper Initialize()
        {
            Thread.CurrentThread.Name = "Main Thread";

            var terrariaAsm = typeof(Terraria.Program).Assembly;

            //var init = typeof(Terraria.Program).GetMethod("ForceLoadAssembly", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Static, null, new Type[] { typeof(Assembly), typeof(bool) }, null);
            //init.Invoke((object)null, new object[] { terrariaAsm, true });
            // Program.LaunchParameters = Utils.ParseArguements(args);
            //ThreadPool.SetMinThreads(8, 8);
            LanguageManager.Instance.SetLanguage(GameCulture.DefaultCulture);
            //Program.InitializeConsoleOutput();
            //Program.SetupLogging();
            //Platform.Get<IWindowService>().SetQuickEditEnabled(false);
            var main = new TerrariaWrapper();

            try
            {
                Lang.InitializeLegacyLocalization();
                SocialAPI.Initialize(null);
                LaunchInitializer.LoadParameters(main);
                main.InitBase();
                //Task.Factory.StartNew(() => main.DedServ());
                //Thread.Sleep(10000);
                //main.Run();
                return(main);
            }
            catch (Exception exception)
            {
            }
            return(null);
        }
Esempio n. 5
0
 public static void LaunchGame(string[] args)
 {
     LaunchParameters = Utils.ParseArguements(args);
     using (Main main = new Main())
     {
         try
         {
             SocialAPI.Initialize();
             LaunchInitializer.LoadParameters(main);
             main.DedServ();
         }
         catch (Exception e)
         {
             DisplayException(e);
         }
     }
 }
Esempio n. 6
0
        internal static int Launch(string[] args)
        {
            try
            {
                ReadCommandLineArgs(CommandLineArgs.Parse(args, ShortToLongArgs));
            }
            catch (Exception e)
            {
                Console.Error.WriteLine("An error occured during command-line argument parsing:");
                Console.Error.WriteLine(e);

                return(ExceptionHandler.GetHResult(e));
            }

            using (var m = new TMain())
            {
                SocialAPI.Initialize(SteamExists() ? SocialMode.Steam : SocialMode.None);
                LaunchInitializer.LoadParameters(m);

                PrismDebug.Init();

                try
                {
                    T.Main.OnEngineLoad += () =>
                    {
                        T.Program.StartForceLoad();

                        ////TODO: move this to another thread (in StartForceLoad)
                        // not really needed, prism is quite small, compared to terraria (and it doesn't have any HUGE methods ;) )
#if !DEV_BUILD
                        //T.Program.ForceLoadAssembly(Assembly.GetExecutingAssembly() /* Prism */, true);
#endif
                    };

                    m.Run();
                }
                catch (Exception e)
                {
                    ExceptionHandler.HandleFatal(e, false);
                }
            }

            return(0);
        }
Esempio n. 7
0
 public static void LaunchGame(string[] args)
 {
     Program.LaunchParameters = Utils.ParseArguements(args);
     ThreadPool.SetMinThreads(8, 8);
     LanguageManager.Instance.SetLanguage("English");
     using (Main game = new Main())
     {
         try
         {
             SocialAPI.Initialize(new SocialMode?());
             LaunchInitializer.LoadParameters(game);
             Main.OnEnginePreload += (Action)(() => Program.StartForceLoad());
             game.Run();
         }
         catch (Exception ex)
         {
             Program.DisplayException(ex);
         }
     }
 }
Esempio n. 8
0
 public static void LaunchGame(string[] args, bool monoArgs = false)
 {
     if (monoArgs)
     {
         args = Utils.ConvertMonoArgsToDotNet(args);
     }
     if (Platform.get_IsOSX())
     {
         // ISSUE: reference to a compiler-generated field
         if (Program.CS\u0024\u003C\u003E9__CachedAnonymousMethodDelegate5 == null)
         {
             // ISSUE: reference to a compiler-generated field
             // ISSUE: method pointer
             Program.CS\u0024\u003C\u003E9__CachedAnonymousMethodDelegate5 = new Action((object)null, __methodptr(\u003CLaunchGame\u003Eb__4));
         }
         // ISSUE: reference to a compiler-generated field
         Main.OnEngineLoad += Program.CS\u0024\u003C\u003E9__CachedAnonymousMethodDelegate5;
     }
     Program.LaunchParameters = Utils.ParseArguements(args);
     ThreadPool.SetMinThreads(8, 8);
     LanguageManager.Instance.SetLanguage(GameCulture.English);
     Program.SetupLogging();
     using (Main game = new Main())
     {
         try
         {
             Program.InitializeConsoleOutput();
             Lang.InitializeLegacyLocalization();
             SocialAPI.Initialize(new SocialMode?());
             LaunchInitializer.LoadParameters(game);
             // ISSUE: method pointer
             Main.OnEnginePreload += new Action((object)null, __methodptr(StartForceLoad));
             game.DedServ();
         }
         catch (Exception ex)
         {
             Program.DisplayException(ex);
         }
     }
 }
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            Activity1.assets = this.Assets;

            /*Stream s = (assets.Open("Content/Sound Bank.xsb"));
             * FileStream f1 = new FileStream("/sdcard/Sound Bank.xsb", FileMode.Create, FileAccess.Write, FileShare.None);
             * BinaryReader f2 = new BinaryReader(s);
             * byte _b;
             * for (int i = 0; i < f2.; i++)
             * {
             *  _b = f2.ReadByte();
             *  f1.WriteByte(_b);
             * }
             *
             *
             *
             *
             * f1.Close();
             * f2.Close();*/
            RequestedOrientation = ScreenOrientation.Landscape;
            RequestPermissions(new string[]
            {
                Manifest.Permission.ReadExternalStorage,
                Manifest.Permission.WriteExternalStorage
            }, 0);
            if (!System.IO.Directory.Exists("/sdcard/Content"))
            {
                string[] fileNames = assets.List("");
                foreach (string fileName in fileNames)
                {
                    try
                    {
                        Android.Util.Log.WriteLine(Android.Util.LogPriority.Error, "terraria", fileName);

                        /*using (StreamReader sr = new StreamReader(assets.Open(fileName)))
                         * {
                         *  string line;
                         *  using (StreamWriter sw = new StreamWriter("/sdcard/" + fileName))
                         *  {
                         *      line = sr.ReadToEnd();
                         *
                         *       sw.Write(line);
                         *
                         *  }
                         * }*/
                        Stream       stream = (assets.Open(fileName));
                        FileStream   fs2    = new FileStream("/sdcard/" + fileName, FileMode.Create, FileAccess.Write, FileShare.None);
                        BinaryReader fs1    = new BinaryReader(stream);
                        byte         new_b;
                        while (true)
                        {
                            try
                            {
                                new_b = fs1.ReadByte();
                                fs2.WriteByte(new_b);
                            }
                            catch (Exception esub)
                            {
                                fs1.Close();
                                fs2.Close();
                                break;
                            }
                        }
                    }
                    catch (Exception e)
                    {
                        System.IO.Directory.CreateDirectory("/sdcard/" + fileName);
                        string[] subDirFileNames1 = assets.List(fileName);
                        foreach (string subDirFileName1 in subDirFileNames1)
                        {
                            try
                            {
                                Android.Util.Log.WriteLine(Android.Util.LogPriority.Error, "terraria", fileName + "/" + subDirFileName1);

                                /*using (StreamReader sr1 = new StreamReader(assets.Open(fileName + "/" + subDirFileName1)))
                                 * {
                                 *  string line1;
                                 *  using (StreamWriter sw1 = new StreamWriter("/sdcard/" + fileName + "/" + subDirFileName1))
                                 *  {
                                 *      line1 = sr1.ReadToEnd();
                                 *
                                 *      sw1.Write(line1);
                                 *  }
                                 * }*/
                                Stream       stream = (assets.Open(fileName + "/" + subDirFileName1));
                                FileStream   fs2    = new FileStream("/sdcard/" + fileName + "/" + subDirFileName1, FileMode.Create, FileAccess.Write, FileShare.None);
                                BinaryReader fs1    = new BinaryReader(stream);
                                byte         new_b;
                                while (true)
                                {
                                    try
                                    {
                                        new_b = fs1.ReadByte();
                                        fs2.WriteByte(new_b);
                                    }
                                    catch (Exception esub)
                                    {
                                        fs1.Close();
                                        fs2.Close();
                                        break;
                                    }
                                }
                            }
                            catch (Exception e1)
                            {
                                System.IO.Directory.CreateDirectory("/sdcard/" + fileName + "/" + subDirFileName1);
                                string[] subDirFileNames2 = assets.List(fileName + "/" + subDirFileName1);
                                foreach (string subDirFileName2 in subDirFileNames2)
                                {
                                    try
                                    {
                                        Android.Util.Log.WriteLine(Android.Util.LogPriority.Error, "terraria", fileName + "/" + subDirFileName1 + "/" + subDirFileName2);

                                        /*using (StreamReader sr2 = new StreamReader(assets.Open(fileName + "/" + subDirFileName1 + "/" + subDirFileName2)))
                                         * {
                                         *  string line2;
                                         *  using (StreamWriter sw2 = new StreamWriter("/sdcard/" + fileName + "/" + subDirFileName1 + "/" + subDirFileName2))
                                         *  {
                                         *      line2 = sr2.ReadToEnd();
                                         *
                                         *      sw2.Write(line2);
                                         *  }
                                         * }*/
                                        Stream       stream = (assets.Open(fileName + "/" + subDirFileName1 + "/" + subDirFileName2));
                                        FileStream   fs2    = new FileStream("/sdcard/" + fileName + "/" + subDirFileName1 + "/" + subDirFileName2, FileMode.Create, FileAccess.Write, FileShare.None);
                                        BinaryReader fs1    = new BinaryReader(stream);
                                        byte         new_b;
                                        while (true)
                                        {
                                            try
                                            {
                                                new_b = fs1.ReadByte();
                                                fs2.WriteByte(new_b);
                                            }
                                            catch (Exception esub)
                                            {
                                                fs1.Close();
                                                fs2.Close();
                                                break;
                                            }
                                        }
                                    }
                                    catch (Exception e2)
                                    {
                                        System.IO.Directory.CreateDirectory("/sdcard/" + fileName + "/" + subDirFileName1 + "/" + subDirFileName2);
                                        string[] subDirFileNames3 = assets.List(fileName + "/" + subDirFileName1 + "/" + subDirFileName2);
                                        foreach (string subDirFileName3 in subDirFileNames3)
                                        {
                                            try
                                            {
                                                Android.Util.Log.WriteLine(Android.Util.LogPriority.Error, "terraria", fileName + "/" + subDirFileName1 + "/" + subDirFileName2 + "/" + subDirFileName3);

                                                /*using (StreamReader sr3 = new StreamReader(assets.Open(fileName + "/" + subDirFileName1 + "/" + subDirFileName2 + "/" + subDirFileName3)))
                                                 * {
                                                 *  string line3;
                                                 *  using (StreamWriter sw3 = new StreamWriter("/sdcard/" + fileName + "/" + subDirFileName1 + "/" + subDirFileName2 + "/" + subDirFileName3))
                                                 *  {
                                                 *      line3 = sr3.ReadToEnd();
                                                 *
                                                 *      sw3.Write(line3);
                                                 *  }
                                                 * }*/
                                                Stream       stream = (assets.Open(fileName + "/" + subDirFileName1 + "/" + subDirFileName2 + "/" + subDirFileName3));
                                                FileStream   fs2    = new FileStream("/sdcard/" + fileName + "/" + subDirFileName1 + "/" + subDirFileName2 + "/" + subDirFileName3, FileMode.Create, FileAccess.Write, FileShare.None);
                                                BinaryReader fs1    = new BinaryReader(stream);
                                                byte         new_b;
                                                while (true)
                                                {
                                                    try
                                                    {
                                                        new_b = fs1.ReadByte();
                                                        fs2.WriteByte(new_b);
                                                    }
                                                    catch (Exception esub)
                                                    {
                                                        fs1.Close();
                                                        fs2.Close();
                                                        break;
                                                    }
                                                }
                                            }
                                            catch (Exception e3)
                                            {
                                                System.IO.Directory.CreateDirectory("/sdcard/" + fileName + "/" + subDirFileName1 + "/" + subDirFileName2 + "/" + subDirFileName3);
                                                string[] subDirFileNames4 = assets.List(fileName + "/" + subDirFileName1 + "/" + subDirFileName2 + "/" + subDirFileName3);
                                                foreach (string subDirFileName4 in subDirFileNames4)
                                                {
                                                    try
                                                    {
                                                        Android.Util.Log.WriteLine(Android.Util.LogPriority.Error, "terraria", fileName + "/" + subDirFileName1 + "/" + subDirFileName2 + "/" + subDirFileName3 + "/" + subDirFileName4);

                                                        /*using (StreamReader sr4 = new StreamReader(assets.Open(fileName + "/" + subDirFileName1 + "/" + subDirFileName2 + "/" + subDirFileName3 + "/" + subDirFileName4)))
                                                         * {
                                                         *  string line4;
                                                         *  using (StreamWriter sw4 = new StreamWriter("/sdcard/" + fileName + "/" + subDirFileName1 + "/" + subDirFileName2 + "/" + subDirFileName3 + "/" + subDirFileName4))
                                                         *  {
                                                         *      line4 = sr4.ReadToEnd();
                                                         *
                                                         *      sw4.Write(line4);
                                                         *  }
                                                         * }*/
                                                        Stream       stream = (assets.Open(fileName + "/" + subDirFileName1 + "/" + subDirFileName2 + "/" + subDirFileName3 + "/" + subDirFileName4));
                                                        FileStream   fs2    = new FileStream("/sdcard/" + fileName + "/" + subDirFileName1 + "/" + subDirFileName2 + "/" + subDirFileName3 + "/" + subDirFileName4, FileMode.Create, FileAccess.Write, FileShare.None);
                                                        BinaryReader fs1    = new BinaryReader(stream);
                                                        byte         new_b;
                                                        while (true)
                                                        {
                                                            try
                                                            {
                                                                new_b = fs1.ReadByte();
                                                                fs2.WriteByte(new_b);
                                                            }
                                                            catch (Exception esub)
                                                            {
                                                                fs1.Close();
                                                                fs2.Close();
                                                                break;
                                                            }
                                                        }
                                                    }
                                                    catch (Exception e4)
                                                    {
                                                        System.IO.Directory.CreateDirectory("/sdcard/" + fileName + "/" + subDirFileName1 + "/" + subDirFileName2 + "/" + subDirFileName3 + "/" + subDirFileName4);
                                                        string[] subDirFileNames5 = assets.List(fileName + "/" + subDirFileName1 + "/" + subDirFileName2 + "/" + subDirFileName3 + "/" + subDirFileName4);
                                                        foreach (string subDirFileName5 in subDirFileNames5)
                                                        {
                                                            try
                                                            {
                                                                Android.Util.Log.WriteLine(Android.Util.LogPriority.Error, "terraria", fileName + "/" + subDirFileName1 + "/" + subDirFileName2 + "/" + subDirFileName3 + "/" + subDirFileName4 + "/" + subDirFileName5);

                                                                /*using (StreamReader sr5 = new StreamReader(assets.Open(fileName + "/" + subDirFileName1 + "/" + subDirFileName2 + "/" + subDirFileName3 + "/" + subDirFileName4 + "/" + subDirFileName5)))
                                                                 * {
                                                                 *  string line5;
                                                                 *  using (StreamWriter sw5 = new StreamWriter("/sdcard/" + fileName + "/" + subDirFileName1 + "/" + subDirFileName2 + "/" + subDirFileName3 + "/" + subDirFileName4 + "/" + subDirFileName5))
                                                                 *  {
                                                                 *      line5 = sr5.ReadToEnd();
                                                                 *
                                                                 *      sw5.Write(line5);
                                                                 *  }
                                                                 * }*/

                                                                Stream       stream = (assets.Open(fileName + "/" + subDirFileName1 + "/" + subDirFileName2 + "/" + subDirFileName3 + "/" + subDirFileName4 + "/" + subDirFileName5));
                                                                FileStream   fs2    = new FileStream("/sdcard/" + fileName + "/" + subDirFileName1 + "/" + subDirFileName2 + "/" + subDirFileName3 + "/" + subDirFileName4 + "/" + subDirFileName5, FileMode.Create, FileAccess.Write, FileShare.None);
                                                                BinaryReader fs1    = new BinaryReader(stream);
                                                                byte         new_b;
                                                                while (true)
                                                                {
                                                                    try
                                                                    {
                                                                        new_b = fs1.ReadByte();
                                                                        fs2.WriteByte(new_b);
                                                                    }
                                                                    catch (Exception esub)
                                                                    {
                                                                        fs1.Close();
                                                                        fs2.Close();
                                                                        break;
                                                                    }
                                                                }
                                                            }
                                                            catch (Exception e5)
                                                            {
                                                                System.IO.Directory.CreateDirectory("/sdcard/" + fileName + "/" + subDirFileName1 + "/" + subDirFileName2 + "/" + subDirFileName3 + "/" + subDirFileName4 + "/" + subDirFileName5);
                                                                string[] subDirFileNames6 = assets.List(fileName + "/" + subDirFileName1 + "/" + subDirFileName2 + "/" + subDirFileName3 + "/" + subDirFileName4 + "/" + subDirFileName5);
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }

            Main main = new Main();

            try
            {
                Lang.InitializeLegacyLocalization();
                //SocialAPI.Initialize();
                LaunchInitializer.LoadParameters(main);
                _view = main.Services.GetService(typeof(View)) as View;
                Main.OnEnginePreload += StartForceLoad;
                SetContentView(_view);
                main.Run();
            }
            catch (Exception e)
            {
                //DisplayException(e);
            }

            /*Thread.CurrentThread.Name = "Main Thread";
             * if (monoArgs)
             * {
             *  args = Utils.ConvertMonoArgsToDotNet(args);
             * }*/
            if (false)
            {
                Main.OnEngineLoad += delegate
                {
                    Main.instance.IsMouseVisible = false;
                };
            }
            //LaunchParameters = Utils.ParseArguements(args);
            //ThreadPool.SetMinThreads(8, 8);
            //LanguageManager.Instance.SetLanguage(GameCulture.DefaultCulture);
            //InitializeConsoleOutput();
            //SetupLogging();
            //Platform.Get<IWindowService>().SetQuickEditEnabled(false);

            /*using Main main = new Main();
             * try
             * {
             *  //Lang.InitializeLegacyLocalization();
             *  //SocialAPI.Initialize();
             *  //LaunchInitializer.LoadParameters(main);
             *  _view = main.Services.GetService(typeof(View)) as View;
             *
             *  SetContentView(_view);
             *  //Main.OnEnginePreload += StartForceLoad;
             *  main.Run();
             * }
             * catch (Exception e)
             * {
             *  //DisplayException(e);
             * }*/
            /*Game1 main = new Game1();
             * try
             * {
             *  //Lang.InitializeLegacyLocalization();
             *  //SocialAPI.Initialize();
             *  //LaunchInitializer.LoadParameters(main);
             *  _view = main.Services.GetService(typeof(View)) as View;
             *
             *  SetContentView(_view);
             *  main.Run();
             * }
             * catch (Exception e)
             * {
             *  //DisplayException(e);
             * }*/
        }