Register

Chat Portrait

An Add-on Module for Foundry Virtual Tabletop

Author: 4535992 Project Source: Project URL Versions 11 - 11 (Verified 11) Last Updated 1 year, 2 months ago

Chat Portrait

If you want to buy me a coffee alt-text

A Foundry VTT module that displays the Actor's portrait images on the chat messages.

This is a upgrade of the project Chat Portrait by ShoyuVanilla ty to ShoyuVanilla

Settings

Preview

Installation

It's always easiest to install modules from the in game add-on browser.

To install this module manually:

  1. Inside the Foundry "Configuration and Setup" screen, click "Add-on Modules"
  2. Click "Install Module"
  3. In the "Manifest URL" field, paste the following url: https://raw.githubusercontent.com/p4535992/foundryvtt-chat-portrait/master/src/module.json
  4. Click 'Install' and wait for installation to complete
  5. Don't forget to enable the module in game using the "Manage Module" button

How help to make the Integration multisystem for my system ?

Since version 0.7.0, the module has been rewritten to allow for each system to have a css file to define the style and a description file of the mapping for the "ImageReplacer" feature.

Now the community can "come" to me a little, testing the css on their browser and help me understand which combination is the best, i file css si trovano nella directory degli styles, here a example for the dnd5e system

So the steps to follow to create or update a system are:

  1. Creation or update of the style file in the styles directory the file must respect the chat-portrait-style-XXX.css nomenclature where XXX is the system id e.g. "dnd5e".
  2. Creation or update of the typescript file for the mapping of the "ImageReplacer" feature if you do not want to use this feature create the file as empty and I'll take care of integrating the version with the empty arrays. In the minimal case you just need to copy the contents of the file generic.ts and insert the id of your system in the property "SYSTEM_ID" remember that you have to rename the file with the system id.
  3. Insert the system if absent in the configuration file systems.ts
  4. Open a pr on contact me in some way, by open a issue ecc.

NOTE: You can use other modules like Custom CSS for manage the css classes, the module help you by defining two css classes you can customize for the purpose of this module chat-portrait-text-size-name for the text chat message (the 'Setup additional custom styling on the text chat message' setting) and chat-portrait-image-size-name for the image prepend the text chat message (the 'Setup additional custom styling on the image prepend the text chat message' setting)

The module will continue to allow the use of custom CSS if desired.

Known Issue\Limitation

Hooks

ChatPortraitEnabled is called before the interaction with the chat is executed. When any of executed hooks return false the interaction is aborted with the default one of foundry.

ChatPortraitReplaceData is called like a replacement to the standard chat portrait recovery image, so any system or GM can use a customized version for a specific module.

Chat Portrait Custom Data

const chatPortraitCustomData = {
    // url or file string reference to the image portrait path
    customIconPortraitImage,
    // [DEPRECATED use instead the 'customImageReplacerData'] Customize your own imageReplacer (Record<string,string>)
    customImageReplacer,
    // Customize your own imageReplacer ( array of {  name: string; icon: string;})
    customImageReplacerData: imageReplacerData,
}

/// WARNING: internal data - do not use if possible
// data schema is defined in: src/scripts/ChatPortraitModels.ts (or scripts/ChatPortraitModels.js)
 

Example

Use your own code to enable/disable the module chat-portrait...

Hooks.call('ChatPortraitEnabled', chatMessage, html, speakerInfo);
// DO SOME CHECK 'BEFORE' APPLY THE CHAT PORTRAIT STYLING
 

How you can use this on your code....

Hooks.on('ChatPortraitEnabled', chatMessage, html, speakerInfo) => {

    // DO SOMETHING AND RETURN OR TRUE OR FALSE FOR ENABLE THE MODULE CHAT PORTRAIT
})
 

Use your own code for give me a customized image reference to put on the portrait , if you want you can give me a specific image reference for the 'Image Replacer" feature.

const chatPortraitCustomData = {
  customIconPortraitImage: "http://myimageurl/test.png", // url or file string reference to the image portrait path
  customImageReplacer: imageReplacer, // [DEPRECATED use instead the 'customImageReplacerData'] Customize your own imageReplacer (Record<string,string>)
  customImageReplacerData: imageReplacerData, // Customize your own imageReplacer ( array of {  name: string; icon: string;})
};

Hooks.call('ChatPortraitReplaceData', chatPortraitCustomData, chatMessage);

// and then i'll do something with `chatPortraitCustomData`

const blabla = chatPortraitCustomData;
 

How you can use this on your code....

Hooks.on('ChatPortraitReplaceData', (chatPortraitCustomData, chatMessage) => {

    // Set your own image

    chatPortraitCustomData.customIconPortraitImage = ......

    // DO SOMETHING AND RETURN A NEW chatPortraitCustomData

    return chatPortraitCustomData; // this is blabla
})
 

Full Example

Hooks.on('ChatPortraitReplaceData', (chatPortraitCustomData, chatMessage) => {
	const speaker = ChatMessage.getSpeakerActor(chatMessage.data.speaker);
	if('KW_WarfareUnitSheet' === speaker?.sheet?.constructor.name) {
		chatPortraitCustomData.iconMainCustomReplacer = {
			"KW_WARFARE.Power": "systems/dnd5e/icons/skills/yellow_08.jpg",
			"KW_WARFARE.Attack": "systems/dnd5e/icons/skills/red_31.jpg",
			"KW_WARFARE.Morale": "systems/dnd5e/icons/skills/yellow_17.jpg",
			"KW_WARFARE.Command": "systems/dnd5e/icons/skills/ice_16.jpg"
		};
	}
	return chatPortraitCustomData;
});
/// WARNING: internal data - do not use if possible // data schema is defined in: src/module/ChatPortraitModels.ts (or module/ChatPortraitModels.js)
 

hooks feature

Systems

For now the following system are the only one i tested

any other system need some fed back from the community

Features/Settings

avatar

background

img1img2

tag

Unknown

NOTE: You can use other modules like Custom CSS for manage the css classes, the module help you by defining two css classes you can customize for the purpose of this module chat-portrait-text-size-name for the text chat message (the 'Setup additional custom styling on the text chat message' setting) and chat-portrait-image-size-name for the image prepend the text chat message (the 'Setup additional custom styling on the image prepend the text chat message' setting)

Example of css piece of code for the dnd5e system to load on your world
.chat-portrait-text-size-name-dnd5e .chat-portrait-system-dnd5e {
  display: flex;
  margin: auto;
}

NOTE: You can use other modules like Custom CSS for manage the css classes, the module help you by defining two css classes you can customize for the purpose of this module chat-portrait-text-size-name for the text chat message (the 'Setup additional custom styling on the text chat message' setting) and chat-portrait-image-size-name for the image prepend the text chat message (the 'Setup additional custom styling on the image prepend the text chat message' setting)

Example of css piece of code for the dnd5e system to load on your world
.chat-portrait-image-size-name-dnd5e .chat-portrait-system-dnd5e {
  display: flex;
  margin: auto;
}

chat_portrait_feature

If you want to add your own system it's very simple!!! you can just give to me a map of strings key=value of label and image, for a live example check out what i have done for d&d5e with the english language here ImageReplacer. It's ugly but it's simple to integrated.

replacer

[ON DEVELOPING SO ANY SUGGESTION IS WELCOME]

If you want to add your own system it's very simple!!! you can just give to me a map of strings key=value of label and image, for a live example check out what i have done for d&d5e with the english language here ImageReplacer. It's ugly but it's simple to integrated.

replacer_damage_types

Categories

Available Versions

  1. Version 0.9.5

    10 months, 3 weeks ago
    Foundry Version 11 - 11 (Verified 11) Manifest URL Read Notes
  2. Version 0.9.4

    1 year, 2 months ago
    Foundry Version 11 - 11 (Verified 11) Manifest URL Read Notes
  3. Version 0.9.3

    Foundry Version 11 - 11 (Verified 11) Manifest URL Read Notes
  4. Version 0.9.1

    Foundry Version 11 - 11 (Verified 11) Manifest URL Read Notes
  5. Version 0.8.44

    Foundry Version 10 - 10 (Verified 10) Manifest URL Read Notes
  6. Version 0.8.43

    Foundry Version 10 - 10 (Verified 10) Manifest URL Read Notes
  7. Version 0.8.41

    Foundry Version 10 - 10 (Verified 10) Manifest URL Read Notes
  8. Version 0.8.38

    Foundry Version 10 - 10 (Verified 10) Manifest URL Read Notes
  9. Version 0.8.34

    Foundry Version 10 - 10 (Verified 10) Manifest URL Read Notes
  10. Version 0.8.31

    Foundry Version 10 - 10 (Verified 10) Manifest URL Read Notes
  11. Version 0.8.30

    Foundry Version 10 - 10 (Verified 10) Manifest URL Read Notes
  12. Version 0.8.28

    Foundry Version 10 - 10 (Verified 10) Manifest URL Read Notes
  13. Version 0.8.27

    Foundry Version 10 - 10 (Verified 10) Manifest URL Read Notes
  14. Version 0.8.26

    Foundry Version 10 - 10 (Verified 10) Manifest URL Read Notes
  15. Version 0.8.23

    Foundry Version 10 - 10 (Verified 10) Manifest URL Read Notes
  16. Version 0.8.22

    Foundry Version 10 - 10 (Verified 10) Manifest URL Read Notes
  17. Version 0.8.17

    Foundry Version 10 - 10 (Verified 10) Manifest URL Read Notes
  18. Version 0.8.11

    Foundry Version 10 - 10 (Verified 10) Manifest URL Read Notes
  19. Version 0.8.2

    Foundry Version 10 - 10 (Verified 10) Manifest URL Read Notes
  20. Version 0.8.0

    Foundry Version 9 - 10 (Verified 10) Manifest URL Read Notes
  21. Version 0.7.2

    Foundry Version 9 - 10 (Verified 9) Manifest URL Read Notes
  22. Version 0.7.1

    Foundry Version 9 - 10 (Verified 9) Manifest URL Read Notes
  23. Version 0.7.0

    Foundry Version 9 - 10 (Verified 9) Manifest URL Read Notes
  24. Version 0.6.2

    Foundry Version 0.8.9 - 10 (Verified 9) Manifest URL Read Notes
  25. Version 0.6.0

    Foundry Version 0.8.9 - 10 (Verified 9) Manifest URL Read Notes
  26. Version 0.5.36

    Foundry Version 0.8.9 - 10 (Verified 9) Manifest URL Read Notes
  27. Version 0.5.33

    Foundry Version 0.8.9 - 10 (Verified 9) Manifest URL Read Notes
  28. Version 0.5.26

    Foundry Version 0.8.6 - 10 (Verified 0.8.9) Manifest URL Read Notes
  29. Version 0.5.19

    Foundry Version 0.8.6 - 10 (Verified 0.8.9) Manifest URL Read Notes
  30. Version 0.5.14

    Foundry Version 0.8.6 - 10 (Verified 0.8.9) Manifest URL Read Notes
  31. Version 0.5.9

    Foundry Version 0.8.6 - 10 (Verified 0.8.9) Manifest URL Read Notes
  32. Version 0.5.3

    Foundry Version 0.8.6 - 10 (Verified 0.8.8) Manifest URL Read Notes
  33. Version 0.2.14

    Foundry Version 0.8.6 - 10 (Verified 0.8.8) Manifest URL Read Notes
  34. Version 0.2.13

    Foundry Version 0.8.6 - 10 (Verified 0.8.8) Manifest URL Read Notes
  35. Version 0.2.1

    Foundry Version 0.6.0 - 10 (Verified 0.7.3) Manifest URL Read Notes