mirror of
https://github.com/DerTyp7/teamspeak-obs-overlay.git
synced 2025-10-30 05:07:12 +01:00
moved determination of isHidden to client object
This commit is contained in:
@@ -10,5 +10,5 @@ const CONFIG = {
|
|||||||
fontStrokeColor: "#000000",
|
fontStrokeColor: "#000000",
|
||||||
},
|
},
|
||||||
hideSelf: false, // Hide yourself in the overlay
|
hideSelf: false, // Hide yourself in the overlay
|
||||||
hideSilent: true, // Only show talking people
|
hideSilent: false, // Only show talking people
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,14 +1,18 @@
|
|||||||
|
// Draw clients in the overlay
|
||||||
|
// Gets called everytime an event has been received (app.js -> ws.onmessage)
|
||||||
function drawClients() {
|
function drawClients() {
|
||||||
let elem = document.getElementById("content");
|
const overlayContent = document.getElementById("content");
|
||||||
|
|
||||||
result = "";
|
let result = "";
|
||||||
if (selfClient) {
|
if (selfClient) {
|
||||||
|
// Loop through all clients which are currently in your channel
|
||||||
getClientsInChannel(selfClient.channel).forEach((c) => {
|
getClientsInChannel(selfClient.channel).forEach((c) => {
|
||||||
isHidden = CONFIG.hideSilent && (c.talkStatus == 0 || c.isMuted());
|
// Open client div
|
||||||
|
result += `<div class="client-div" ${c.isHidden() ? "hidden" : ""} style="color:${
|
||||||
result += `<div class="client-div" ${isHidden ? "hidden" : ""} style="color:${
|
|
||||||
CONFIG.style.fontColor
|
CONFIG.style.fontColor
|
||||||
}; font-size:${CONFIG.style.fontSize}">`;
|
}; font-size:${CONFIG.style.fontSize}">`;
|
||||||
|
|
||||||
|
// Add image
|
||||||
result += '<div class="client-img-div">';
|
result += '<div class="client-img-div">';
|
||||||
if (c.outputMuted) {
|
if (c.outputMuted) {
|
||||||
result += ' <img src="img/muted_output.svg" />';
|
result += ' <img src="img/muted_output.svg" />';
|
||||||
@@ -19,12 +23,16 @@ function drawClients() {
|
|||||||
} else {
|
} else {
|
||||||
result += ' <img src="img/off.svg" />';
|
result += ' <img src="img/off.svg" />';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Close client div
|
||||||
result += "</div>";
|
result += "</div>";
|
||||||
|
|
||||||
|
// Add client text (name of the client)
|
||||||
result += `<div class="client-text-div"
|
result += `<div class="client-text-div"
|
||||||
style="-webkit-text-stroke:${CONFIG.style.fontStrokeSize} ${CONFIG.style.fontStrokeColor};
|
style="-webkit-text-stroke:${CONFIG.style.fontStrokeSize} ${CONFIG.style.fontStrokeColor};
|
||||||
"><p style="background:${CONFIG.style.fontBackground};">${c.name}</p></div></div>`;
|
"><p style="background:${CONFIG.style.fontBackground};">${c.name}</p></div></div>`;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
elem.innerHTML = result;
|
overlayContent.innerHTML = result;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,14 +6,7 @@ class Channel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class Client {
|
class Client {
|
||||||
constructor(
|
constructor(id, channel, name, inputMuted = false, outputMuted = false, talkStatus = 0) {
|
||||||
id,
|
|
||||||
channel,
|
|
||||||
name,
|
|
||||||
inputMuted = false,
|
|
||||||
outputMuted = false,
|
|
||||||
talkStatus = 0
|
|
||||||
) {
|
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.channel = channel;
|
this.channel = channel;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
@@ -26,6 +19,12 @@ class Client {
|
|||||||
isMuted() {
|
isMuted() {
|
||||||
return this.inputMuted == true || this.outputMuted == true;
|
return this.inputMuted == true || this.outputMuted == true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
isHidden() {
|
||||||
|
return (
|
||||||
|
(CONFIG.hideSilent && (this.talkStatus == 0 || this.isMuted())) || (CONFIG.hideSelf && this.id == selfClient.id)
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class List {
|
class List {
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ function getClientsInChannel(channel) {
|
|||||||
|
|
||||||
clientList.items.forEach((e) => {
|
clientList.items.forEach((e) => {
|
||||||
if (e.channel) {
|
if (e.channel) {
|
||||||
if (e.channel.id == channel.id && !(CONFIG.hideSelf && selfClient && e.id == selfClient.id)) {
|
if (e.channel.id == channel.id) {
|
||||||
result.push(e);
|
result.push(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user