Skip to content

Commit

Permalink
Merge pull request #11 from CristianVasile23/dev
Browse files Browse the repository at this point in the history
Release 4.0.0
  • Loading branch information
CristianVasile23 committed May 18, 2023
2 parents e6f4e66 + 9949616 commit fdc16f1
Show file tree
Hide file tree
Showing 15 changed files with 315 additions and 118 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
@@ -1,3 +1,9 @@
## 4.0.0

- Added module settings. You can now change the way some features look as well as toggling some on/off. More customization options will be added in the future.
- Added support for FoundryVTT V11.
- Fixed small bugs and added missing localization for some text.

## 3.5.0

- Added the _Speak As_ functionality. When a conversation is active, the GM can now toggle if they want chat messages to be sent under the name of the currently active conversation participant.
Expand Down
6 changes: 0 additions & 6 deletions README.md
Expand Up @@ -14,12 +14,6 @@ These conversations can then be saved, edited, and even embedded into other jour

https://user-images.githubusercontent.com/51834117/223569960-3a119bb8-1a5f-4ad8-8f5d-d6a0b2d07e4f.mp4

# Disclaimer

Initially, this module was made as a very simple module to solve some of the issues I had as a GM during my sessions. As I added more features and polished it, I decided to also release it.

As of this moment, I feel that the module is feature complete and has all the functionality I envisioned for it. I will continue to support the module for future versions of Foundry as well as fix any possible issues that may occur. That said, I don't think I will be adding additional features unless I feel that they would greatly benefit the module.

# Known Issues

If you encounter any issues, feel free to report them and I will look into them.
Expand Down
103 changes: 103 additions & 0 deletions css/active-participant.css
@@ -0,0 +1,103 @@
.conversation-hud-active-participant {
display: none;
flex-direction: column;
align-items: center;
justify-content: center;
position: relative;
}

/* Portrait types */
.conversation-hud-active-participant.vertical {
height: 100%;
width: 30vw;
max-width: 420px;
}
.conversation-hud-active-participant.horizontal {
width: 40vw;
max-width: 620px;
aspect-ratio: 16/9;
}
.conversation-hud-active-participant.square {
width: min(30vw, 50vh);
height: min(30vw, 50vh);
max-width: 620px;
max-height: 620px;
}

.conversation-hud-active-participant img {
height: 100%;
width: 100%;
object-fit: cover;
object-position: top center;
border-radius: 15px;
box-shadow: 0 0 10px var(--color-shadow-dark);
}

/* CSS rules for image anchor */
.conversation-participant img.top,
.conversation-hud-active-participant img.top {
object-position: top center;
}
.conversation-participant img.center,
.conversation-hud-active-participant img.center {
object-position: center;
}
.conversation-participant img.bottom,
.conversation-hud-active-participant img.bottom {
object-position: bottom center;
}

.active-participant-image {
display: none;
background-color: rgba(0, 0, 0, 0.5);
}
.active-participant-image.active {
display: block;
}

.active-participant-name {
display: none;
position: absolute;

bottom: 0;
left: 0;
right: 0;

margin: 0;
padding-top: 5px;
padding-bottom: 5px;
padding-left: 5px;
padding-right: 5px;

overflow: hidden;
white-space: nowrap;

font-size: 16px;
text-align: center;
color: var(--color-text-light-highlight);
text-overflow: ellipsis;

background-color: rgba(0, 0, 0, 0.65);
border-top: 1px solid var(--color-border-dark);
border-radius: 0px 0px 15px 15px;
}
.active-participant-name.active {
display: block;
}

/* Font sizes */
.active-participant-name.verySmall {
font-size: 10px;
}
.active-participant-name.small {
font-size: 13px;
}
.active-participant-name.regular {
font-size: 16px;
}
.active-participant-name.large {
font-size: 19px;
}
.active-participant-name.veryLarge {
font-size: 22px;
}
57 changes: 1 addition & 56 deletions css/hud.css
Expand Up @@ -46,16 +46,6 @@
max-height: calc(100vh - 54px - 62px);
}

.conversation-hud-active-participant {
display: none;
flex-direction: column;
align-items: center;
justify-content: center;
position: relative;
height: 100%;
width: 30vw;
max-width: 420px;
}
.conversation-hud-wrapper.visible .conversation-hud-active-participant {
display: flex;
}
Expand All @@ -74,56 +64,10 @@
border: 0;
}

.conversation-hud-active-participant img {
height: 100%;
width: 100%;
object-fit: cover;
object-position: top center;
border-radius: 15px;
box-shadow: 0 0 10px var(--color-shadow-dark);
}
.conversation-hud-wrapper.minimized .conversation-hud-active-participant img {
box-shadow: unset;
}

.active-participant-image {
display: none;
background-color: rgba(0, 0, 0, 0.5);
}
.active-participant-image.active {
display: block;
}

.active-participant-name {
display: none;
position: absolute;

bottom: 0;
left: 0;
right: 0;

margin: 0;
padding-top: 5px;
padding-bottom: 5px;
padding-left: 5px;
padding-right: 5px;

overflow: hidden;
white-space: nowrap;

font-size: 16px;
text-align: center;
color: var(--color-text-light-highlight);
text-overflow: ellipsis;

background-color: rgba(0, 0, 0, 0.65);
border-top: 1px solid var(--color-border-dark);
border-radius: 0px 0px 15px 15px;
}
.active-participant-name.active {
display: block;
}

.conversation-hud-participant-list {
display: none;
flex-flow: column;
Expand Down Expand Up @@ -345,6 +289,7 @@
box-shadow: 0 0 10px #9b8dff;
}

/* Dropzone CSS */
.conversation-hud-content .conversation-hud-dropzone {
display: none;
flex-flow: column;
Expand Down
3 changes: 2 additions & 1 deletion css/main.css
@@ -1,2 +1,3 @@
@import url("./hud.css");
@import url("./conversation-sheet.css");
@import url("./active-participant.css");
@import url("./conversation-sheet.css");
1 change: 1 addition & 0 deletions js/constants.js
@@ -0,0 +1 @@
export const MODULE_NAME = "conversation-hud";
52 changes: 33 additions & 19 deletions js/conversation.js
Expand Up @@ -9,6 +9,8 @@ import {
updateConversationLayout,
} from "./helpers.js";
import { socket } from "./init.js";
import { MODULE_NAME } from "./constants.js";
import { ModuleSettings } from "./settings.js";

export class ConversationHud {
// Function that initializes the class data
Expand Down Expand Up @@ -68,19 +70,23 @@ export class ConversationHud {
game.ConversationHud.conversationIsVisible = conversationVisible;
game.ConversationHud.activeConversation = conversationData;

// Data that is passed to the template
const template_data = {
// Render templates
const renderedHtml = await renderTemplate("modules/conversation-hud/templates/conversation.hbs", {
participants: conversationData.participants,
isGM: game.user.isGM,
};

// Render templates
const renderedHtml = await renderTemplate("modules/conversation-hud/templates/conversation.hbs", template_data);
portraitStyle: game.settings.get(MODULE_NAME, ModuleSettings.portraitStyle),
portraitAnchor: game.settings.get(MODULE_NAME, ModuleSettings.portraitAnchor),
activeParticipantFontSize: game.settings.get(MODULE_NAME, ModuleSettings.activeParticipantFontSize),
});
const conversationControls = await renderTemplate("modules/conversation-hud/templates/conversation_controls.hbs", {
isGM: game.user.isGM,
isMinimized: game.ConversationHud.conversationIsMinimized,
isVisible: game.ConversationHud.conversationIsVisible,
isSpeakingAs: game.ConversationHud.conversationIsSpeakingAs,
features: {
minimizeEnabled: game.settings.get(MODULE_NAME, ModuleSettings.enableMinimize),
speakAsEnabled: game.settings.get(MODULE_NAME, ModuleSettings.enableSpeakAs),
},
});

// Create the conversation container
Expand Down Expand Up @@ -192,14 +198,14 @@ export class ConversationHud {
// Set conversation data
game.ConversationHud.activeConversation = conversationData;

// Data that is passed to the template
const template_data = {
// Render template
const renderedHtml = await renderTemplate("modules/conversation-hud/templates/conversation.hbs", {
participants: conversationData.participants,
isGM: game.user.isGM,
};

// Render template
const renderedHtml = await renderTemplate("modules/conversation-hud/templates/conversation.hbs", template_data);
portraitStyle: game.settings.get(MODULE_NAME, ModuleSettings.portraitStyle),
portraitAnchor: game.settings.get(MODULE_NAME, ModuleSettings.portraitAnchor),
activeParticipantFontSize: game.settings.get(MODULE_NAME, ModuleSettings.activeParticipantFontSize),
});

// Add rendered template to the conversation hud
const conversationHud = document.getElementById("ui-conversation-hud");
Expand Down Expand Up @@ -426,18 +432,26 @@ export class ConversationHud {

// Function that minimizes or maximizes the active conversation
async toggleActiveConversationMode() {
if (checkIfConversationActive()) {
game.ConversationHud.conversationIsMinimized = !game.ConversationHud.conversationIsMinimized;
updateConversationControls();
updateConversationLayout();
if (game.settings.get(MODULE_NAME, ModuleSettings.enableMinimize)) {
if (checkIfConversationActive()) {
game.ConversationHud.conversationIsMinimized = !game.ConversationHud.conversationIsMinimized;
updateConversationControls();
updateConversationLayout();
}
} else {
ui.notifications.error(game.i18n.localize("CHUD.errors.featureNotEnabled"));
}
}

// Function that toggles the speaking as mode
async toggleSpeakingAsMode() {
if (checkIfUserGM() && checkIfConversationActive()) {
game.ConversationHud.conversationIsSpeakingAs = !game.ConversationHud.conversationIsSpeakingAs;
updateConversationControls();
if (game.settings.get(MODULE_NAME, ModuleSettings.enableSpeakAs)) {
if (checkIfUserGM() && checkIfConversationActive()) {
game.ConversationHud.conversationIsSpeakingAs = !game.ConversationHud.conversationIsSpeakingAs;
updateConversationControls();
}
} else {
ui.notifications.error(game.i18n.localize("CHUD.errors.featureNotEnabled"));
}
}

Expand Down
6 changes: 6 additions & 0 deletions js/helpers.js
@@ -1,4 +1,6 @@
import { socket } from "./init.js";
import { MODULE_NAME } from "./constants.js";
import { ModuleSettings } from "./settings.js";

export async function getActorDataFromDragEvent(event) {
try {
Expand Down Expand Up @@ -136,6 +138,10 @@ export async function updateConversationControls() {
isMinimized: game.ConversationHud.conversationIsMinimized,
isVisible: game.ConversationHud.conversationIsVisible,
isSpeakingAs: game.ConversationHud.conversationIsSpeakingAs,
features: {
minimizeEnabled: game.settings.get(MODULE_NAME, ModuleSettings.enableMinimize),
speakAsEnabled: game.settings.get(MODULE_NAME, ModuleSettings.enableSpeakAs),
},
});

const updatedControls = document.createElement("section");
Expand Down
7 changes: 6 additions & 1 deletion js/init.js
@@ -1,5 +1,7 @@
import { MODULE_NAME } from "./constants.js";
import { ConversationHud } from "./conversation.js";
import { checkConversationDataAvailability, handleOnClickContentLink } from "./helpers.js";
import { registerSettings } from "./settings.js";

// Warning hook in case libWrapper is not installed
Hooks.once("ready", () => {
Expand All @@ -18,7 +20,7 @@ Hooks.on("init", () => {
// Register the module within libWrapper
if (libWrapper) {
libWrapper.register(
"conversation-hud",
MODULE_NAME,
"TextEditor._onClickContentLink",
function (wrapped, event) {
return handleOnClickContentLink.bind(this)(event, wrapped);
Expand All @@ -27,6 +29,9 @@ Hooks.on("init", () => {
);
}

// Register settings
registerSettings();

// Initialize the ConversationHUD object
game.ConversationHud = new ConversationHud();
game.ConversationHud.init();
Expand Down

0 comments on commit fdc16f1

Please sign in to comment.