Ejemplo n.º 1
0
    private void InitMenu()
    {
        // Recording device
        recordingDevicePickerControl = new(recordingDevicePicker, Microphone.devices.ToList());
        recordingDevicePickerControl.SelectItem(settings.MicProfile.Name);
        recordingDevicePickerControl.Selection.Subscribe(newValue => settings.SetMicProfileName(newValue));

        // Language
        languagePickerControl = new LabeledItemPickerControl <SystemLanguage>(languagePicker, translationManager.GetTranslatedLanguages());
        languagePickerControl.SelectItem(settings.GameSettings.language);
        languagePickerControl.Selection.Subscribe(newValue => settings.GameSettings.language = newValue);
        settings.ObserveEveryValueChanged(it => it.GameSettings.language)
        .Subscribe(newValue =>
        {
            translationManager.currentLanguage = newValue;
            translationManager.ReloadTranslationsAndUpdateScene();
        });

        // Dev Mode
        devModePickerControl = new BoolPickerControl(devModePicker);
        devModePickerControl.SelectItem(settings.IsDevModeEnabled);
        devModePickerControl.Selection.Subscribe(newValue => settings.IsDevModeEnabled = newValue);
        settings
        .ObserveEveryValueChanged(it => it.IsDevModeEnabled)
        .Subscribe(newValue => OnDevModeEnabledChanged(newValue));

        // Show/hide menu overlay
        HideMenu();
        showMenuButton.RegisterCallbackButtonTriggered(() => ShowMenu());
        hiddenCloseMenuButton.RegisterCallbackButtonTriggered(() => HideMenu());
        closeMenuButton.RegisterCallbackButtonTriggered(() => HideMenu());
    }
Ejemplo n.º 2
0
    public void OnInjectionFinished()
    {
        // Select recording device if none.
        if (settings.MicProfile.Name.IsNullOrEmpty() ||
            !Microphone.devices.Contains(settings.MicProfile.Name))
        {
            settings.SetMicProfileName(Microphone.devices.FirstOrDefault());
        }

        settings.ObserveEveryValueChanged(it => it.MicProfile)
        .Subscribe(_ => OnMicProfileChanged());
        micSampleRecorder.IsRecording.Subscribe(OnRecordingStateChanged);
        micSampleRecorder.FinalSampleRate.Subscribe(_ => UpdateRecordingDeviceInfo());

        // All controls are hidden until a connection has been established.
        onlyVisibleWhenConnected.ForEach(it => it.HideByDisplay());
        onlyVisibleWhenNotConnected.ForEach(it => it.ShowByDisplay());
        connectionThroubleshootingText.HideByDisplay();
        serverErrorResponseText.HideByDisplay();

        toggleRecordingButton.RegisterCallbackButtonTriggered(ToggleRecording);

        clientNameTextField.value = settings.ClientName;
        clientNameTextField.RegisterCallback <NavigationSubmitEvent>(_ => OnClientNameTextFieldSubmit());
        clientNameTextField.RegisterCallback <BlurEvent>(_ => OnClientNameTextFieldSubmit());

        visualizeAudioToggle.value = settings.ShowAudioWaveForm;
        audioWaveForm.SetVisibleByDisplay(settings.ShowAudioWaveForm);
        visualizeAudioToggle.RegisterValueChangedCallback(changeEvent =>
        {
            audioWaveForm.SetVisibleByDisplay(changeEvent.newValue);
            settings.ShowAudioWaveForm = changeEvent.newValue;
        });

        clientSideConnectRequestManager.ConnectEventStream
        .Subscribe(UpdateConnectionStatus);

        songListRequestor.SongListEventStream.Subscribe(evt => HandleSongListEvent(evt));

        UpdateVersionInfoText();

        audioWaveForm.RegisterCallbackOneShot <GeometryChangedEvent>(evt =>
        {
            audioWaveFormVisualization = new AudioWaveFormVisualization(gameObject, audioWaveForm);
        });

        songSearchTextField.RegisterValueChangedCallback(evt =>
        {
            songSearchHint.SetVisibleByDisplay(songSearchTextField.value.IsNullOrEmpty());
            UpdateSongList();
        });

        InitTabGroup();
        InitMenu();
    }
Ejemplo n.º 3
0
    private void InitTabGroup()
    {
        TabGroupControl tabGroupControl = new TabGroupControl();

        tabGroupControl.AllowNoContainerVisible = false;
        tabGroupControl.AddTabGroupButton(showMicViewButton, micViewContainer);
        tabGroupControl.AddTabGroupButton(showSongViewButton, songViewContainer);
        tabGroupControl.ShowContainer(micViewContainer);

        showSongViewButton.RegisterCallbackButtonTriggered(() =>
        {
            micSampleRecorder.StopRecording();
            songSearchTextField.value = "";
            ShowSongList();
        });
    }
    private void UpdateRecordingDeviceButtons()
    {
        recordingDeviceButtonContainer.Clear();
        if (Microphone.devices.Length <= 1)
        {
            // No real choice
            return;
        }

        Microphone.devices.ForEach(device =>
        {
            Button deviceButton = new Button();
            deviceButton.RegisterCallbackButtonTriggered(
                () => clientSideMicSampleRecorder.SetRecordingDevice(device));
            deviceButton.text = $"{device}";
            recordingDeviceButtonContainer.Add(deviceButton);
        });
    }
    private void Start()
    {
        clientSideMicSampleRecorder.DeviceName
        .Subscribe(_ => UpdateSelectedRecordingDeviceText());
        clientSideMicSampleRecorder.SampleRate
        .Subscribe(_ => UpdateSelectedRecordingDeviceText());
        clientSideMicSampleRecorder.IsRecording
        .Subscribe(OnRecordingStateChanged);

        // All controls are hidden until a connection has been established.
        uiDoc.rootVisualElement.Query(null, "onlyVisibleWhenConnected").ForEach(it => it.Hide());
        connectionThroubleshootingText.Hide();
        serverErrorResponseText.Hide();

        toggleRecordingButton.RegisterCallbackButtonTriggered(ToggleRecording);

        clientNameTextField.value = settings.ClientName;
        clientNameTextField.RegisterCallback <NavigationSubmitEvent>(_ => OnClientNameTextFieldSubmit());
        clientNameTextField.RegisterCallback <BlurEvent>(_ => OnClientNameTextFieldSubmit());

        visualizeAudioToggle.value = settings.ShowAudioWaveForm;
        audioWaveForm.SetVisible(settings.ShowAudioWaveForm);
        visualizeAudioToggle.RegisterValueChangedCallback(changeEvent =>
        {
            audioWaveForm.SetVisible(changeEvent.newValue);
            settings.ShowAudioWaveForm = changeEvent.newValue;
        });

        clientSideConnectRequestManager.ConnectEventStream
        .Subscribe(UpdateConnectionStatus);

        songListRequestor.SongListEventStream.Subscribe(evt => HandleSongListEvent(evt));

        showSongListButton.RegisterCallbackButtonTriggered(() => ShowSongList());
        closeSongListButton.RegisterCallbackButtonTriggered(() => songListContainer.Hide());

        UpdateVersionInfoText();
    }