Skip to content
Permalink
Browse files

Merge pull request #213 from tildar/Add_Beep_Volume_Control

Add volume control to settings
  • Loading branch information...
Manuel-777 committed Mar 8, 2019
2 parents dba5b92 + b50d07a commit 4d38c784a1e56ff7ba682235ac3051147f63e909
Showing with 36 additions and 5 deletions.
  1. +3 −0 window_background/background.js
  2. +27 −0 window_main/renderer.js
  3. +6 −5 window_overlay/overlay.js
@@ -62,6 +62,7 @@ const defaultCfg = {
settings: {
overlay_sideboard: false,
sound_priority: false,
sound_priority_volume: 1,
cards_quality: "small",
show_overlay: true,
show_overlay_always: false,
@@ -782,6 +783,8 @@ function updateSettings(_settings, relay) {
if (_settings.overlay_ontop == undefined) _settings.overlay_ontop = true;
if (_settings.overlay_scale == undefined) _settings.overlay_scale = 100;
if (_settings.skip_firstpass == undefined) _settings.skip_firstpass = false;
if (_settings.sound_priority_volume == undefined)
_settings.sound_priority_volume = 1;

skipFirstPass = _settings.skip_firstpass;

@@ -1970,6 +1970,17 @@ function open_settings(openSection) {
settings.sound_priority
);

var sliderSoundVolume = $('<div class="slidecontainer_settings"></div>');
sliderSoundVolume.appendTo(section);
var sliderSoundVolumeLabel = $(`<label style="width: 400px;">Volume: ${Math.round(settings.sound_priority_volume*100)}%</label>`);
sliderSoundVolumeLabel.appendTo(sliderSoundVolume);
var sliderSoundVolumeInput = $(
'<input type="range" min="0" max="1" step=".001" value="' +
settings.sound_priority_volume +
'" class="slider sliderSoundVolume" id="settings_soundpriorityvolume">'
);
sliderSoundVolumeInput.appendTo(sliderSoundVolume);

var label = $('<label class="but_container_label">Export Format:</label>');
label.appendTo(section);
var icd = $('<div class="input_container"></div>');
@@ -2423,6 +2434,17 @@ function open_settings(openSection) {
overlayScale = parseInt(this.value);
updateSettings();
});

$(".sliderSoundVolume").off();

$(".sliderSoundVolume").on("click mouseup", function() {
sliderSoundVolumeLabel.html(`Volume: ${Math.round(settings.sound_priority_volume*100)}%`);
let { Howl, Howler } = require("howler");
let sound = new Howl({ src: ["../sounds/blip.mp3"] });
updateSettings();
Howler.volume(settings.sound_priority_volume);
sound.play();
});
}

function alphaFromTransparency(transparency) {
@@ -2524,6 +2546,10 @@ function updateSettings() {
.checked;
var soundPriority = document.getElementById("settings_soundpriority").checked;

var soundPriorityVolume = document.getElementById(
"settings_soundpriorityvolume"
).value;

var backColor = $(".color_picker")
.spectrum("get")
.toRgbString();
@@ -2549,6 +2575,7 @@ function updateSettings() {
var exportFormat = document.getElementById("settings_export_format").value;
settings = {
sound_priority: soundPriority,
sound_priority_volume: soundPriorityVolume,
show_overlay: showOverlay,
show_overlay_always: showOverlayAlways,
startup: startup,
@@ -36,6 +36,7 @@ let playerSeat = 0;
let oppName = "";
let turnPriority = 0;
let soundPriority = false;
let soundPriorityVolume = 1;
let overlayAlpha = 1;
let overlayAlphaBack = 1;
let oddsSampleSize = 1;
@@ -60,11 +61,6 @@ let mana = {
8: "x"
};

const Howler = require("howler");
let sound = new Howl({
src: ["../sounds/blip.mp3"]
});

const TransparencyMouseFix = require("electron-transparency-mouse-fix");
const fix = new TransparencyMouseFix({
fixPointerEvents: "auto"
@@ -235,6 +231,7 @@ ipc.on("set_settings", function(event, settings) {

showSideboard = settings.overlay_sideboard;
soundPriority = settings.sound_priority;
soundPriorityVolume = settings.sound_priority_volume;
$(".top").css("display", "");
$(".overlay_deckname").css("display", "");
$(".overlay_deckcolors").css("display", "");
@@ -541,6 +538,10 @@ ipc.on("set_turn", function(
) {
playerSeat = _we;
if (turnPriority != _priority && _priority == _we && soundPriority) {
// playBlip();
let { Howl, Howler } = require("howler");
let sound = new Howl({ src: ["../sounds/blip.mp3"] });
Howler.volume(soundPriorityVolume);
sound.play();
}
//turnPhase = _phase;

0 comments on commit 4d38c78

Please sign in to comment.
You can’t perform that action at this time.