//Set up listener for dropDown with resolution void SetResolutionListener(ref Dropdown _displayDropdown) { _displayDropdown.onValueChanged.AddListener( delegate { Dropdown local_displayDropdown = display.GetComponent <Dropdown>(); WindowResolution winRes = GetWinResFromString(local_displayDropdown.captionText.text); VideoManager.SetResolution(winRes.width, winRes.height); }); }
//get WindowResolution from string YYYYxYYYY WindowResolution GetWinResFromString(string _resTxt) { int splitPos = _resTxt.IndexOf("x"); string Wstr = _resTxt.Substring(0, splitPos); string Hstr = _resTxt.Substring(splitPos + 1, _resTxt.Length - 1 - splitPos); int W = int.Parse(Wstr); int H = int.Parse(Hstr); WindowResolution winRes = new WindowResolution(W, H); return(winRes); }
public OptionView(LauncherWindow window) { _texturePacks = new List <TexturePack>(); _lastTexturePack = null; Window = window; this.MinWidth = 250; OptionLabel = new Label("Options") { Font = Font.WithSize(16), TextAlignment = Alignment.Center }; ResolutionLabel = new Label("Select a resolution..."); ResolutionComboBox = new ComboBox(); int resolutionIndex = -1; for (int i = 0; i < WindowResolution.Defaults.Length; i++) { ResolutionComboBox.Items.Add(WindowResolution.Defaults[i].ToString()); if (resolutionIndex == -1) { resolutionIndex = ((WindowResolution.Defaults[i].Width == UserSettings.Local.WindowResolution.Width) && (WindowResolution.Defaults[i].Height == UserSettings.Local.WindowResolution.Height)) ? i : -1; } } if (resolutionIndex == -1) { ResolutionComboBox.Items.Add(UserSettings.Local.WindowResolution.ToString()); resolutionIndex = ResolutionComboBox.Items.Count - 1; } ResolutionComboBox.SelectedIndex = resolutionIndex; FullscreenCheckBox = new CheckBox { Label = "Fullscreen mode", State = (UserSettings.Local.IsFullscreen) ? CheckBoxState.On : CheckBoxState.Off }; InvertMouseCheckBox = new CheckBox { Label = "Inverted mouse", State = (UserSettings.Local.InvertedMouse) ? CheckBoxState.On : CheckBoxState.Off }; TexturePackLabel = new Label("Select a texture pack..."); TexturePackImageField = new DataField <Image>(); TexturePackTextField = new DataField <string>(); TexturePackStore = new ListStore(TexturePackImageField, TexturePackTextField); TexturePackListView = new ListView { MinHeight = 200, SelectionMode = SelectionMode.Single, DataSource = TexturePackStore, HeadersVisible = false }; OpenFolderButton = new Button("Open texture pack folder"); BackButton = new Button("Back"); TexturePackListView.Columns.Add("Image", TexturePackImageField); TexturePackListView.Columns.Add("Text", TexturePackTextField); ResolutionComboBox.SelectionChanged += (sender, e) => { UserSettings.Local.WindowResolution = WindowResolution.FromString(ResolutionComboBox.SelectedText); UserSettings.Local.Save(); }; FullscreenCheckBox.Clicked += (sender, e) => { UserSettings.Local.IsFullscreen = !UserSettings.Local.IsFullscreen; UserSettings.Local.Save(); }; InvertMouseCheckBox.Clicked += (sender, e) => { UserSettings.Local.InvertedMouse = !UserSettings.Local.InvertedMouse; UserSettings.Local.Save(); }; TexturePackListView.SelectionChanged += (sender, e) => { var texturePack = _texturePacks[TexturePackListView.SelectedRow]; if (_lastTexturePack != texturePack) { UserSettings.Local.SelectedTexturePack = texturePack.Name; UserSettings.Local.Save(); } }; OpenFolderButton.Clicked += (sender, e) => { var dir = new DirectoryInfo(Paths.TexturePacks); Process.Start(dir.FullName); }; BackButton.Clicked += (sender, e) => { Window.InteractionBox.Remove(this); Window.InteractionBox.PackEnd(Window.MainMenuView); }; OfficialAssetsButton = new Button("Download Minecraft assets") { Visible = false }; OfficialAssetsButton.Clicked += OfficialAssetsButton_Clicked; OfficialAssetsProgress = new ProgressBar() { Visible = false, Indeterminate = true }; LoadTexturePacks(); this.PackStart(OptionLabel); this.PackStart(ResolutionLabel); this.PackStart(ResolutionComboBox); this.PackStart(FullscreenCheckBox); this.PackStart(InvertMouseCheckBox); this.PackStart(TexturePackLabel); this.PackStart(TexturePackListView); this.PackStart(OfficialAssetsProgress); this.PackStart(OfficialAssetsButton); this.PackStart(OpenFolderButton); this.PackEnd(BackButton); }