Ejemplo n.º 1
0
        public async void LoginCommand()
        {
            try
            {
                Conductor.IsProcessing = true;
                var response = await HttpService.GetAuthAsync(Login, Password, UniqueProvider.Value());

                Conductor.IsProcessing = false;
                if (response.Item1)
                {
                    throw new Exception(response.Item2);
                }
                var userData = JsonConvert.DeserializeObject <UserData>(response.Item2);
                var message  = Properties.Settings.Default.language == "ru-RU" ? "Вы успешно авторизовались" : "You successfully signed in";
                Properties.Settings.Default.email = Login;
                Properties.Settings.Default.Save();
                Conductor.ShowBottomSheet(message);
                Conductor.Init(userData);
            }
            catch (Exception ex)
            {
                Conductor.IsProcessing = false;
                Conductor.ShowBottomSheet(ex.Message);
            }
        }
Ejemplo n.º 2
0
        protected override async void OnViewLoaded()
        {
            base.OnViewLoaded();
            try
            {
                IsProcessing = true;
                await Task.Run(() => UniqueProvider.Value());

                var sha1 = "";
                using (var md5 = new SHA1CryptoServiceProvider())
                {
                    using (var fs = new FileStream(Assembly.GetExecutingAssembly().Location, FileMode.Open, FileAccess.Read))
                    {
                        var byteArray = md5.ComputeHash(fs);
                        sha1 = BitConverter.ToString(byteArray).Replace("-", string.Empty);
                    }
                }
                var result = await HttpService.GetAppSettingsAsync();

                IsProcessing = false;
                if (result.Item1)
                {
                    ShowBottomSheet(result.Item2);
                    return;
                }
                AppSettings = JsonConvert.DeserializeObject <AppSettings>(result.Item2);
                if (AppSettings.IsFrozen)
                {
                    IsUpdateDialogOpen = true;
                    return;
                }
                if (AppSettings.Apphash.ToUpper() != sha1)
                {
                    UpdateIsReady      = true;
                    IsUpdateDialogOpen = true;
                    return;
                }
                if (Properties.Settings.Default.apphash != sha1)
                {
                    IsChangelogDialogOpen = true;
                    Properties.Settings.Default.apphash = sha1;
                    Properties.Settings.Default.Save();
                }
                ShowLogin();
            }
            catch (Exception ex)
            {
                IsExitRequested = false;
                ShowBottomSheet(ex.Message);
            }
        }
Ejemplo n.º 3
0
 public async void OnCloseRegisterDialog(DialogClosingEventArgs eventArgs)
 {
     try
     {
         var result = (bool)eventArgs.Parameter;
         if (result)
         {
             Conductor.IsProcessing = true;
             var response = await HttpService.GetRegisterUserAsync(Login, Password, UniqueProvider.Value());
             Conductor.IsProcessing = false;
             if (response.Item1)
             {
                 throw new Exception(response.Item2);
             }
             var message = Properties.Settings.Default.language == "ru-RU" ? "Регистрация завершена" : "You successfully signed up";
             Conductor.ShowBottomSheet(message);
         }
     }
     catch (Exception ex)
     {
         Conductor.IsProcessing = false;
         Conductor.ShowBottomSheet(ex.Message);
     }
 }
Ejemplo n.º 4
0
        public async void Initiation()
        {
            try
            {
                (Items.ElementAt(3) as LoginViewModel).IsEnabled = false;
                IsLoading      = true;
                ProcessingText = "Loading user's data...";
                var response = await HttpService.GetUserDataAsync();

                if (response.Item1)
                {
                    IsLoading = false;
                    ShowError(response.Item2);
                    ShowLogin();
                    return;
                }
                if (response.Item2.Contains("token_failed"))
                {
                    IsLoading = false;
                    ShowError("Authorization token is expired. Please sign in again.");
                    ShowLogin();
                    return;
                }
                var userData = JsonConvert.DeserializeObject <UserData>(response.Item2);
                var buyLinks = JsonConvert.DeserializeObject <BuyLinks>(userData.buy.ToString());
                ProcessingText = "Processing user's data...";
                var hwid = await Task.Run(() => UniqueProvider.Value());

                if (userData.hwid == "0")
                {
                    response = await HttpService.GetHwidAsync(hwid);

                    if (response.Item1)
                    {
                        IsLoading = false;
                        ShowError(response.Item2);
                        ShowLogin();
                        return;
                    }
                    userData.hwid = hwid;
                }

                if (userData.hwid != hwid)
                {
                    IsLoading = false;
                    if (Properties.Settings.Default.language == "ru-RU")
                    {
                        ShowError("Ваш HWID изменился и не совпадает с привязанным, воспользуйтесь услугой сброса на сайте в профиле");
                    }
                    else
                    {
                        ShowError("Your HWID is changed and doesn't match with previous one, use hwid reset service via the profile page on the website");
                    }
                    ShowLogin();
                    return;
                }
                ProcessingText = "Getting current prices...";
                response       = await HttpService.GetPricesAsync();

                if (response.Item1)
                {
                    IsLoading = false;
                    ShowError(response.Item2);
                    ShowLogin();
                    return;
                }
                var prices = JsonConvert.DeserializeObject <PriceData[]>(response.Item2);
                userData.username  = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(userData.username);
                userData.gender[1] = Properties.Settings.Default.language == "ru-RU" ? userData.gender[0] == "0" ? "Мужчина" : "Женщина" : userData.gender[0] == "0" ? "Male" : "Female";
                userData.avatar    = $"http://{userData.avatar}";
                var registerData = UnixTimeStampToDateTime(Convert.ToDouble(userData.register_date));
                userData.register_date = $"{registerData.ToShortDateString()} {registerData.ToShortTimeString()}";
                var daysLeftValue = Convert.ToDouble(userData.days_left);
                var daysLeftTime  = UnixTimeStampToDateTime(daysLeftValue);
                if (daysLeftValue == 0 || daysLeftTime < DateTime.Now)
                {
                    userData.days_left = "подписка не куплена";
                }
                else
                {
                    userData.days_left = $"{daysLeftTime.ToShortDateString()} {daysLeftTime.ToShortTimeString()}";
                }
                (Items[0] as StoreViewModel).IsEnabled    = true;
                (Items[0] as StoreViewModel).Prices       = prices;
                (Items[0] as StoreViewModel).BuyLinks     = buyLinks;
                (Items[1] as ProfileViewModel).IsEnabled  = true;
                (Items[1] as ProfileViewModel).UserData   = userData;
                (Items[2] as SettingsViewModel).IsEnabled = true;
                (Items[2] as SettingsViewModel).UserData  = userData;
                this.ActiveItem = Items[0];

                IsLoading = false;
                tabAnim   = (this.View as Window).FindResource("TabAnimation") as Storyboard;
                tabAnim.Begin();
            }
            catch (Exception ex)
            {
                IsLoading = false;
                ShowError(ex.Message);
                ShowLogin();
                return;
            }
        }
Ejemplo n.º 5
0
        public async void ModInstallAndRunCommand()
        {
            try
            {
                IsInjectError = false;
                if (!UserData.IsSubscriber)
                {
                    var message = Properties.Settings.Default.language == "ru-RU" ? "Время подписки истекло, обновите подписку" : "Your subscription is expired, repurchase subscription";
                    Conductor.ShowBottomSheet(message);
                    return;
                }
                Conductor.IsProcessing = true;
                var response = await HttpService.GetUserDataAsync(UserData.Email, UniqueProvider.Value());

                Conductor.IsProcessing = false;
                if (response.Item1)
                {
                    Conductor.ShowBottomSheet(response.Item2);
                    return;
                }
                UserData = JsonConvert.DeserializeObject <UserData>(response.Item2);
                if (!UserData.IsSubscriber)
                {
                    var message = Properties.Settings.Default.language == "ru-RU" ? "Время подписки истекло, обновите подписку" : "Your subscription is expired, repurchase subscription";
                    Conductor.ShowBottomSheet(message);
                    return;
                }

                if (!Directory.Exists(this.PubgPath) || !Directory.Exists($@"{PubgPath}\Binaries"))
                {
                    var message = Properties.Settings.Default.language == "ru-RU" ? "Некорректный путь до PUBG" : "Path to PUBG folder is incorrect";
                    throw new Exception(message);
                }

                Process[] processes = Process.GetProcesses();
                foreach (Process process in processes)
                {
                    if (process.ProcessName == "TslGame")
                    {
                        var message = Properties.Settings.Default.language == "ru-RU" ? "PUBG уже запущен" : "PUBG is already running";
                        throw new Exception(message);
                    }
                }

                var steamprocess = processes.FirstOrDefault(x => x.ProcessName == "Steam");
                if (steamprocess == null)
                {
                    IsMailRuVersion = true;
                }
                else
                {
                    IsMailRuVersion = false;
                }

                if (!Directory.Exists(PubgPath))
                {
                    var message = Properties.Settings.Default.language == "ru-RU" ? "Не удалось найти TslGame" : "Couldn't find TslGame folder";
                    throw new Exception(message);
                }
                Conductor.IsProcessing = true;
                FullClean();
                Conductor.IsProcessing = true;
                IsFileRestored         = false;
                await ModInstall();

                if (!IsMailRuVersion)
                {
                    Process.Start("steam://run/578080");
                }
                var cts               = new CancellationTokenSource();
                var token             = cts.Token;
                var waitForLaunchTask = Task.Run(() => { CheckForPubgLaunched(token); }, token);
                Conductor.IsProcessing = false;
                IsGameProcessing       = true;
                try
                {
                    //Conductor.MinimizeWindow();
                    waitForLaunchTask.Wait();
                }
                catch (Exception ex)
                {
                    IsGameProcessing       = false;
                    Conductor.IsProcessing = false;
                    Conductor.ShowBottomSheet(ex.Message);
                    cts.Cancel();
                    FullClean();
                }
            }
            catch (Exception ex)
            {
                IsGameProcessing       = false;
                Conductor.IsProcessing = false;
                File.WriteAllText("log.txt", ex.ToString() + "\n\n" + ex.StackTrace);
                Conductor.ShowBottomSheet(ex.Message);
                FullClean();
            }
        }
Ejemplo n.º 6
0
        public async void ModInstallAndRunCommand(int e)
        {
            try
            {
                if (!UserData.IsSubscriber)
                {
                    var message = Properties.Settings.Default.language == "ru-RU" ? "Время подписки истекло, обновите подписку" : "Your subscription is expired, repurchase subscription";
                    Conductor.ShowBottomSheet(message);
                    return;
                }
                Conductor.IsProcessing = true;
                var response = await HttpService.GetUserDataAsync(UserData.Email, UniqueProvider.Value());

                Conductor.IsProcessing = false;
                if (response.Item1)
                {
                    Conductor.ShowBottomSheet(response.Item2);
                    return;
                }
                UserData = JsonConvert.DeserializeObject <UserData>(response.Item2);
                if (!UserData.IsSubscriber)
                {
                    var message = Properties.Settings.Default.language == "ru-RU" ? "Время подписки истекло, обновите подписку" : "Your subscription is expired, repurchase subscription";
                    Conductor.ShowBottomSheet(message);
                    return;
                }

                if (!Directory.Exists(this.PubgPath) || !this.PubgPath.Contains("PUBG") || !Directory.Exists($@"{PubgPath}\TslGame\Binaries"))
                {
                    var message = Properties.Settings.Default.language == "ru-RU" ? "Некорректный путь до PUBG" : "Path to PUBG folder is incorrect";
                    throw new Exception(message);
                }

                Process[] processes = Process.GetProcesses();
                foreach (Process process in processes)
                {
                    if (process.ProcessName == "TslGame")
                    {
                        var message = Properties.Settings.Default.language == "ru-RU" ? "PUBG уже запущен" : "PUBG is already running";
                        throw new Exception(message);
                    }
                }

                var steamprocess = processes.FirstOrDefault(x => x.ProcessName == "Steam");
                if (steamprocess == null)
                {
                    IsMailRuVersion = true;
                }
                else
                {
                    IsMailRuVersion = false;
                }

                if (!Directory.Exists(PubgPath))
                {
                    var message = Properties.Settings.Default.language == "ru-RU" ? "Не удалось найти PUBG в steamapps" : "Steamapps doesn't contain PUBG";
                    throw new Exception(message);
                }
                Conductor.IsProcessing = true;
                FullClean();
                IsFileRestored = false;
                var appdata        = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
                var reshadeZipPath = $@"{appdata}\Reshade.zip";
                if (File.Exists(reshadeZipPath))
                {
                    File.Delete(reshadeZipPath);
                }
                if (File.Exists($@"{appdata}\TslGame-WindowsNoEditor_ui.pak"))
                {
                    File.Delete($@"{appdata}\TslGame-WindowsNoEditor_ui.pak");
                }
                var reshadePath = $@"{appdata}\Reshade";
                if (Directory.Exists(reshadePath))
                {
                    Directory.Delete(reshadePath, true);
                }
                string downloadModLink;
                switch (e)
                {
                case 1:
                    downloadModLink = "http://ih943403.myihor.ru/pubg.mod/Mod1_TslGame-WindowsNoEditor_ui.pak";
                    break;

                case 2:
                    downloadModLink = "http://ih943403.myihor.ru/pubg.mod/Mod2_TslGame-WindowsNoEditor_ui.pak";
                    break;

                case 3:
                    downloadModLink = "http://ih943403.myihor.ru/pubg.mod/Mod3_TslGame-WindowsNoEditor_ui.pak";
                    break;

                default:
                    Conductor.IsProcessing = false;
                    return;
                }
                var reshadeDownloadLink = "http://ih943403.myihor.ru/pubg.mod/Reshade.zip";
                using (WebClient wc = new WebClient())
                {
                    if (IsReshadeEnabled)
                    {
                        await wc.DownloadFileTaskAsync(new System.Uri(reshadeDownloadLink), reshadeZipPath);
                    }
                    await wc.DownloadFileTaskAsync(new System.Uri(downloadModLink), $@"{appdata}\TslGame-WindowsNoEditor_ui.pak");

                    //if (File.Exists($@"{PubgPath}\TslGame\Binaries\Win64\TslGame.exe"))
                    //    File.Delete($@"{PubgPath}\TslGame\Binaries\Win64\TslGame.exe");
                    //await wc.DownloadFileTaskAsync(new System.Uri("http://ih943403.myihor.ru/pubg.mod/TslGame.exe"), $@"{PubgPath}\TslGame\Binaries\Win64\TslGame.exe");
                };

                if (IsReshadeEnabled)
                {
                    System.IO.Compression.ZipFile.ExtractToDirectory(reshadeZipPath, appdata);
                }
                if (File.Exists(reshadeZipPath))
                {
                    File.Delete(reshadeZipPath);
                }

                if (File.Exists($@"{PubgPath}\TslGame\Content\TslGame-WindowsNoEditor_erangel_lod.pak"))
                {
                    File.Delete($@"{PubgPath}\TslGame\Content\TslGame-WindowsNoEditor_erangel_lod.pak");
                }

                var originalLodPakPath = $@"{PubgPath}\TslGame\Content\Paks\TslGame-WindowsNoEditor_erangel_lod.pak";
                if (File.Exists(originalLodPakPath) && !File.Exists($@"{PubgPath}\TslGame\Content\TslGame-WindowsNoEditor_erangel_lod.pak"))
                {
                    File.Move(originalLodPakPath, $@"{PubgPath}\TslGame\Content\TslGame-WindowsNoEditor_erangel_lod.pak");
                }


                var originalUIPakPath = $@"{PubgPath}\TslGame\Content\Paks\TslGame-WindowsNoEditor_ui.pak";
                if (File.Exists(originalUIPakPath) && !File.Exists($@"{PubgPath}\TslGame\Content\Paks\TslGame-WindowsNoEditor_erangel_lod.pak"))
                {
                    File.Move(originalUIPakPath, $"{originalUIPakPath.Replace("TslGame-WindowsNoEditor_ui.pak", "TslGame-WindowsNoEditor_erangel_lod.pak")}");
                }

                if (File.Exists($@"{appdata}\TslGame-WindowsNoEditor_ui.pak") && !File.Exists($@"{PubgPath}\TslGame\Content\Paks\TslGame-WindowsNoEditor_ui.pak"))
                {
                    File.Move($@"{appdata}\TslGame-WindowsNoEditor_ui.pak", $@"{PubgPath}\TslGame\Content\Paks\TslGame-WindowsNoEditor_ui.pak");
                }

                if (IsReshadeEnabled)
                {
                    if (!Directory.Exists($@"{PubgPath}\TslGame\Binaries\Win64\ReShade") && Directory.Exists($@"{reshadePath}\ReShade"))
                    {
                        SymbolicLinkSupport.DirectoryInfoExtensions.CreateSymbolicLink(new DirectoryInfo($@"{reshadePath}\ReShade"), $@"{PubgPath}\TslGame\Binaries\Win64\ReShade");
                    }

                    if (!File.Exists($@"{PubgPath}\TslGame\Binaries\Win64\d3d11.dll") && File.Exists($@"{reshadePath}\d3d11.dll"))
                    {
                        SymbolicLinkSupport.FileInfoExtensions.CreateSymbolicLink(new FileInfo($@"{reshadePath}\d3d11.dll"), $@"{PubgPath}\TslGame\Binaries\Win64\d3d11.dll");
                    }

                    if (!File.Exists($@"{PubgPath}\TslGame\Binaries\Win64\ReShade.fx") && File.Exists($@"{reshadePath}\ReShade.fx"))
                    {
                        SymbolicLinkSupport.FileInfoExtensions.CreateSymbolicLink(new FileInfo($@"{reshadePath}\ReShade.fx"), $@"{PubgPath}\TslGame\Binaries\Win64\ReShade.fx");
                    }
                }

                if (!IsMailRuVersion)
                {
                    Process.Start("steam://run/578080");
                }
                var cts               = new CancellationTokenSource();
                var token             = cts.Token;
                var waitForLaunchTask = Task.Run(() => { CheckForPubgLaunched(token); }, token);
                Conductor.IsProcessing = false;
                IsGameProcessing       = true;
                try
                {
                    //Conductor.MinimizeWindow();
                    waitForLaunchTask.Wait();
                }
                catch (AggregateException ex)
                {
                    IsGameProcessing       = false;
                    Conductor.IsProcessing = false;
                    Conductor.ShowBottomSheet(ex.Message);
                    cts.Cancel();
                    FullClean();
                }
                catch (Exception ex)
                {
                    IsGameProcessing       = false;
                    Conductor.IsProcessing = false;
                    Conductor.ShowBottomSheet(ex.Message);
                    cts.Cancel();
                    FullClean();
                }
            }
            catch (Exception ex)
            {
                IsGameProcessing       = false;
                Conductor.IsProcessing = false;
                Conductor.ShowBottomSheet(ex.Message);
                FullClean();
            }
        }