diff --git a/app/assets/javascripts/configureTrack.js b/app/assets/javascripts/configureTrack.js index f224e6412..260034c14 100644 --- a/app/assets/javascripts/configureTrack.js +++ b/app/assets/javascripts/configureTrack.js @@ -16,10 +16,8 @@ }; var VOICE_CHAT = { - NO_CHAT: "-1", - CHAT: "0", - SESSION: "1", - MIC: "2" + NO_CHAT: "0", + CHAT: "1" }; var instrument_array = []; @@ -41,7 +39,6 @@ var devices = []; var originalDeviceId; var originalVoiceChat; - var currentVoiceChat; var configure_audio_instructions = { "Win32": "Choose the audio profile you would like to use for this session. If needed, use arrow buttons to assign audio inputs " + @@ -221,7 +218,7 @@ $cloneAudio.appendTo('#audio-inputs-unused'); // add it to the unused Voice Chat box - if ($('#voice-chat-type').val() == VOICE_CHAT.SESSION) { + if ($('#voice-chat-type').val() == VOICE_CHAT.CHAT) { $cloneChat.appendTo('#voice-inputs-unused'); } }); @@ -230,11 +227,11 @@ } function _syncVoiceChatType() { - logger.debug("syncVoiceChatDialog:originalVoiceChat=" + originalVoiceChat); var $option1 = $('#voice-chat-type > option[value="1"]'); + var voiceChatType = $('#voice-chat-type').val(); - // remove Session Audio option from voice chat if none are available - if ($('#audio-inputs-unused > option').size() === 0 && $('#voice-inputs-selection > option').size() === 0) { + // remove option 1 from voice chat type dropdown if no music (based on what's unused on the Music Audio tab) or chat inputs are available + if ($('#audio-inputs-unused > option').size() === 0 && chatOtherUnassignedList.length === 0 && chatOtherAssignedList.length === 0) { logger.debug("Removing Option 1 from Voice Chat dropdown."); $option1.remove(); } @@ -242,7 +239,7 @@ // make sure it's not already in list before adding back if ($option1.length === 0) { logger.debug("Adding Option 1 back to Voice Chat dropdown."); - $('#voice-chat-type').prepend(''); + $('#voice-chat-type').append(''); } } } @@ -268,13 +265,34 @@ $cloneChat.appendTo('#voice-inputs-unused'); - // add it to the unused Music Input box if the selection is Session - if ($('#voice-chat-type').val() == VOICE_CHAT.SESSION) { + // add it to the unused Music Input box if the selected input is not type "chat" + if (!isChatInput(this.value)) { $cloneAudio.appendTo('#audio-inputs-unused'); } }); } + function isChatInput(id) { + // copy the arrays since $.grep modifies them + var chatOtherUnassignedListCopy = chatOtherUnassignedList; + var chatOtherAssignedListCopy = chatOtherAssignedList; + + // is this input in the unassigned list? + $.grep(chatOtherUnassignedListCopy, function(n,i){ + return n.chat && n.id === id; + }); + + // is this input in the assigned list? + $.grep(chatOtherAssignedListCopy, function(n,i){ + return n.chat && n.id === id; + }); + + logger.debug("chatOtherUnassignedListCopy=" + JSON.stringify(chatOtherUnassignedListCopy)); + logger.debug("chatOtherAssignedListCopy=" + JSON.stringify(chatOtherAssignedListCopy)); + + return chatOtherUnassignedListCopy.length > 0 || chatOtherAssignedListCopy.length > 0; + } + function audioDriverChanged() { context.jamClient.TrackSetMusicDevice($('#audio-drivers').val()); @@ -291,7 +309,9 @@ function voiceChatChanged() { var voiceChatVal = $('#voice-chat-type').val(); + logger.debug("voiceChatVal=" + voiceChatVal); + if (voiceChatVal == VOICE_CHAT.NO_CHAT) { logger.debug("VOICE_CHAT.NO_CHAT"); _addSelectedVoiceInputsToMusicInputs(); @@ -301,42 +321,28 @@ } else if (voiceChatVal == VOICE_CHAT.CHAT) { logger.debug("VOICE_CHAT.CHAT"); - _addSelectedVoiceInputsToMusicInputs(); $('#voice-inputs-unused').empty(); $('#voice-inputs-selection').empty(); + // add the chat inputs (unassigned and assigned) to the unused box to force the user to select again context.JK.loadOptions($('#template-option').html(), $('#voice-inputs-unused'), chatOtherUnassignedList, "id", "name", -1); - context.JK.loadOptions($('#template-option').html(), $('#voice-inputs-selection'), chatOtherAssignedList, "id", "name", -1); - } - else if (voiceChatVal == VOICE_CHAT.SESSION) { - logger.debug("VOICE_CHAT.SESSION"); - - $('#voice-inputs-unused').empty(); - $('#voice-inputs-selection').empty(); + context.JK.loadOptions($('#template-option').html(), $('#voice-inputs-unused'), chatOtherAssignedList, "id", "name", -1); + // add each unused music input if it doesn't already exist $('#audio-inputs-unused > option').each(function() { if ($('#voice-inputs-unused > option[value="' + this.value + '"]').length === 0) { $('#voice-inputs-unused').append(''); } }); } - else if (voiceChatVal == VOICE_CHAT.MIC) { - logger.debug("VOICE_CHAT.MIC"); - _addSelectedVoiceInputsToMusicInputs(); - - $('#voice-inputs-unused').empty(); - $('#voice-inputs-selection').empty(); - } - - currentVoiceChat = voiceChatVal; } function _addSelectedVoiceInputsToMusicInputs() { $('#voice-inputs-selection > option').each(function() { - // if this input is not in the available music inputs box and the current selection is not voice devices, add + // if this input is not already in the available music inputs box and the selected input is not chat input, add // it to the unused music inputs box - if ($('#audio-inputs-unused > option[value="' + this.value + '"]').length === 0 && currentVoiceChat != VOICE_CHAT.CHAT) { + if ($('#audio-inputs-unused > option[value="' + this.value + '"]').length === 0 && !isChatInput(this.value)) { $('#audio-inputs-unused').append(''); } }); @@ -447,19 +453,16 @@ var chatOption = $('#voice-chat-type').val(); - if (chatOption == VOICE_CHAT.SESSION) { + if (chatOption == VOICE_CHAT.CHAT) { context.JK.loadOptions($('#template-option').html(), $('#voice-inputs-unused'), chatUnassignedList, "id", "name", -1); context.JK.loadOptions($('#template-option').html(), $('#voice-inputs-selection'), chatAssignedList, "id", "name", -1); - } - // populate with voice devices - else if (chatOption == VOICE_CHAT.CHAT) { context.JK.loadOptions($('#template-option').html(), $('#voice-inputs-unused'), chatOtherUnassignedList, "id", "name", -1); context.JK.loadOptions($('#template-option').html(), $('#voice-inputs-selection'), chatOtherAssignedList, "id", "name", -1); } // disable inputs - else if (chatOption == VOICE_CHAT.MIC || chatOption == VOICE_CHAT.NO_CHAT) { + else if (chatOption == VOICE_CHAT.NO_CHAT) { } } } @@ -648,11 +651,11 @@ } function saveVoiceChatSettings() { - currentVoiceChat = $('#voice-chat-type').val(); - originalVoiceChat = currentVoiceChat; + var voiceChatType = $('#voice-chat-type').val(); + originalVoiceChat = voiceChatType; - logger.debug("Calling TrackSetChatUsesMusic with value = " + currentVoiceChat); - context.jamClient.TrackSetChatUsesMusic(currentVoiceChat); + logger.debug("Calling TrackSetChatEnable with value = " + voiceChatType); + context.jamClient.TrackSetChatEnable(voiceChatType == VOICE_CHAT.CHAT ? true : false); // UNASSIGNED VOICE CHAT $('#voice-inputs-unused > option').each(function() { @@ -674,7 +677,6 @@ context.jamClient.TrackSetMusicDevice(originalDeviceId); $('#voice-chat-type').val(originalVoiceChat); - currentVoiceChat = originalVoiceChat; app.layout.closeDialog('configure-audio'); } @@ -745,14 +747,14 @@ } else { var chatType = $('#voice-chat-type').val(); - if (chatType == VOICE_CHAT.SESSION || chatType == VOICE_CHAT.CHAT) { + if (chatType == VOICE_CHAT.CHAT) { var $voiceInputSelection = $('#voice-inputs-selection > option'); - if ($voiceInputSelection.size() === 0 || $voiceInputSelection.size() > 2) { + if ($voiceInputSelection.size() === 0) { errMsg = noTrackErrMsg; isValid = false; } } - else if (chatType == VOICE_CHAT.MIC || chatType == VOICE_CHAT.NO_CHAT) { + else if (chatType == VOICE_CHAT.NO_CHAT) { // NO VALIDATION NEEDED } @@ -783,12 +785,11 @@ }); }); - originalVoiceChat = context.jamClient.TrackGetChatUsesMusic(); - currentVoiceChat = originalVoiceChat; - $('#voice-chat-type').val(originalVoiceChat); - + originalVoiceChat = context.jamClient.TrackGetChatEnable() ? VOICE_CHAT.CHAT : VOICE_CHAT.NO_CHAT; logger.debug("originalVoiceChat=" + originalVoiceChat); + $('#voice-chat-type').val(originalVoiceChat); + originalDeviceId = context.jamClient.TrackGetMusicDeviceID(); context.jamClient.TrackLoadAssignments(); @@ -796,8 +797,8 @@ var $option1 = $('#voice-chat-type > option[value="1"]'); - // remove Session Audio option from voice chat if none are available and not already assigned - if (inputUnassignedList.length === 0 && chatAssignedList.length === 0) { + // remove option 1 from voice chat if none are available and not already assigned + if (inputUnassignedList.length === 0 && chatAssignedList.length === 0 && chatOtherAssignedList.length === 0 && chatOtherUnassignedList.length === 0) { logger.debug("Removing Option 1 from Voice Chat dropdown."); $option1.remove(); } @@ -805,7 +806,7 @@ else { if ($option1.length === 0) { logger.debug("Adding Option 1 back to Voice Chat dropdown."); - $('#voice-chat-type').prepend(''); + $('#voice-chat-type').append(''); } } } diff --git a/app/assets/javascripts/fakeJamClient.js b/app/assets/javascripts/fakeJamClient.js index 73f05e6c1..662859ea2 100644 --- a/app/assets/javascripts/fakeJamClient.js +++ b/app/assets/javascripts/fakeJamClient.js @@ -370,6 +370,14 @@ } } + function TrackGetChatEnable() { + return true; + } + + function TrackSetChatEnable(chat) { + + } + function TrackSaveAssignments() {} function TrackGetDevices() { @@ -567,6 +575,9 @@ this.TrackOpenControlPanel = TrackOpenControlPanel; this.TrackIsMusicDeviceType = TrackIsMusicDeviceType; + this.TrackGetChatEnable = TrackGetChatEnable; + this.TrackSetChatEnable = TrackSetChatEnable; + this.TrackGetChatUsesMusic = TrackGetChatUsesMusic; this.TrackSetChatUsesMusic = TrackSetChatUsesMusic; diff --git a/app/assets/javascripts/ftue.js b/app/assets/javascripts/ftue.js index b1c052d3f..4fdd29c0c 100644 --- a/app/assets/javascripts/ftue.js +++ b/app/assets/javascripts/ftue.js @@ -232,10 +232,10 @@ // that we're using music for voice-chat. if ($('[layout-wizard-step="2"] select[data-device="voice-chat-input"]').val()) { // Voice input selected - jamClient.TrackSetChatUsesMusic(0); + jamClient.TrackSetChatEnable(true); } else { // No voice input selected. - jamClient.TrackSetChatUsesMusic(-1); + jamClient.TrackSetChatEnable(false); } logger.debug("Calling FTUESave(" + persist + ")"); diff --git a/app/views/clients/_configureTrack.html.erb b/app/views/clients/_configureTrack.html.erb index 12c533676..b05eddd01 100644 --- a/app/views/clients/_configureTrack.html.erb +++ b/app/views/clients/_configureTrack.html.erb @@ -138,10 +138,8 @@