public void LocalizatorEnvironmentProvided(LocalizatorEnvironmentInfo obj)
        {
            ApplicationConfigInfo config = Provide();

            config.LocalizatorEnvironment = obj;
            config.Save();
        }
        private HttpFileInfo GetLatestTranslationInfo()
        {
            Downloader downloader           = new Downloader(CancelEvent);
            LocalizatorEnvironmentInfo info = InteractionService.LocalizatorEnvironment.Provide();

            HttpFileInfo latest = null;

            foreach (string url in info.TranslationUrls)
            {
                try
                {
                    HttpFileInfo fileInfo = downloader.GetRemoteFileInfo(url).ContinueWith(t => t.Result).Result;
                    if (latest == null || latest.LastModified < fileInfo.LastModified)
                    {
                        latest = fileInfo;
                    }
                }
                catch (Exception ex)
                {
                    Log.Warning(ex, "Не удалось получить информацию о файле: [{0}]", url);
                }
            }

            return(latest);
        }
 public void Load()
 {
     lock (FileLock)
     {
         XmlElement config = XmlHelper.LoadDocument(ConfigurationFilePath);
         GameLocation = GameLocationInfo.FromXml(config["GameLocation"]);
         WorkingLocation = WorkingLocationInfo.FromXml(config["WorkingLocation"]);
         FileCommanderSelectedNodePath = config.FindString("FileCommanderSelectedNodePath");
         LocalizatorEnvironment = LocalizatorEnvironmentInfo.FromXml(config["LocalizatorEnvironment"]);
     }
 }
示例#4
0
        private void OnLocalizatorEnvironmentProvided(LocalizatorEnvironmentInfo obj)
        {
            _info = obj;

            OnPropertyChanged(nameof(IsFullScreen));
            OnPropertyChanged(nameof(IsFullHd));
            OnPropertyChanged(nameof(IsNihonVoice));
            OnPropertyChanged(nameof(SwitchButtons));
            OnPropertyChanged(nameof(AntiAliasing));
            OnPropertyChanged(nameof(ShadowResolution));
        }
示例#5
0
 public void Load()
 {
     lock (FileLock)
     {
         XmlElement config = XmlHelper.LoadDocument(ConfigurationFilePath);
         GameLocation    = GameLocationInfo.FromXml(config["GameLocation"]);
         WorkingLocation = WorkingLocationInfo.FromXml(config["WorkingLocation"]);
         FileCommanderSelectedNodePath = config.FindString("FileCommanderSelectedNodePath");
         LocalizatorEnvironment        = LocalizatorEnvironmentInfo.FromXml(config["LocalizatorEnvironment"]);
     }
 }
        private async Task Patch(DirectoryInfo translationDir)
        {
            Position = 0;

            if (CancelEvent.IsSet())
                return;

            FFXIIIGamePart gamePart = FFXIIIGamePart.Part1; // TODO
            InteractionService.SetGamePart(gamePart);

            String configurationFilePath = Path.Combine(translationDir.FullName, PatcherService.ConfigurationFileName);
            XmlElement config = XmlHelper.LoadDocument(configurationFilePath);
            LocalizatorEnvironmentInfo info = LocalizatorEnvironmentInfo.FromXml(config["LocalizatorEnvironment"]);
            info.Validate();

            LocalizatorEnvironmentInfo currentInfo = InteractionService.LocalizatorEnvironment.Provide();
            currentInfo.UpdateUrls(info);

            InteractionService.LocalizatorEnvironment.SetValue(currentInfo);
            InteractionService.WorkingLocation.SetValue(new WorkingLocationInfo(translationDir.FullName));

            if (currentInfo.IsIncompatible(typeof(App).Assembly.GetName().Version))
            {
                if (MessageBox.Show(this.GetParentElement<Window>(), "Ваша версия программы установки несовместима с текущим перевод. Обновить?", "Ошибка!", MessageBoxButton.YesNo, MessageBoxImage.Error) != MessageBoxResult.Yes)
                    return;

                string path = await DownloadLatestPatcher();
                DirectoryInfo updatePath = ExtractZipToTempFolder(path);
                string destination = AppDomain.CurrentDomain.BaseDirectory.TrimEnd('\\');

                string patcherPath = Path.Combine(updatePath.FullName, "Pulse.Patcher.exe");
                ProcessStartInfo procInfo = new ProcessStartInfo(patcherPath, $"/u \"{destination}\"")
                {
                    CreateNoWindow = true,
                    UseShellExecute = false,
                    WorkingDirectory = updatePath.FullName
                };
                
                Process.Start(procInfo);
                Environment.Exit(0);
            }

            if (CancelEvent.IsSet())
                return;

            GameLocationInfo gameLocation = PatcherService.GetGameLocation(gamePart);
            await Task.Run(() => Patch(translationDir, gameLocation));
        }
        private async Task<HttpFileInfo> GetLatestPatcherUrl(Downloader downloader)
        {
            LocalizatorEnvironmentInfo info = InteractionService.LocalizatorEnvironment.Provide();

            HttpFileInfo latest = null;
            foreach (string url in info.PatherUrls)
            {
                try
                {
                    HttpFileInfo fileInfo = await downloader.GetRemoteFileInfo(url);
                    if (latest == null || latest.LastModified < fileInfo.LastModified)
                        latest = fileInfo;
                }
                catch (Exception ex)
                {
                    Log.Warning(ex, "Не удалось получить информацию о файле: [{0}]", url);
                }
            }
            return latest;
        }
示例#8
0
        public MainWindow()
        {
            InitializeComponent();
            Unloaded  += OnUnloaded;
            MouseDown += OnMouseDown;

            _player = _disposables.Add(BackgroundMusicPlayer.TryCreateAndPlay());
            PlayButton.GameSettings = GameSettings;
            PlayButton.MusicPlayer  = _player;

            LocalizatorEnvironmentInfo info = InteractionService.LocalizatorEnvironment.Provide();

            if (!info.PlayMusic)
            {
                OnMusicButtonClick(MusicButton, new RoutedEventArgs());
            }
            if (!info.ExitAfterRunGame)
            {
                OnSwitchButtonClick(SwitchButton, new RoutedEventArgs());
            }
        }
示例#9
0
        public GameSettingsControl()
        {
            SetCols(2);
            SetRows(9);

            Width               = 250;
            VerticalAlignment   = VerticalAlignment.Top;
            HorizontalAlignment = HorizontalAlignment.Left;
            Margin              = new Thickness(5);
            DataContext         = this;

            _info = InteractionService.LocalizatorEnvironment.Provide();
            InteractionService.LocalizatorEnvironment.InfoProvided += OnLocalizatorEnvironmentProvided;

            LinearGradientBrush backgroundStroke = new LinearGradientBrush
            {
                EndPoint          = new Point(0.5, 1),
                StartPoint        = new Point(0.5, 0),
                RelativeTransform = new RotateTransform(115, 0.5, 0.5),
                GradientStops     = new GradientStopCollection
                {
                    new GradientStop(Color.FromArgb(0xff, 0x61, 0x61, 0x61), 0),
                    new GradientStop(Color.FromArgb(0xff, 0xF2, 0xF2, 0xF2), 0.504),
                    new GradientStop(Color.FromArgb(0xff, 0xAE, 0xB1, 0xB1), 1)
                }
            };

            backgroundStroke.Freeze();

            LinearGradientBrush backgroundFill = new LinearGradientBrush
            {
                MappingMode   = BrushMappingMode.RelativeToBoundingBox,
                StartPoint    = new Point(0.5, 1.0),
                EndPoint      = new Point(0.5, -0.4),
                GradientStops = new GradientStopCollection
                {
                    new GradientStop(Color.FromArgb(0xBB, 0x44, 0x71, 0xc1), 0),
                    new GradientStop(Color.FromArgb(0xBB, 0x28, 0x36, 0x65), 1)
                }
            };

            backgroundFill.Freeze();

            Rectangle backround = AddUiElement(new Rectangle {
                Stroke = backgroundStroke, Fill = backgroundFill, StrokeThickness = 5
            }, 0, 0, 9, 2);

            InverseBoolConverter inverseBoolConverter = new InverseBoolConverter();
            Thickness            rowMargin            = new Thickness(0, 8, 0, 3);

            const string screenGroup = "Отображение:";

            AddUiElement(UiTextBlockFactory.Create(screenGroup), 0, 0, 0, 2).Margin = rowMargin;
            AddUiElement(UiRadioButtonFactory.Create(screenGroup, "Экран", true), 1, 0).SetBinding(ToggleButton.IsCheckedProperty, new Binding("IsFullScreen")
            {
                Mode = BindingMode.TwoWay
            });
            AddUiElement(UiRadioButtonFactory.Create(screenGroup, "Окно", false), 1, 1).SetBinding(ToggleButton.IsCheckedProperty, new Binding("IsFullScreen")
            {
                Mode = BindingMode.TwoWay, Converter = inverseBoolConverter
            });

            const string resolutionGroup = "Разрешение:";

            AddUiElement(UiTextBlockFactory.Create(resolutionGroup), 2, 0, 0, 2).Margin = rowMargin;
            AddUiElement(UiRadioButtonFactory.Create(resolutionGroup, "1920x1080", true), 3, 0).SetBinding(ToggleButton.IsCheckedProperty, new Binding("IsFullHd")
            {
                Mode = BindingMode.TwoWay
            });
            AddUiElement(UiRadioButtonFactory.Create(resolutionGroup, "1280x720", false), 3, 1).SetBinding(ToggleButton.IsCheckedProperty, new Binding("IsFullHd")
            {
                Mode = BindingMode.TwoWay, Converter = inverseBoolConverter
            });

            const string voiceGroup = "Озвучка:";

            AddUiElement(UiTextBlockFactory.Create(voiceGroup), 4, 0, 0, 2).Margin = rowMargin;
            AddUiElement(UiRadioButtonFactory.Create(voiceGroup, "Японская", true), 5, 0).SetBinding(ToggleButton.IsCheckedProperty, new Binding("IsNihonVoice")
            {
                Mode = BindingMode.TwoWay
            });
            AddUiElement(UiRadioButtonFactory.Create(voiceGroup, "Английская", false), 5, 1).SetBinding(ToggleButton.IsCheckedProperty, new Binding("IsNihonVoice")
            {
                Mode = BindingMode.TwoWay, Converter = inverseBoolConverter
            });

            UiCheckBox switchButtons = AddUiElement(UiCheckBoxFactory.Create("Поменять кнопки X/O", null), 6, 0, 0, 2);

            switchButtons.Margin       = rowMargin;
            switchButtons.IsThreeState = true;
            switchButtons.SetBinding(ToggleButton.IsCheckedProperty, new Binding("SwitchButtons")
            {
                Mode = BindingMode.TwoWay
            });

            AddUiElement(UiTextBlockFactory.Create("MSAA:"), 7, 0).Margin = rowMargin;
            UiComboBox antiAliasing = AddUiElement(UiComboBoxFactory.Create(), 8, 0);

            antiAliasing.ItemStringFormat = "x{0}";
            antiAliasing.ItemsSource      = new[] { 2, 4, 8, 16 };
            antiAliasing.SelectedIndex    = 3;
            antiAliasing.SetBinding(Selector.SelectedItemProperty, new Binding("AntiAliasing")
            {
                Mode = BindingMode.TwoWay
            });
            antiAliasing.Margin = new Thickness(0, 0, 0, 8);

            AddUiElement(UiTextBlockFactory.Create("Тени:"), 7, 1).Margin = rowMargin;
            UiComboBox shadows = AddUiElement(UiComboBoxFactory.Create(), 8, 1);

            shadows.ItemStringFormat = "{0}x{0}";
            shadows.ItemsSource      = new[] { 512, 1024, 2048, 4096, 8192 };
            shadows.SelectedIndex    = 1;
            shadows.SetBinding(Selector.SelectedItemProperty, new Binding("ShadowResolution")
            {
                Mode = BindingMode.TwoWay
            });
            shadows.Margin = new Thickness(0, 0, 0, 8);

            foreach (FrameworkElement child in Children)
            {
                if (!ReferenceEquals(child, backround))
                {
                    child.Margin = new Thickness(child.Margin.Left + 8, child.Margin.Top, child.Margin.Right + 8, child.Margin.Bottom);
                }

                TextBlock textblock = child as TextBlock;
                if (textblock != null)
                {
                    textblock.Foreground = Brushes.WhiteSmoke;
                    textblock.FontWeight = FontWeight.FromOpenTypeWeight(500);
                    continue;
                }

                Control control = child as Control;
                if (control != null && !(control is ComboBox))
                {
                    control.Foreground = Brushes.WhiteSmoke;
                }
            }
        }