Skip to content

Commit

Permalink
Merge pull request #13 from MoonIsFalling/feature/sendToChat
Browse files Browse the repository at this point in the history
added "send To Chat" Button to the Show to Playersdialog.
It allows to send the selected actions to the chat
  • Loading branch information
MoonIsFalling authored Feb 2, 2023
2 parents e83b616 + e4b3799 commit 0f9b405
Show file tree
Hide file tree
Showing 10 changed files with 73 additions and 17 deletions.
15 changes: 9 additions & 6 deletions dist/languages/en.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
{
"DisplayActions2e.WindowTitle": "Pf2e Actions",
"DisplayActions2e.ButtonName": "Pf2eActions",
"DisplayActions2e.ButtonHint": "Display Actions",
"DisplayActions2e.ButtonIcon": "pf2-actions a",
"DisplayActions2e.ShowPermissions": "Show with Permissions",
"DisplayActions2e.Duplication": "Duplicate",
"DisplayActions2e":{
"WindowTitle": "Pf2e Actions",
"ButtonName": "Pf2eActions",
"ButtonHint": "Display Actions",
"ButtonIcon": "pf2-actions a",
"ShowPermissions": "Show with Permissions",
"Duplication": "Duplicate",
"SentToChat": "Send to Chat"
},
"selectiveshow": {
"Show" : "Show",
"ShowAll": "Show All",
Expand Down
6 changes: 3 additions & 3 deletions dist/module.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
],
"title": "Pf2e Display Actions",
"description": "A small module to display the pathfinder action economy for convinience.",
"version": "1.8.0",
"version": "1.9.0",
"packs": [],
"system": [
"pf2e"
Expand All @@ -36,8 +36,8 @@
"scripts/module.js"
],
"url": "https://github.com/MoonIsFalling/pf2e-display-actions",
"manifest": "https://github.com/MoonIsFalling/pf2e-display-actions/releases/download/1.8.0/module.json",
"download": "https://github.com/MoonIsFalling/pf2e-display-actions/releases/download/1.8.0/module.zip",
"manifest": "https://github.com/MoonIsFalling/pf2e-display-actions/releases/download/1.9.0/module.json",
"download": "https://github.com/MoonIsFalling/pf2e-display-actions/releases/download/1.9.0/module.zip",
"includes": [
"./images/**",
"./languages/**",
Expand Down
21 changes: 21 additions & 0 deletions dist/scripts/module.js

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

2 changes: 1 addition & 1 deletion dist/scripts/module.js.map

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions dist/templates/selectiveshow.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@
<button type="button" class="show">{{localize "selectiveshow.Show"}}</button>
<button type="button" class="show-all">{{localize "selectiveshow.ShowAll"}}</button>
<button type="button" class="show-permissions">{{localize "DisplayActions2e.ShowPermissions"}}</button>
<button type="button" class="send-to-chat">{{localize "DisplayActions2e.SentToChat"}}</button>
</div>
</form>
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "pf2e-display-actions",
"version": "1.8.0",
"version": "1.9.0",
"description": "A small module to display the pathfinder action economy for convinience.",
"license": "MIT",
"private": true,
Expand Down
15 changes: 9 additions & 6 deletions src/languages/en.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
{
"DisplayActions2e.WindowTitle": "Pf2e Actions",
"DisplayActions2e.ButtonName": "Pf2eActions",
"DisplayActions2e.ButtonHint": "Display Actions",
"DisplayActions2e.ButtonIcon": "pf2-actions a",
"DisplayActions2e.ShowPermissions": "Show with Permissions",
"DisplayActions2e.Duplication": "Duplicate",
"DisplayActions2e":{
"WindowTitle": "Pf2e Actions",
"ButtonName": "Pf2eActions",
"ButtonHint": "Display Actions",
"ButtonIcon": "pf2-actions a",
"ShowPermissions": "Show with Permissions",
"Duplication": "Duplicate",
"SentToChat": "Send to Chat"
},
"selectiveshow": {
"Show" : "Show",
"ShowAll": "Show All",
Expand Down
1 change: 1 addition & 0 deletions src/templates/selectiveshow.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@
<button type="button" class="show">{{localize "selectiveshow.Show"}}</button>
<button type="button" class="show-all">{{localize "selectiveshow.ShowAll"}}</button>
<button type="button" class="show-permissions">{{localize "DisplayActions2e.ShowPermissions"}}</button>
<button type="button" class="send-to-chat">{{localize "DisplayActions2e.SentToChat"}}</button>
</div>
</form>
14 changes: 14 additions & 0 deletions src/ts/apps/selectiveShow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import {moduleId, socketEvent} from '../constants';
import {DisplayActions2eData, EmitData} from '../types';
import {handleSendToChat} from '../utils';

export class SelectiveShowApp extends FormApplication {
private userNameList: string[];
Expand Down Expand Up @@ -78,6 +79,19 @@ export class SelectiveShowApp extends FormApplication {

this.close();
});

html.find('.send-to-chat').click(ev => {
ev.preventDefault();
this._updateObject();

handleSendToChat({
operation: 'sendToChat',
state: this.displayActionState,
user: game.userId,
});

this.close();
});
}

protected override _updateObject(): Promise<unknown> {
Expand Down
13 changes: 13 additions & 0 deletions src/ts/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,19 @@ export function handleDuplication(data: EmitData) {
module.displayActions2e.push(dialog);
}

export function handleSendToChat(data: EmitData) {
let app = checkForApp(data);
if (app) {
if (app.rendered) {
// find the actions html, then wrap it to create "outerHtml"
let msg = app.element.find('.window-content').find('.flexbox-actions').wrapAll('<div>').parent();
ChatMessage.create({
content: msg.html(),
});
}
}
}

/**
* helper function to check if the wanted app already exists in the module
* @param data data from emit
Expand Down

0 comments on commit 0f9b405

Please sign in to comment.