• R/O
  • SSH

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

This is a fork of Zandronum used on servers hosted by The Sentinels Playground (TSPG), Euroboros (EB), and Down Under Doomers (DUD).


Commit MetaInfo

Revisionf7f71df283685334835b4c0ebfbe01353745a9c0 (tree)
Time2024-04-15 04:06:25
AuthorAdam Kaminski <kaminskiadam9@gmai...>
CommiterAdam Kaminski

Log Message

The list of record drivers on the voice chat options menu now updates when a driver is plugged or unplugged. The microphone test also stops when the record driver is unplugged and gets deselected when no more drivers are connected.

Change Summary

Incremental Difference

diff -r f868262fd8be -r f7f71df28368 src/menu/multiplayermenu.cpp
--- a/src/menu/multiplayermenu.cpp Mon Apr 08 19:25:28 2024 -0300
+++ b/src/menu/multiplayermenu.cpp Sun Apr 14 15:06:25 2024 -0400
@@ -612,32 +612,52 @@
612612 if ( opt != nullptr )
613613 {
614614 TArray<FString> recordDriverList;
615- FOptionValues::Pair pair;
616-
617615 VOIPController::GetInstance( ).RetrieveRecordDrivers( recordDriverList );
618616
619- ( *opt )->mValues.Clear( );
620-
621- if ( recordDriverList.Size( ) > 0 )
622- {
623- for ( unsigned int i = 0; i < recordDriverList.Size( ); i++ )
624- {
625- pair.Value = i;
626- pair.Text = recordDriverList[i];
627- ( *opt )->mValues.Push( pair );
628- }
629- }
630- else
631- {
632- pair.Value = 0;
633- pair.Text = "None";
634- ( *opt )->mValues.Push( pair );
635- }
617+ RefreshRecordDriverList( *opt, recordDriverList );
636618 }
637619
638620 Super::Init( parent, desc );
639621 }
640622
623+ virtual void Ticker( void )
624+ {
625+ Super::Ticker( );
626+
627+ FOptionValues **opt = OptionValues.CheckKey( "ZA_RecordDrivers" );
628+ TArray<FString> recordDriverList;
629+
630+ VOIPController::GetInstance( ).RetrieveRecordDrivers( recordDriverList );
631+
632+ if ( opt != nullptr )
633+ {
634+ int numRecordDrivers = ( *opt )->mValues.Size( );
635+
636+ // [AK] "None" doesn't count as a record driver.
637+ if ( stricmp(( *opt )->mValues[0].Text, "None" ) == 0 )
638+ numRecordDrivers = 0;
639+
640+ // [AK] Refresh the list of record drivers if any got added or removed.
641+ if ( numRecordDrivers != recordDriverList.Size( ))
642+ RefreshRecordDriverList( *opt, recordDriverList );
643+ }
644+
645+ // [AK] Stop the microphone test if we're not recording (e.g. the device was disconnected).
646+ if (( VOIPController::GetInstance( ).IsRecording( ) == false ) && ( VOIPController::GetInstance( ).IsTestingMicrophone( )))
647+ {
648+ VOIPController::GetInstance( ).SetMicrophoneTest( false );
649+
650+ // [AK] If no record drivers are connected, then the microphone test bar shouldn't be selected.
651+ if ( recordDriverList.Size( ) == 0 )
652+ {
653+ FOptionMenuItem *it = mDesc->GetItem( "MicTestBar" );
654+
655+ if (( it != nullptr ) && ( it == mDesc->mItems[mDesc->mSelectedItem] ))
656+ mDesc->mSelectedItem = FirstSelectable( );
657+ }
658+ }
659+ }
660+
641661 virtual void Close( void )
642662 {
643663 // [AK] Stop testing the microphone when we exit the menu.
@@ -646,6 +666,36 @@
646666
647667 Super::Close( );
648668 }
669+
670+private:
671+ void RefreshRecordDriverList( FOptionValues *opt, TArray<FString> recordDriverList )
672+ {
673+ FOptionValues::Pair pair;
674+
675+ if ( opt == nullptr )
676+ return;
677+
678+ opt->mValues.Clear( );
679+
680+ if ( recordDriverList.Size( ) > 0 )
681+ {
682+ for ( unsigned int i = 0; i < recordDriverList.Size( ); i++ )
683+ {
684+ pair.Value = i;
685+ pair.Text = recordDriverList[i];
686+ opt->mValues.Push( pair );
687+ }
688+ }
689+ else
690+ {
691+ pair.Value = 0;
692+ pair.Text = "None";
693+ opt->mValues.Push( pair );
694+ }
695+
696+ if ( static_cast<unsigned>( voice_recorddriver ) >= opt->mValues.Size( ))
697+ voice_recorddriver = opt->mValues.Size( ) - 1;
698+ }
649699 };
650700
651701 IMPLEMENT_CLASS( DVoiceChatMenu )
diff -r f868262fd8be -r f7f71df28368 src/menu/optionmenuitems.h
--- a/src/menu/optionmenuitems.h Mon Apr 08 19:25:28 2024 -0300
+++ b/src/menu/optionmenuitems.h Sun Apr 14 15:06:25 2024 -0400
@@ -1454,7 +1454,7 @@
14541454
14551455 public:
14561456 FOptionMenuMicTestBar( const char *label ) :
1457- FOptionMenuItem( label ),
1457+ FOptionMenuItem( label, "MicTestBar" ),
14581458 mBarTexture( TexMan.FindTexture( "MICBAR" )) { }
14591459
14601460 virtual bool Activate( void );
diff -r f868262fd8be -r f7f71df28368 src/voicechat.h
--- a/src/voicechat.h Mon Apr 08 19:25:28 2024 -0300
+++ b/src/voicechat.h Sun Apr 14 15:06:25 2024 -0400
@@ -340,6 +340,7 @@
340340 //*****************************************************************************
341341 // EXTERNAL CONSOLE VARIABLES
342342
343+EXTERN_CVAR( Int, voice_recorddriver )
343344 EXTERN_CVAR( Int, sv_allowvoicechat )
344345 EXTERN_CVAR( Bool, sv_proximityvoicechat )
345346 EXTERN_CVAR( Float, sv_minproximityrolloffdist )