Skip to content

Commit

Permalink
a
Browse files Browse the repository at this point in the history
  • Loading branch information
theripper93 committed Nov 12, 2024
1 parent 34f0e0e commit dc04464
Show file tree
Hide file tree
Showing 7 changed files with 101 additions and 105 deletions.
File renamed without changes.
2 changes: 1 addition & 1 deletion packs/macros/CURRENT
Original file line number Diff line number Diff line change
@@ -1 +1 @@
MANIFEST-002114
MANIFEST-002178
6 changes: 3 additions & 3 deletions packs/macros/LOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
2024/10/16-14:15:53.372 7a34 Recovering log #2113
2024/10/16-14:15:53.376 7a34 Delete type=0 #2113
2024/10/16-14:15:53.376 7a34 Delete type=3 #2112
2024/11/12-15:07:01.224 6d5c Recovering log #2176
2024/11/12-15:07:01.227 6d5c Delete type=0 #2176
2024/11/12-15:07:01.228 6d5c Delete type=3 #2174
10 changes: 7 additions & 3 deletions packs/macros/LOG.old
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
2024/10/16-01:43:45.004 4cf0 Recovering log #2110
2024/10/16-01:43:45.007 4cf0 Delete type=0 #2110
2024/10/16-01:43:45.007 4cf0 Delete type=3 #2108
2024/11/11-15:36:42.114 74d4 Recovering log #2173
2024/11/11-15:36:42.118 74d4 Delete type=0 #2173
2024/11/11-15:36:42.118 74d4 Delete type=3 #2172
2024/11/11-15:41:20.363 7628 Level-0 table #2177: started
2024/11/11-15:41:20.363 7628 Level-0 table #2177: 0 bytes OK
2024/11/11-15:41:20.364 7628 Delete type=0 #2175
2024/11/11-15:41:20.373 7628 Manual compaction at level-0 from '!macros!5zElsDCnePqaHmQ6' @ 72057594037927935 : 1 .. '!macros!uPDEi0D43DJ8ifBf' @ 0 : 0; will stop at (end)
Binary file not shown.
28 changes: 27 additions & 1 deletion scripts/const.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,30 @@ export const MODULE_SCOPE = "wall-height";
export const TOP_KEY = "top";
export const BOTTOM_KEY = "bottom";
export const ENABLE_ADVANCED_VISION_KEY = "advancedVision";
export const ENABLE_ADVANCED_MOVEMENT_KEY = "wallHeightAdvancedMovement";
export const ENABLE_ADVANCED_MOVEMENT_KEY = "wallHeightAdvancedMovement";


export function showWelcome() {
if (!game.user.isGM) return;
const FALLBACK_MESSAGE = `<h1><i class="fa-solid fa-block-brick"></i> Wall Height</h1> <p><strong>New to Wall Height? Visit the <a href="https://wiki.theripper93.com/free/wall-height">Wiki</a> for a quickstart guide and resources.</strong></p> <p>Special thanks to all my <a href="https://www.patreon.com/theripper93">Patreons</a> for making ongoing updates and development possible. Supporting gives you access to <strong>30+ premium modules</strong> and priority support.</p> <strong style="font-size: large;">Want to level up your games? </strong><p>Check out the premium module collection!</p> <iframe width="100%" height="auto" src="https://www.youtube.com/embed/2Iq_so_GsLA" title="3D Canvas Overview" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe> <p><strong>Explore all resources and modules:</strong></p> <ul> <li><a href="https://theripper93.com/">Check out all my free and premium modules</a></li> <li><a href="https://wiki.theripper93.com/free/wall-height">Wall Height Wiki</a></li> <li><a href="https://www.patreon.com/theripper93">Support on Patreon</a></li><li><a href="https://discord.theripper93.com/">Discord Channel</a></li> </ul> `;

// Settings key used for the "Don't remind me again" setting
const DONT_REMIND_AGAIN_KEY = "chat-welcome-message-shown";

// Dialog code
game.settings.register(MODULE_SCOPE, DONT_REMIND_AGAIN_KEY, {
default: false,
type: Boolean,
scope: "world",
config: false,
});
if (game.user.isGM && !game.settings.get(MODULE_SCOPE, DONT_REMIND_AGAIN_KEY)) {

ChatMessage.create({
user: game.user.id,
whisper: game.users.filter(u => u.isGM).map(u => u.id),
blind: true,
content: FALLBACK_MESSAGE,
});
}
}
160 changes: 63 additions & 97 deletions scripts/wall-height.js
Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
import { registerWrappers } from "./patches.js";
import { getWallBounds,getSceneSettings,migrateData,getTokenLOSheight } from "./utils.js";
import { MODULE_SCOPE, TOP_KEY, BOTTOM_KEY, ENABLE_ADVANCED_VISION_KEY, ENABLE_ADVANCED_MOVEMENT_KEY } from "./const.js";
import { getWallBounds, getSceneSettings, migrateData, getTokenLOSheight } from "./utils.js";
import { MODULE_SCOPE, TOP_KEY, BOTTOM_KEY, ENABLE_ADVANCED_VISION_KEY, ENABLE_ADVANCED_MOVEMENT_KEY, showWelcome } from "./const.js";

const MODULE_ID = 'wall-height';
const MODULE_ID = "wall-height";

Object.defineProperty(Token.prototype, "losHeight", {
get: function myProperty() {
return getTokenLOSheight(this);
return getTokenLOSheight(this);
},
});

Hooks.once("init",()=>{
Hooks.once("init", () => {
registerWrappers();
registerSettings();
WallHeight.cacheSettings();
});

Hooks.once("ready", ()=>{
if(!game.user.isGM) return;
if(game.settings.get(MODULE_ID, 'migrateOnStartup')) WallHeight.migrateAll();
if(game.settings.get(MODULE_ID, 'migrateTokenHeight')) {
Hooks.once("ready", () => {
if (!game.user.isGM) return;
if (game.settings.get(MODULE_ID, "migrateOnStartup")) WallHeight.migrateAll();
if (game.settings.get(MODULE_ID, "migrateTokenHeight")) {
WallHeight.migrateTokenHeight();
game.settings.set(MODULE_ID, 'migrateTokenHeight',false)
game.settings.set(MODULE_ID, "migrateTokenHeight", false);
}
})
});

function registerSettings() {
game.settings.register(MODULE_ID, 'enableWallText', {
game.settings.register(MODULE_ID, "enableWallText", {
name: game.i18n.localize(`${MODULE_SCOPE}.settings.enableWallText.name`),
hint: game.i18n.localize(`${MODULE_SCOPE}.settings.enableWallText.hint`),
scope: 'world',
scope: "world",
config: true,
type: Boolean,
default: true,
Expand All @@ -48,9 +48,8 @@ function registerSettings() {
onChange: () => {
WallHeight.cacheSettings();
},
});
});


game.settings.register(MODULE_ID, "defaultLosHeight", {
name: game.i18n.localize(`${MODULE_SCOPE}.settings.defaultLosHeight.name`),
hint: game.i18n.localize(`${MODULE_SCOPE}.settings.defaultLosHeight.hint`),
Expand Down Expand Up @@ -80,43 +79,45 @@ function registerSettings() {
},
});

game.settings.register(MODULE_ID, 'globalAdvancedLighting', {
game.settings.register(MODULE_ID, "globalAdvancedLighting", {
name: game.i18n.localize(`${MODULE_SCOPE}.settings.globalAdvancedLighting.name`),
hint: game.i18n.localize(`${MODULE_SCOPE}.settings.globalAdvancedLighting.hint`),
scope: 'world',
scope: "world",
config: true,
type: Boolean,
default: true,
});

game.settings.register(MODULE_ID, 'migrateOnStartup', {
game.settings.register(MODULE_ID, "migrateOnStartup", {
name: game.i18n.localize(`${MODULE_SCOPE}.settings.migrateOnStartup.name`),
hint: game.i18n.localize(`${MODULE_SCOPE}.settings.migrateOnStartup.hint`),
scope: 'world',
scope: "world",
config: true,
type: Boolean,
default: false
default: false,
});
game.settings.register(MODULE_ID, 'migrateTokenHeight', {
scope: 'world',

game.settings.register(MODULE_ID, "migrateTokenHeight", {
scope: "world",
config: false,
type: Boolean,
default: false
default: false,
});
}

Hooks.on("renderWallConfig", (app, html, data) => {
html = html[0] ?? html;
const {advancedVision} = getSceneSettings(canvas.scene);
if(!advancedVision) return;
const { advancedVision } = getSceneSettings(canvas.scene);
if (!advancedVision) return;
let { top, bottom } = getWallBounds(app.document);
top = parseFloat(top);
bottom = parseFloat(bottom);
const topLabel = game.i18n.localize(`${MODULE_SCOPE}.WallHeightTopLabel`);
const bottomLabel = game.i18n.localize(`${MODULE_SCOPE}.WallHeightBottomLabel`);
const moduleLabel = game.i18n.localize(`${MODULE_SCOPE}.ModuleLabel`);
html.querySelector(`.door-options`).insertAdjacentHTML("afterend", `
html.querySelector(`.door-options`).insertAdjacentHTML(
"afterend",
`
<fieldset>
<legend>${moduleLabel}</legend>
<div class="form-group">
Expand All @@ -129,32 +130,33 @@ Hooks.on("renderWallConfig", (app, html, data) => {
</div>
</legend>
</fieldset>
`);
`,
);
app.setPosition({ height: "auto" });
});

Hooks.on("renderAmbientLightConfig", (app, html, data) => {
if(html.querySelector(`input[name="flags.${MODULE_SCOPE}.advancedLighting"]`)) return;
const {advancedVision} = getSceneSettings(canvas.scene);
if(!advancedVision) return;
if (html.querySelector(`input[name="flags.${MODULE_SCOPE}.advancedLighting"]`)) return;
const { advancedVision } = getSceneSettings(canvas.scene);
if (!advancedVision) return;
const label = game.i18n.localize(`${MODULE_SCOPE}.advancedLightingLabel`);
const notes = game.i18n.localize(`${MODULE_SCOPE}.advancedLightingNotes`);
const rangeTop = game.i18n.localize(`${MODULE_SCOPE}.levelsRangeTop`);
const distance = (app.document.parent?.grid.units ?? game.system.grid.units) || game.i18n.localize(`${MODULE_SCOPE}.distance`);
const checked = app.document.getFlag(MODULE_SCOPE, "advancedLighting") ? "checked" : "";
const globalAdvancedLighting = game.settings.get(MODULE_ID, 'globalAdvancedLighting');
const globalAdvancedLighting = game.settings.get(MODULE_ID, "globalAdvancedLighting");
const warnEnabledGlobally = `<p class="hint" style="color: red;">${game.i18n.localize(`${MODULE_SCOPE}.ALGlobal`)}</p>`;
const hint = globalAdvancedLighting ? warnEnabledGlobally : ""
const hint = globalAdvancedLighting ? warnEnabledGlobally : "";
const _injectHTML = `<div class="form-group">
<label>${label}</label>
<input type="checkbox" name="flags.${MODULE_SCOPE}.advancedLighting" ${checked} ${globalAdvancedLighting ? "disabled" : ""}>
${hint}
<p class="hint">${notes}</p>
</div>`
</div>`;
html.querySelector(`input[name="walls"]`).closest(".form-group").insertAdjacentHTML("afterend", _injectHTML);
app.setPosition({ height: "auto" });

if(WallHeight.isLevels) return
if (WallHeight.isLevels) return;
const top = app.document.flags?.levels?.rangeTop;
const elevationHtml = `
<div class="form-group slim">
Expand All @@ -163,33 +165,32 @@ Hooks.on("renderAmbientLightConfig", (app, html, data) => {
<input name="flags.levels.rangeTop" type="number" step="any" value="${Number.isFinite(top) ? top : ""}" placeholder="Infinity">
</div>
</div>
`
`;
html.querySelector(`input[name="x"]`).closest(".form-group").insertAdjacentHTML("afterend", elevationHtml);
app.setPosition({ height: "auto" });

})
});

Hooks.on("renderAmbientSoundConfig", (app, html, data) => {
if(html.querySelector(`input[name="flags.${MODULE_SCOPE}.advancedLighting"]`)) return;
const {advancedVision} = getSceneSettings(canvas.scene);
if(!advancedVision) return;
if (html.querySelector(`input[name="flags.${MODULE_SCOPE}.advancedLighting"]`)) return;
const { advancedVision } = getSceneSettings(canvas.scene);
if (!advancedVision) return;
const label = game.i18n.localize(`${MODULE_SCOPE}.advancedLightingLabel`);
const notes = game.i18n.localize(`${MODULE_SCOPE}.advancedLightingNotes`);
const checked = app.document.getFlag(MODULE_SCOPE, "advancedLighting") ? "checked" : "";
const rangeTop = game.i18n.localize(`${MODULE_SCOPE}.levelsRangeTop`);
const distance = (canvas.scene.grid.units ?? game.system?.grid?.units) || game.i18n.localize(`${MODULE_SCOPE}.distance`);
const globalAdvancedLighting = game.settings.get(MODULE_ID, 'globalAdvancedLighting');
const globalAdvancedLighting = game.settings.get(MODULE_ID, "globalAdvancedLighting");
const warnEnabledGlobally = `<p class="hint" style="color: red;">${game.i18n.localize(`${MODULE_SCOPE}.ALGlobal`)}</p>`;
const hint = globalAdvancedLighting ? warnEnabledGlobally : ""
const hint = globalAdvancedLighting ? warnEnabledGlobally : "";
const _injectHTML = `<div class="form-group">
<label>${label}</label>
<input type="checkbox" name="flags.${MODULE_SCOPE}.advancedLighting" ${checked} ${globalAdvancedLighting ? "disabled" : ""}>
${hint}
<p class="hint">${notes}</p>
</div>`
</div>`;
html.querySelector(`input[name="walls"]`).closest(".form-group").insertAdjacentHTML("afterend", _injectHTML);
app.setPosition({ height: "auto" });
if(WallHeight.isLevels) return
if (WallHeight.isLevels) return;
const top = app.document.flags?.levels?.rangeTop;
const elevationHtml = `
<div class="form-group slim">
Expand All @@ -198,10 +199,10 @@ Hooks.on("renderAmbientSoundConfig", (app, html, data) => {
<input name="flags.levels.rangeTop" type="number" step="any" value="${Number.isFinite(top) ? top : ""}" placeholder="Infinity">
</div>
</div>
`
`;
html.querySelector(`input[name="radius"]`).closest(".form-group").insertAdjacentHTML("afterend", elevationHtml);
app.setPosition({ height: "auto" });
})
});

Hooks.on("renderTokenConfig", (app, html, data) => {
html = html[0] ?? html;
Expand All @@ -222,28 +223,34 @@ Hooks.on("renderTokenConfig", (app, html, data) => {
`;
html.querySelector('input[name="lockRotation"]').closest(".form-group").insertAdjacentHTML("afterend", newHtml);
app.setPosition({ height: "auto" });
});
});

Hooks.on("renderSceneConfig", (app, html, data) => {
html = html[0] ?? html;
const {advancedVision} = getSceneSettings(app.document);
const { advancedVision } = getSceneSettings(app.document);
const enableVisionKeyLabel = game.i18n.localize(`${MODULE_SCOPE}.AdvancedVisionLabel`);
const moduleLabel = game.i18n.localize(`${MODULE_SCOPE}.ModuleLabel`);
html.querySelector(`input[name="environment.globalLight.enabled"]`).closest(".form-group").insertAdjacentHTML("afterend", `
html.querySelector(`input[name="environment.globalLight.enabled"]`)
.closest(".form-group")
.insertAdjacentHTML(
"afterend",
`
<fieldset>
<legend>${moduleLabel}</legend>
<div class="form-group">
<li class="flexrow">
<label>${enableVisionKeyLabel}</label>
<input name="flags.${MODULE_SCOPE}.${ENABLE_ADVANCED_VISION_KEY}" type="checkbox" data-dtype="Boolean" `+ ((advancedVision || advancedVision==null)?`checked`:``)+`>
<input name="flags.${MODULE_SCOPE}.${ENABLE_ADVANCED_VISION_KEY}" type="checkbox" data-dtype="Boolean" ` +
(advancedVision || advancedVision == null ? `checked` : ``) +
`>
</li>
</div>
</fieldset>`
);
</fieldset>`,
);
app.setPosition({ height: "auto" });
});

Handlebars.registerHelper('if_null', function(a, opts) {
Handlebars.registerHelper("if_null", function (a, opts) {
if (a == null) {
return opts.fn(this);
} else {
Expand All @@ -254,46 +261,5 @@ Handlebars.registerHelper('if_null', function(a, opts) {
// First time message

Hooks.once("ready", () => {
if(game.modules.get("levels-3d-preview")?.active) return;
// Module title
const MODULE_TITLE = game.modules.get(MODULE_ID).title;

const FALLBACK_MESSAGE_TITLE = "Welcome to Wall Height";
const FALLBACK_MESSAGE = `<large>
<p><strong>I (theripper93) am now taking over the development of Wall Height, be sure to stop by my <a href="https://theripper93.com/">Discord</a> for help and support from the wonderful community as well as many resources</strong></p>
<p>Thanks to all the patreons supporting the development of my modules making continued updates possible!</p>
<p>If you want to support the development of the module you can do so here : <a href="https://www.patreon.com/theripper93">Patreon</a> </p></large>
<p><strong>Patreons</strong> get also access to <strong>15+ premium modules</strong></p>
<p>Want even more verticality? Go Full 3D</p>
<h1>3D Canvas</h1>
<iframe width="385" height="225" src="https://www.youtube.com/embed/rziXLJEfxqI" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
<p>Check 3D Canvas and all my other <strong>15+ premium modules <a href="https://theripper93.com/">Here</a></strong></p>`;

// Settings key used for the "Don't remind me again" setting
const DONT_REMIND_AGAIN_KEY = "popup-dont-remind-again";

// Dialog code
game.settings.register(MODULE_ID, DONT_REMIND_AGAIN_KEY, {
name: "",
default: false,
type: Boolean,
scope: "world",
config: false,
});
if (game.user.isGM && !game.settings.get(MODULE_ID, DONT_REMIND_AGAIN_KEY)) {
new Dialog({
title: FALLBACK_MESSAGE_TITLE,
content: FALLBACK_MESSAGE,
buttons: {
dont_remind: {
icon: '<i class="fas fa-times"></i>',
label: "Don't remind me again",
callback: () => game.settings.set(MODULE_ID, DONT_REMIND_AGAIN_KEY, true),
},
},
default: "dont_remind",
}).render(true);
}
});

showWelcome();
});

0 comments on commit dc04464

Please sign in to comment.