Skip to content

Commit

Permalink
New formatted message macro
Browse files Browse the repository at this point in the history
  • Loading branch information
saif-ellafi committed Nov 14, 2021
1 parent b1e21d6 commit 4ca2b8b
Show file tree
Hide file tree
Showing 7 changed files with 99 additions and 11 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
### 1.4.2
* Added new macro "Formatted Message" allows for formatting Chat style with formats (title, subtitle, bold) and color
* Fixed a redundant entry in compendium packs

### 1.4.1
* Added an optional setting that enables 3D dice on d100 table rolls

Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ for the support
* Allows Increasing and Decreasing Chaos Rank with a button
* Roll Tables for manual use in Foundry
* Configuration to point to custom Roll Tables to the Macros to customize your fate
* Formatted Message macro allows styling a chat message (color, title, bold, etc)

### Functionalities

Expand Down
4 changes: 2 additions & 2 deletions module.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
"JeansenVaars",
"Tana Pigeon (Word Mill Games)"
],
"version": "1.4.1",
"version": "1.4.2",
"minimumCoreVersion": "0.8.9",
"url": "https://github.com/saif-ellafi/foundryvtt-mythic-gme.git",
"manifest": "https://github.com/saif-ellafi/foundryvtt-mythic-gme/releases/latest/download/module.json",
"download": "https://github.com/saif-ellafi/foundryvtt-mythic-gme/releases/download/1.4.1/foundryvtt-mythic-gme_1.4.1.zip",
"download": "https://github.com/saif-ellafi/foundryvtt-mythic-gme/releases/download/1.4.2/foundryvtt-mythic-gme_1.4.2.zip",
"compatibleCoreVersion": "0.8.9",
"scripts": [
"mythic-gme-tools.js"
Expand Down
82 changes: 82 additions & 0 deletions mythic-gme-tools.js
Original file line number Diff line number Diff line change
Expand Up @@ -597,3 +597,85 @@ async function dealCard({
default: "close"
}).render(true);
}

function mgeFormattedChat() {

const formattedChatDialog = `
<form>
<label for="mgme_format_style">Style:</label>
<select id="mgme_format_style" style="margin-bottom: 10px;">
<option value="title" selected>Title</option>
<option value="subtitle">Subtitle</option>
<option value="bold">Bold</option>
<option value="italic">Italic</option>
<option value="underline">Underline</option>
<option value="normal">Normal</option>
</select>
<label for="mgme_format_color">Color:</label>
<input id="mgme_format_color" style="margin-bottom: 10px" placeholder="default"/>
<label for="mgme_format_text">Message:</label>
<input id="mgme_format_text" style="margin-bottom: 10px"/>
</form>
`

let dialogue = new Dialog({
title: `Formatted Text`,
content: formattedChatDialog,
render: html => html[0].getElementsByTagName("input").mgme_format_text.focus(),
buttons: {
submit: {
icon: '',
label: 'Submit',
callback: () => {
let message;
let color = $("#mgme_format_color").val();
if (color && color !== '') {
color = `style="color:${color};"`;
} else {
`style="color:inherit;"`;
}
let text = $("#mgme_format_text").val();
if (!text || text === '') return;
switch ($("#mgme_format_style").val()) {
case '':
case 'normal':
case undefined: {
message = `<span ${color}>${text}</span>`;
break;
}
case 'title': {
message = `<h1 ${color}>${text}</h1>`;
break;
}
case 'subtitle': {
message = `<h2 ${color}>${text}</h2>`;
break;
}
case 'bold': {
message = `<b ${color}>${text}</b>`;
break;
}
case 'italic': {
message = `<em ${color}>${text}</em>`;
break;
}
case 'underline': {
message = `<u ${color}>${text}</u>`;
break;
}
}

let subjectChat = {
content: message,
speaker: ChatMessage.getSpeaker()
};
ChatMessage.create(subjectChat);
}
}
},
default: "submit"
})

dialogue.render(true)

}
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "foundryvtt-mythic-gme",
"version": "1.4.1",
"version": "1.4.2",
"description": "A set of Macros and Random Tables for playing with the Mythic Game Master Emulator",
"main": "mythic-gme-tools.js",
"scripts": {
Expand Down
13 changes: 7 additions & 6 deletions packs/mythic-gme-macros.db
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{"name":"Fate Chart","type":"script","author":"nsNIAHJHoLpLD0GO","img":"icons/svg/clockwork.svg","scope":"global","command":"mgeFateChart()","folder":null,"sort":0,"permission":{"default":0,"xqxgNJxuQawzC1dQ":3,"IqlhGYYOCpicp39V":3,"nsNIAHJHoLpLD0GO":3},"flags":{"core":{"sourceId":"Macro.pkAtd1tkluuLEjbz"}},"_id":"1nPO9CooCaoCI1Jf"}
{"name":"Random Event","type":"script","author":"nsNIAHJHoLpLD0GO","img":"icons/svg/sun.svg","scope":"global","command":"mgeRandomEvent()","folder":null,"sort":0,"permission":{"default":0,"xqxgNJxuQawzC1dQ":3,"IqlhGYYOCpicp39V":3,"nsNIAHJHoLpLD0GO":3},"flags":{"core":{"sourceId":"Macro.PVKb2yKiyRy6xghw"}},"_id":"7v2O3P8h9ofqKtHZ"}
{"name":"Scene Alteration","type":"script","author":"nsNIAHJHoLpLD0GO","img":"icons/svg/explosion.svg","scope":"global","command":"mgeSceneAlteration()","folder":null,"sort":0,"permission":{"default":0,"xqxgNJxuQawzC1dQ":3,"IqlhGYYOCpicp39V":3,"nsNIAHJHoLpLD0GO":3},"flags":{"core":{"sourceId":"Macro.aHjCw1eLIfrdkCbd"}},"_id":"SNxyVZQEDKz3ROhi"}
{"name":"Complex Question","type":"script","author":"nsNIAHJHoLpLD0GO","img":"icons/svg/stoned.svg","scope":"global","command":"mgeComplexQuestion()","folder":null,"sort":0,"permission":{"default":0,"nsNIAHJHoLpLD0GO":3},"flags":{"core":{"sourceId":"Macro.mUyHaxkhuPJv3JPc"}},"_id":"7inKXjQtRgEZ070H"}
{"name":"Increase Chaos","type":"script","author":"nsNIAHJHoLpLD0GO","img":"icons/svg/up.svg","scope":"global","command":"mgeIncreaseChaos()","folder":null,"sort":0,"permission":{"default":0,"xqxgNJxuQawzC1dQ":3,"IqlhGYYOCpicp39V":3,"nsNIAHJHoLpLD0GO":3},"flags":{"core":{"sourceId":"Macro.xtGSCNZPEWYwgfOD"}},"_id":"7xkWsFNImRtThklB"}
{"name":"Decrease Chaos","type":"script","author":"nsNIAHJHoLpLD0GO","img":"icons/svg/down.svg","scope":"global","command":"mgeDecreaseChaos()","folder":null,"sort":0,"permission":{"default":0,"xqxgNJxuQawzC1dQ":3,"IqlhGYYOCpicp39V":3,"nsNIAHJHoLpLD0GO":3},"flags":{"core":{"sourceId":"Macro.vReASdOdjdiEwWI3"}},"_id":"U7bp779v5YLnZyw7"}
{"name":"Decrease Chaos","type":"script","author":"xqxgNJxuQawzC1dQ","img":"icons/svg/down.svg","scope":"global","command":"mgeDecreaseChaos()","folder":null,"sort":0,"permission":{"default":0,"xqxgNJxuQawzC1dQ":3,"IqlhGYYOCpicp39V":3,"nsNIAHJHoLpLD0GO":3},"flags":{"core":{"sourceId":"Macro.vReASdOdjdiEwWI3"}},"_id":"374C1LUS0zvOKgr5"}
{"name":"Fate Chart","type":"script","author":"xqxgNJxuQawzC1dQ","img":"icons/svg/clockwork.svg","scope":"global","command":"mgeFateChart()","folder":null,"sort":0,"permission":{"default":0,"xqxgNJxuQawzC1dQ":3,"IqlhGYYOCpicp39V":3,"nsNIAHJHoLpLD0GO":3},"flags":{"core":{"sourceId":"Macro.pkAtd1tkluuLEjbz"}},"_id":"6uQ1ozJTRiKP5HcI"}
{"name":"Increase Chaos","type":"script","author":"xqxgNJxuQawzC1dQ","img":"icons/svg/up.svg","scope":"global","command":"mgeIncreaseChaos()","folder":null,"sort":0,"permission":{"default":0,"xqxgNJxuQawzC1dQ":3,"IqlhGYYOCpicp39V":3,"nsNIAHJHoLpLD0GO":3},"flags":{"core":{"sourceId":"Macro.xtGSCNZPEWYwgfOD"}},"_id":"7Bek2C2t8jFi2Ijl"}
{"name":"Random Event","type":"script","author":"xqxgNJxuQawzC1dQ","img":"icons/svg/sun.svg","scope":"global","command":"mgeRandomEvent()","folder":null,"sort":0,"permission":{"default":0,"xqxgNJxuQawzC1dQ":3,"IqlhGYYOCpicp39V":3,"nsNIAHJHoLpLD0GO":3},"flags":{"core":{"sourceId":"Macro.PVKb2yKiyRy6xghw"}},"_id":"JatICb1AhYKtZhRj"}
{"name":"Scene Alteration","type":"script","author":"xqxgNJxuQawzC1dQ","img":"icons/svg/explosion.svg","scope":"global","command":"mgeSceneAlteration()","folder":null,"sort":0,"permission":{"default":0,"xqxgNJxuQawzC1dQ":3,"IqlhGYYOCpicp39V":3,"nsNIAHJHoLpLD0GO":3},"flags":{"core":{"sourceId":"Macro.aHjCw1eLIfrdkCbd"}},"_id":"UCRmooGG60WdDvPb"}
{"name":"Complex Question","type":"script","author":"xqxgNJxuQawzC1dQ","img":"icons/svg/stoned.svg","scope":"global","command":"mgeComplexQuestion()","folder":null,"sort":0,"permission":{"default":0,"nsNIAHJHoLpLD0GO":3,"xqxgNJxuQawzC1dQ":3},"flags":{"core":{"sourceId":"Macro.mUyHaxkhuPJv3JPc"}},"_id":"bAwrI9gsGdu6a22K"}
{"name":"Formatted Message","type":"script","author":"xqxgNJxuQawzC1dQ","img":"icons/svg/daze.svg","scope":"global","command":"mgeFormattedChat();","folder":null,"sort":0,"permission":{"default":0,"xqxgNJxuQawzC1dQ":3},"flags":{"core":{"sourceId":"Macro.DMyJtr5J8LU6pirF"}},"_id":"iBb0DYI2ovRLUc7M"}

0 comments on commit 4ca2b8b

Please sign in to comment.