Ejemplo n.º 1
0
        public void SaveSelectedTabToSettings(TabName t)
        {
            //save last tab
            var tab = t.ToString();

            LauncherSettings.SetValue(LauncherSettings.LAUNCHER_TAB, tab);
        }
Ejemplo n.º 2
0
        public PatchForm()
        {
            InitializeComponent();

            CurrentlyLoading = true;

            string gameFolder = LauncherSettings.GetValue(LauncherSettings.GAME_FOLDER);

            if (gameFolder != null)
            {
                tbGameDirectory.Text = gameFolder;

                UnlockPatchInterface();
            }
            else
            {
                LockPatchInterface();
            }

            btnRefreshAvailablePatches_Click(null, null);

            var exitlag = LauncherSettings.GetValue(LauncherSettings.EXITLAG);

            if (exitlag == "true")
            {
                cbExitLag.Checked = true;
            }


            CurrentlyLoading = false;
        }
Ejemplo n.º 3
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            //Restores the last opened tab
            string lastTab = LauncherSettings.GetValue(LauncherSettings.LAUNCHER_TAB);

            if (lastTab != null)
            {
                var tab = tabControl.TabPages.OfType <TabPage>().FirstOrDefault(o => o.Text == lastTab);
                if (tab != null)
                {
                    tabControl.SelectedTab = tab;
                }
            }

            string gameFolder = LauncherSettings.GetValue(LauncherSettings.GAME_FOLDER);

            if (gameFolder != null)
            {
                tbGameDirectory.Text = gameFolder;
                UnlockPatchInterface();
            }
            else
            {
                LockPatchInterface();
            }

            btnRefreshAvailablePatches_Click(null, null);
        }
Ejemplo n.º 4
0
        private void btnDownloadInstall_Click(object sender, EventArgs e)
        {
            string downloadUrl = LauncherSettings.GetWebValue(LauncherSettings.INSTALLER_URL);
            string filename    = downloadUrl.Substring(downloadUrl.LastIndexOf('/') + 1);
            string tempPath    = Path.Combine(LauncherSettings.TempDir, filename);

            KillProcess(filename);


            /*
             * try
             * {
             *  WebClient wc = new WebClient();
             *  wc.DownloadFile(downloadUrl, tempPath);
             * }
             * catch(Exception ex)
             * {
             *  MessageBox.Show($"Failed to download {downloadUrl}\n\n{ex}");
             * }
             *
             * try
             * {
             *  Process.Start(tempPath);
             * }
             * catch { } //eat it
             */

            DownloadFile(downloadUrl, tempPath, null);
        }
Ejemplo n.º 5
0
        private void btnRefreshAvailablePatches_Click(object sender, EventArgs e)
        {
            string downloadUrl = $"{LauncherSettings.GetValue(LauncherSettings.PATCH_SERVER_ROOT)}/patchlist.php";

            try
            {
                var osVerMajor = System.Environment.OSVersion.Version.Major;
                var osVerMinor = System.Environment.OSVersion.Version.Minor;

                if (((osVerMajor <= 6) && (osVerMinor < 2)))
                { // OS Check for Win 7 SP1 (NT 6.2) or Lower
                    //MessageBox.Show(System.Environment.OSVersion.Version.ToString());
                    ServicePointManager.Expect100Continue = true;
                    ServicePointManager.SecurityProtocol  = SecurityProtocolType.Tls12;
                }

                WebClient wc        = new WebClient();
                string    patchlist = wc.DownloadString(downloadUrl);

                lbPatches.Items.Clear();

                foreach (var item in patchlist.Split('|'))
                {
                    if (!string.IsNullOrWhiteSpace(item))
                    {
                        lbPatches.Items.Add(item);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show($"Failed to list available patches\n\n{ex}");
            }
        }
Ejemplo n.º 6
0
        private void btnDownloadInstall_Click(object sender, EventArgs e)
        {
            string downloadUrl = LauncherSettings.GetWebValue(LauncherSettings.INSTALLER_URL);
            string filename    = downloadUrl.Substring(downloadUrl.LastIndexOf('/') + 1);
            string tempPath    = Path.Combine(LauncherSettings.TempDir, filename);

            KillProcess(filename);

            DownloadForm.DownloadFile(downloadUrl, tempPath, null);
        }
Ejemplo n.º 7
0
        private void btnGithub_Click(object sender, EventArgs e)
        {
            string githubUrl = LauncherSettings.GetWebValue(LauncherSettings.GITHUB_REPO);

            if (string.IsNullOrEmpty(githubUrl))
            {
                MessageBox.Show("Could not fetch the github url");
                return;
            }

            Process.Start(githubUrl);
        }
Ejemplo n.º 8
0
        private void btnTranslation_Click(object sender, EventArgs e)
        {
            string Url = LauncherSettings.GetWebValue(LauncherSettings.TRANSLATE_LINK);

            if (string.IsNullOrEmpty(Url))
            {
                MessageBox.Show("Could not fetch the translation url");
                return;
            }

            Process.Start(Url);
        }
Ejemplo n.º 9
0
        private void btnDiscord_Click(object sender, EventArgs e)
        {
            string Url = LauncherSettings.GetWebValue(LauncherSettings.DISCORD_LINK);

            if (string.IsNullOrEmpty(Url))
            {
                MessageBox.Show("Could not fetch the discord url");
                return;
            }

            Process.Start(Url);
        }
Ejemplo n.º 10
0
        private void btnGetKRFont_Click(object sender, EventArgs e)
        {
            string Url = LauncherSettings.GetWebValue(LauncherSettings.GOOGLE_FONT);

            if (string.IsNullOrEmpty(Url))
            {
                MessageBox.Show("Could not fetch the font url");
                return;
            }

            Process.Start(Url);
        }
Ejemplo n.º 11
0
        private void btnOpenGuide2_Click(object sender, EventArgs e)
        {
            string guideUrl = LauncherSettings.GetWebValue(LauncherSettings.GAME_GUIDE);

            if (string.IsNullOrEmpty(guideUrl))
            {
                MessageBox.Show("Could not fetch the guide url");
                return;
            }

            Process.Start(guideUrl);
        }
Ejemplo n.º 12
0
        public void lbPatches_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (lbPatches.SelectedIndex == -1)
            {
                lbPatchDescription.Text = "";
                lbPatchStatus.Text      = "";
                return;
            }


            string patchname           = lbPatches.SelectedItem.ToString();
            string patchDescriptionUrl = $"{LauncherSettings.GetValue(LauncherSettings.PATCH_SERVER_ROOT)}/{patchname}/description.txt";
            string patchDateUrl        = $"{LauncherSettings.GetValue(LauncherSettings.PATCH_SERVER_ROOT)}/{patchname}/patchdate.php";

            try
            {
                WebClient wc = new WebClient();
                string    patchDescription = wc.DownloadString(patchDescriptionUrl);

                lbPatchDescription.Text = patchDescription;
            }
            catch { } //eat it

            string installedPatchDate = LauncherSettings.GetValue(patchname);

            if (installedPatchDate == null)
            {
                lbPatchStatus.Text = "Not installed";
            }
            else
            {
                string serverPatchDate = null;

                try
                {
                    WebClient wc = new WebClient();
                    serverPatchDate = wc.DownloadString(patchDateUrl);
                }
                catch { } //eat it

                if (serverPatchDate == null)
                {
                    lbPatchStatus.Text = "Error fetching server patch date";
                }
                else
                {
                    string postText = (installedPatchDate == serverPatchDate ? "" : "\n(Update available)");
                    lbPatchStatus.Text = $"Installed patch date:\n{installedPatchDate}\n\nOnline patch date:\n{serverPatchDate}{postText}";
                }
            }
        }
Ejemplo n.º 13
0
        private void btnInstallPatch_Click(object sender, EventArgs e)
        {
            if (lbPatches.SelectedIndex == -1)
            {
                return;
            }


            string patchname    = lbPatches.SelectedItem.ToString();
            string patchPackUrl = $"{LauncherSettings.GetValue(LauncherSettings.PATCH_SERVER_ROOT)}/{patchname}/pack.zip";
            string tempFilename = Path.Combine(LauncherSettings.TempDir, "pack.zip");
            string ms2Folder    = tbGameDirectory.Text;

            DownloadForm.DownloadFile(patchPackUrl, tempFilename, ms2Folder);
        }
Ejemplo n.º 14
0
        private void cbExitLag_CheckedChanged(object sender, EventArgs e)
        {
            if (CurrentlyLoading)
            {
                return;
            }

            if (cbExitLag.Checked)
            {
                LauncherSettings.SetValue(LauncherSettings.EXITLAG, "true");
                Program.SwitchToExitlagIfNeeded();
            }
            else
            {
                LauncherSettings.SetValue(LauncherSettings.EXITLAG, "false");
            }
        }
Ejemplo n.º 15
0
        private void tabControl_Selected(object sender, TabControlEventArgs e)
        {
            //save last tab
            var tab = tabControl.SelectedTab;

            LauncherSettings.SetValue(LauncherSettings.LAUNCHER_TAB, tab.Text);

            //init the launch tab only if needed to save ressources on init loading
            if (tab.Text == "Launch" && bForm == null)
            {
                bForm                 = new BrowserForm();
                bForm.TopLevel        = false;
                bForm.FormBorderStyle = FormBorderStyle.None;
                tab.Controls.Add(bForm);
                bForm.Dock = DockStyle.Fill;
                bForm.Show();
            }
        }
Ejemplo n.º 16
0
        public static void SwitchToExitlagIfNeeded()
        {
            try
            {
                var currentFilename = System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName;
                var currentName     = new FileInfo(currentFilename).Name;

                var exitlag = LauncherSettings.GetValue(LauncherSettings.EXITLAG);
                if (exitlag == "true" && currentName != "gamestarter.exe")
                {
                    string gamestarterExePath = Path.Combine(LauncherSettings.AppDir, "gamestarter.exe");
                    File.Copy(currentFilename, gamestarterExePath, true);
                    Process.Start(gamestarterExePath);
                    Environment.Exit(0);
                }
            }
            catch { } //eat it
        }
Ejemplo n.º 17
0
        static void Main()
        {
            LauncherSettings.MakeSureFolderExists(LauncherSettings.AppDir);

            SwitchToExitlagIfNeeded();

            LauncherSettings.MakeSureFolderExists(LauncherSettings.TempDir);
            LauncherSettings.MakeSureFolderExists(LauncherSettings.PatchDir);

            CheckUpdateIEVersion();

            Arguments.GameId = "106498";

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

            Application.Run(new KMS2Launcher.MainForm());
            //Application.Run(new MainForm());
            //Application.Run(new BrowserForm());
        }
Ejemplo n.º 18
0
        public BrowserForm()
        {
            this.InitializeComponent();

            PageLoadedTimer.Interval = 500;
            PageLoadedTimer.Tick    += PageLoadedTimer_Tick;


            this.WebBrowser.Url = new Uri(Arguments.LoginRedirectUrl);

            this.ModeToolStripComboBox.ComboBox.DataSource = this.StartModes.Keys.ToList();
            this.ModeToolStripComboBox.SelectedItem        = Settings.Default.StartMode;

            string pass = LauncherSettings.GetValue(LauncherSettings.REMEMBER_PASSWORD);

            if (!string.IsNullOrWhiteSpace(pass))
            {
                tbRememberPassword.Text = pass;
            }
        }
Ejemplo n.º 19
0
        public void ReloadPrevTabFromSettings()
        {
            //Restores the last opened tab
            string lastTab = LauncherSettings.GetValue(LauncherSettings.LAUNCHER_TAB);

            TabName tab = TabName.WELCOME;

            if (lastTab != null)
            {
                try
                {
                    tab = (TabName)Enum.Parse(typeof(TabName), lastTab);
                }
                catch (Exception ex)
                {
                    //MessageBox.Show(ex.ToString());
                }
            }

            SelectTab(tab);
        }
Ejemplo n.º 20
0
        private void btnBrowseGameDirectory_Click(object sender, EventArgs e)
        {
            FolderBrowserDialog fbd    = new FolderBrowserDialog();
            DialogResult        result = fbd.ShowDialog();

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

            string folder    = fbd.SelectedPath;
            string x64Folder = Path.Combine(folder, "x64");

            var rootFiles = Directory.GetFiles(folder);
            var x64Files  = Directory.GetFiles(x64Folder);

            string MS2   = x64Files.FirstOrDefault(it => it.ToUpper().Contains("MAPLESTORY2.EXE"));
            string NGM   = rootFiles.FirstOrDefault(it => it.ToUpper().Contains("NGM.EXE"));
            string NGM64 = rootFiles.FirstOrDefault(it => it.ToUpper().Contains("NGM64.EXE"));

            bool maplestoryLocated = !(string.IsNullOrWhiteSpace(MS2));
            bool launcherLocated   = !string.IsNullOrWhiteSpace(NGM) || !string.IsNullOrWhiteSpace(NGM64);

            if (!maplestoryLocated || !launcherLocated)
            {
                MessageBox.Show("Could not find Maplestory2 and/or the Nexon game launcher.");
                folder = "";
                tbGameDirectory.Text = folder;
                LauncherSettings.DeleteValue(LauncherSettings.GAME_FOLDER);
                LockPatchInterface();
                return;
            }

            tbGameDirectory.Text = folder;
            LauncherSettings.SetValue(LauncherSettings.GAME_FOLDER, folder);
            UnlockPatchInterface();
        }
Ejemplo n.º 21
0
        public void DownloadComplete(string downloadedFile, string extractDirectory)
        {
            try
            {
                if (extractDirectory != null)
                {
                    if (!Directory.Exists(extractDirectory))
                    {
                        Directory.CreateDirectory(extractDirectory);
                    }

                    try
                    {
                        //System.IO.Compression.ZipFile.ExtractToDirectory(downloadedFile, extractDirectory);

                        using (ZipArchive archive = ZipFile.OpenRead(downloadedFile))
                        {
                            foreach (var entry in archive.Entries)
                            {
                                var entryPath = Path.Combine(extractDirectory, entry.FullName).Replace("/", "\\");

                                if (entryPath.EndsWith("\\"))
                                {
                                    if (!Directory.Exists(entryPath))
                                    {
                                        Directory.CreateDirectory(entryPath);
                                    }
                                }
                                else
                                {
                                    entry.ExtractToFile(entryPath, true);
                                }
                            }
                        }

                        MessageBox.Show("Patch installed successfully");

                        string patchname    = lbPatches.SelectedItem.ToString();
                        string patchDateUrl = $"{LauncherSettings.GetValue(LauncherSettings.PATCH_SERVER_ROOT)}/{patchname}/patchdate.php";

                        string serverPatchDate = null;

                        try
                        {
                            WebClient wc = new WebClient();
                            serverPatchDate = wc.DownloadString(patchDateUrl);
                        }
                        catch { return; } //eat it

                        LauncherSettings.SetValue(patchname, serverPatchDate);

                        lbPatches_SelectedIndexChanged(null, null);
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show($"An error occurred during extraction\n\n{ex}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);

                        return;
                    }


                    if (File.Exists(downloadedFile))
                    {
                        File.Delete(downloadedFile);
                    }
                }
                else
                {
                    Process.Start(downloadedFile);
                }
            }
            finally
            {
                dForm.Close();
                dForm = null;
            }
        }
Ejemplo n.º 22
0
 private void lbRememberPassword_TextChanged(object sender, EventArgs e)
 {
     LauncherSettings.SetValue(LauncherSettings.REMEMBER_PASSWORD, tbRememberPassword.Text);
 }