Skip to content

Commit 80a9419

Browse files
committed
11.05 changes
1 parent a697ad4 commit 80a9419

16 files changed

+341
-99
lines changed

CHANGELOG.md

+17-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
# Version 11.05
2+
3+
Fixed issue with playing a slideshow when a scene loads.
4+
5+
Added the option to use a video file for a Slideshow slide.
6+
7+
Fixed issue with adding loot to an Encounter from a Journal Entry
8+
9+
Added the option to set sell and buy adjustments based on item type.
10+
11+
Added number display for progress list sheet.
12+
13+
Removed loading indication if error with slideshow image.
14+
15+
Cleared warning message with changes to Combat Details.
16+
117
# Version 11.04
218

319
Fixed DC configuration in systems that don't have support for skills lists.
@@ -34,7 +50,7 @@ Added In Progress back to the quest sheet.
3450

3551
# Version 11.03
3652

37-
Added Saving Thorws to the DC Config for Encounters
53+
Added Saving Throws to the DC Config for Encounters
3854

3955
Fixed warning about the private property of compendiums being discontinued.
4056

apps/adjust-price.js

+125
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
import { MonksEnhancedJournal, log, setting, i18n } from '../monks-enhanced-journal.js';
2+
import { MEJHelpers } from '../helpers.js';
3+
4+
export class AdjustPrice extends FormApplication {
5+
constructor(object, options = {}) {
6+
super(options);
7+
8+
this.object = object;
9+
}
10+
11+
/** @override */
12+
static get defaultOptions() {
13+
return mergeObject(super.defaultOptions, {
14+
id: "adjust-price",
15+
classes: ["adjust-price", "monks-journal-sheet", "dialog"],
16+
title: i18n("MonksEnhancedJournal.AdjustPrices"),
17+
template: "modules/monks-enhanced-journal/templates/adjust-price.html",
18+
width: 400,
19+
height: 'auto',
20+
closeOnSubmit: true,
21+
submitOnClose: false,
22+
submitOnChange: false
23+
});
24+
}
25+
26+
getData(options) {
27+
const original = game.system?.documentTypes?.Item || [];
28+
let types = original.filter(x => MonksEnhancedJournal.includedTypes.includes(x));
29+
types = types.reduce((obj, t) => {
30+
const label = CONFIG.Item?.typeLabels?.[t] ?? t;
31+
obj[t] = game.i18n.has(label) ? game.i18n.localize(label) : t;
32+
return obj;
33+
}, {});
34+
let defaultAdjustment = setting("adjustment-defaults");
35+
let adjustment = duplicate(defaultAdjustment);
36+
if (this.object)
37+
adjustment = this.object.getFlag('monks-enhanced-journal', 'adjustment') || {};
38+
else
39+
defaultAdjustment = {};
40+
let data = {
41+
adjustment,
42+
types,
43+
defaultAdjustment
44+
}
45+
data.showConvert = !!this.object;
46+
47+
return mergeObject(super.getData(options), data );
48+
}
49+
50+
activateListeners(html) {
51+
super.activateListeners(html);
52+
53+
$('.convert-button', html).on("click", this.convertItems.bind(this, html));
54+
$('.cancel', html).on("click", this.close.bind(this));
55+
$('.reset', html).on("click", this.resetValues.bind(this));
56+
57+
$('.sell-field', html).on("blur", this.validateField.bind(this));
58+
}
59+
60+
resetValues(event) {
61+
event.stopPropagation();
62+
event.preventDefault();
63+
64+
$('.sell-field', this.element).val('');
65+
$('.buy-field', this.element).val('');
66+
}
67+
68+
validateField(event) {
69+
let val = parseFloat($(event.currentTarget).val());
70+
if (!isNaN(val) && val < 0) {
71+
$(event.currentTarget).val('');
72+
}
73+
}
74+
75+
async _updateObject(event, formData) {
76+
let data = foundry.utils.expandObject(formData);
77+
78+
for (let [k,v] of Object.entries(data.adjustment)) {
79+
if (v.sell == undefined)
80+
delete data.adjustment[k].sell;
81+
if (v.buy == undefined)
82+
delete data.adjustment[k].buy;
83+
84+
if (Object.keys(data.adjustment[k]).length == 0)
85+
delete data.adjustment[k];
86+
}
87+
88+
if (this.object) {
89+
await this.object.unsetFlag('monks-enhanced-journal', 'adjustment');
90+
await this.object.setFlag('monks-enhanced-journal', 'adjustment', data.adjustment);
91+
} else
92+
await game.settings.set("monks-enhanced-journal", "adjustment-defaults", data.adjustment, { diff: false });
93+
}
94+
95+
async convertItems(html, event) {
96+
event.stopPropagation();
97+
event.preventDefault();
98+
99+
const fd = new FormDataExtended(html[0]);
100+
let data = foundry.utils.expandObject(fd.object);
101+
102+
for (let [k, v] of Object.entries(data.adjustment)) {
103+
if (v.sell == undefined)
104+
delete data.adjustment[k].sell;
105+
if (v.buy == undefined)
106+
delete data.adjustment[k].buy;
107+
108+
if (Object.keys(data.adjustment[k]).length == 0)
109+
delete data.adjustment[k];
110+
}
111+
112+
let adjustment = Object.assign({}, setting("adjustment-defaults"), data.adjustment || {});
113+
114+
let items = this.object.getFlag('monks-enhanced-journal', 'items') || [];
115+
116+
for (let item of items) {
117+
let sell = adjustment[item.type]?.sell ?? adjustment.default.sell ?? 1;
118+
let price = MEJHelpers.getPrice(getProperty(item, "flags.monks-enhanced-journal.price"));
119+
let cost = Math.max(Math.ceil((price.value * sell), 1)) + " " + price.currency;
120+
setProperty(item, "flags.monks-enhanced-journal.cost", cost);
121+
}
122+
123+
await this.object.update({ "flags.monks-enhanced-journal.items": items }, { focus: false });
124+
}
125+
}

css/apsjournal.css

+8-8
Original file line numberDiff line numberDiff line change
@@ -190,15 +190,15 @@
190190
/**
191191
* Core Style Overrides
192192
**/
193-
:root[mejtheme] .editor-content table tbody tr td {
193+
:root[mejtheme] .monks-journal-sheet .editor-content table tbody tr td {
194194
padding: 0 15px;
195195
}
196196

197-
:root[mejtheme] .editor-content table tbody tr td:first-child {
197+
:root[mejtheme] .monks-journal-sheet .editor-content table tbody tr td:first-child {
198198
white-space: nowrap;
199199
}
200200

201-
:root[mejtheme] .editor-content blockquote {
201+
:root[mejtheme] .monks-journal-sheet .editor-content blockquote {
202202
margin-bottom: 1.5em;
203203
}
204204

@@ -207,21 +207,21 @@
207207
margin: 1em 5%;
208208
}
209209

210-
:root[mejtheme] table thead,
211-
:root[mejtheme] table tfoot {
210+
:root[mejtheme] .monks-journal-sheet table thead,
211+
:root[mejtheme] .monks-journal-sheet table tfoot {
212212
color: rgb(var(--mej-light-0));
213213
background: var(--apsj-primary);
214214
font-family: var(--apsj-font-scalycaps);
215215
font-weight: 700;
216216
text-shadow: 1px 1px 2px rgb(var(--mej-dark-0));
217217
}
218218

219-
:root[mejtheme] table thead a.hyperlink,
220-
:root[mejtheme] table tfoot a.hyperlink {
219+
:root[mejtheme] .monks-journal-sheet table thead a.hyperlink,
220+
:root[mejtheme] .monks-journal-sheet table tfoot a.hyperlink {
221221
color: var(--apsj-yellow);
222222
}
223223

224-
:root[mejtheme] tbody tr td {
224+
:root[mejtheme] .monks-journal-sheet tbody tr td {
225225
font-family: var(--apsj-font-scalysans);
226226
font-weight: 400;
227227
}

css/monks-journal-sheet.css

+9
Original file line numberDiff line numberDiff line change
@@ -1197,13 +1197,22 @@ body:not(.system-pf2e) .monks-journal-sheet .sheet-container .tag {
11971197
box-shadow: 0 0 4px #b2c3ff;
11981198
border-radius: 4px;
11991199
margin: 0px 4px;
1200+
position: relative;
12001201
}
12011202
.monks-journal-sheet .list-list .progress:first-child {
12021203
margin-left: 0px;
12031204
}
12041205
.monks-journal-sheet .list-list .progress:last-child {
12051206
margin-right: 0px;
12061207
}
1208+
.monks-journal-sheet .list-list .progress-value {
1209+
position: absolute;
1210+
top: 0px;
1211+
left: 0px;
1212+
width: 100%;
1213+
text-align: center;
1214+
color: #ffffff;
1215+
}
12071216
.monks-journal-sheet .list-list .progress-bar {
12081217
position: relative;
12091218
margin: 1px;

lang/en.json

+3
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@
7676
"MonksEnhancedJournal.party-loot-entity.hint": "When selling items, add option to ",
7777
"MonksEnhancedJournal.start-toc-collapsed.name": "Start TOC Collapsed",
7878
"MonksEnhancedJournal.start-toc-collapsed.hint": "Start with the Table of Contents collapsed",
79+
"MonksEnhancedJournal.defaultprices.name": "Default Prices",
80+
"MonksEnhancedJournal.defaultprices.hint": "Default prices for shops",
7981

8082
"MonksEnhancedJournal.SlideConfiguration": "Slide Configuration",
8183
"MonksEnhancedJournal.DCConfiguration": "DC Configuration",
@@ -487,6 +489,7 @@
487489
"MonksEnhancedJournal.msg.PleaseSelectJournal": "Please select a Journal",
488490
"MonksEnhancedJournal.msg.ShopIsNotReceivingItems": "Shop is not receiving items at this time",
489491
"MonksEnhancedJournal.msg.NoItemsToAssign": "No items to assign to a target",
492+
"MonksEnhancedJournal.msg.CannotSellItem": "This shop does not buy back this item",
490493

491494
"MonksEnhancedJournal.Contain": "Contain",
492495
"MonksEnhancedJournal.Cover": "Cover",

module.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"title": "Monk's Enhanced Journal",
33
"description": "Treat the journal like it's going to be popped out and used as a digital guide book. Add extra information to summarize an encounter. Show summaries of people and places. Allow for bookmarking of commonly used pages",
4-
"version": "11.04",
4+
"version": "11.05",
55
"authors": [
66
{
77
"name": "IronMonk",
@@ -95,7 +95,7 @@
9595
"css/apsjournal.css"
9696
],
9797
"url": "https://github.com/ironmonk88/monks-enhanced-journal",
98-
"download": "https://github.com/ironmonk88/monks-enhanced-journal/archive/11.04.zip",
98+
"download": "https://github.com/ironmonk88/monks-enhanced-journal/archive/11.05.zip",
9999
"manifest": "https://github.com/ironmonk88/monks-enhanced-journal/releases/latest/download/module.json",
100100
"bugs": "https://github.com/ironmonk88/monks-enhanced-journal/issues",
101101
"allowBugReporter": true,

monks-enhanced-journal.js

+51-10
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,8 @@ export class MonksEnhancedJournal {
9797
static quantityname = "quantity";
9898
static currencyname = "currency";
9999

100+
static includedTypes = ["armor", "consumable", "backpack", "equipment", "kit", "treasure", "weapon", "tool", "loot"];
101+
100102
constructor() {
101103
}
102104

@@ -1007,14 +1009,16 @@ export class MonksEnhancedJournal {
10071009
}
10081010

10091011
let sceneActivate = function (wrapped, ...args) {
1010-
if (this.journal && this.journal.type == 'slideshow') {
1012+
if (MonksEnhancedJournal.getMEJType(this.journal) == 'slideshow') {
10111013
if (game.user.isGM) {
10121014
//start slideshow for everyone
1013-
MonksEnhancedJournal.fixType(this.journal);
1014-
const cls = (this.journal._getSheetClass ? this.journal._getSheetClass() : null);
1015-
const sheet = new cls(this.journal, { render: false });
1015+
let page = this.journal.pages.contents[0];
1016+
MonksEnhancedJournal.fixType(page);
1017+
const cls = (page._getSheetClass ? page._getSheetClass() : null);
1018+
const sheet = new cls(page, { render: false });
10161019
if (sheet.playSlideshow)
10171020
sheet.playSlideshow();
1021+
MonksEnhancedJournal.openJournalEntry(this.journal);
10181022
}
10191023
}
10201024
return wrapped(...args);
@@ -1920,6 +1924,33 @@ export class MonksEnhancedJournal {
19201924
}
19211925
}
19221926

1927+
static async fixAdjustments() {
1928+
if (setting('fix-adjustment')) {
1929+
let defaultAdjustments = setting('adjustment-defaults');
1930+
defaultAdjustments.default = mergeObject({ sell: 1, buy: 0.5 }, defaultAdjustments.default);
1931+
for (let journal of game.journal) {
1932+
if (MonksEnhancedJournal.getMEJType(journal) == "shop") {
1933+
let page = journal.pages.contents[0];
1934+
1935+
let adjustment = getProperty(page, "flags.monks-enhanced-journal.adjustment") || {};
1936+
let defValue = {
1937+
sell: adjustment.default?.sell ?? getProperty(page, "flags.monks-enhanced-journal.sell"),
1938+
buy: adjustment.default?.buy ?? getProperty(page, "flags.monks-enhanced-journal.buy")
1939+
};
1940+
1941+
if (defValue.sell || defValue.buy) {
1942+
if (defValue.sell && defValue.sell == defaultAdjustments.default.sell) delete defValue.sell;
1943+
if (defValue.buy && defValue.buy == defaultAdjustments.default.buy) delete defValue.buy;
1944+
if (Object.keys(defValue).length != 0) {
1945+
adjustment.default = defValue;
1946+
await page.update({ flags: { "monks-enhanced-journal": { adjustment: adjustment } } });
1947+
}
1948+
}
1949+
}
1950+
}
1951+
}
1952+
}
1953+
19231954
static registerSheetClasses() {
19241955
let types = MonksEnhancedJournal.getDocumentTypes();
19251956
let labels = MonksEnhancedJournal.getTypeLabels();
@@ -2374,6 +2405,12 @@ export class MonksEnhancedJournal {
23742405
// game.settings.set("monks-enhanced-journal", "fix-person", false);
23752406
} catch { }
23762407
}
2408+
if (setting("fix-adjustment")) {
2409+
try {
2410+
MonksEnhancedJournal.fixAdjustments();
2411+
game.settings.set("monks-enhanced-journal", "fix-adjustment", false);
2412+
} catch { }
2413+
}
23772414
}
23782415

23792416
MonksEnhancedJournal.cleanPageState();
@@ -2432,11 +2469,13 @@ export class MonksEnhancedJournal {
24322469
}
24332470
}
24342471
*/
2435-
2436-
let oldDragMouseUp = Draggable.prototype._onDragMouseUp;
2437-
Draggable.prototype._onDragMouseUp = function (event) {
2438-
Hooks.call(`dragEnd${this.app.constructor.name}`, this.app);
2439-
return oldDragMouseUp.call(this, event);
2472+
if (!game.modules.get('monks-combat-details')?.active) {
2473+
patchFunc("Draggable.prototype._onDragMouseUp", async function (wrapped, ...args) {
2474+
for (const cls of this.app.constructor._getInheritanceChain()) {
2475+
Hooks.callAll(`dragEnd${cls.name}`, this.app, this.app.position);
2476+
}
2477+
return wrapped(...args);
2478+
});
24402479
}
24412480
}
24422481

@@ -2804,9 +2843,11 @@ export class MonksEnhancedJournal {
28042843
textarea.append($('<div>').addClass('slide-text').attr({'data-id': t.id}).html(t.text).css(style));
28052844
}
28062845

2846+
let tag = VideoHelper.hasVideoExtension(slide.img) ? "<video>" : "<img>";
2847+
28072848
return $('<div>').addClass("slide animate-slide loading").attr('data-slide-id', slide.id)
28082849
.append($('<div>').addClass('slide-background').append($('<div>').attr('style', background)))
2809-
.append($('<img>').addClass('slide-image').attr('src', slide.img).css({ 'object-fit': slide.sizing}))
2850+
.append($(tag).addClass('slide-image').attr({ 'src': slide.img, 'loop': true, 'autoplay': "true" }).css({ 'object-fit': slide.sizing}))
28102851
.append(textarea);
28112852
}
28122853

0 commit comments

Comments
 (0)