Skip to content

Commit

Permalink
Add auto-swap and whisper option
Browse files Browse the repository at this point in the history
  • Loading branch information
cswendrowski committed Mar 24, 2021
1 parent 938aaac commit 291c866
Show file tree
Hide file tree
Showing 7 changed files with 125 additions and 44 deletions.
34 changes: 34 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
## Changelog

### Fork -


### v1.1.0

Added notifications for new messages in inactive tabs.
Fixed new messages showing up incorrectly.

### v1.2.0

In Character messages without a scene attached will now show on the IC tab when toggled

### v1.3.4

You can now automatically send In Character and Out of Character chat messages to Discord. There is one global module setting for OOC messages. IC messages can be per-scene via a Scene setting - if this is not found, it will fallback to a global IC webhook if configured in the Module Settings.

Tabbed Chat now also properly integrates with https://github.com/sPOiDar/fvtt-module-hide-gm-rolls

### v1.6.0

Thanks to David Zvekic:
* Now works properly with Vance's Resizable Sidebar.
* Flush now only deletes the messages from the active TAB, leaving the messages on other tabs clean.

Thanks to mclemente:
* Polyglot messages should now correctly show / hide

Other changes:
* Chat messages can now be changed to be global instead of per-scene
* Users can now use a setting to autonavigate to a new tab when a message comes in
* Swapping off then back on to the Chat tab should now correctly highlight the active tab
* Whispers can now be treated as In Character instead of OOC
26 changes: 4 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
![](https://img.shields.io/badge/Foundry-v0.6.2-informational)
![](https://img.shields.io/badge/Foundry-v0.7.9-informational)
[![](https://img.shields.io/badge/Buy%20Me%20A%20Coffee-%243-orange)](https://www.buymeacoffee.com/T2tZvWJ)


Expand All @@ -8,25 +8,7 @@ Splits the Chatlog into In Character (per scene), Rolls (per scene), and Out of

![](./tabbed-chatlog.gif)

## Maintenance Mode


## Changelog

### David Zvekic Fork -
-- Now works properly with Vance's Resizable Sidebar.
-- Flush now only deletes the messages from the active TAB, leaving the messages on other tabs clean.

### v1.1.0

Added notifications for new messages in inactive tabs.
Fixed new messages showing up incorrectly.

### v1.2.0

In Character messages without a scene attached will now show on the IC tab when toggled

### v1.3.4

You can now automatically send In Character and Out of Character chat messages to Discord. There is one global module setting for OOC messages. IC messages can be per-scene via a Scene setting - if this is not found, it will fallback to a global IC webhook if configured in the Module Settings.

Tabbed Chat now also properly integrates with https://github.com/sPOiDar/fvtt-module-hide-gm-rolls
This repository is no longer receiving active attention. I view the Module to be in a stable and feature-complete state, and will be focusing my efforts on other modules.
PR's are welcome, and I'll try to investigate bugs and keep the module up to date with Foundry in a timely manner.
6 changes: 6 additions & 0 deletions languages/cn.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@
"TC.SETTINGS.PerSceneName": "是否应按场景拆分“角色和角色”消息?",
"TC.SETTINGS.PerSceneHint": "默认禁用",

"TC.SETTINGS.AutoNavigateName": "新消息应该自动交换到该选项卡吗?",
"TC.SETTINGS.AutoNavigateHint": "默认为错误的",

"TC.SETTINGS.IcWhispersName": "交换低语以显示在“角色内聊天”中而不是OOC中?",
"TC.SETTINGS.IcWhispersHint": "默认为错误的",

"TC.TABS.IC": "角色",
"TC.TABS.OOC": "超游",
"TC.TABS.Rolls": "掷骰"
Expand Down
6 changes: 6 additions & 0 deletions languages/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@
"TC.SETTINGS.PerSceneName": "Should In Character and Roll messages be split per Scene?",
"TC.SETTINGS.PerSceneHint": "Defaults to True",

"TC.SETTINGS.AutoNavigateName": "Should new messages automatically swap to that tab?",
"TC.SETTINGS.AutoNavigateHint": "Defaults to False",

"TC.SETTINGS.IcWhispersName": "Swap Whispers to show up in In Character chat instead of OOC?",
"TC.SETTINGS.IcWhispersHint": "Defaults to False",

"TC.TABS.IC": "In Character",
"TC.TABS.OOC": "OOC",
"TC.TABS.Rolls": "Rolls"
Expand Down
6 changes: 6 additions & 0 deletions languages/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@
"TC.SETTINGS.PerSceneName": "¿Deben dividirse los mensajes In Character y Roll por escena? ",
"TC.SETTINGS.PerSceneHint": "Opción habilitada por defecto",

"TC.SETTINGS.AutoNavigateName": "¿Los mensajes nuevos deberían cambiar automáticamente a esa pestaña?",
"TC.SETTINGS.AutoNavigateHint": "Por defecto es falsa",

"TC.SETTINGS.IcWhispersName": "¿Cambiar susurros para que aparezcan en el chat de personaje en lugar de OOC? ",
"TC.SETTINGS.IcWhispersHint": "Por defecto es falsa",

"TC.TABS.IC": "Personaje",
"TC.TABS.OOC": "Jugador",
"TC.TABS.Rolls": "Tiradas"
Expand Down
6 changes: 6 additions & 0 deletions languages/zh-tw.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@
"TC.SETTINGS.PerSceneName": "是否应按场景拆分“角色和角色”消息?",
"TC.SETTINGS.PerSceneHint": "默認禁用",

"TC.SETTINGS.AutoNavigateName": "新消息應該自動交換到該選項卡嗎?",
"TC.SETTINGS.AutoNavigateHint": "默认为错误的",

"TC.SETTINGS.IcWhispersName": "交換低語以顯示在“角色內聊天”中而不是OOC中? ",
"TC.SETTINGS.IcWhispersHint": "默认为错误的",

"TC.TABS.IC": "角色",
"TC.TABS.OOC": "超遊",
"TC.TABS.Rolls": "擲骰"
Expand Down
85 changes: 63 additions & 22 deletions tabbed-chatlog.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ function isMessageTypeVisible(messageType) {
case CHAT_MESSAGE_TYPES.EMOTE:
return true;
case CHAT_MESSAGE_TYPES.WHISPER:
return false;
return game.settings.get("tabbed-chatlog", "icWhispers");
case CHAT_MESSAGE_TYPES.ROLL:
return false;
}
Expand All @@ -69,7 +69,7 @@ function isMessageTypeVisible(messageType) {
case CHAT_MESSAGE_TYPES.EMOTE:
return false;
case CHAT_MESSAGE_TYPES.WHISPER:
return true;
return !game.settings.get("tabbed-chatlog", "icWhispers");
case CHAT_MESSAGE_TYPES.ROLL:
return false;
}
Expand Down Expand Up @@ -114,7 +114,9 @@ Hooks.on("renderChatLog", async function (chatLog, html, user) {
toPrepend += `<a class="item ooc" data-tab="ooc">${game.i18n.localize("TC.TABS.OOC")}</a></nav><i id="oocNotification" class="notification-pip fas fa-exclamation-circle" style="display: none;"></i>`;
html.prepend(toPrepend);

const tabs = new TabsV2({
window.game.tabbedchat = {};

window.game.tabbedchat.tabs = new TabsV2({
navSelector: ".tabs",
contentSelector: ".content",
initial: "tab1",
Expand Down Expand Up @@ -147,7 +149,11 @@ Hooks.on("renderChatLog", async function (chatLog, html, user) {
$("#chat-log").scrollTop(9999999);
}
});
tabs.bind(html[0]);
window.game.tabbedchat.tabs.bind(html[0]);

$("[data-tab=\"chat\"]").click(() => {
setTimeout(() => $(".item." + currentTab).addClass("active"), 100);
});
});

Hooks.on("renderChatMessage", (chatMessage, html, data) => {
Expand All @@ -162,7 +168,7 @@ Hooks.on("renderChatMessage", (chatMessage, html, data) => {
if (data.message.speaker.scene != undefined && game.settings.get("tabbed-chatlog", "perScene")) {
html.addClass("scenespecific");
html.addClass("scene" + data.message.speaker.scene);
if (data.message.speaker.scene != game.user.viewedScene) {
if (data.message.speaker.scene != game.user?.viewedScene) {
sceneMatches = false;
}
}
Expand All @@ -182,23 +188,20 @@ Hooks.on("renderChatMessage", (chatMessage, html, data) => {
html.css("display", "list-item");
} else if (data.message.type == 5 && sceneMatches) {
if (!html.hasClass('gm-roll-hidden')) {
if (game.dice3d && game.settings.get("dice-so-nice", "settings").enabled && game.settings.get("dice-so-nice", "enabled")) {
if (!game.settings.get("dice-so-nice", "immediatelyDisplayChatMessages")) return;
}
html.css("display", "list-item");
}
} else {
html.css("display", "none");
}
} else if (currentTab == "ic") {
if ((data.message.type == 2 || data.message.type == 3) && sceneMatches) {
if ((data.message.type == 2 || data.message.type == 3 || (data.message.type == 4 && game.settings.get("tabbed-chatlog", "icWhispers"))) && 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) {
if (data.message.type == 1 || (data.message.type == 4 && !game.settings.get("tabbed-chatlog", "icWhispers"))) {
html.css("display", "list-item");
} else {
html.css("display", "none");
Expand All @@ -216,32 +219,52 @@ Hooks.on("createChatMessage", (chatMessage, content) => {
var sceneMatches = true;

if (chatMessage.data.speaker.scene) {
if (chatMessage.data.speaker.scene != game.user.viewedScene) {
if (chatMessage.data.speaker.scene != game.user?.viewedScene) {
sceneMatches = false;
}
}

if (chatMessage.data.type == 0) {
if (currentTab != "rolls" && sceneMatches) {
setRollsNotifyProperties();
$("#rollsNotification").show();
if (game.settings.get("tabbed-chatlog", "autoNavigate")) {
window.game.tabbedchat.tabs.activate("rolls", {triggerCallback: true});
}
else {
setRollsNotifyProperties();
$("#rollsNotification").show();
}
}
} else if (chatMessage.data.type == 5) {
if (currentTab != "rolls" && sceneMatches && chatMessage.data.whisper.length == 0) {
setRollsNotifyProperties();
$("#rollsNotification").show();
if (game.settings.get("tabbed-chatlog", "autoNavigate")) {
window.game.tabbedchat.tabs.activate("rolls", {triggerCallback: true});
}
else {
setRollsNotifyProperties();
$("#rollsNotification").show();
}
}
} else if (chatMessage.data.type == 2 || chatMessage.data.type == 3) {
} else if (chatMessage.data.type == 2 || chatMessage.data.type == 3 || (chatMessage.data.type == 4 && game.settings.get("tabbed-chatlog", "icWhispers"))) {
if (currentTab != "ic" && sceneMatches) {
setICNotifyProperties();
$("#icNotification").show();
if (game.settings.get("tabbed-chatlog", "autoNavigate")) {
window.game.tabbedchat.tabs.activate("ic", {triggerCallback: true});
}
else {
setICNotifyProperties();
$("#icNotification").show();
}
}
} else {
if (salonEnabled && chatMessage.data.type == 4) return;
if (salonEnabled && chatMessage.data.type == 4 && !game.settings.get("tabbed-chatlog", "icWhispers")) return;

if (currentTab != "ooc") {
setOOCNotifyProperties();
$("#oocNotification").show();
if (game.settings.get("tabbed-chatlog", "autoNavigate")) {
window.game.tabbedchat.tabs.activate("ooc", {triggerCallback: true});
}
else {
setOOCNotifyProperties();
$("#oocNotification").show();
}
}
}
});
Expand Down Expand Up @@ -440,7 +463,7 @@ Hooks.on('sidebarCollapse', (sidebar, collapsing) => {


Hooks.on('ready', () => {
if (game.modules.get('narrator-tools')) {
if (game.modules.get('narrator-tools')?.active) {
NarratorTools._msgtype = 2;
}

Expand Down Expand Up @@ -557,6 +580,24 @@ Hooks.on('init', () => {
type: Boolean,
});

game.settings.register('tabbed-chatlog', 'icWhispers', {
name: game.i18n.localize("TC.SETTINGS.IcWhispersName"),
hint: game.i18n.localize("TC.SETTINGS.IcWhispersHint"),
scope: 'world',
config: true,
default: false,
type: Boolean,
});

game.settings.register('tabbed-chatlog', 'autoNavigate', {
name: game.i18n.localize("TC.SETTINGS.AutoNavigateName"),
hint: game.i18n.localize("TC.SETTINGS.AutoNavigateHint"),
scope: 'client',
config: true,
default: false,
type: Boolean,
});

salonEnabled = game.data.modules.find(x => x.id == "salon")?.active;
});

Expand Down

0 comments on commit 291c866

Please sign in to comment.