public static Setting Create(I18N.I18NString description, SettingType type, string value, SettingDependency dependency = null) { var setting = new Setting() { Type = type, Value = value, DefaultValue = value, Description = description, Dependency = dependency }; return(setting); }
private void AddTitle(StackPanel panel, I18N.I18NString title) { TextBlock textBlock = new TextBlock() { TextWrapping = TextWrapping.WrapWithOverflow, Padding = new Thickness(5), Margin = new Thickness(5), Focusable = true }; textBlock.Inlines.Add(new Bold(new Run(I18N.Get(title)))); panel.Children.Add(textBlock); }
public static Setting Create(I18N.I18NString description, bool value, SettingDependency dependency = null) { var setting = new Setting() { Type = SettingType.BOOLEAN, Value = value ? "1" : "0", DefaultValue = value ? "1" : "0", Description = description, Dependency = dependency }; return(setting); }
private void LoadReadme() { AboutText.Inlines.Clear(); try { AboutText.Inlines.Add(File.ReadAllText(HLVRPaths.VRReadme, Encoding.UTF8)); } catch (IOException e) { AboutText.Inlines.Clear(); var errorMsg = new I18N.I18NString("ErrorMsgCouldNotLoadReadme", "Couldn't load README.txt: %s"); AboutText.Inlines.Add(new Regex(Regex.Escape("%s")).Replace(I18N.Get(errorMsg), e.Message, 1)); } }
public static Setting Create(I18N.I18NString description, OrderedDictionary <string, I18N.I18NString> allowedValues, string defaultvalue, SettingDependency dependency = null) { var setting = new Setting() { Type = SettingType.ENUM, Value = defaultvalue, DefaultValue = defaultvalue, Description = description, Dependency = dependency }; foreach (var allowedValue in allowedValues) { setting.AllowedValues.Add(allowedValue.Key, allowedValue.Value); } return(setting); }
private void AddDescription(StackPanel panel, I18N.I18NString description) { if (description == null) { return; } TextBlock textBlock = new TextBlock() { TextWrapping = TextWrapping.WrapWithOverflow, Padding = new Thickness(5, 0, 5, 5), Margin = new Thickness(5, 0, 5, 5), Focusable = true }; textBlock.FontSize *= 0.8; textBlock.Inlines.Add(new Run(I18N.Get(description))); panel.Children.Add(textBlock); }
private static void InitModSettings() { if (AreModSettingsInitialized) { return; } ModSettings = new ModSettings(); if (!HLVRPaths.CheckHLDirectory() || !HLVRPaths.CheckModDirectory()) { AreModSettingsInitialized = false; return; } if (File.Exists(HLVRPaths.VRModSettingsFile)) { if (!TryLoadSettings(HLVRPaths.VRModSettingsFile)) { var errorMsg = new I18N.I18NString("ErrorMsgCouldNotLoadModSettings", "Couldn't load mod settings file. If you chose OK, HLVRConfig will replace settings with default values. If you chose Cancel, config tabs will not be available."); var errorTitle = new I18N.I18NString("Error", "Error"); var result = MessageBox.Show(I18N.Get(errorMsg), I18N.Get(errorTitle), MessageBoxButton.OKCancel, MessageBoxImage.Warning); if (result != MessageBoxResult.OK) { AreModSettingsInitialized = false; return; } } } if (!TryStoreSettings(ModSettings, HLVRPaths.VRModSettingsFile)) { var errorMsg = new I18N.I18NString("ErrorMsgCouldNotSynchronizeModSettings", "Couldn't synchronize mod settings. Config tabs are not available."); var errorTitle = new I18N.I18NString("Error", "Error"); MessageBox.Show(I18N.Get(errorMsg), I18N.Get(errorTitle), MessageBoxButton.OK, MessageBoxImage.Warning); AreModSettingsInitialized = false; return; } AreModSettingsInitialized = true; }
private void AddInput(OrderedDictionary <SettingCategory, OrderedDictionary <string, Setting> > settingcategories, StackPanel panel, SettingCategory category, string name, I18N.I18NString label, Setting value) { StackPanel inputPanel = new StackPanel() { Orientation = Orientation.Horizontal, Margin = new Thickness(5), }; inputPanel.Children.Add(new TextBlock() { TextWrapping = TextWrapping.NoWrap, Padding = new Thickness(5), Margin = new Thickness(5), Focusable = true, MinWidth = 150, Text = I18N.Get(label) }); if (value.AllowedValues.Count == 0) { var textbox = MakeTextBox(value); textbox.TextChanged += (object sender, TextChangedEventArgs e) => { HLVRSettingsManager.TrySetSetting(settingcategories, category, name, textbox.Text); }; inputPanel.Children.Add(textbox); if (value.Type == SettingType.SPEED || value.Type == SettingType.DISTANCE) { var meterTextbox = MakeTextBox(value); meterTextbox.Text = UnitToMeter(textbox.Text); bool preventinfiniteloop = false; textbox.TextChanged += (object sender, TextChangedEventArgs e) => { if (preventinfiniteloop) { return; } preventinfiniteloop = true; meterTextbox.Text = UnitToMeter(textbox.Text); preventinfiniteloop = false; }; meterTextbox.TextChanged += (object sender, TextChangedEventArgs e) => { if (preventinfiniteloop) { return; } preventinfiniteloop = true; textbox.Text = MeterToUnit(meterTextbox.Text); preventinfiniteloop = false; }; inputPanel.Children.Add(CreateMiniText(value.Type == SettingType.SPEED ? "units/s" : "units")); inputPanel.Children.Add(meterTextbox); inputPanel.Children.Add(CreateMiniText(value.Type == SettingType.SPEED ? "cm/s" : "cm")); inputPanel.Children.Add(CreateDefaultLabel(value.DefaultValue + "/" + UnitToMeter(value.DefaultValue))); } else { inputPanel.Children.Add(CreateDefaultLabel(value.DefaultValue)); } } else { var combobox = new ComboBox() { MinWidth = 200, }; int index = 0; int selectedIndex = 0; I18N.I18NString defaultValue = null; foreach (var allowedValue in value.AllowedValues) { var comboboxitem = new ComboBoxItem() { }; comboboxitem.Content = allowedValue.Value; combobox.Items.Add(comboboxitem); if (allowedValue.Key.Equals(value.Value)) { selectedIndex = index; } if (allowedValue.Key.Equals(value.DefaultValue)) { defaultValue = allowedValue.Value; } index++; } combobox.SelectedIndex = selectedIndex; combobox.SelectionChanged += (object sender, SelectionChangedEventArgs e) => { HLVRSettingsManager.TrySetSetting(settingcategories, category, name, ((I18N.I18NString)(combobox.SelectedValue as ComboBoxItem).Content).Key); }; inputPanel.Children.Add(combobox); if (defaultValue != null) { inputPanel.Children.Add(CreateDefaultLabel(I18N.Get(defaultValue))); } } panel.Children.Add(inputPanel); }
private void AddCheckBox(OrderedDictionary <SettingCategory, OrderedDictionary <string, Setting> > settingcategories, StackPanel panel, SettingCategory category, string name, I18N.I18NString label, bool isChecked, bool isDefaultChecked) { StackPanel inputPanel = new StackPanel() { Orientation = Orientation.Horizontal, }; CheckBox cb = new CheckBox { Name = name, Content = new Run(I18N.Get(label)), Margin = new Thickness(10), IsChecked = isChecked }; cb.Checked += (object sender, RoutedEventArgs e) => { HLVRSettingsManager.TrySetSetting(settingcategories, category, name, true); }; cb.Unchecked += (object sender, RoutedEventArgs e) => { HLVRSettingsManager.TrySetSetting(settingcategories, category, name, false); }; cb.Indeterminate += (object sender, RoutedEventArgs e) => { HLVRSettingsManager.TrySetSetting(settingcategories, category, name, false); }; inputPanel.Children.Add(cb); panel.Children.Add(inputPanel); }
public SettingCategory(I18N.I18NString title, I18N.I18NString description, SettingDependency dependency = null) { Title = title; Description = description; Dependency = dependency; }
public SettingCategory(I18N.I18NString title, SettingDependency dependency = null) { Title = title; Dependency = dependency; }
public SettingCategory(I18N.I18NString title) { Title = title; }