Exemplo n.º 1
0
        private async void Window_Loaded(object sender, RoutedEventArgs e)
        {
            if (Process.GetProcessesByName("MapleStory").Length > 0 ||
                Process.GetProcessesByName("NGM").Length > 0)
            {
                var mbr = MessageBox.Show("You are already playing MapleStory! Continue?", "Verdant", MessageBoxButton.YesNo, MessageBoxImage.Exclamation);
                if (mbr == MessageBoxResult.No)
                {
                    Close();
                    return;
                }
            }

            mapleIdLabel.Content = "Loading...";


            // NAVER LOGIN
            // check for preexist login data, and verify if session still valid
            // or, if new, show the dialog!
            // we need to run the async function synchronously - not the greatest but we'll just do this for now
            if (Account.Preloaded)
            {
                await checkAccountLogin();

                if (!Account.LoggedIn)
                {
                    (new LoginNew(Account)).ShowDialog();
                }
            }
            else
            {
                (new LoginNew(Account)).ShowDialog();
            }

            if (!Account.LoggedIn)
            {
                Close();
                return;
            }

            statusLabel.Content = "Logged in.";


            // MAPLE LOGIN/CHANNEL
            Maple = new MapleGame(Account);

            try
            {
                await Maple.Init();
            }
            catch (MapleGame.MapleNotFoundException)
            {
                MessageBox.Show("Looks like we couldn't find your installation of MapleStory! Make sure you have KMS + NGM installed properly!");
                Close();
                return;
            }
            catch (MapleGame.ChannelingRequiredException)
            {
                mapleIdLabel.Content = "Loading... (channeling)";
                try
                {
                    await Maple.Channel();
                }
                catch
                {
                    MessageBox.Show("Error channeling with Nexon and your Naver account. Please try again later.");
                    Close();
                    return;
                }
            }
            catch
            {
                MessageBox.Show("Error connecting to Maple right now, or you have not made a Maple ID! Please try again later.");
                Close();
                return;
            }

            mapleIdLabel.Content = "Web Main Character (대표 캐릭터): " + Maple.MainCharName;

            if (Maple.CharacterImageUrl != null)
            {
                charImage.Source = Tools.UrlToXamlImage(Maple.CharacterImageUrl);
            }

            changeMapleIdButton.IsEnabled = true;
            startButton.IsEnabled         = true;
        }
Exemplo n.º 2
0
        private async void Window_Loaded(object sender, RoutedEventArgs e)
        {
            mapleIdLabel.Content = "Loading...";

            string[] args       = Environment.GetCommandLineArgs();
            bool     loadCustom = false;

            if (args.Length > 1)
            {
                // custom form
                if (args[1].EndsWith(".dll"))
                {
                    loadCustom = true;
                }

                // custom cookie file
                else if (args[1].EndsWith(".vdt"))
                {
                    PathToCookies = args[1];
                }

                else
                {
                    QuickStart = args[1];
                }
            }



            // NAVER LOGIN
            // check for preexist login data, and verify if session still valid
            // or, if new, show the dialog!
            // we need to run the async function synchronously - not the greatest but we'll just do this for now
            if (Account.Preloaded)
            {
                await checkAccountLogin();

                if (!Account.LoggedIn)
                {
                    (new LoginNew(Account)).ShowDialog();
                }
            }
            else
            {
                (new LoginNew(Account)).ShowDialog();
            }

            if (!Account.LoggedIn)
            {
                Close();
                return;
            }

            statusLabel.Content = "Logged in.";


            // custom form post-login load
            if (loadCustom)
            {
                Assembly asm = Assembly.LoadFile(Path.GetFullPath(args[1]));
                Type     t   = asm.GetExportedTypes().First(a => typeof(Window).IsAssignableFrom(a));

                Window w = (Window)Activator.CreateInstance(t, Account);
                w.Title += " (powered by Verdant)";

                w.Show();
                Close();
                return;
            }


            // MAPLE LOGIN/CHANNEL
            if (Process.GetProcessesByName("MapleStory").Length > 0 ||
                Process.GetProcessesByName("NGM").Length > 0)
            {
                var mbr = MessageBox.Show("You are already playing MapleStory! Continue?", "Verdant", MessageBoxButton.YesNo, MessageBoxImage.Exclamation);
                if (mbr == MessageBoxResult.No)
                {
                    Close();
                    return;
                }
            }

            Maple = new MapleGame(Account);

            try
            {
                await Maple.Init();
            }
            catch (VerdantException.GameNotFoundException)
            {
                MessageBox.Show("Looks like we couldn't find your installation of MapleStory! Make sure you have KMS + NGM installed properly!");
                Close();
                return;
            }
            catch (VerdantException.ChannelingRequiredException)
            {
                mapleIdLabel.Content = "Loading... (channeling)";
                try
                {
                    await Maple.Channel();
                }
                catch
                {
                    MessageBox.Show("Error channeling with Nexon and your Naver account. Please try again later.");
                    Close();
                    return;
                }
            }
            catch
            {
                MessageBox.Show("Error connecting to Maple right now, or you have not made a Maple ID! Please try again later.");
                Close();
                return;
            }


            if (QuickStart != null)
            {
                mapleIdLabel.Content = "Quickstarting...";
                startGame();
                return;
            }

            mapleIdLabel.Content = "Web Main Character (대표 캐릭터): " + Maple.MainCharName;

            if (Maple.CharacterImageUrl != null)
            {
                charImage.Source = Tools.UrlToXamlImage(Maple.CharacterImageUrl);
            }


            toggleUi(true);
        }