Skip to content

Commit

Permalink
a
Browse files Browse the repository at this point in the history
  • Loading branch information
theripper93 committed Jul 3, 2024
1 parent 3ca056a commit 20531eb
Show file tree
Hide file tree
Showing 14 changed files with 28 additions and 625 deletions.
520 changes: 0 additions & 520 deletions old/config.js

This file was deleted.

File renamed without changes.
2 changes: 1 addition & 1 deletion packs/levels-samples/CURRENT
Original file line number Diff line number Diff line change
@@ -1 +1 @@
MANIFEST-002640
MANIFEST-002696
6 changes: 3 additions & 3 deletions packs/levels-samples/LOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
2024/06/26-15:51:21.678 4f1c Recovering log #2639
2024/06/26-15:51:21.681 4f1c Delete type=0 #2639
2024/06/26-15:51:21.681 4f1c Delete type=3 #2638
2024/07/03-02:22:49.033 1654 Recovering log #2694
2024/07/03-02:22:49.037 1654 Delete type=0 #2694
2024/07/03-02:22:49.037 1654 Delete type=3 #2692
11 changes: 8 additions & 3 deletions packs/levels-samples/LOG.old
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
2024/06/26-04:21:36.991 4450 Recovering log #2636
2024/06/26-04:21:36.994 4450 Delete type=0 #2636
2024/06/26-04:21:36.994 4450 Delete type=3 #2634
2024/07/02-13:12:09.798 1654 Recovering log #2690
2024/07/02-13:12:09.801 1654 Delete type=0 #2690
2024/07/02-13:12:09.801 1654 Delete type=3 #2688
2024/07/03-02:21:52.763 673c Level-0 table #2695: started
2024/07/03-02:21:52.763 673c Level-0 table #2695: 0 bytes OK
2024/07/03-02:21:52.765 673c Delete type=0 #2693
2024/07/03-02:21:52.765 673c Manual compaction at level-0 from '!scenes!i1noRqT20RD5stIK' @ 72057594037927935 : 1 .. '!scenes.walls!zksLSgRdh6f8jiUO.z5ptMNOLPqAgK6MH' @ 0 : 0; will stop at (end)
2024/07/03-02:21:52.765 673c Manual compaction at level-1 from '!scenes!i1noRqT20RD5stIK' @ 72057594037927935 : 1 .. '!scenes.walls!zksLSgRdh6f8jiUO.z5ptMNOLPqAgK6MH' @ 0 : 0; will stop at (end)
Binary file not shown.
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-002635
MANIFEST-002691
6 changes: 3 additions & 3 deletions packs/macros/LOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
2024/06/26-15:51:21.666 5d94 Recovering log #2634
2024/06/26-15:51:21.669 5d94 Delete type=0 #2634
2024/06/26-15:51:21.669 5d94 Delete type=3 #2633
2024/07/03-02:22:49.025 7268 Recovering log #2689
2024/07/03-02:22:49.029 7268 Delete type=0 #2689
2024/07/03-02:22:49.029 7268 Delete type=3 #2687
11 changes: 8 additions & 3 deletions packs/macros/LOG.old
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
2024/06/26-04:21:36.978 740c Recovering log #2631
2024/06/26-04:21:36.981 740c Delete type=0 #2631
2024/06/26-04:21:36.981 740c Delete type=3 #2629
2024/07/02-13:12:09.784 2c90 Recovering log #2685
2024/07/02-13:12:09.787 2c90 Delete type=0 #2685
2024/07/02-13:12:09.787 2c90 Delete type=3 #2683
2024/07/03-02:21:52.757 673c Level-0 table #2690: started
2024/07/03-02:21:52.757 673c Level-0 table #2690: 0 bytes OK
2024/07/03-02:21:52.759 673c Delete type=0 #2688
2024/07/03-02:21:52.759 673c Manual compaction at level-0 from '!macros!2LfY4Ky5rRDkK7h8' @ 72057594037927935 : 1 .. '!macros!yx7Eb76rfzjh0LEO' @ 0 : 0; will stop at (end)
2024/07/03-02:21:52.759 673c Manual compaction at level-1 from '!macros!2LfY4Ky5rRDkK7h8' @ 72057594037927935 : 1 .. '!macros!yx7Eb76rfzjh0LEO' @ 0 : 0; will stop at (end)
Binary file not shown.
15 changes: 4 additions & 11 deletions scripts/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -460,15 +460,7 @@ Hooks.on("renderDrawingConfig", (app, html, data) => {
Hooks.on("renderMeasuredTemplateConfig", (app, html, data) => {
const injHtml = injectConfig.inject(app, html, {
moduleId: "levels",
inject: 'input[name="width"]',
elevation: {
type: "text",
dType: "Number",
label: game.i18n.localize("levels.template.elevation.name"),
units: game.i18n.localize("levels.tileconfig.range.unit"),
default: Infinity,
step: "any",
},
inject: '[name="elevation"]',
special: {
type: "number",
label: game.i18n.localize("levels.template.depth.name"),
Expand Down Expand Up @@ -508,9 +500,10 @@ Hooks.on("renderTokenHUD", (data, hud, drawData) => {

Hooks.on("preCreateMeasuredTemplate", (template) => {
const templateData = CONFIG.Levels.handlers.TemplateHandler.getTemplateData();
if (template.flags?.levels?.elevation) return;
if (template.elevation) return;
template.updateSource({
flags: { levels: { elevation: templateData.elevation, special: templateData.special } },
elevation: templateData.elevation,
flags: { levels: { special: templateData.special } },
});
});

Expand Down
74 changes: 0 additions & 74 deletions scripts/handlers/templateHandler.js
Original file line number Diff line number Diff line change
@@ -1,78 +1,4 @@
export class TemplateHandler{
static isVisible(wrapped, ...args){
const result = wrapped(...args);
return result;
const currentElevation = CONFIG.Levels.currentToken?.losHeight
const templateElevation = this.document.flags.levels?.elevation;
if(currentElevation === undefined || templateElevation === undefined || !CONFIG.Levels.currentToken) return result;
const origin = {
x: CONFIG.Levels.currentToken.x,
y: CONFIG.Levels.currentToken.y,
z: currentElevation
}
const target = {
x: this.center.x,
y: this.center.y,
z: templateElevation
}
const isVisible = !CONFIG.Levels.handlers.SightHandler.testCollision(origin,target);
return result && isVisible;
}

static async drawTooltip(wrapped, ...args){
await wrapped(...args);
if(this.document.getFlag(CONFIG.Levels.MODULE_ID, "elevation")===0) return this;
this.tooltip = this.addChild(_templateDrawTooltip(this));

function _templateDrawTooltip(template) {
// Create the tooltip Text

const tipFlag = template.document.getFlag(CONFIG.Levels.MODULE_ID, "elevation");
let tipN;
if (tipFlag === undefined) {
if (CONFIG.Levels.UI.nextTemplateHeight !== undefined) {
tipN = CONFIG.Levels.UI.nextTemplateHeight;
} else {
const cToken =
canvas.tokens.controlled[0] || _token;
tipN = cToken?.document?.elevation ?? 0;
}
} else {
tipN = tipFlag;
}
let units = canvas.scene.grid.units;
const tip = tipN > 0 ? `+${tipN} ${units}` : `${tipN} ${units}`;
const style = CONFIG.canvasTextStyle.clone();
style.fontSize = Math.max(
Math.round(canvas.dimensions.size * 0.36 * 12) / 12,
36
);
const text = new PreciseText(tip, style);
text.anchor.set(0.5, 2);
return text;
}
return this;
}

static _refreshRulerText() {
let special = this.document.flags.levels?.special// || _levels?.nextTemplateSpecial
let text;
let u = canvas.scene.grid.units;
if ( this.document.t === "rect" ) {
let d = canvas.dimensions;
let dx = Math.round(this.ray.dx) * (d.distance / d.size);
let dy = Math.round(this.ray.dy) * (d.distance / d.size);
let w = Math.round(dx * 10) / 10;
let h = Math.round(dy * 10) / 10;
text = special ? `${w}${u} x ${h}${u} x ${special}${u}` : `${w}${u} x ${h}${u}`;
} else {
let d = Math.round(this.document.distance * 10) / 10;
text = special ? `${d}${u} x ${special}${u}` : `${d}${u}`;
}
this.ruler.text = text;
this.ruler.position.set(this.ray.dx + 10, this.ray.dy + 5);
}

static getTemplateData(wipeStore = true){
const cToken = canvas.tokens.controlled[0] || _token;
const handMode =
Expand Down
6 changes: 0 additions & 6 deletions scripts/wrappers.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,5 @@ export function registerWrappers() {

libWrapper.register(LevelsConfig.MODULE_ID, "CONFIG.Note.objectClass.prototype.isVisible", LevelsConfig.handlers.NoteHandler.isVisible, "WRAPPER");

libWrapper.register(LevelsConfig.MODULE_ID, "CONFIG.MeasuredTemplate.objectClass.prototype.draw", LevelsConfig.handlers.TemplateHandler.drawTooltip, "WRAPPER");

libWrapper.register(LevelsConfig.MODULE_ID, "CONFIG.MeasuredTemplate.objectClass.prototype._refreshRulerText", LevelsConfig.handlers.TemplateHandler._refreshRulerText, "OVERRIDE");

libWrapper.register(LevelsConfig.MODULE_ID, "CONFIG.MeasuredTemplate.objectClass.prototype.isVisible", LevelsConfig.handlers.TemplateHandler.isVisible, "WRAPPER");

libWrapper.register(LevelsConfig.MODULE_ID, "CONFIG.Token.objectClass.prototype.isVisible", LevelsConfig.handlers.UIHandler.tokenUIWrapperIsVisible, "WRAPPER");
}

0 comments on commit 20531eb

Please sign in to comment.