Exemplo n.º 1
0
        private void SettingControl_MouseEnter(object sender, MouseEventArgs e)
        {
            if (sender == null)
            {
                return;
            }

            GLSettingViewModel viewModel = ((ContentControl)sender)?.DataContext as GLSettingViewModel;

            if (viewModel == null)
            {
                return;
            }

            SetStatusMessage(viewModel.Description);
        }
Exemplo n.º 2
0
        public void Init(string cfgSpec, string cfgFile)
        {
            _file = cfgFile;

            try
            {
                _spec = Util.Deserialize <Iros._7th.Workshop.ConfigSettings.ConfigSpec>(cfgSpec);
            }
            catch (Exception e)
            {
                Logger.Error(e);
                MessageDialogWindow.Show("Failed to read the required spec xml file to display settings. The window mus close.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                this.Close();
                return;
            }

            if (!File.Exists(_file))
            {
                // copy default .cfg file if missing
                File.Copy(Path.Combine(Sys.PathToGameDriverFolder, "7H_GameDriver.cfg"), _file, true);
            }

            _settings = new Iros._7th.Workshop.ConfigSettings.Settings(File.ReadAllLines(_file));
            _settings.SetMissingDefaults(_spec.Settings);

            Dictionary <string, int> tabOrders = new Dictionary <string, int>()
            {
                { "Graphics", 0 },
                { "Rendering", 1 },
                { "Advanced", 3 }
            };

            foreach (var items in _spec.Settings.GroupBy(s => s.Group)
                     .Select(g => new { settingGroup = g, SortOrder = tabOrders[g.Key] })
                     .OrderBy(g => g.SortOrder)
                     .Select(g => g.settingGroup))
            {
                TabItem tab = new TabItem()
                {
                    Header = items.Key,
                };

                StackPanel stackPanel = new StackPanel()
                {
                    Margin = new Thickness(0, 5, 0, 0)
                };

                ScrollViewer scrollViewer = new ScrollViewer()
                {
                    VerticalScrollBarVisibility = ScrollBarVisibility.Auto
                };

                foreach (Iros._7th.Workshop.ConfigSettings.Setting setting in items)
                {
                    GLSettingViewModel settingViewModel = new GLSettingViewModel(setting, _settings);

                    ContentControl settingControl = new ContentControl();
                    settingControl.DataContext = settingViewModel;
                    settingControl.MouseEnter += SettingControl_MouseEnter;

                    ViewModels.Add(settingViewModel);
                    stackPanel.Children.Add(settingControl);
                }

                if (items.Key == "Advanced")
                {
                    // add clear texture cache button
                    btnClearTextureCache = new Button()
                    {
                        Content             = "Clear Texture Cache",
                        ToolTip             = $"Will delete everything under {Path.Combine(Sys.Settings.AaliFolder, "cache")}",
                        HorizontalAlignment = HorizontalAlignment.Left,
                        VerticalAlignment   = VerticalAlignment.Top,
                        Margin = new Thickness(5, 0, 0, 0)
                    };
                    btnClearTextureCache.Click += BtnClearTextureCache_Click;

                    stackPanel.Children.Add(btnClearTextureCache);
                }


                scrollViewer.Content = stackPanel;
                tab.Content          = scrollViewer;
                tabCtrlMain.Items.Add(tab);
            }
        }
Exemplo n.º 3
0
        public bool Init(string cfgSpec, string cfgFile)
        {
            _file = cfgFile;

            try
            {
                _spec = Util.Deserialize <Iros._7th.Workshop.ConfigSettings.ConfigSpec>(cfgSpec);
            }
            catch (Exception e)
            {
                Logger.Error(e);
                MessageDialogWindow.Show(ResourceHelper.Get(StringKey.FailedToReadRequiredSpecXmlFile), ResourceHelper.Get(StringKey.Error), MessageBoxButton.OK, MessageBoxImage.Error);
                return(false);
            }

            if (!File.Exists(_file))
            {
                // copy default .cfg file if missing
                File.Copy(Path.Combine(Sys.PathToGameDriverFolder, "FFNx.cfg"), _file, true);
            }

            _settings = new Iros._7th.Workshop.ConfigSettings.Settings(File.ReadAllLines(_file));
            _settings.SetMissingDefaults(_spec.Settings);

            Dictionary <string, int> tabOrders = new Dictionary <string, int>()
            {
                { ResourceHelper.Get(StringKey.Graphics), 0 },
                { ResourceHelper.Get(StringKey.Cheats), 1 },
                { ResourceHelper.Get(StringKey.Advanced), 2 }
            };

            foreach (var items in _spec.Settings.GroupBy(s => s.Group)
                     .Select(g => new { settingGroup = g, SortOrder = tabOrders[g.Key] })
                     .OrderBy(g => g.SortOrder)
                     .Select(g => g.settingGroup))
            {
                TabItem tab = new TabItem()
                {
                    Header = items.Key,
                };

                StackPanel stackPanel = new StackPanel()
                {
                    Margin = new Thickness(0, 5, 0, 0)
                };

                ScrollViewer scrollViewer = new ScrollViewer()
                {
                    VerticalScrollBarVisibility = ScrollBarVisibility.Auto
                };

                foreach (Iros._7th.Workshop.ConfigSettings.Setting setting in items)
                {
                    GLSettingViewModel settingViewModel = new GLSettingViewModel(setting, _settings);

                    ContentControl settingControl = new ContentControl();
                    settingControl.DataContext = settingViewModel;
                    settingControl.MouseEnter += SettingControl_MouseEnter;

                    ViewModels.Add(settingViewModel);
                    stackPanel.Children.Add(settingControl);
                }

                if (items.Key == ResourceHelper.Get(StringKey.Advanced))
                {
                    // add clear texture cache button
                    btnClearTextureCache = new Button()
                    {
                        Content             = ResourceHelper.Get(StringKey.ClearTextureCache),
                        ToolTip             = $"{ResourceHelper.Get(StringKey.WillDeleteEverythingUnder)} {Path.Combine(Sys.Settings.AaliFolder, "cache")}",
                        HorizontalAlignment = HorizontalAlignment.Left,
                        VerticalAlignment   = VerticalAlignment.Top,
                        Margin = new Thickness(5, 0, 0, 0)
                    };
                    btnClearTextureCache.Click += BtnClearTextureCache_Click;

                    stackPanel.Children.Add(btnClearTextureCache);
                }


                scrollViewer.Content = stackPanel;
                tab.Content          = scrollViewer;
                tabCtrlMain.Items.Add(tab);
            }

            return(true);
        }