Skip to content

Commit

Permalink
Merge pull request #178 from Oxy949/feature/uniform-size
Browse files Browse the repository at this point in the history
Added option for image height as a percentage of the device screen height and option for uniform images size
  • Loading branch information
megahead11 authored Nov 13, 2024
2 parents b31a396 + 46a80b9 commit 86b2231
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/scripts/Theatre.js
Original file line number Diff line number Diff line change
Expand Up @@ -2300,8 +2300,15 @@ export class Theatre {
let sprite = new PIXI.Sprite(resources[resName]);
let portWidth = resources[resName].width;
let portHeight = resources[resName].height;
let maxHeight = game.settings.get(CONSTANTS.MODULE_ID, "theatreImageSize");
if (portHeight > maxHeight) {

let usePercent = game.settings.get(CONSTANTS.MODULE_ID, "theatreImageUsePercent");
let maxHeightPixel = game.settings.get(CONSTANTS.MODULE_ID, "theatreImageSize");
let maxHeightPercent = window.innerHeight * game.settings.get(CONSTANTS.MODULE_ID, "theatreImageSizePercent");
let useUniform = game.settings.get(CONSTANTS.MODULE_ID, "theatreImageSizeUniform");

let maxHeight = usePercent ? maxHeightPercent : maxHeightPixel;

if (portHeight > maxHeight || useUniform) {
portWidth *= maxHeight / portHeight;
portHeight = maxHeight;
}
Expand Down
27 changes: 27 additions & 0 deletions src/scripts/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,33 @@ export const registerSettings = function () {
type: Number,
});


game.settings.register(CONSTANTS.MODULE_ID, "theatreImageUsePercent", {
name: "Use screen height as maximum image height",
scope: "world",
config: true,
default: false,
type: Boolean,
});

game.settings.register(CONSTANTS.MODULE_ID, "theatreImageSizePercent", {
name: "Maximum image height (percent)",
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",
scope: "client",
config: true,
default: 0.7,
type: Number
});

game.settings.register(CONSTANTS.MODULE_ID, "theatreImageSizeUniform", {
name: "Uniform image height",
hint: "Set all images size to the maximum height",
scope: "world",
config: true,
default: false,
type: Boolean,
});

game.settings.register(CONSTANTS.MODULE_ID, "theatreNarratorHeight", {
name: "Theatre.UI.Settings.narrHeight",
hint: "Theatre.UI.Settings.narrHeightHint",
Expand Down

0 comments on commit 86b2231

Please sign in to comment.