Merge branch 'staging' of https://github.com/Tony-sama/SillyTavern into music

This commit is contained in:
Cohee 2023-08-24 22:47:12 +03:00
commit b914921bf7
5 changed files with 69 additions and 36 deletions

View File

@ -96,7 +96,8 @@ function downloadAssetsList(url) {
.catch((error) => {
console.error(error);
toastr.error("Problem with assets URL", DEBUG_PREFIX + "Cannot get assets list");
$('#assets-connect-button').addClass("fa-plug-circle-xmark");
$('#assets-connect-button').addClass("fa-plug-circle-exclamation");
$('#assets-connect-button').addClass("redOverlayGlow");
});
});
}
@ -171,15 +172,15 @@ jQuery(async () => {
try {
console.debug(DEBUG_PREFIX, "Confimation, loading assets...");
downloadAssetsList(assetsJsonUrl.val());
connectButton.removeClass("fa-plug");
connectButton.removeClass("fa-plug-circle-xmark");
connectButton.removeClass("fa-plug-circle-exclamation");
connectButton.removeClass("redOverlayGlow");
connectButton.addClass("fa-plug-circle-check");
} catch (error) {
console.error('Error:', error);
toastr.error(`Cannot get assets list from ${assetsJsonUrl.val()}`);
connectButton.removeClass("fa-plug");
connectButton.removeClass("fa-plug-circle-check");
connectButton.addClass("fa-plug-circle-xmark");
connectButton.addClass("fa-plug-circle-exclamation");
connectButton.removeClass("redOverlayGlow");
}
}
else {

View File

@ -8,7 +8,7 @@
<label for="assets-json-url-field">Assets URL</label>
<div class="assets-connect-div">
<input id="assets-json-url-field" class="text_pole widthUnset flex1">
<i id="assets-connect-button" class="menu_button fa-solid fa-plug fa-xl"></i>
<i id="assets-connect-button" class="menu_button fa-solid fa-plug-circle-exclamation fa-xl redOverlayGlow"></i>
</div>
<div>
<p>Please refresh ST after downloading new asset to use them.</p>

View File

@ -91,23 +91,37 @@ function loadSettings() {
}
$("#audio_enabled").prop('checked', extension_settings.audio.enabled);
$("#audio_character_bgm_volume").text(extension_settings.audio.bgm_volume);
$("#audio_bgm_volume").text(extension_settings.audio.bgm_volume);
$("#audio_ambient_volume").text(extension_settings.audio.ambient_volume);
$("#audio_character_bgm_volume_slider").val(extension_settings.audio.bgm_volume);
$("#audio_bgm_volume_slider").val(extension_settings.audio.bgm_volume);
$("#audio_ambient_volume_slider").val(extension_settings.audio.ambient_volume);
if (extension_settings.audio.bgm_muted) {
$("#audio_character_bgm_mute_icon").toggleClass("fa-volume-high");
$("#audio_character_bgm_mute_icon").toggleClass("fa-volume-mute");
$("#audio_character_bgm").prop("muted", true);
$("#audio_bgm_mute_icon").removeClass("fa-volume-high");
$("#audio_bgm_mute_icon").addClass("fa-volume-mute");
$("#audio_bgm_mute").addClass("redOverlayGlow");
$("#audio_bgm").prop("muted", true);
}
else{
$("#audio_bgm_mute_icon").addClass("fa-volume-high");
$("#audio_bgm_mute_icon").removeClass("fa-volume-mute");
$("#audio_bgm_mute").removeClass("redOverlayGlow");
$("#audio_bgm").prop("muted", false);
}
if (extension_settings.audio.ambient_muted) {
$("#audio_ambient_mute_icon").toggleClass("fa-volume-high");
$("#audio_ambient_mute_icon").toggleClass("fa-volume-mute");
$("#audio_ambient_mute_icon").removeClass("fa-volume-high");
$("#audio_ambient_mute_icon").addClass("fa-volume-mute");
$("#audio_ambient_mute").addClass("redOverlayGlow");
$("#audio_ambient").prop("muted", true);
}
else{
$("#audio_ambient_mute_icon").addClass("fa-volume-high");
$("#audio_ambient_mute_icon").removeClass("fa-volume-mute");
$("#audio_ambient_mute").removeClass("redOverlayGlow");
$("#audio_ambient").prop("muted", false);
}
$("#audio_bgm_cooldown").val(extension_settings.audio.bgm_cooldown);
@ -117,12 +131,12 @@ function loadSettings() {
async function onEnabledClick() {
extension_settings.audio.enabled = $('#audio_enabled').is(':checked');
if (extension_settings.audio.enabled) {
if ($("#audio_character_bgm").attr("src") != "")
$("#audio_character_bgm")[0].play();
if ($("#audio_bgm").attr("src") != "")
$("#audio_bgm")[0].play();
if ($("#audio_ambient").attr("src") != "")
$("#audio_ambient")[0].play();
} else {
$("#audio_character_bgm")[0].pause();
$("#audio_bgm")[0].pause();
$("#audio_ambient")[0].pause();
}
saveSettingsDebounced();
@ -130,9 +144,10 @@ async function onEnabledClick() {
async function onBGMMuteClick() {
extension_settings.audio.bgm_muted = !extension_settings.audio.bgm_muted;
$("#audio_character_bgm_mute_icon").toggleClass("fa-volume-high");
$("#audio_character_bgm_mute_icon").toggleClass("fa-volume-mute");
$("#audio_character_bgm").prop("muted", !$("#audio_character_bgm").prop("muted"));
$("#audio_bgm_mute_icon").toggleClass("fa-volume-high");
$("#audio_bgm_mute_icon").toggleClass("fa-volume-mute");
$("#audio_bgm").prop("muted", !$("#audio_bgm").prop("muted"));
$("#audio_bgm_mute").toggleClass("redOverlayGlow");
saveSettingsDebounced();
}
@ -141,13 +156,14 @@ async function onAmbientMuteClick() {
$("#audio_ambient_mute_icon").toggleClass("fa-volume-high");
$("#audio_ambient_mute_icon").toggleClass("fa-volume-mute");
$("#audio_ambient").prop("muted", !$("#audio_ambient").prop("muted"));
$("#audio_ambient_mute").toggleClass("redOverlayGlow");
saveSettingsDebounced();
}
async function onBGMVolumeChange() {
extension_settings.audio.bgm_volume = ~~($("#audio_character_bgm_volume_slider").val());
$("#audio_character_bgm").prop("volume", extension_settings.audio.bgm_volume * 0.01);
$("#audio_character_bgm_volume").text(extension_settings.audio.bgm_volume);
extension_settings.audio.bgm_volume = ~~($("#audio_bgm_volume_slider").val());
$("#audio_bgm").prop("volume", extension_settings.audio.bgm_volume * 0.01);
$("#audio_bgm_volume").text(extension_settings.audio.bgm_volume);
saveSettingsDebounced();
//console.debug(DEBUG_PREFIX,"UPDATED BGM MAX TO",extension_settings.audio.bgm_volume);
}
@ -470,7 +486,7 @@ async function updateBGM() {
}
else {
console.log(DEBUG_PREFIX, "Switching BGM to", currentExpressionBGM)
const audio = $("#audio_character_bgm");
const audio = $("#audio_bgm");
if (audio.attr("src") == audio_file_path) {
console.log(DEBUG_PREFIX, "Already playing, ignored");
@ -533,16 +549,16 @@ jQuery(async () => {
$('#extensions_settings').append(windowHtml);
loadSettings();
$("#audio_character_bgm").attr("loop", true);
$("#audio_bgm").attr("loop", true);
$("#audio_ambient").attr("loop", true);
$("#audio_character_bgm").hide();
$("#audio_bgm").hide();
$("#audio_ambient").hide();
$("#audio_character_bgm_mute").on("click", onBGMMuteClick);
$("#audio_character_ambient_mute").on("click", onAmbientMuteClick);
$("#audio_bgm_mute").on("click", onBGMMuteClick);
$("#audio_ambient_mute").on("click", onAmbientMuteClick);
$("#audio_enabled").on("click", onEnabledClick);
$("#audio_character_bgm_volume_slider").on("input", onBGMVolumeChange);
$("#audio_bgm_volume_slider").on("input", onBGMVolumeChange);
$("#audio_ambient_volume_slider").on("input", onAmbientVolumeChange);
$("#audio_bgm_cooldown").on("input", onBGMCooldownInput);
@ -550,11 +566,11 @@ jQuery(async () => {
// DBG
$("#audio_debug").on("click", function () {
if ($("#audio_debug").is(':checked')) {
$("#audio_character_bgm").show();
$("#audio_bgm").show();
$("#audio_ambient").show();
}
else {
$("#audio_character_bgm").hide();
$("#audio_bgm").hide();
$("#audio_ambient").hide();
}
});

View File

@ -10,4 +10,8 @@
padding: 5px;
width: 50px;
height: 30px;
}
.audio-mute-button-muted {
color: red;
}

View File

@ -19,19 +19,19 @@
</div>
<div>
<div>
<label for="audio_character_bgm_volume_slider">Music <span id="audio_character_bgm_volume"></span></label>
<label for="audio_bgm_volume_slider">Music <span id="audio_bgm_volume"></span></label>
<div class="mixer-div">
<div id="audio_character_bgm_mute" class="menu_button audio-mute-button">
<i class="fa-solid fa-volume-high fa-lg" id="audio_character_bgm_mute_icon"></i>
<div id="audio_bgm_mute" class="menu_button audio-mute-button">
<i class="fa-solid fa-volume-high fa-lg" id="audio_bgm_mute_icon"></i>
</div>
<input type="range" class ="slider" id ="audio_character_bgm_volume_slider" value = "0" maxlength ="100">
<input type="range" class ="slider" id ="audio_bgm_volume_slider" value = "0" maxlength ="100">
</div>
<audio id="audio_character_bgm" controls src="">
<audio id="audio_bgm" controls src="">
</div>
<div>
<label for="audio_ambient_volume_slider">Ambient <span id="audio_ambient_volume"></span></label>
<div class="mixer-div">
<div id="audio_character_ambient_mute" class="menu_button audio-mute-button">
<div id="audio_ambient_mute" class="menu_button audio-mute-button">
<i class="fa-solid fa-volume-high fa-lg" id="audio_ambient_mute_icon"></i>
</div>
<input type="range" class ="slider" id ="audio_ambient_volume_slider" value = "0" maxlength ="100">
@ -43,6 +43,18 @@
<input id="audio_bgm_cooldown" class="text_pole wide30p">
</div>
</div>
<div>
<b>Hint:</b>
<i>
Create new folder in the
<b>public/characters/</b>
folder and name it as the name of the character.
Create a folder name <b>bgm</b> inside of it.
Put bgm music with expressions there. File names should follow the pattern:
<it>[expression_label]_[number].mp3</it>
By default one of the <it>neutral_[number].mp3</it> will play if classify module is not active.
</i>
</div>
</div>
</div>
</div>