Skip to content

Commit 86b2231

Browse files
authored
Merge pull request #178 from Oxy949/feature/uniform-size
Added option for image height as a percentage of the device screen height and option for uniform images size
2 parents b31a396 + 46a80b9 commit 86b2231

File tree

2 files changed

+36
-2
lines changed

2 files changed

+36
-2
lines changed

src/scripts/Theatre.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2300,8 +2300,15 @@ export class Theatre {
23002300
let sprite = new PIXI.Sprite(resources[resName]);
23012301
let portWidth = resources[resName].width;
23022302
let portHeight = resources[resName].height;
2303-
let maxHeight = game.settings.get(CONSTANTS.MODULE_ID, "theatreImageSize");
2304-
if (portHeight > maxHeight) {
2303+
2304+
let usePercent = game.settings.get(CONSTANTS.MODULE_ID, "theatreImageUsePercent");
2305+
let maxHeightPixel = game.settings.get(CONSTANTS.MODULE_ID, "theatreImageSize");
2306+
let maxHeightPercent = window.innerHeight * game.settings.get(CONSTANTS.MODULE_ID, "theatreImageSizePercent");
2307+
let useUniform = game.settings.get(CONSTANTS.MODULE_ID, "theatreImageSizeUniform");
2308+
2309+
let maxHeight = usePercent ? maxHeightPercent : maxHeightPixel;
2310+
2311+
if (portHeight > maxHeight || useUniform) {
23052312
portWidth *= maxHeight / portHeight;
23062313
portHeight = maxHeight;
23072314
}

src/scripts/settings.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,33 @@ export const registerSettings = function () {
5252
type: Number,
5353
});
5454

55+
56+
game.settings.register(CONSTANTS.MODULE_ID, "theatreImageUsePercent", {
57+
name: "Use screen height as maximum image height",
58+
scope: "world",
59+
config: true,
60+
default: false,
61+
type: Boolean,
62+
});
63+
64+
game.settings.register(CONSTANTS.MODULE_ID, "theatreImageSizePercent", {
65+
name: "Maximum image height (percent)",
66+
hint: "Set max image height as a percentage of the device screen height. Used only if the 'Use screen height as maximum image height' is enabled",
67+
scope: "client",
68+
config: true,
69+
default: 0.7,
70+
type: Number
71+
});
72+
73+
game.settings.register(CONSTANTS.MODULE_ID, "theatreImageSizeUniform", {
74+
name: "Uniform image height",
75+
hint: "Set all images size to the maximum height",
76+
scope: "world",
77+
config: true,
78+
default: false,
79+
type: Boolean,
80+
});
81+
5582
game.settings.register(CONSTANTS.MODULE_ID, "theatreNarratorHeight", {
5683
name: "Theatre.UI.Settings.narrHeight",
5784
hint: "Theatre.UI.Settings.narrHeightHint",

0 commit comments

Comments
 (0)