From dc04464c531da49fbd9181014927daa44bfb6a75 Mon Sep 17 00:00:00 2001 From: theripper93 Date: Tue, 12 Nov 2024 15:32:33 +0100 Subject: [PATCH] a --- packs/macros/{002115.log => 002179.log} | 0 packs/macros/CURRENT | 2 +- packs/macros/LOG | 6 +- packs/macros/LOG.old | 10 +- .../{MANIFEST-002114 => MANIFEST-002178} | Bin 159 -> 159 bytes scripts/const.js | 28 ++- scripts/wall-height.js | 160 +++++++----------- 7 files changed, 101 insertions(+), 105 deletions(-) rename packs/macros/{002115.log => 002179.log} (100%) rename packs/macros/{MANIFEST-002114 => MANIFEST-002178} (80%) diff --git a/packs/macros/002115.log b/packs/macros/002179.log similarity index 100% rename from packs/macros/002115.log rename to packs/macros/002179.log diff --git a/packs/macros/CURRENT b/packs/macros/CURRENT index ed40996..22a4a5a 100644 --- a/packs/macros/CURRENT +++ b/packs/macros/CURRENT @@ -1 +1 @@ -MANIFEST-002114 +MANIFEST-002178 diff --git a/packs/macros/LOG b/packs/macros/LOG index b789fcf..1a87343 100644 --- a/packs/macros/LOG +++ b/packs/macros/LOG @@ -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 diff --git a/packs/macros/LOG.old b/packs/macros/LOG.old index 0fb6857..a7f002a 100644 --- a/packs/macros/LOG.old +++ b/packs/macros/LOG.old @@ -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) diff --git a/packs/macros/MANIFEST-002114 b/packs/macros/MANIFEST-002178 similarity index 80% rename from packs/macros/MANIFEST-002114 rename to packs/macros/MANIFEST-002178 index 3a9dba40b2136b03e1a5da21b75106a7cae80ec7..9cc64f205a1a7ec91fd179830ac7edcae34fdb62 100644 GIT binary patch delta 24 fcmbQwIG=GspWr-~rn6iOj7-gfoD9q@f-HOhUC#ye delta 24 gcmbQwIG=GspWxX9>Dyckj7*0GI2o9a2(a)00AQX5WdHyG diff --git a/scripts/const.js b/scripts/const.js index beb3287..dcde51d 100644 --- a/scripts/const.js +++ b/scripts/const.js @@ -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"; \ No newline at end of file +export const ENABLE_ADVANCED_MOVEMENT_KEY = "wallHeightAdvancedMovement"; + + +export function showWelcome() { + if (!game.user.isGM) return; + const FALLBACK_MESSAGE = `

Wall Height

New to Wall Height? Visit the Wiki for a quickstart guide and resources.

Special thanks to all my Patreons for making ongoing updates and development possible. Supporting gives you access to 30+ premium modules and priority support.

Want to level up your games?

Check out the premium module collection!

Explore all resources and modules:

`; + + // 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, + }); + } +} \ No newline at end of file diff --git a/scripts/wall-height.js b/scripts/wall-height.js index d75a9bc..e88c26c 100644 --- a/scripts/wall-height.js +++ b/scripts/wall-height.js @@ -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, @@ -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`), @@ -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", + `
${moduleLabel}
@@ -129,32 +130,33 @@ Hooks.on("renderWallConfig", (app, html, data) => {
- `); + `, + ); 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 = `

${game.i18n.localize(`${MODULE_SCOPE}.ALGlobal`)}

`; - const hint = globalAdvancedLighting ? warnEnabledGlobally : "" + const hint = globalAdvancedLighting ? warnEnabledGlobally : ""; const _injectHTML = `
${hint}

${notes}

-
` + `; 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 = `
@@ -163,33 +165,32 @@ Hooks.on("renderAmbientLightConfig", (app, html, data) => {
- ` + `; 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 = `

${game.i18n.localize(`${MODULE_SCOPE}.ALGlobal`)}

`; - const hint = globalAdvancedLighting ? warnEnabledGlobally : "" + const hint = globalAdvancedLighting ? warnEnabledGlobally : ""; const _injectHTML = `
${hint}

${notes}

-
` + `; 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 = `
@@ -198,10 +199,10 @@ Hooks.on("renderAmbientSoundConfig", (app, html, data) => {
- ` + `; 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; @@ -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", + `
${moduleLabel}
  • - +
  • -
    ` - ); + `, + ); 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 { @@ -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 = ` -

    I (theripper93) am now taking over the development of Wall Height, be sure to stop by my Discord for help and support from the wonderful community as well as many resources

    - -

    Thanks to all the patreons supporting the development of my modules making continued updates possible!

    -

    If you want to support the development of the module you can do so here : Patreon

    -

    Patreons get also access to 15+ premium modules

    -

    Want even more verticality? Go Full 3D

    -

    3D Canvas

    - -

    Check 3D Canvas and all my other 15+ premium modules Here

    `; - - // 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: '', - label: "Don't remind me again", - callback: () => game.settings.set(MODULE_ID, DONT_REMIND_AGAIN_KEY, true), - }, - }, - default: "dont_remind", - }).render(true); - } - }); - + showWelcome(); +});