public override void StartRecording()
    {
        SteamUser.StartVoiceRecording();
        uint n;

        isRecording = SteamUser.GetAvailableVoice(out n) != EVoiceResult.k_EVoiceResultNotRecording;
    }
Esempio n. 2
0
 protected override void Update()
 {
     try
     {
         if (!IsLocal)
         {
             return;
         }
         if (GetComponentInParent <FirstPersonCharacter>() && WalkieTalkie.gameObject.activeInHierarchy)
         {
             if (recording)
             {
                 uint nBytesWritten;
                 uint nUncompressBytesWritten;
                 if (SteamUser.GetVoice(true, vc_cmp, 65536U, out nBytesWritten, false, null, 0U, out nUncompressBytesWritten, 0U) != EVoiceResult.k_EVoiceResultOK || nBytesWritten <= 0U)
                 {
                     return;
                 }
                 if (BoltNetwork.isServer)
                 {
                     ForwardVoiceData(vc_cmp, (int)nBytesWritten);
                 }
                 else
                 {
                     try
                     {
                         SendVoiceData(vc_cmp, (int)nBytesWritten, BoltNetwork.server);
                     }
                     catch (Exception e)
                     {
                         Logger.Exception("SendVoiceData failed!", e);
                         base.SendVoiceData(vc_cmp, (int)nBytesWritten, BoltNetwork.server);
                     }
                 }
             }
             else
             {
                 SteamUser.StartVoiceRecording();
                 SteamFriends.SetInGameVoiceSpeaking(SteamUser.GetSteamID(), true);
                 recording = true;
             }
         }
         else
         {
             if (!recording)
             {
                 return;
             }
             recording = false;
             SteamFriends.SetInGameVoiceSpeaking(SteamUser.GetSteamID(), false);
             SteamUser.StopVoiceRecording();
         }
     }
     catch (Exception e)
     {
         Logger.Exception("Failed to update CoopVoice", e);
     }
 }
Esempio n. 3
0
 private void Update()
 {
     if (this.IsLocal)
     {
         if (base.GetComponentInParent <BoltEntity>().IsOwner() && this.WalkieTalkie.gameObject.activeInHierarchy)
         {
             if (this.recording)
             {
                 uint num;
                 uint num2;
                 if (SteamUser.GetVoice(true, this.vc_cmp, 65536u, out num, false, null, 0u, out num2, 0u) == EVoiceResult.k_EVoiceResultOK && num > 0u)
                 {
                     BoltEntity component = base.GetComponent <BoltEntity>();
                     if (component && component.isAttached)
                     {
                         if (BoltNetwork.isServer)
                         {
                             this.ForwardVoiceData(this.vc_cmp, (int)num);
                         }
                         else
                         {
                             this.SendVoiceData(this.vc_cmp, (int)num, BoltNetwork.server);
                         }
                     }
                 }
             }
             else
             {
                 SteamUser.StartVoiceRecording();
                 SteamFriends.SetInGameVoiceSpeaking(SteamUser.GetSteamID(), true);
                 this.recording = true;
             }
         }
         else if (this.recording)
         {
             this.recording = false;
             SteamFriends.SetInGameVoiceSpeaking(SteamUser.GetSteamID(), false);
             SteamUser.StopVoiceRecording();
         }
     }
 }
Esempio n. 4
0
        private void Update()
        {
            var nSample = sampleRateMethod == SampleRateMethod.Optimal ? (int)SteamUser.GetVoiceOptimalSampleRate() : sampleRateMethod == SampleRateMethod.Native ? AudioSettings.outputSampleRate : (int)customSampleRate;

            if (nSample != sampleRate)
            {
                sampleRate = nSample;
                OutputSource.Stop();

                if (OutputSource.clip != null)
                {
                    Destroy(OutputSource.clip);
                }

                if (useAudioStreaming)
                {
                    OutputSource.clip = AudioClip.Create("VOICE", sampleRate * 2, 1, (int)sampleRate, true, OnAudioRead);
                    OutputSource.Play();
                }
                else
                {
                    OutputSource.clip = AudioClip.Create("VOICE", sampleRate * 2, 1, (int)sampleRate, false);
                }
            }

            if (!useAudioStreaming && OutputSource.loop)
            {
                OutputSource.loop = false;
                OutputSource.clip = AudioClip.Create("VOICE", sampleRate * 2, 1, (int)sampleRate, false);
            }
            else if (useAudioStreaming && !OutputSource.loop)
            {
                OutputSource.loop = true;
                OutputSource.clip = AudioClip.Create("VOICE", sampleRate * 2, 1, (int)sampleRate, true, OnAudioRead);
                OutputSource.Play();
            }

            if (!useAudioStreaming && clipBuffer.Count > 0 && !OutputSource.isPlaying)
            {
                OutputSource.clip = clipBuffer.Dequeue();
                OutputSource.Play();
            }

            packetCounter -= Time.unscaledDeltaTime;

            if (packetCounter <= 0)
            {
                packetCounter = bufferLength;

                if (isRecording)
                {
                    var result = SteamUser.GetAvailableVoice(out uint pcbCompressed);
                    switch (result)
                    {
                    case EVoiceResult.k_EVoiceResultOK:
                        //All is well check the compressed size to see if we have data and if so package it
                        byte[] buffer = new byte[pcbCompressed];
                        SteamUser.GetVoice(true, buffer, pcbCompressed, out uint bytesWriten);
                        if (bytesWriten > 0)
                        {
                            VoiceStream.Invoke(buffer);
                        }
                        break;

                    case EVoiceResult.k_EVoiceResultNoData:
                        //No data so do nothing
                        break;

                    case EVoiceResult.k_EVoiceResultNotInitialized:
                        //Not initalized ... report the error
                        Debug.LogError("The Steam Voice systemis not initalized and will be stoped.");
                        SteamUser.StopVoiceRecording();
                        break;

                    case EVoiceResult.k_EVoiceResultNotRecording:
                        //We are not recording but think we are
                        SteamUser.StartVoiceRecording();
                        break;

                    case EVoiceResult.k_EVoiceResultRestricted:
                        //User is chat restricted ... report this out and turn off recording.
                        StopedOnChatRestricted.Invoke();
                        SteamUser.StopVoiceRecording();
                        break;
                    }
                }
            }
        }
Esempio n. 5
0
 /// <summary>
 /// Starts the Steam API recording audio from the user's configured mic
 /// </summary>
 public void StartRecording()
 {
     isRecording = true;
     SteamUser.StartVoiceRecording();
 }
Esempio n. 6
0
        public static void Init()
        {
            if (Instance == null)
            {
                try
                {
                    Instance = BeatSaberUI.CreateCustomMenu <CustomMenu>("Multiplayer Lobby");

                    CustomViewController middleViewController = BeatSaberUI.CreateViewController <CustomViewController>();
                    ListViewController   leftViewController   = BeatSaberUI.CreateViewController <ListViewController>();
                    rightViewController = BeatSaberUI.CreateViewController <TableViewController>();

                    Instance.SetMainViewController(middleViewController, true, (firstActivation, type) =>
                    {
                        if (firstActivation)
                        {
                            try
                            {
                                Button host = middleViewController.CreateUIButton("CreditsButton", new Vector2(BASE.x, BASE.y + 2.5f), new Vector2(25f, 7f));
                                host.SetButtonTextSize(3f);
                                host.ToggleWordWrapping(false);
                                host.SetButtonText("Disconnect");
                                host.onClick.AddListener(delegate
                                {
                                    try
                                    {
                                        SteamAPI.Disconnect();
                                        Instance.Dismiss();
                                        MultiplayerListing.Instance.Present();
                                    }
                                    catch (Exception e)
                                    {
                                        Logger.Error(e);
                                    }
                                });
                                float offs = 0;
                                offs      += 10f;
                                Button vc  = middleViewController.CreateUIButton("CreditsButton", new Vector2(BASE.x, BASE.y + 2.5f - offs), new Vector2(25f, 7f));
                                vc.SetButtonTextSize(3f);
                                vc.ToggleWordWrapping(false);
                                vc.SetButtonText(Controllers.PlayerController.Instance.VoipEnabled ? "Disable Voice Chat" : "Enable Voice Chat");
                                vc.onClick.AddListener(delegate
                                {
                                    try
                                    {
                                        if (!Controllers.PlayerController.Instance.VoipEnabled)
                                        {
                                            vc.SetButtonText("Disable Voice Chat");
                                            Controllers.PlayerController.Instance.VoipEnabled = true;
                                            SteamUser.StartVoiceRecording();
                                        }
                                        else
                                        {
                                            vc.SetButtonText("Enable Voice Chat");
                                            Controllers.PlayerController.Instance.VoipEnabled = false;
                                            SteamUser.StopVoiceRecording();
                                        }
                                    }
                                    catch (Exception e)
                                    {
                                        Logger.Error(e);
                                    }
                                });
                                var t        = middleViewController.CreateText("You can use Online Lobby in the Main Menu to choose songs for your lobby. \n\nYou can also control all the default Game Modifiers for the lobby through the Online Lobby Menu as well.", new Vector2(0, BASE.y - 10f));
                                var tt       = middleViewController.CreateText("If something goes wrong, click the disconnect button above and just reconnect to the lobby.", new Vector2(0, 0 - BASE.y));
                                t.alignment  = TMPro.TextAlignmentOptions.Center;
                                tt.alignment = TMPro.TextAlignmentOptions.Center;
                            } catch (Exception e)
                            {
                                Data.Logger.Error(e);
                            }

                            /*   Button g = middleViewController.CreateUIButton("CreditsButton", new Vector2(0, 0), new Vector2(25f, 25f));
                             * g.SetButtonTextSize(7f);
                             * g.ToggleWordWrapping(false);
                             * g.SetButtonText("Select a Song");
                             * g.onClick.AddListener(delegate {
                             *     try
                             *     {
                             *         if (SteamAPI.IsHost())
                             *         {
                             *             SteamAPI.SetSong("112D7FA45FA06F36FF41029099E95B98", "TaKillYa");
                             *             SteamAPI.SetDifficulty((byte)2);
                             *             SteamAPI.RequestPlay(new GameplayModifiers(new GameplayModifiers()));
                             *         }
                             *     }
                             *     catch (Exception e)
                             *     {
                             *         Logger.Error(e);
                             *     }
                             * });*/
                        }
                    });
                    Instance.SetLeftViewController(leftViewController, false, (firstActivation, type) =>
                    {
                        if (firstActivation)
                        {
                            refreshFriendsList(leftViewController);
                            leftViewController.CreateText("Invite Friends", new Vector2(BASE.x + 62.5f, BASE.y));

                            Button b = leftViewController.CreateUIButton("CreditsButton", new Vector2(BASE.x + 80f, BASE.y + 2.5f), new Vector2(25f, 7f));
                            b.SetButtonText("Refresh");
                            b.SetButtonTextSize(3f);
                            b.ToggleWordWrapping(false);
                            b.onClick.AddListener(delegate()
                            {
                                refreshFriendsList(leftViewController);
                            });


                            invite = leftViewController.CreateUIButton("CreditsButton", new Vector2(BASE.x + 80f, 0 - BASE.y + 2.5f), new Vector2(25f, 7f));
                            invite.SetButtonText("Invite");
                            invite.SetButtonTextSize(3f);
                            invite.ToggleWordWrapping(false);
                            invite.interactable = false;
                            invite.onClick.AddListener(delegate()
                            {
                                if (selectedPlayer > 0)
                                {
                                    SteamAPI.InviteUserToLobby(new CSteamID(selectedPlayer));
                                }
                            });
                        }
                    });
                    Instance.SetRightViewController(rightViewController, false, (active, type) => {
                        if (active)
                        {
                            rightViewController.CreateText("Lobby Leaderboard", new Vector2(BASE.x + 62.5f, BASE.y));
                        }
                        RefreshScores();
                    });
                } catch (Exception e)
                {
                    Data.Logger.Error(e);
                }
            }
        }
    public void RenderOnGUI()
    {
        GUILayout.BeginArea(new Rect(Screen.width - 200, 0, 200, Screen.height));
        GUILayout.Label("Variables:");
        GUILayout.Label("m_Ticket: " + m_Ticket);
        GUILayout.Label("m_pcbTicket: " + m_pcbTicket);
        GUILayout.Label("m_HAuthTicket: " + m_HAuthTicket);
        GUILayout.Label("m_VoiceLoopback: " + m_VoiceLoopback);
        GUILayout.EndArea();

        GUILayout.BeginVertical("box");
        m_ScrollPos = GUILayout.BeginScrollView(m_ScrollPos, GUILayout.Width(Screen.width - 215), GUILayout.Height(Screen.height - 33));

        GUILayout.Label("GetHSteamUser() : " + SteamUser.GetHSteamUser());

        GUILayout.Label("BLoggedOn() : " + SteamUser.BLoggedOn());

        GUILayout.Label("GetSteamID() : " + SteamUser.GetSteamID());

        //SteamUser.InitiateGameConnection() // N/A - Too Hard to test like this.

        //SteamUser.TerminateGameConnection() // ^

        //SteamUser.TrackAppUsageEvent() // Legacy function with no documentation

        {
            string Buffer;
            bool   ret = SteamUser.GetUserDataFolder(out Buffer, 260);
            GUILayout.Label("GetUserDataFolder(out Buffer, 260) : " + ret + " -- " + Buffer);
        }

        if (GUILayout.Button("StartVoiceRecording()"))
        {
            SteamUser.StartVoiceRecording();
            print("SteamUser.StartVoiceRecording()");
        }

        if (GUILayout.Button("StopVoiceRecording()"))
        {
            SteamUser.StopVoiceRecording();
            print("SteamUser.StopVoiceRecording()");
        }

        {
            uint         Compressed;
            EVoiceResult ret = SteamUser.GetAvailableVoice(out Compressed);
            GUILayout.Label("GetAvailableVoice(out Compressed) : " + ret + " -- " + Compressed);

            if (ret == EVoiceResult.k_EVoiceResultOK && Compressed > 0)
            {
                byte[] DestBuffer = new byte[1024];
                uint   BytesWritten;
                ret = SteamUser.GetVoice(true, DestBuffer, 1024, out BytesWritten);
                //print("SteamUser.GetVoice(true, DestBuffer, 1024, out BytesWritten) : " + ret + " -- " + BytesWritten);

                if (ret == EVoiceResult.k_EVoiceResultOK && BytesWritten > 0)
                {
                    byte[] DestBuffer2 = new byte[11025 * 2];
                    uint   BytesWritten2;
                    ret = SteamUser.DecompressVoice(DestBuffer, BytesWritten, DestBuffer2, (uint)DestBuffer2.Length, out BytesWritten2, 11025);
                    //print("SteamUser.DecompressVoice(DestBuffer, BytesWritten, DestBuffer2, (uint)DestBuffer2.Length, out BytesWritten2, 11025) - " + ret + " -- " + BytesWritten2);

                    if (ret == EVoiceResult.k_EVoiceResultOK && BytesWritten2 > 0)
                    {
                        AudioSource source;
                        if (!m_VoiceLoopback)
                        {
                            m_VoiceLoopback = new GameObject("Voice Loopback");
                            source          = m_VoiceLoopback.AddComponent <AudioSource>();
                            source.clip     = AudioClip.Create("Testing!", 11025, 1, 11025, false);
                        }
                        else
                        {
                            source = m_VoiceLoopback.GetComponent <AudioSource>();
                        }

                        float[] test = new float[11025];
                        for (int i = 0; i < test.Length; ++i)
                        {
                            test[i] = (short)(DestBuffer2[i * 2] | DestBuffer2[i * 2 + 1] << 8) / 32768.0f;
                        }
                        source.clip.SetData(test, 0);
                        source.Play();
                    }
                }
            }
        }

        GUILayout.Label("GetVoiceOptimalSampleRate() : " + SteamUser.GetVoiceOptimalSampleRate());

        {
            if (GUILayout.Button("GetAuthSessionTicket(Ticket, 1024, out pcbTicket)"))
            {
                m_Ticket      = new byte[1024];
                m_HAuthTicket = SteamUser.GetAuthSessionTicket(m_Ticket, 1024, out m_pcbTicket);
                print("SteamUser.GetAuthSessionTicket(Ticket, 1024, out pcbTicket) - " + m_HAuthTicket + " -- " + m_pcbTicket);
            }

            if (GUILayout.Button("BeginAuthSession(m_Ticket, (int)m_pcbTicket, SteamUser.GetSteamID())"))
            {
                if (m_HAuthTicket != HAuthTicket.Invalid && m_pcbTicket != 0)
                {
                    EBeginAuthSessionResult ret = SteamUser.BeginAuthSession(m_Ticket, (int)m_pcbTicket, SteamUser.GetSteamID());
                    print("SteamUser.BeginAuthSession(m_Ticket, " + (int)m_pcbTicket + ", " + SteamUser.GetSteamID() + ") - " + ret);
                }
                else
                {
                    print("Call GetAuthSessionTicket first!");
                }
            }
        }

        if (GUILayout.Button("EndAuthSession(SteamUser.GetSteamID())"))
        {
            SteamUser.EndAuthSession(SteamUser.GetSteamID());
            print("SteamUser.EndAuthSession(" + SteamUser.GetSteamID() + ")");
        }

        if (GUILayout.Button("CancelAuthTicket(m_HAuthTicket)"))
        {
            SteamUser.CancelAuthTicket(m_HAuthTicket);
            print("SteamUser.CancelAuthTicket(" + m_HAuthTicket + ")");
        }

        GUILayout.Label("UserHasLicenseForApp(SteamUser.GetSteamID(), SteamUtils.GetAppID()) : " + SteamUser.UserHasLicenseForApp(SteamUser.GetSteamID(), SteamUtils.GetAppID()));

        GUILayout.Label("BIsBehindNAT() : " + SteamUser.BIsBehindNAT());

        if (GUILayout.Button("AdvertiseGame(CSteamID.NonSteamGS, TestConstants.k_IpAdress127_0_0_1, TestConstants.k_Port27015)"))
        {
            SteamUser.AdvertiseGame(CSteamID.NonSteamGS, TestConstants.k_IpAdress127_0_0_1, TestConstants.k_Port27015);
            print("SteamUser.AdvertiseGame(" + CSteamID.NonSteamGS + ", " + TestConstants.k_IpAdress127_0_0_1 + ", " + TestConstants.k_Port27015 + ")");
        }

        if (GUILayout.Button("RequestEncryptedAppTicket(k_unSecretData, sizeof(uint))"))
        {
            byte[]         k_unSecretData = System.BitConverter.GetBytes(0x5444);
            SteamAPICall_t handle         = SteamUser.RequestEncryptedAppTicket(k_unSecretData, sizeof(uint));
            OnEncryptedAppTicketResponseCallResult.Set(handle);
            print("SteamUser.RequestEncryptedAppTicket(" + k_unSecretData + ", " + sizeof(uint) + ") : " + handle);
        }

        if (GUILayout.Button("GetEncryptedAppTicket(rgubTicket, 1024, out cubTicket)"))
        {
            byte[] rgubTicket = new byte[1024];
            uint   cubTicket;
            bool   ret = SteamUser.GetEncryptedAppTicket(rgubTicket, 1024, out cubTicket);
            print("SteamUser.GetEncryptedAppTicket(" + rgubTicket + ", " + 1024 + ", " + "out cubTicket" + ") : " + ret + " -- " + cubTicket);
        }

        // SpaceWar does not have trading cards, so this function will only ever return 0 and produce an annoying warning.
        if (GUILayout.Button("GetGameBadgeLevel(1, false)"))
        {
            int ret = SteamUser.GetGameBadgeLevel(1, false);
            print("SteamUser.GetGameBadgeLevel(" + 1 + ", " + false + ") : " + ret);
        }

        GUILayout.Label("GetPlayerSteamLevel() : " + SteamUser.GetPlayerSteamLevel());

        if (GUILayout.Button("RequestStoreAuthURL(\"https://steampowered.com\")"))
        {
            SteamAPICall_t handle = SteamUser.RequestStoreAuthURL("https://steampowered.com");
            OnStoreAuthURLResponseCallResult.Set(handle);
            print("SteamUser.RequestStoreAuthURL(" + "\"https://steampowered.com\"" + ") : " + handle);
        }

        GUILayout.Label("BIsPhoneVerified() : " + SteamUser.BIsPhoneVerified());

        GUILayout.Label("BIsTwoFactorEnabled() : " + SteamUser.BIsTwoFactorEnabled());

        GUILayout.Label("BIsPhoneIdentifying() : " + SteamUser.BIsPhoneIdentifying());

        GUILayout.Label("BIsPhoneRequiringVerification() : " + SteamUser.BIsPhoneRequiringVerification());

        if (GUILayout.Button("GetMarketEligibility()"))
        {
            SteamAPICall_t handle = SteamUser.GetMarketEligibility();
            OnMarketEligibilityResponseCallResult.Set(handle);
            print("SteamUser.GetMarketEligibility() : " + handle);
        }

        GUILayout.EndScrollView();
        GUILayout.EndVertical();
    }
Esempio n. 8
0
        public void Init(ulong mySteamID)
        {
            if (isInitialized)
            {
                return;
            }
            isInitialized = true;

            RemoveListenerSteamID(mySteamID);
            this.mySteamID        = new CSteamID(mySteamID);
            newConnectionCallback = Callback <P2PSessionRequest_t> .Create(t => SteamNetworking.AcceptP2PSessionWithUser(t.m_steamIDRemote));

            // default accept all

            Program.MainWindow.InvokeFunc(() => GlobalHook.RegisterHandler(PushToTalkHotkey, (key, pressed) =>
            {
                if (pressed)
                {
                    if (!isRecording)
                    {
                        SteamUser.StartVoiceRecording();
                        SteamFriends.SetInGameVoiceSpeaking(new CSteamID(mySteamID), true);
                        isRecording = true;
                        talkWaiter.Set();
                        lastPacket[mySteamID] = DateTime.Now;
                        UserStartsTalking(mySteamID);
                    }
                }
                else
                {
                    if (isRecording)
                    {
                        SteamUser.StopVoiceRecording();
                        SteamFriends.SetInGameVoiceSpeaking(new CSteamID(mySteamID), false);
                        isRecording           = false;
                        lastPacket[mySteamID] = null;
                        UserStopsTalking(mySteamID);
                    }
                }
                return(false);
            }));

            soundOut = new DirectSoundOut();

            mixer           = new MixingSampleProvider(WaveFormat.CreateIeeeFloatWaveFormat(sampleRate, 1));
            mixer.ReadFully = true;

            mixerWrapper = new MixerWrapper <ulong>(mixer);


            silencer = new byte[(int)(new WaveFormat(sampleRate, 1).AverageBytesPerSecond *silencerBufferMs / 1000.0 / 2 * 2)];

            soundOut.Init(mixer);
            soundOut.Play();

            new Thread(RecordingFunc).Start();
            if (testLoopback)
            {
                new Thread(LoopbackFunc).Start();
            }
            else
            {
                new Thread(PlayingFunc).Start();
            }

            foreach (var t in targetSteamIDs)
            {
                SendDummyP2PPacket(t.Key);
            }
            lastPacket[mySteamID] = null;
            UserVoiceEnabled(mySteamID);
        }
    //public void playVoiceIfAvailable()
    //{
    //    uint Compressed;
    //    uint Uncompressed;
    //    ret = SteamUser.GetAvailableVoice(out Compressed, out Uncompressed, 11025);


    //    if (ret == EVoiceResult.k_EVoiceResultOK && Compressed > 0)
    //    {
    //        //Console.WriteLine("GetAvailableVoice(out Compressed, out Uncompressed, 11025) : " + ret + " -- " + Compressed + " -- " + Uncompressed);
    //        uint BytesWritten;
    //        uint UncompressedBytesWritten;
    //        ret = SteamUser.GetVoice(true, DestBuffer, 1024, out BytesWritten, true, UncompressedDestBuffer, (uint)DestBuffer.Length, out UncompressedBytesWritten, 11025);
    //        //Console.WriteLine("SteamUser.GetVoice(true, DestBuffer, 1024, out BytesWritten, true, UncompressedDestBuffer, (uint)DestBuffer.Length, out UncompressedBytesWritten, 11025) : " + ret + " -- " + BytesWritten + " -- " + UncompressedBytesWritten);

    //        if (ret == EVoiceResult.k_EVoiceResultOK && BytesWritten > 0)
    //        {

    //            uint BytesWritten2;
    //            ret = SteamUser.DecompressVoice(DestBuffer, BytesWritten, DestBuffer2, (uint)DestBuffer2.Length, out BytesWritten2, 11025);
    //            //Console.WriteLine("SteamUser.DecompressVoice(DestBuffer, BytesWritten, DestBuffer2, (uint)DestBuffer2.Length, out BytesWritten2, 11025) - " + ret + " -- " + BytesWritten2);

    //            if (ret == EVoiceResult.k_EVoiceResultOK && BytesWritten2 > 0)
    //            {

    //                //converts to doubles?
    //                //for (int i = 0; i < test.Length; ++i)
    //                //{
    //                //    test[i] = (short)(DestBuffer2[i * 2] | DestBuffer2[i * 2 + 1] << 8) / 32768.0f;
    //                //}
    //                //source.clip.SetData(test, 0);

    //                MemoryStream stream = new MemoryStream(DestBuffer2);

    //                SoundEffect sound = new SoundEffect(stream.ToArray(), 11025, AudioChannels.Mono);
    //                sound.Play();

    //                stream.Dispose();
    //                //sound.Dispose();

    //                ////AudioSource source;
    //                //if (!m_VoiceLoopback)
    //                //{
    //                //    m_VoiceLoopback = new GameObject("Voice Loopback");
    //                //    source = m_VoiceLoopback.AddComponent<AudioSource>();
    //                //    source.clip = AudioClip.Create("Testing!", 11025, 1, 11025, false, false);
    //                //}
    //                //else
    //                //{
    //                //    source = m_VoiceLoopback.GetComponent<AudioSource>();
    //                //}


    //                //source.Play();
    //            }
    //        }
    //    }
    //}



    //Client A must retrieve a session ticket by calling SteamUser()->GetAuthSessionTicket().
    //Client A must send its session ticket to client B.
    //Client B must pass client A's ticket to SteamUser()->BeginAuthSession(), which will perform a quick validity check. If the ticket is valid, BeginAuthSession() will forward the ticket to then the Steam backend to verify that the ticket has not been reused and was issued by the account owner of client A. The result of this verification will be returned in a ValidateAuthTicketResponse_t callback.
    //When the multiplayer session terminates:
    //    Client A must pass the handle initially returned from GetAuthSessionTicket() to SteamUser()->CancelAuthTicket().
    //    Client B must pass the SteamID of client A to SteamUser()->EndAuthSession().


    public void RenderOnGUI()
    {
        //GUILayout.BeginArea(new Rect(Screen.width - 200, 0, 200, Screen.height));
        //GUILayout.Label("m_HAuthTicket: " + m_HAuthTicket);
        //GUILayout.Label("m_pcbTicket: " + m_pcbTicket);
        //GUILayout.EndArea();

        //GUILayout.Label("GetHSteamUser() : " + SteamUser.GetHSteamUser());
        //GUILayout.Label("BLoggedOn() : " + SteamUser.BLoggedOn());
        //GUILayout.Label("GetSteamID() : " + SteamUser.GetSteamID());

        //GUILayout.Label("InitiateGameConnection() : " + SteamUser.InitiateGameConnection()); // N/A - Too Hard to test like this.
        //GUILayout.Label("TerminateGameConnection() : " + SteamUser.TerminateGameConnection()); // ^
        //GUILayout.Label("TrackAppUsageEvent() : " + SteamUser.TrackAppUsageEvent()); // Legacy function with no documentation

        {
            string Buffer;
            bool   ret = SteamUser.GetUserDataFolder(out Buffer, 260);
            Console.WriteLine("GetUserDataFolder(out Buffer, 260) : " + ret + " -- " + Buffer);
        }

        //if (GUILayout.Button("StartVoiceRecording()"))
        {
            SteamUser.StartVoiceRecording();
            Console.WriteLine("SteamUser.StartVoiceRecording()");
        }

        //if (GUILayout.Button("StopVoiceRecording()"))
        {
            SteamUser.StopVoiceRecording();
            Console.WriteLine("SteamUser.StopVoiceRecording()");
        }

        {
            //GUILayout.Label("GetVoiceOptimalSampleRate() : " + SteamUser.GetVoiceOptimalSampleRate());

            {
                //if (GUILayout.Button("GetAuthSessionTicket(Ticket, 1024, out pcbTicket)"))
                {
                    m_Ticket      = new byte[1024];
                    m_HAuthTicket = SteamUser.GetAuthSessionTicket(m_Ticket, 1024, out m_pcbTicket);
                    Console.WriteLine("SteamUser.GetAuthSessionTicket(Ticket, 1024, out pcbTicket) - " + m_HAuthTicket + " -- " + m_pcbTicket);
                }

                //if (GUILayout.Button("BeginAuthSession(m_Ticket, (int)m_pcbTicket, SteamUser.GetSteamID())"))
                {
                    if (m_HAuthTicket != HAuthTicket.Invalid && m_pcbTicket != 0)
                    {
                        EBeginAuthSessionResult ret = SteamUser.BeginAuthSession(m_Ticket, (int)m_pcbTicket, SteamUser.GetSteamID());
                        Console.WriteLine("SteamUser.BeginAuthSession(m_Ticket, " + (int)m_pcbTicket + ", " + SteamUser.GetSteamID() + ") - " + ret);
                    }
                    else
                    {
                        Console.WriteLine("Call GetAuthSessionTicket first!");
                    }
                }
            }

            //if (GUILayout.Button("EndAuthSession(SteamUser.GetSteamID())"))
            {
                SteamUser.EndAuthSession(SteamUser.GetSteamID());
                Console.WriteLine("SteamUser.EndAuthSession(" + SteamUser.GetSteamID() + ")");
            }

            //if (GUILayout.Button("CancelAuthTicket(m_HAuthTicket)"))
            {
                SteamUser.CancelAuthTicket(m_HAuthTicket);
                Console.WriteLine("SteamUser.CancelAuthTicket(" + m_HAuthTicket + ")");
            }

            Console.WriteLine("UserHasLicenseForApp(SteamUser.GetSteamID(), SteamUtils.GetAppID()) : " + SteamUser.UserHasLicenseForApp(SteamUser.GetSteamID(), SteamUtils.GetAppID()));
            Console.WriteLine("BIsBehindNAT() : " + SteamUser.BIsBehindNAT());

            //if (GUILayout.Button("AdvertiseGame(2, 127.0.0.1, 27015)"))
            {
                SteamUser.AdvertiseGame(CSteamID.NonSteamGS, 2130706433, 27015);
                Console.WriteLine("SteamUser.AdvertiseGame(2, 2130706433, 27015)");
            }

            //if (GUILayout.Button("RequestEncryptedAppTicket()"))
            {
                byte[]         k_unSecretData = System.BitConverter.GetBytes(0x5444);
                SteamAPICall_t handle         = SteamUser.RequestEncryptedAppTicket(k_unSecretData, sizeof(uint));
                OnEncryptedAppTicketResponseCallResult.Set(handle);
                Console.WriteLine("SteamUser.RequestEncryptedAppTicket(k_unSecretData, " + sizeof(uint) + ") - " + handle);
            }

            //if (GUILayout.Button("GetEncryptedAppTicket()"))
            {
                byte[] rgubTicket = new byte[1024];
                uint   cubTicket;
                bool   ret = SteamUser.GetEncryptedAppTicket(rgubTicket, 1024, out cubTicket);
                Console.WriteLine("SteamUser.GetEncryptedAppTicket() - " + ret + " -- " + cubTicket);
            }

            //GUILayout.Label("GetGameBadgeLevel(1, false) : " + SteamUser.GetGameBadgeLevel(1, false)); // SpaceWar does not have trading cards, so this function will only ever return 0 and produce an annoying warning.
            Console.WriteLine("GetPlayerSteamLevel() : " + SteamUser.GetPlayerSteamLevel());

            //if (GUILayout.Button("RequestStoreAuthURL(\"https://steampowered.com\")"))
            {
                SteamAPICall_t handle = SteamUser.RequestStoreAuthURL("https://steampowered.com");
                OnStoreAuthURLResponseCallResult.Set(handle);
                Console.WriteLine("SteamUser.RequestStoreAuthURL(\"https://steampowered.com\") - " + handle);
            }

#if _PS3
            //GUILayout.Label("LogOn() : " + SteamUser.LogOn());
            //GUILayout.Label("LogOnAndLinkSteamAccountToPSN : " + SteamUser.LogOnAndLinkSteamAccountToPSN());
            //GUILayout.Label("LogOnAndCreateNewSteamAccountIfNeeded : " + SteamUser.LogOnAndCreateNewSteamAccountIfNeeded());
            //GUILayout.Label("GetConsoleSteamID : " + SteamUser.GetConsoleSteamID());
#endif
        }
    }
 public void startRecordingVoice()
 {
     SteamUser.StartVoiceRecording();
 }
    public void RenderOnGUI()
    {
        GUILayout.BeginArea(new Rect(Screen.width - 200, 0, 200, Screen.height));
        GUILayout.Label("m_HAuthTicket: " + m_HAuthTicket);
        GUILayout.Label("m_pcbTicket: " + m_pcbTicket);
        GUILayout.EndArea();

        GUILayout.Label("GetHSteamUser() : " + SteamUser.GetHSteamUser());
        GUILayout.Label("BLoggedOn() : " + SteamUser.BLoggedOn());
        GUILayout.Label("GetSteamID() : " + SteamUser.GetSteamID());

        //GUILayout.Label("InitiateGameConnection() : " + SteamUser.InitiateGameConnection()); // N/A - Too Hard to test like this.
        //GUILayout.Label("TerminateGameConnection() : " + SteamUser.TerminateGameConnection()); // ^
        //GUILayout.Label("TrackAppUsageEvent() : " + SteamUser.TrackAppUsageEvent()); // Legacy function with no documentation

        {
            string Buffer;
            bool   ret = SteamUser.GetUserDataFolder(out Buffer, 260);
            GUILayout.Label("GetUserDataFolder(out Buffer, 260) : " + ret + " -- " + Buffer);
        }

        if (GUILayout.Button("StartVoiceRecording()"))
        {
            SteamUser.StartVoiceRecording();
            print("SteamUser.StartVoiceRecording()");
        }

        if (GUILayout.Button("StopVoiceRecording()"))
        {
            SteamUser.StopVoiceRecording();
            print("SteamUser.StopVoiceRecording()");
        }

        {
            uint         Compressed;
            uint         Uncompressed;
            EVoiceResult ret = SteamUser.GetAvailableVoice(out Compressed, out Uncompressed, 11025);
            GUILayout.Label("GetAvailableVoice(out Compressed, out Uncompressed, 11025) : " + ret + " -- " + Compressed + " -- " + Uncompressed);

            if (ret == EVoiceResult.k_EVoiceResultOK && Compressed > 0)
            {
                byte[] DestBuffer             = new byte[1024];
                byte[] UncompressedDestBuffer = new byte[1024];
                uint   BytesWritten;
                uint   UncompressedBytesWritten;
                ret = SteamUser.GetVoice(true, DestBuffer, 1024, out BytesWritten, true, UncompressedDestBuffer, (uint)DestBuffer.Length, out UncompressedBytesWritten, 11025);
                //print("SteamUser.GetVoice(true, DestBuffer, 1024, out BytesWritten, true, UncompressedDestBuffer, (uint)DestBuffer.Length, out UncompressedBytesWritten, 11025) : " + ret + " -- " + BytesWritten + " -- " + UncompressedBytesWritten);

                if (ret == EVoiceResult.k_EVoiceResultOK && BytesWritten > 0)
                {
                    byte[] DestBuffer2 = new byte[11025 * 2];
                    uint   BytesWritten2;
                    ret = SteamUser.DecompressVoice(DestBuffer, BytesWritten, DestBuffer2, (uint)DestBuffer2.Length, out BytesWritten2, 11025);
                    //print("SteamUser.DecompressVoice(DestBuffer, BytesWritten, DestBuffer2, (uint)DestBuffer2.Length, out BytesWritten2, 11025) - " + ret + " -- " + BytesWritten2);

                    if (ret == EVoiceResult.k_EVoiceResultOK && BytesWritten2 > 0)
                    {
                        AudioSource source;
                        if (!m_VoiceLoopback)
                        {
                            m_VoiceLoopback = new GameObject("Voice Loopback");
                            source          = m_VoiceLoopback.AddComponent <AudioSource>();
                            source.clip     = AudioClip.Create("Testing!", 11025, 1, 11025, false, false);
                        }
                        else
                        {
                            source = m_VoiceLoopback.GetComponent <AudioSource>();
                        }

                        float[] test = new float[11025];
                        for (int i = 0; i < test.Length; ++i)
                        {
                            test[i] = (short)(DestBuffer2[i * 2] | DestBuffer2[i * 2 + 1] << 8) / 32768.0f;
                        }
                        source.clip.SetData(test, 0);
                        source.Play();
                    }
                }
            }
        }

        GUILayout.Label("GetVoiceOptimalSampleRate() : " + SteamUser.GetVoiceOptimalSampleRate());

        {
            if (GUILayout.Button("GetAuthSessionTicket(Ticket, 1024, out pcbTicket)"))
            {
                m_Ticket      = new byte[1024];
                m_HAuthTicket = SteamUser.GetAuthSessionTicket(m_Ticket, 1024, out m_pcbTicket);
                print("SteamUser.GetAuthSessionTicket(Ticket, 1024, out pcbTicket) - " + m_HAuthTicket + " -- " + m_pcbTicket);
            }

            if (GUILayout.Button("BeginAuthSession(m_Ticket, (int)m_pcbTicket, SteamUser.GetSteamID())"))
            {
                if (m_HAuthTicket != HAuthTicket.Invalid && m_pcbTicket != 0)
                {
                    EBeginAuthSessionResult ret = SteamUser.BeginAuthSession(m_Ticket, (int)m_pcbTicket, SteamUser.GetSteamID());
                    print("SteamUser.BeginAuthSession(m_Ticket, " + (int)m_pcbTicket + ", " + SteamUser.GetSteamID() + ") - " + ret);
                }
                else
                {
                    print("Call GetAuthSessionTicket first!");
                }
            }
        }

        if (GUILayout.Button("EndAuthSession(SteamUser.GetSteamID())"))
        {
            SteamUser.EndAuthSession(SteamUser.GetSteamID());
            print("SteamUser.EndAuthSession(" + SteamUser.GetSteamID() + ")");
        }

        if (GUILayout.Button("CancelAuthTicket(m_HAuthTicket)"))
        {
            SteamUser.CancelAuthTicket(m_HAuthTicket);
            print("SteamUser.CancelAuthTicket(" + m_HAuthTicket + ")");
        }

        GUILayout.Label("UserHasLicenseForApp(SteamUser.GetSteamID(), SteamUtils.GetAppID()) : " + SteamUser.UserHasLicenseForApp(SteamUser.GetSteamID(), SteamUtils.GetAppID()));
        GUILayout.Label("BIsBehindNAT() : " + SteamUser.BIsBehindNAT());

        if (GUILayout.Button("AdvertiseGame(2, 127.0.0.1, 27015)"))
        {
            SteamUser.AdvertiseGame(CSteamID.NonSteamGS, 2130706433, 27015);
            print("SteamUser.AdvertiseGame(2, 2130706433, 27015)");
        }

        if (GUILayout.Button("RequestEncryptedAppTicket()"))
        {
            byte[]         k_unSecretData = System.BitConverter.GetBytes(0x5444);
            SteamAPICall_t handle         = SteamUser.RequestEncryptedAppTicket(k_unSecretData, sizeof(uint));
            OnEncryptedAppTicketResponseCallResult.Set(handle);
            print("SteamUser.RequestEncryptedAppTicket(k_unSecretData, " + sizeof(uint) + ") - " + handle);
        }

        if (GUILayout.Button("GetEncryptedAppTicket()"))
        {
            byte[] rgubTicket = new byte[1024];
            uint   cubTicket;
            bool   ret = SteamUser.GetEncryptedAppTicket(rgubTicket, 1024, out cubTicket);
            print("SteamUser.GetEncryptedAppTicket() - " + ret + " -- " + cubTicket);
        }

        //GUILayout.Label("GetGameBadgeLevel(1, false) : " + SteamUser.GetGameBadgeLevel(1, false)); // SpaceWar does not have trading cards, so this function will only ever return 0 and produce an annoying warning.
        GUILayout.Label("GetPlayerSteamLevel() : " + SteamUser.GetPlayerSteamLevel());

        if (GUILayout.Button("RequestStoreAuthURL(\"https://steampowered.com\")"))
        {
            SteamAPICall_t handle = SteamUser.RequestStoreAuthURL("https://steampowered.com");
            OnStoreAuthURLResponseCallResult.Set(handle);
            print("SteamUser.RequestStoreAuthURL(\"https://steampowered.com\") - " + handle);
        }

#if _PS3
        //GUILayout.Label("LogOn() : " + SteamUser.LogOn());
        //GUILayout.Label("LogOnAndLinkSteamAccountToPSN : " + SteamUser.LogOnAndLinkSteamAccountToPSN());
        //GUILayout.Label("LogOnAndCreateNewSteamAccountIfNeeded : " + SteamUser.LogOnAndCreateNewSteamAccountIfNeeded());
        //GUILayout.Label("GetConsoleSteamID : " + SteamUser.GetConsoleSteamID());
#endif
    }
Esempio n. 12
0
 private void Update()
 {
     if (base.channel.isOwner)
     {
         if (OptionsSettings.chatVoiceOut && Input.GetKey(ControlsSettings.voice) && !base.player.life.isDead)
         {
             if (!this.isTalking)
             {
                 this.isTalking    = true;
                 this.wasRecording = true;
                 this.lastTalk     = Time.realtimeSinceStartup;
                 if (this.hasWalkieTalkie)
                 {
                     this.audioSource.PlayOneShot(Resources.Load <AudioClip>("Sounds/General/Radio"), 0.75f);
                 }
                 SteamUser.StartVoiceRecording();
                 SteamFriends.SetInGameVoiceSpeaking(Provider.user, this.isTalking);
                 if (this.onTalked != null)
                 {
                     this.onTalked(this.isTalking);
                 }
             }
         }
         else if ((!OptionsSettings.chatVoiceOut || !Input.GetKey(ControlsSettings.voice) || base.player.life.isDead) && this.isTalking)
         {
             this.isTalking = false;
             if (this.hasWalkieTalkie)
             {
                 this.audioSource.PlayOneShot(Resources.Load <AudioClip>("Sounds/General/Radio"), 0.75f);
             }
             SteamUser.StopVoiceRecording();
             SteamFriends.SetInGameVoiceSpeaking(Provider.user, this.isTalking);
             if (this.onTalked != null)
             {
                 this.onTalked(this.isTalking);
             }
         }
         if (this.wasRecording && (double)(Time.realtimeSinceStartup - this.lastTalk) > 0.1)
         {
             this.wasRecording = this.isTalking;
             this.lastTalk     = Time.realtimeSinceStartup;
             uint num;
             uint num2;
             if (SteamUser.GetAvailableVoice(ref num, ref num2, 0u) == null && num > 0u)
             {
                 SteamUser.GetVoice(true, this.bufferSend, num, ref num, false, null, num2, ref num2, PlayerVoice.FREQUENCY);
                 if (num > 0u)
                 {
                     for (int i = (int)(num + 4u); i > 4; i--)
                     {
                         this.bufferSend[i] = this.bufferSend[i - 5];
                     }
                     this.bufferSend[4] = ((!this.hasWalkieTalkie) ? 0 : 1);
                     if (this.hasWalkieTalkie)
                     {
                         int    call = base.channel.getCall("tellVoice");
                         int    size;
                         byte[] packet;
                         base.channel.getPacketVoice(ESteamPacket.UPDATE_VOICE, call, out size, out packet, this.bufferSend, (int)num);
                         for (int j = 0; j < Provider.clients.Count; j++)
                         {
                             if (Provider.clients[j].playerID.steamID != Provider.client && Provider.clients[j].player != null && Provider.clients[j].player.voice.canHearRadio && Provider.clients[j].player.quests.radioFrequency == base.player.quests.radioFrequency)
                             {
                                 Provider.send(Provider.clients[j].playerID.steamID, ESteamPacket.UPDATE_VOICE, packet, size, base.channel.id);
                             }
                         }
                     }
                     else
                     {
                         base.channel.sendVoice("tellVoice", ESteamCall.PEERS, base.transform.position, EffectManager.MEDIUM, ESteamPacket.UPDATE_VOICE, this.bufferSend, (int)num);
                     }
                 }
             }
         }
     }
     else if (!Provider.isServer)
     {
         if (this.usingWalkieTalkie)
         {
             this.audioSource.spatialBlend = 0f;
         }
         else
         {
             this.audioSource.spatialBlend = 1f;
         }
         if (this.isPlaying)
         {
             if (this.lastPlay > this.audioSource.time)
             {
                 this.played += this.audioSource.clip.length;
             }
             this.lastPlay = this.audioSource.time;
             if (this.played + this.audioSource.time >= this.playback)
             {
                 this.isPlaying = false;
                 this.audioSource.Stop();
                 if (this.usingWalkieTalkie)
                 {
                     this.audioSource.PlayOneShot(Resources.Load <AudioClip>("Sounds/General/Radio"), 0.75f);
                 }
                 this.audioSource.time = 0f;
                 this.write            = 0;
                 this.playback         = 0f;
                 this.played           = 0f;
                 this.lastPlay         = 0f;
                 this.needsPlay        = false;
                 this.isTalking        = false;
                 if (this.onTalked != null)
                 {
                     this.onTalked(this.isTalking);
                 }
             }
         }
         else if (this.needsPlay)
         {
             this.delayPlay -= Time.deltaTime;
             if (this.delayPlay <= 0f)
             {
                 this.isPlaying = true;
                 this.audioSource.Play();
                 if (this.usingWalkieTalkie)
                 {
                     this.audioSource.PlayOneShot(Resources.Load <AudioClip>("Sounds/General/Radio"), 0.75f);
                 }
                 this.isTalking = true;
                 if (this.onTalked != null)
                 {
                     this.onTalked(this.isTalking);
                 }
             }
         }
     }
 }
Esempio n. 13
0
        public static void Init()
        {
            if (Instance == null)
            {
                try
                {
                    Instance = BeatSaberUI.CreateCustomMenu <CustomMenu>("Multiplayer Lobby");

                    CustomViewController middleViewController = BeatSaberUI.CreateViewController <CustomViewController>();
                    ListViewController   leftViewController   = BeatSaberUI.CreateViewController <ListViewController>();
                    rightViewController = BeatSaberUI.CreateViewController <TableViewController>();

                    Instance.SetMainViewController(middleViewController, true, (firstActivation, type) =>
                    {
                        if (firstActivation)
                        {
                            try
                            {
                                Button host = middleViewController.CreateUIButton("CreditsButton", new Vector2(BASE.x, BASE.y + 2.5f), new Vector2(25f, 7f));
                                host.SetButtonTextSize(3f);
                                host.ToggleWordWrapping(false);
                                host.SetButtonText("Disconnect");
                                host.onClick.AddListener(delegate
                                {
                                    try
                                    {
                                        SteamAPI.Disconnect();
                                        Instance.Dismiss();
                                        MultiplayerListing.Instance.Present();
                                    }
                                    catch (Exception e)
                                    {
                                        Logger.Error(e);
                                    }
                                });
                                float offs = 0;
                                offs      += 10f;
                                Button vc  = middleViewController.CreateUIButton("CreditsButton", new Vector2(BASE.x, BASE.y + 2.5f - offs), new Vector2(25f, 7f));
                                vc.SetButtonTextSize(3f);
                                vc.ToggleWordWrapping(false);
                                vc.SetButtonText(VoiceChatWorker.VoipEnabled ? "Disable Voice Chat" : "Enable Voice Chat");
                                vc.onClick.AddListener(delegate
                                {
                                    try
                                    {
                                        if (!VoiceChatWorker.VoipEnabled)
                                        {
                                            vc.SetButtonText("Disable Voice Chat");
                                            VoiceChatWorker.VoipEnabled = true;
                                            SteamUser.StartVoiceRecording();
                                        }
                                        else
                                        {
                                            vc.SetButtonText("Enable Voice Chat");
                                            VoiceChatWorker.VoipEnabled = false;
                                            SteamUser.StopVoiceRecording();
                                        }
                                    }
                                    catch (Exception e)
                                    {
                                        Logger.Error(e);
                                    }
                                });
                                offs  += 10f;
                                rejoin = middleViewController.CreateUIButton("CreditsButton", new Vector2(BASE.x, BASE.y + 2.5f - offs), new Vector2(25f, 7f));
                                rejoin.SetButtonTextSize(3f);
                                rejoin.ToggleWordWrapping(false);
                                rejoin.SetButtonText("Re-Join Song");
                                rejoin.interactable = false;
                                rejoin.onClick.AddListener(delegate
                                {
                                    if (SteamAPI.GetLobbyData().Screen == LobbyPacket.SCREEN_TYPE.IN_GAME && SteamAPI.GetLobbyData().CurrentSongOffset > 0f)
                                    {
                                        WaitingMenu.autoReady             = true;
                                        WaitingMenu.timeRequestedToLaunch = new DateTimeOffset(DateTime.UtcNow).ToUnixTimeSeconds();
                                        WaitingMenu.Instance.Present();
                                    }
                                });
                                bodyText           = middleViewController.CreateText("You can use Online Lobby in the Main Menu to choose songs for your lobby. \n\nYou can also control all the default Game Modifiers for the lobby through the Online Lobby Menu as well.", new Vector2(0, BASE.y - 10f));
                                var tt             = middleViewController.CreateText("If something goes wrong, click the disconnect button above and just reconnect to the lobby.", new Vector2(0, 0 - BASE.y));
                                bodyText.alignment = TMPro.TextAlignmentOptions.Center;
                                tt.alignment       = TMPro.TextAlignmentOptions.Center;
                            } catch (Exception e)
                            {
                                Logger.Error(e);
                            }
                        }
                    });
                    Instance.SetLeftViewController(leftViewController, false, (firstActivation, type) =>
                    {
                        if (firstActivation)
                        {
                            refreshFriendsList(leftViewController);
                            leftViewController.CreateText("Invite Friends", new Vector2(BASE.x + 62.5f, BASE.y));

                            Button b = leftViewController.CreateUIButton("CreditsButton", new Vector2(BASE.x + 80f, BASE.y + 2.5f), new Vector2(25f, 7f));
                            b.SetButtonText("Refresh");
                            b.SetButtonTextSize(3f);
                            b.ToggleWordWrapping(false);
                            b.onClick.AddListener(delegate()
                            {
                                refreshFriendsList(leftViewController);
                            });


                            invite = leftViewController.CreateUIButton("CreditsButton", new Vector2(BASE.x + 80f, 0 - BASE.y + 2.5f), new Vector2(25f, 7f));
                            invite.SetButtonText("Invite");
                            invite.SetButtonTextSize(3f);
                            invite.ToggleWordWrapping(false);
                            invite.interactable = false;
                            invite.onClick.AddListener(delegate()
                            {
                                if (selectedPlayer > 0)
                                {
                                    SteamAPI.InviteUserToLobby(new CSteamID(selectedPlayer));
                                }
                            });
                        }
                    });
                    Instance.SetRightViewController(rightViewController, false, (firstActivation, type) => {
                        if (firstActivation)
                        {
                            rightViewController.CreateText("Lobby Leaderboard", new Vector2(BASE.x + 62.5f, BASE.y));
                        }
                        RefreshScores();
                    });
                } catch (Exception e)
                {
                    Logger.Error(e);
                }
            }
        }