private void AddToolbarButton(UIView view) { _toolbar_Button = (UICheckButton)view.AddUIComponent(typeof(UICheckButton)); _toolbar_Button.atlas = _atlas; _toolbar_Button.normalBgSprite = "OptionBase"; _toolbar_Button.hoveredBgSprite = "OptionBaseFocused"; _toolbar_Button.pressedBgSprite = "OptionBasePressed"; _toolbar_Button.normalFgSprite = "Music"; _toolbar_Button.width = 36; _toolbar_Button.height = 36; Vector2 screenResolution = view.GetScreenResolution(); _toolbar_Button.relativePosition = new Vector3(screenResolution.x - _toolbar_Button.width - 10 - 20 - 40, screenResolution.y - _toolbar_Button.height / 2 - 120 + 7); _toolbar_Button.eventClick += delegate { _toolbar_Button_MouseDown_Timer = -1; _current_Settings_Panel.isVisible = !_current_Settings_Panel.isVisible; }; //Drag,drop _toolbar_Button.eventMouseDown += (component, eventParam) => { _toolbar_Button_MouseDown_Timer = 60; }; _toolbar_Button.eventMouseUp += (component, eventParam) => { if (_toolbar_Button_dragging) { gameObject.GetComponent <SettingsManager>().SaveModSettings(); _toolbar_Button_dragging = false; } _toolbar_Button_dragging = false; _toolbar_Button_MouseDown_Timer = -1; }; }
private void AddToolbarButton(UIView view) { _toolbar_Button = (UICheckButton)view.AddUIComponent(typeof(UICheckButton)); _toolbar_Button.atlas = _atlas; _toolbar_Button.normalBgSprite = "OptionBase"; _toolbar_Button.hoveredBgSprite = "OptionBaseFocused"; _toolbar_Button.pressedBgSprite = "OptionBasePressed"; _toolbar_Button.normalFgSprite = "Music"; _toolbar_Button.width = 36; _toolbar_Button.height = 36; Vector2 screenResolution = view.GetScreenResolution(); _toolbar_Button.relativePosition = new Vector3(screenResolution.x - _toolbar_Button.width - 10 - 20 - 40, screenResolution.y - _toolbar_Button.height / 2 - 120 + 7); _toolbar_Button.eventClick += delegate { _toolbar_Button_MouseDown_Timer = -1; _current_Settings_Panel.isVisible = !_current_Settings_Panel.isVisible; }; //Drag,drop _toolbar_Button.eventMouseDown += (component, eventParam) => { _toolbar_Button_MouseDown_Timer = 60; }; _toolbar_Button.eventMouseUp += (component, eventParam) => { if (_toolbar_Button_dragging) { gameObject.GetComponent<SettingsManager>().SaveModSettings(); _toolbar_Button_dragging = false; } _toolbar_Button_dragging = false; _toolbar_Button_MouseDown_Timer = -1; }; }
private void InitializeHeaderToolbar() { //Header background { var header = AddUIComponent <UIPanel>(); header.relativePosition = Vector3.zero; header.width = this.width; header.height = 80; header.backgroundSprite = "GenericTab"; } { _MusicVolumeSlider = AddUIComponent <UISlider>(); _MusicVolumeSlider.relativePosition = new Vector3(15, 22); _MusicVolumeSlider.width = 100; _MusicVolumeSlider.height = 10; //_MusicVolumeSlider.backgroundSprite = "GenericPanelLight"; //_MusicVolumeSlider.color = new Color32(255, 255, 255, 100); _MusicVolumeSlider.minValue = 0; _MusicVolumeSlider.maxValue = 100; _MusicVolumeSlider.tooltip = "Drag to change the music volume"; UIPanel thumb = _MusicVolumeSlider.AddUIComponent <UIPanel>(); thumb.width = 15; thumb.height = 15; thumb.backgroundSprite = "GenericProgressBarFill"; UIPanel fill = _MusicVolumeSlider.AddUIComponent <UIPanel>(); fill.backgroundSprite = "GenericProgressBarFill"; //fill.color = new Color32(79, 210, 233, 255); _MusicVolumeSlider.fillIndicatorObject = fill; _MusicVolumeSlider.thumbObject = thumb; _MusicVolumeSlider.eventValueChanged += delegate(UIComponent component, float value) { if (this.m_IsDisposing) { return; } //I use x100 because it failed with 0..1? value = value / 100f; if (_MusicAudioVolume.value != value) { _MusicAudioVolume.value = value; } }; } { _Previous_Track = AddUIComponent <UIButton>(); _Previous_Track.width = 36; _Previous_Track.height = 36; _Previous_Track.relativePosition = new Vector3(130, 10); _Previous_Track.tooltip = "Play previous track"; _Previous_Track.atlas = _atlas; _Previous_Track.hoveredBgSprite = "OptionBaseFocused"; _Previous_Track.pressedBgSprite = "OptionBasePressed"; _Previous_Track.normalFgSprite = "Previous"; _Previous_Track.eventClick += delegate(UIComponent component, UIMouseEventParameter eventParam) { AudioWatcher.RequestSwitchToPreviousMusic(); }; } { _Next_Track = AddUIComponent <UIButton>(); _Next_Track.width = 36; _Next_Track.height = 36; _Next_Track.relativePosition = new Vector3(130 + 40, 10); _Next_Track.normalBgSprite = "GenericPanel"; _Next_Track.tooltip = "Play next track"; _Next_Track.atlas = _atlas; _Next_Track.hoveredBgSprite = "OptionBaseFocused"; _Next_Track.pressedBgSprite = "OptionBasePressed"; _Next_Track.normalFgSprite = "Next"; _Next_Track.eventClick += delegate(UIComponent component, UIMouseEventParameter eventParam) { AudioWatcher.RequestSwitchMusic(); }; } { _SortAscending = AddUIComponent <UIButton>(); _SortAscending.width = 36; _SortAscending.height = 36; _SortAscending.relativePosition = new Vector3(130 + 40 * 2, 10); _SortAscending.normalBgSprite = "GenericPanel"; _SortAscending.tooltip = "Sort ascending"; _SortAscending.atlas = _atlas; _SortAscending.hoveredBgSprite = "OptionBaseFocused"; _SortAscending.pressedBgSprite = "OptionBasePressed"; _SortAscending.normalFgSprite = "SortAscending"; _SortAscending.eventClick += delegate(UIComponent component, UIMouseEventParameter eventParam) { MusicManager.MusicEntries.Sort(new Comparison <MusicEntry>((x, y) => { return(x.BaseName.CompareTo(y.BaseName)); })); MusicManager.SaveMusicFileSettings(); UpdateMusicListPreserveScroll(); }; } { _SortDescending = AddUIComponent <UIButton>(); _SortDescending.width = 36; _SortDescending.height = 36; _SortDescending.relativePosition = new Vector3(130 + 40 * 3, 10); _SortDescending.normalBgSprite = "GenericPanel"; _SortDescending.tooltip = "Sort ascending"; _SortDescending.atlas = _atlas; _SortDescending.hoveredBgSprite = "OptionBaseFocused"; _SortDescending.pressedBgSprite = "OptionBasePressed"; _SortDescending.normalFgSprite = "SortDescending"; _SortDescending.eventClick += delegate(UIComponent component, UIMouseEventParameter eventParam) { MusicManager.MusicEntries.Sort(new Comparison <MusicEntry>((x, y) => { return(-x.BaseName.CompareTo(y.BaseName)); })); MusicManager.SaveMusicFileSettings(); UpdateMusicListPreserveScroll(); }; } { _Filter = AddUIComponent <UITextField>(); _Filter.width = width - 130 - 40 - 36 - 10 - 10 - 36 * 3 - 10; _Filter.height = 36; _Filter.relativePosition = new Vector3(130 + 40 + 10 + 36 * 3, 10); _Filter.padding = new RectOffset(6, 6, 3, 3); _Filter.builtinKeyNavigation = true; _Filter.isInteractive = true; _Filter.readOnly = false; _Filter.horizontalAlignment = UIHorizontalAlignment.Left; _Filter.verticalAlignment = UIVerticalAlignment.Middle; _Filter.selectionSprite = "EmptySprite"; _Filter.selectionBackgroundColor = new Color32(0, 172, 234, 255); _Filter.normalBgSprite = "TextFieldPanel"; _Filter.disabledTextColor = new Color32(0, 0, 0, 128); _Filter.color = new Color32(60, 60, 60, 255); _Filter.textColor = Color.gray; _Filter.padding = new RectOffset(6, 6, 9, 9); _Filter_Clear = AddUIComponent <UIButton>(); _Filter_Clear.width = 22; _Filter_Clear.height = 22; _Filter_Clear.relativePosition = _Filter.relativePosition + new Vector3(7 + _Filter.width - 36, 7); _Filter_Clear.atlas = _atlas; _Filter_Clear.normalFgSprite = "Search"; _Filter_Clear.hoveredColor = new Color32(255, 255, 255, 128); _Filter.eventTextChanged += delegate { if (!Filtered) { _Filter_Clear.normalFgSprite = "Search"; } else { _Filter_Clear.normalFgSprite = "Clear"; } UpdateMusicList(); }; _Filter_Clear.eventClick += (component, eventParam) => { _Filter.text = ""; }; } { _enable_Playlist_random = AddUIComponent <UICheckButton>(); _enable_Playlist_random.width = 36; _enable_Playlist_random.height = 36; _enable_Playlist_random.relativePosition = new Vector3(width - 10 - 36, 10); _enable_Playlist_random.normalBgSprite = "GenericPanel"; _enable_Playlist_random.tooltip = "Enable randomized playback"; _enable_Playlist_random.atlas = _atlas; _enable_Playlist_random.normalBgSprite = "OptionBase"; _enable_Playlist_random.hoveredBgSprite = "OptionBaseFocused"; _enable_Playlist_random.pressedBgSprite = "OptionBasePressed"; _enable_Playlist_random.normalFgSprite = "Shuffle"; _enable_Playlist_random.eventCheckStateChanged += delegate(UICheckButton sender, bool state) { if (SettingsManager.ModOptions.RandomTrackSelection != state) { SettingsManager.ModOptions.RandomTrackSelection = state; SettingsManager.SaveModSettings(); } }; } }