예제 #1
0
        static void Main(string[] args)
        {
            AppDomain.CurrentDomain.UnhandledException += OnUnhandledException;

            foreach(string arg in args)
            {
                if (arg == "-r")
                {
                    int timeout = 0;
                    while (LauncherHelper.checkInstance())
                    {
                        if (timeout == 3)
                        {
                            if (MessageBox.Show(LanguageManager.Translation.pmsbProgRun) == DialogResult.OK)
                            {
                                return;
                            }
                        }
                        Thread.Sleep(500);
                        timeout++;
                    }
                }
            }

            Config = new Configuration();
            Config.Load(Program.ConfigurationFilename);

            if (File.Exists("ygopro_vs.exe") && !File.Exists("devpro.dll"))
            {
                File.Copy("ygopro_vs.exe", "devpro.dll");
                File.Delete("ygopro_vs.exe");
                Config.GameExe = "devpro.dll";
                Config.Save(ConfigurationFilename);
            }

            LanguageManager = new LanguageManager();
            //LanguageManager.Save("English");
            LanguageManager.Load(Config.Language);

            if (LauncherHelper.checkInstance())
                if (MessageBox.Show(LanguageManager.Translation.pmsbProgRun) == DialogResult.OK)
                    return;

            UserInfo = new UserData();
            ServerConnection = new NetClient();

            if (!Config.DebugMode)
            {
                if (CheckUpdates())
                    return;

                CheckServerInfo();
            }

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            LoginService = new Authenticator(Config.DefaultUsername, Config.Password, ServerConnection, UserInfo);

            if(!ServerConnection.Connect(Config.ServerAddress, Config.ServerPort))
            {
                MessageBox.Show(LanguageManager.Translation.pMsbErrorToServer);
            }

            if (Config.AutoLogin && Config.DefaultUsername.Length < 15)
            {

                LoginService.Authenticate();
                Thread.Sleep(2000);
            }

            if (UserInfo.Username == "" && UserInfo.LoginKey == "")
            {
                LoginWindow = new Login_frm(Config, ServerConnection, LoginService);

                if (LoginWindow.ShowDialog() != DialogResult.OK)
                {
                    return;
                }
            }

            if (!ServerConnection.IsConnected)
            {
                return;
            }

            if (UserInfo.Username != "" && UserInfo.LoginKey != "")
                Application.Run(new Main_frm());
            else
            {
                Config.AutoLogin = false;
                Config.Save(ConfigurationFilename);
                MessageBox.Show(LanguageManager.Translation.pMsbBadLog);
            }
        }
예제 #2
0
        static void Main(string[] args)
        {
            bool forcelogin = false;
            foreach(string arg in args)
            {
                if (arg == "-r")
                {
                    int timeout = 0;
                    while (LauncherHelper.checkInstance())
                    {
                        if (timeout == 3)
                        {
                            if (MessageBox.Show(LanguageManager.Translation.pmsbProgRun) == DialogResult.OK)
                            {
                                return;
                            }
                        }
                        Thread.Sleep(500);
                        timeout++;
                    }
                }
                if (arg == "-l")
                {
                    forcelogin = true;
                }
            }

            Config = new Configuration();
            LoadConfig(Program.ConfigurationFilename);
            #if DEBUG
            Config.DebugMode = true;
            #endif

            //if (Config.ConfigReset181000)
            //{
            //    if (MessageBox.Show("Major changes were made this update and requires user settings to be reset.") == DialogResult.OK)
            //    {
            //        Config = new Configuration();
            //        Config.ConfigReset181000 = false;
            //        SaveConfig(ConfigurationFilename, Config);
            //        Process process = new Process();
            //        ProcessStartInfo startInfos = new ProcessStartInfo(Application.ExecutablePath, "-r");
            //        process.StartInfo = startInfos;
            //        process.Start();
            //        Application.Exit();
            //    }
            //}
            //new update server - Forced change to prevent resting a users config
            Config.UpdaterAddress = "http://ygopro.de/launcher/checkversion.php";
            Config.ServerInfoAddress = "http://ygopro.de/launcher/serverinfo.php";

            if (!Config.DebugMode)
               AppDomain.CurrentDomain.UnhandledException += OnUnhandledException;

            if (forcelogin)
            {
                Config.AutoLogin = false;
            }

            LanguageManager = new LanguageManager();
            //LanguageManager.Save("English");
            LanguageManager.Load(Config.Language);

            if (LauncherHelper.checkInstance())
                if (MessageBox.Show(LanguageManager.Translation.pmsbProgRun) == DialogResult.OK)
                    return;

            UserInfo = new UserData();
            ServerConnection = new NetClient();

            if (!Config.DebugMode)
            {
                if (CheckUpdates())
                    return;

                CheckServerInfo();
            }

            #if DEBUG
            ServerList.Add(new Server() { ServerName = "Debug", ServerAddress = "86.0.24.143", ServerPort = 7922, GamePort = 7911, ChatAddress = "86.0.24.143", ChatPort = 6666 });
            #endif
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            if (Program.Config.NewUpdate)
            {
                LauncherHelper.CardManager = new CardDatabase.CardsManager();
                LauncherHelper.CardManager.Init();
                if (LauncherHelper.CardManager.Loaded)
                {
                    FileCleaner cleaner = new FileCleaner();
                    cleaner.ShowDialog();
                }
            }

            Server serverinfo = null;

            foreach (Server server in ServerList)
            {
                if (server.ServerName == Config.DefaultServer)
                {
                    serverinfo = server;
                     Config.ServerAddress = serverinfo.ServerAddress; Config.GamePort = serverinfo.GamePort; Config.ServerPort = serverinfo.ServerPort;
                     Config.ChatServerAddress = serverinfo.ChatAddress; Config.ChatPort = serverinfo.ChatPort; Config.ServerName = serverinfo.ServerName;
                }
            }

            LoginService = new Authenticator(Config.DefaultUsername, Config.Password, ServerConnection, UserInfo);

            if (serverinfo != null)
            {
                if (!ServerConnection.Connect(Config.ServerName,Config.ServerAddress, Config.ServerPort))
                {
                    MessageBox.Show(LanguageManager.Translation.pMsbErrorToServer);
                }

                if (Config.AutoLogin && Config.DefaultUsername.Length < 15)
                {

                    LoginService.Authenticate();
                    Thread.Sleep(2000);
                }
            }

            if (UserInfo.Username == "" && UserInfo.LoginKey == "")
            {
                LoginWindow = new Login_frm(Config, ServerConnection, LoginService);

                if (LoginWindow.ShowDialog() != DialogResult.OK)
                {
                    return;
                }
            }

            if (!ServerConnection.IsConnected)
            {
                return;
            }

            if (UserInfo.Username != "" && UserInfo.LoginKey != "")
            {
                if(forcelogin)
                    LoadConfig(ConfigurationFilename);
                MainForm = new Main_frm();
                Application.Run(MainForm);
            }
            else
            {
                Config.AutoLogin = false;
                SaveConfig(ConfigurationFilename, Config);
                MessageBox.Show(LanguageManager.Translation.pMsbBadLog);
            }
        }