diff --git a/README.md b/README.md index 7312977..a9ae88a 100644 --- a/README.md +++ b/README.md @@ -12,3 +12,7 @@ Splits the Chatlog into In Character (per scene), Rolls (per scene), and Out of ## Changelog +### v1.1.0 + +Added notifications for new messages in inactive tabs. +Fixed new messages showing up incorrectly. \ No newline at end of file diff --git a/module.json b/module.json index a41e96c..b4815c6 100644 --- a/module.json +++ b/module.json @@ -2,7 +2,7 @@ "name": "tabbed-chatlog", "title": "Tabbed Chatlog", "description": "Splits the Chatlog into In Character (per scene), Rolls (per scene), and Out of Character (global).", - "version": "1.0.0", + "version": "1.1.0", "minimumCoreVersion": "0.6.2", "compatibleCoreVersion": "0.6.0", "author": "Cody Swendrowski ", diff --git a/styles/tabbed-chatlog.css b/styles/tabbed-chatlog.css index 4fa08ef..0bd965a 100644 --- a/styles/tabbed-chatlog.css +++ b/styles/tabbed-chatlog.css @@ -24,6 +24,29 @@ display: none; } +.type4 { + display: none; +} + .type5 { display: none; } + +.hardHide { + display: none !important; +} + +#icNotification { + top: 35px; + right: 196px; +} + +#oocNotification { + top: 35px; + right: -3px; +} + +#rollsNotification { + top: 35px; + right: 92px; +} diff --git a/tabbed-chatlog.js b/tabbed-chatlog.js index 1560e58..7dcdf1c 100644 --- a/tabbed-chatlog.js +++ b/tabbed-chatlog.js @@ -17,8 +17,11 @@ Hooks.on("renderChatLog", async function(chatLog, html, user) { console.log(html); console.log(user); - //html.prepend('
Content 1
Content 2
'); - html.prepend(''); + var toPrepend = ''; + html.prepend(toPrepend); var me = this; const tabs = new TabsV2({ @@ -36,7 +39,10 @@ Hooks.on("renderChatLog", async function(chatLog, html, user) { $(".type2").hide(); $(".type3").hide(); $(".type4").hide(); + $(".type5").removeClass("hardHide"); $(".type5").show(); + + $("#rollsNotification").hide(); } else if (tab == "ic") { $(".type0").hide(); @@ -46,15 +52,19 @@ Hooks.on("renderChatLog", async function(chatLog, html, user) { $(".type4").hide(); $(".type5").hide(); - console.log("Showing messages for " + game.user.viewedScene); + $("#icNotification").hide(); } else if (tab == "ooc") { $(".type0").hide(); + $(".type1").removeClass("hardHide"); $(".type1").show(); $(".type2").hide(); $(".type3").hide(); - $(".type4").hide(); + $(".type3").removeClass("hardHide"); + $(".type4").show(); $(".type5").hide(); + + $("#oocNotification").hide(); } else { console.log("Unknown tab " + tab + "!"); @@ -74,15 +84,71 @@ Hooks.on("renderChatMessage", (chatMessage, html, data) => { html.addClass("type" + data.message.type); + var sceneMatches = true; + if (data.message.type == 0 || data.message.type == 2 || data.message.type == 3 || data.message.type == 5) { if (data.message.speaker.scene != undefined) { html.addClass("scenespecific"); html.addClass("scene" + data.message.speaker.scene); + if (data.message.speaker.scene != game.user.viewedScene) { + sceneMatches = false; + } } } - if (currentTab == "ooc") { - html.css("display", "list-item"); + if (currentTab == "rolls") { + if (data.message.type == 5 && sceneMatches) + { + html.css("display", "list-item"); + } + else { + html.css("display", "none"); + } + } + else if (currentTab == "ic") { + if ((data.message.type == 2 || data.message.type == 3) && sceneMatches) + { + html.css("display", "list-item"); + } + else { + html.css("cssText", "display: none !important;"); + html.addClass("hardHide"); + } + } + else if (currentTab == "ooc") { + if (data.message.type == 1 || data.message.type == 4) + { + html.css("display", "list-item"); + } + else { + html.css("display", "none"); + } + } +}); + +Hooks.on("createChatMessage", (chatMessage, content) => { + var sceneMatches = true; + + if (chatMessage.data.speaker.scene) { + if (chatMessage.data.speaker.scene != game.user.viewedScene) { + sceneMatches = false; + } + } + + if (chatMessage.data.type == 5) { + if (currentTab != "rolls" && sceneMatches) { + $("#rollsNotification").show(); + } + } + else if (chatMessage.data.type == 2 || chatMessage.data.type == 3) { + if (currentTab != "ic" && sceneMatches) { + $("#icNotification").show(); + } + } + else { + if (currentTab != "ooc") { + $("#oocNotification").show(); + } } });