Register

Chat Portrait

An Add-on Module for Foundry Virtual Tabletop

Author: 4535992 Project Source: Project URL Version 10 Last Updated 2 months, 3 weeks ago

Chat Portrait

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

NOTE: If you are a javascript developer and not a typescript developer, you can just use the javascript files under the dist folder

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/ShoyuVanilla/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/module/ChatPortraitModels.ts (or module/ChatPortraitModels.js)

Example

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

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

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

Hooks.on('ChatPortraitEnabled', () => {

    // 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;
});

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.8.44

    Compatible Foundry Versions: 10 - 10 Installation Link: Manifest URL Update Notes: Read Notes
  2. Version 0.8.43

    Compatible Foundry Versions: 10 - 10 Installation Link: Manifest URL Update Notes: Read Notes
  3. Version 0.8.41

    Compatible Foundry Versions: 10 - 10 Installation Link: Manifest URL Update Notes: Read Notes
  4. Version 0.8.38

    Compatible Foundry Versions: 10 - 10 Installation Link: Manifest URL Update Notes: Read Notes
  5. Version 0.8.34

    Compatible Foundry Versions: 10 - 10 Installation Link: Manifest URL Update Notes: Read Notes
  6. Version 0.8.31

    Compatible Foundry Versions: 10 - 10 Installation Link: Manifest URL Update Notes: Read Notes
  7. Version 0.8.30

    Compatible Foundry Versions: 10 - 10 Installation Link: Manifest URL Update Notes: Read Notes
  8. Version 0.8.28

    Compatible Foundry Versions: 10 - 10 Installation Link: Manifest URL Update Notes: Read Notes
  9. Version 0.8.27

    Compatible Foundry Versions: 10 - 10 Installation Link: Manifest URL Update Notes: Read Notes
  10. Version 0.8.26

    Compatible Foundry Versions: 10 - 10 Installation Link: Manifest URL Update Notes: Read Notes
  11. Version 0.8.23

    Compatible Foundry Versions: 10 - 10 Installation Link: Manifest URL Update Notes: Read Notes
  12. Version 0.8.22

    Compatible Foundry Versions: 10 - 10 Installation Link: Manifest URL Update Notes: Read Notes
  13. Version 0.8.17

    Compatible Foundry Versions: 10 - 10 Installation Link: Manifest URL Update Notes: Read Notes
  14. Version 0.8.11

    Compatible Foundry Versions: 10 - 10 Installation Link: Manifest URL Update Notes: Read Notes
  15. Version 0.8.2

    Compatible Foundry Versions: 10 - 10 Installation Link: Manifest URL Update Notes: Read Notes
  16. Version 0.8.0

    Compatible Foundry Versions: 9 - 10 Installation Link: Manifest URL Update Notes: Read Notes
  17. Version 0.7.2

    Compatible Foundry Versions: 9 - 9 Installation Link: Manifest URL Update Notes: Read Notes
  18. Version 0.7.1

    Compatible Foundry Versions: 9 - 9 Installation Link: Manifest URL Update Notes: Read Notes
  19. Version 0.7.0

    Compatible Foundry Versions: 9 - 9 Installation Link: Manifest URL Update Notes: Read Notes
  20. Version 0.6.2

    Compatible Foundry Versions: 0.8.9 - 9 Installation Link: Manifest URL Update Notes: Read Notes
  21. Version 0.6.0

    Compatible Foundry Versions: 0.8.9 - 9 Installation Link: Manifest URL Update Notes: Read Notes
  22. Version 0.5.36

    Compatible Foundry Versions: 0.8.9 - 9 Installation Link: Manifest URL Update Notes: Read Notes
  23. Version 0.5.33

    Compatible Foundry Versions: 0.8.9 - 9 Installation Link: Manifest URL Update Notes: Read Notes
  24. Version 0.5.26

    Compatible Foundry Versions: 0.8.6 - 0.8.9 Installation Link: Manifest URL Update Notes: Read Notes
  25. Version 0.5.19

    Compatible Foundry Versions: 0.8.6 - 0.8.9 Installation Link: Manifest URL Update Notes: Read Notes
  26. Version 0.5.14

    Compatible Foundry Versions: 0.8.6 - 0.8.9 Installation Link: Manifest URL Update Notes: Read Notes
  27. Version 0.5.9

    Compatible Foundry Versions: 0.8.6 - 0.8.9 Installation Link: Manifest URL Update Notes: Read Notes
  28. Version 0.5.3

    Compatible Foundry Versions: 0.8.6 - 0.8.8 Installation Link: Manifest URL Update Notes: Read Notes
  29. Version 0.2.14

    Compatible Foundry Versions: 0.8.6 - 0.8.8 Installation Link: Manifest URL Update Notes: Read Notes
  30. Version 0.2.13

    Compatible Foundry Versions: 0.8.6 - 0.8.8 Installation Link: Manifest URL Update Notes: Read Notes
  31. Version 0.2.1

    Compatible Foundry Versions: 0.6.0 - 0.7.3 Installation Link: Manifest URL Update Notes: Read Notes