Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UI: added basic cl_voipSendTarget support to the ui #163

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions code/ui/ui_local.h
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,7 @@ extern void Menu_SetCursor(menuframework_s *s, int cursor);
extern void Menu_SetCursorToItem(menuframework_s *m, void *ptr);
extern sfxHandle_t Menu_DefaultKey(menuframework_s *s, int key);
extern sfxHandle_t ScrollList_Key(menulist_s *l, int key);
extern void SpinControl_Init(menulist_s *s);

extern sfxHandle_t menu_move_sound;
extern sfxHandle_t menu_switch_sound;
Expand Down
2 changes: 1 addition & 1 deletion code/ui/ui_qmenu.c
Original file line number Diff line number Diff line change
Expand Up @@ -729,7 +729,7 @@ static void Slider_Draw(menuslider_s *s) {
SpinControl_Init
=================
*/
static void SpinControl_Init(menulist_s *s) {
void SpinControl_Init(menulist_s *s) {
int len;
int l;
const char *str;
Expand Down
1 change: 0 additions & 1 deletion code/ui/ui_serverinfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
#define ARROWDOWN1 "menu/server/arrowdown1"

static char *serverinfo_artlist[] = {ARROWUP0, ARROWUP1, ARROWDOWN0, ARROWDOWN1,

NULL};

#define ID_ADD 100
Expand Down
61 changes: 60 additions & 1 deletion code/ui/ui_sound.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,13 @@ SOUND OPTIONS MENU
#define ID_GAINWHILECAPTURE 22
#define ID_VOIPMODE 23
#define ID_RECORDMODE 24
#define ID_CAPTURETARGET 25

#define POSITION_X 180

static const char *recording_modes[] = {"Push to talk", "Automatic", 0};
static const char *recording_modes[] = {"Push to talk", "Automatic", NULL};
static const char *capture_targets[] = {"all", "none", "attacker", "crosshair", "spatial", NULL};
static const char *capture_target_custom[] = {"custom", NULL};

#define DEFAULT_SDL_SND_SPEED 44100

Expand Down Expand Up @@ -91,6 +94,8 @@ typedef struct {
menutext_s voipmode_grayed;
menuslider_s voiceThresholdVAD;
menuslider_s voiceGainDuringCapture;
menulist_s captureTarget;
qboolean customCaptureTarget;

menubitmap_s apply;
menubitmap_s back;
Expand All @@ -101,6 +106,36 @@ typedef struct {

static soundOptionsInfo_t soundOptionsInfo;

static void UI_SoundOptionsMenu_UpdateCaptureTarget(void) {
int i;
const char **s;
char captureTarget[MAX_CVAR_VALUE_STRING];

trap_Cvar_VariableStringBuffer("cl_voipSendTarget", captureTarget, sizeof(captureTarget));

for (i = 0, s = capture_targets; *s != NULL; ++s, ++i) {
if (!strcmp(*s, captureTarget)) {
soundOptionsInfo.customCaptureTarget = qfalse;
soundOptionsInfo.captureTarget.curvalue = i;
soundOptionsInfo.captureTarget.generic.flags &= ~QMF_INACTIVE;
soundOptionsInfo.captureTarget.itemnames = capture_targets;
soundOptionsInfo.captureTarget.generic.toolTip =
"'all' to broadcast to everyone. "
"'none' to send to no one. "
"'attacker' to send to the last person that hit you. "
"'crosshair' to send to the people currently in your crosshair. "
"'spatial' to talk to all people in hearing range.";
SpinControl_Init(&soundOptionsInfo.captureTarget);
return;
}
}
soundOptionsInfo.captureTarget.itemnames = capture_target_custom;
soundOptionsInfo.captureTarget.generic.toolTip = "Custom settings found";
soundOptionsInfo.captureTarget.generic.flags |= QMF_INACTIVE;
soundOptionsInfo.customCaptureTarget = qtrue;
SpinControl_Init(&soundOptionsInfo.captureTarget);
}

static void UI_SoundOptionsMenu_Update(void) {
// openAL and a high rate are conditions for all voip settings
qboolean disableVoip = 25000 > trap_Cvar_VariableValue("rate");
Expand All @@ -116,6 +151,7 @@ static void UI_SoundOptionsMenu_Update(void) {
soundOptionsInfo.voipRecordMode.generic.flags |= QMF_GRAYED;
soundOptionsInfo.voiceThresholdVAD.generic.flags |= QMF_GRAYED;
soundOptionsInfo.voiceGainDuringCapture.generic.flags |= QMF_GRAYED;
soundOptionsInfo.captureTarget.generic.flags |= QMF_GRAYED;
} else {
soundOptionsInfo.voipmode_grayed.generic.flags |= QMF_HIDDEN;
soundOptionsInfo.voipmode.generic.flags &= ~QMF_GRAYED;
Expand All @@ -124,9 +160,11 @@ static void UI_SoundOptionsMenu_Update(void) {
soundOptionsInfo.voipRecordMode.generic.flags |= QMF_GRAYED;
soundOptionsInfo.voiceThresholdVAD.generic.flags |= QMF_GRAYED;
soundOptionsInfo.voiceGainDuringCapture.generic.flags |= QMF_GRAYED;
soundOptionsInfo.captureTarget.generic.flags |= QMF_GRAYED;
} else {
soundOptionsInfo.voipRecordMode.generic.flags &= ~QMF_GRAYED;
soundOptionsInfo.voiceGainDuringCapture.generic.flags &= ~QMF_GRAYED;
soundOptionsInfo.captureTarget.generic.flags &= QMF_GRAYED;

if (hideVADThreshold)
soundOptionsInfo.voiceThresholdVAD.generic.flags |= QMF_GRAYED;
Expand All @@ -135,6 +173,8 @@ static void UI_SoundOptionsMenu_Update(void) {
}
}

UI_SoundOptionsMenu_UpdateCaptureTarget();

// move voip settings down to make space for the voipmode_grayed text
// or move them back up
y = soundOptionsInfo.voipmode_grayed.generic.y;
Expand All @@ -148,6 +188,8 @@ static void UI_SoundOptionsMenu_Update(void) {
soundOptionsInfo.voiceThresholdVAD.generic.y = y;
y += BIGCHAR_HEIGHT + 2;
soundOptionsInfo.voiceGainDuringCapture.generic.y = y;
y += BIGCHAR_HEIGHT + 2;
soundOptionsInfo.captureTarget.generic.y = y;
}
/*
=================
Expand Down Expand Up @@ -206,6 +248,12 @@ static void UI_SoundOptionsMenu_Event(void *ptr, int event) {
trap_Cvar_SetValue("cl_voipVADThreshold", soundOptionsInfo.voiceThresholdVAD.curvalue / 10);
break;

case ID_CAPTURETARGET:
if (!soundOptionsInfo.customCaptureTarget) {
trap_Cvar_Set("cl_voipSendTarget", capture_targets[soundOptionsInfo.captureTarget.curvalue]);
}
break;

case ID_BACK:
UI_PopMenu();
break;
Expand Down Expand Up @@ -443,6 +491,16 @@ static void UI_SoundOptionsMenu_Init(void) {
"This is the volume of audio coming out of your speakers while you are recording sound for transmission. This "
"prevents audio feedback and echo. If you're using headphones, you don't need to turn this down.";

y += BIGCHAR_HEIGHT + 2;
soundOptionsInfo.captureTarget.generic.type = MTYPE_SPINCONTROL;
soundOptionsInfo.captureTarget.generic.name = "Capture Target:";
soundOptionsInfo.captureTarget.generic.flags = QMF_SMALLFONT;
soundOptionsInfo.captureTarget.generic.callback = UI_SoundOptionsMenu_Event;
soundOptionsInfo.captureTarget.generic.id = ID_CAPTURETARGET;
soundOptionsInfo.captureTarget.generic.x = POSITION_X;
soundOptionsInfo.captureTarget.generic.y = y;
soundOptionsInfo.customCaptureTarget = qtrue;

soundOptionsInfo.back.generic.type = MTYPE_BITMAP;
soundOptionsInfo.back.generic.name = BACK0;
soundOptionsInfo.back.generic.flags = QMF_LEFT_JUSTIFY | QMF_PULSEIFFOCUS;
Expand Down Expand Up @@ -480,6 +538,7 @@ static void UI_SoundOptionsMenu_Init(void) {
Menu_AddItem(&soundOptionsInfo.menu, (void *)&soundOptionsInfo.voipRecordMode);
Menu_AddItem(&soundOptionsInfo.menu, (void *)&soundOptionsInfo.voiceThresholdVAD);
Menu_AddItem(&soundOptionsInfo.menu, (void *)&soundOptionsInfo.voiceGainDuringCapture);
Menu_AddItem(&soundOptionsInfo.menu, (void *)&soundOptionsInfo.captureTarget);
Menu_AddItem(&soundOptionsInfo.menu, (void *)&soundOptionsInfo.back);
Menu_AddItem(&soundOptionsInfo.menu, (void *)&soundOptionsInfo.apply);

Expand Down