intelligent-system-design-language 0.3.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/agents/langium-language-designer.md +38 -0
- package/.claude/agents/typescript-vscode-expert.md +29 -0
- package/.claude/agents/ui-ux-designer.md +36 -0
- package/.claude/settings.local.json +33 -0
- package/.idea/inspectionProfiles/Project_Default.xml +7 -0
- package/.idea/isdl.iml +14 -0
- package/.idea/modules.xml +9 -0
- package/.idea/vcs.xml +7 -0
- package/.idea/watcherTasks.xml +4 -0
- package/.vscodeignore +18 -0
- package/LICENSE +674 -0
- package/README.md +86 -0
- package/bin/cli.js +4 -0
- package/bin/lsp.js +8 -0
- package/isdl.png +0 -0
- package/out/_backgrounds.scss +91 -0
- package/out/_handlebars.scss +505 -0
- package/out/_isdlStyles.scss +1357 -0
- package/out/_vuetifyOverrides.scss +425 -0
- package/out/_vuetifyStyles.scss +31957 -0
- package/out/cli/cli-util.js +39 -0
- package/out/cli/cli-util.js.map +1 -0
- package/out/cli/components/_backgrounds.scss +91 -0
- package/out/cli/components/_handlebars.scss +505 -0
- package/out/cli/components/_isdlStyles.scss +1357 -0
- package/out/cli/components/_vuetifyOverrides.scss +425 -0
- package/out/cli/components/_vuetifyStyles.scss +31957 -0
- package/out/cli/components/active-effect-sheet-generator.js +643 -0
- package/out/cli/components/active-effect-sheet-generator.js.map +1 -0
- package/out/cli/components/base-actor-sheet-generator.js +125 -0
- package/out/cli/components/base-actor-sheet-generator.js.map +1 -0
- package/out/cli/components/base-sheet-generator.js +525 -0
- package/out/cli/components/base-sheet-generator.js.map +1 -0
- package/out/cli/components/chat-card-generator.js +683 -0
- package/out/cli/components/chat-card-generator.js.map +1 -0
- package/out/cli/components/css-generator.js +58 -0
- package/out/cli/components/css-generator.js.map +1 -0
- package/out/cli/components/damage-roll-generator.js +173 -0
- package/out/cli/components/damage-roll-generator.js.map +1 -0
- package/out/cli/components/datamodel-generator.js +672 -0
- package/out/cli/components/datamodel-generator.js.map +1 -0
- package/out/cli/components/derived-data-generator.js +1340 -0
- package/out/cli/components/derived-data-generator.js.map +1 -0
- package/out/cli/components/hotbar-drop-hook-generator.js +95 -0
- package/out/cli/components/hotbar-drop-hook-generator.js.map +1 -0
- package/out/cli/components/init-hook-generator.js +597 -0
- package/out/cli/components/init-hook-generator.js.map +1 -0
- package/out/cli/components/keywords-generator.js +220 -0
- package/out/cli/components/keywords-generator.js.map +1 -0
- package/out/cli/components/language-generator.js +110 -0
- package/out/cli/components/language-generator.js.map +1 -0
- package/out/cli/components/measured-template-preview.js +234 -0
- package/out/cli/components/measured-template-preview.js.map +1 -0
- package/out/cli/components/method-generator.js +1812 -0
- package/out/cli/components/method-generator.js.map +1 -0
- package/out/cli/components/ready-hook-generator.js +448 -0
- package/out/cli/components/ready-hook-generator.js.map +1 -0
- package/out/cli/components/token-generator.js +138 -0
- package/out/cli/components/token-generator.js.map +1 -0
- package/out/cli/components/utils.js +176 -0
- package/out/cli/components/utils.js.map +1 -0
- package/out/cli/components/vue/base-components/vue-attribute.js +148 -0
- package/out/cli/components/vue/base-components/vue-attribute.js.map +1 -0
- package/out/cli/components/vue/base-components/vue-boolean.js +77 -0
- package/out/cli/components/vue/base-components/vue-boolean.js.map +1 -0
- package/out/cli/components/vue/base-components/vue-calculator.js +106 -0
- package/out/cli/components/vue/base-components/vue-calculator.js.map +1 -0
- package/out/cli/components/vue/base-components/vue-damage-application.js +369 -0
- package/out/cli/components/vue/base-components/vue-damage-application.js.map +1 -0
- package/out/cli/components/vue/base-components/vue-damage-bonuses.js +225 -0
- package/out/cli/components/vue/base-components/vue-damage-bonuses.js.map +1 -0
- package/out/cli/components/vue/base-components/vue-damage-resistances.js +256 -0
- package/out/cli/components/vue/base-components/vue-damage-resistances.js.map +1 -0
- package/out/cli/components/vue/base-components/vue-damage-track.js +134 -0
- package/out/cli/components/vue/base-components/vue-damage-track.js.map +1 -0
- package/out/cli/components/vue/base-components/vue-date-time.js +55 -0
- package/out/cli/components/vue/base-components/vue-date-time.js.map +1 -0
- package/out/cli/components/vue/base-components/vue-dice.js +111 -0
- package/out/cli/components/vue/base-components/vue-dice.js.map +1 -0
- package/out/cli/components/vue/base-components/vue-die.js +86 -0
- package/out/cli/components/vue/base-components/vue-die.js.map +1 -0
- package/out/cli/components/vue/base-components/vue-document-choice.js +172 -0
- package/out/cli/components/vue/base-components/vue-document-choice.js.map +1 -0
- package/out/cli/components/vue/base-components/vue-document-choices.js +203 -0
- package/out/cli/components/vue/base-components/vue-document-choices.js.map +1 -0
- package/out/cli/components/vue/base-components/vue-document-link.js +73 -0
- package/out/cli/components/vue/base-components/vue-document-link.js.map +1 -0
- package/out/cli/components/vue/base-components/vue-extended-choice.js +101 -0
- package/out/cli/components/vue/base-components/vue-extended-choice.js.map +1 -0
- package/out/cli/components/vue/base-components/vue-inventory.js +532 -0
- package/out/cli/components/vue/base-components/vue-inventory.js.map +1 -0
- package/out/cli/components/vue/base-components/vue-macro-choice.js +150 -0
- package/out/cli/components/vue/base-components/vue-macro-choice.js.map +1 -0
- package/out/cli/components/vue/base-components/vue-measured-template.js +543 -0
- package/out/cli/components/vue/base-components/vue-measured-template.js.map +1 -0
- package/out/cli/components/vue/base-components/vue-money.js +496 -0
- package/out/cli/components/vue/base-components/vue-money.js.map +1 -0
- package/out/cli/components/vue/base-components/vue-number.js +184 -0
- package/out/cli/components/vue/base-components/vue-number.js.map +1 -0
- package/out/cli/components/vue/base-components/vue-paperdoll.js +56 -0
- package/out/cli/components/vue/base-components/vue-paperdoll.js.map +1 -0
- package/out/cli/components/vue/base-components/vue-parent-property-reference.js +89 -0
- package/out/cli/components/vue/base-components/vue-parent-property-reference.js.map +1 -0
- package/out/cli/components/vue/base-components/vue-prosemirror.js +31 -0
- package/out/cli/components/vue/base-components/vue-prosemirror.js.map +1 -0
- package/out/cli/components/vue/base-components/vue-resource.js +149 -0
- package/out/cli/components/vue/base-components/vue-resource.js.map +1 -0
- package/out/cli/components/vue/base-components/vue-roll-visualizer.js +121 -0
- package/out/cli/components/vue/base-components/vue-roll-visualizer.js.map +1 -0
- package/out/cli/components/vue/base-components/vue-self-property-reference.js +75 -0
- package/out/cli/components/vue/base-components/vue-self-property-reference.js.map +1 -0
- package/out/cli/components/vue/base-components/vue-string-choice.js +111 -0
- package/out/cli/components/vue/base-components/vue-string-choice.js.map +1 -0
- package/out/cli/components/vue/base-components/vue-string-choices.js +216 -0
- package/out/cli/components/vue/base-components/vue-string-choices.js.map +1 -0
- package/out/cli/components/vue/base-components/vue-string.js +73 -0
- package/out/cli/components/vue/base-components/vue-string.js.map +1 -0
- package/out/cli/components/vue/base-components/vue-text-field.js +66 -0
- package/out/cli/components/vue/base-components/vue-text-field.js.map +1 -0
- package/out/cli/components/vue/base-components/vue-tracker.js +444 -0
- package/out/cli/components/vue/base-components/vue-tracker.js.map +1 -0
- package/out/cli/components/vue/vue-action-component-generator.js +88 -0
- package/out/cli/components/vue/vue-action-component-generator.js.map +1 -0
- package/out/cli/components/vue/vue-active-effect-sheet-generator.js +1016 -0
- package/out/cli/components/vue/vue-active-effect-sheet-generator.js.map +1 -0
- package/out/cli/components/vue/vue-base-components-generator.js +59 -0
- package/out/cli/components/vue/vue-base-components-generator.js.map +1 -0
- package/out/cli/components/vue/vue-datatable-component-generator.js +307 -0
- package/out/cli/components/vue/vue-datatable-component-generator.js.map +1 -0
- package/out/cli/components/vue/vue-datatable-sheet-class-generator.js +342 -0
- package/out/cli/components/vue/vue-datatable-sheet-class-generator.js.map +1 -0
- package/out/cli/components/vue/vue-datatable2-component-generator.js +939 -0
- package/out/cli/components/vue/vue-datatable2-component-generator.js.map +1 -0
- package/out/cli/components/vue/vue-document-creation-app.js +140 -0
- package/out/cli/components/vue/vue-document-creation-app.js.map +1 -0
- package/out/cli/components/vue/vue-document-creation-sheet.js +105 -0
- package/out/cli/components/vue/vue-document-creation-sheet.js.map +1 -0
- package/out/cli/components/vue/vue-generator.js +240 -0
- package/out/cli/components/vue/vue-generator.js.map +1 -0
- package/out/cli/components/vue/vue-mixin.js +338 -0
- package/out/cli/components/vue/vue-mixin.js.map +1 -0
- package/out/cli/components/vue/vue-pinned-datatable-component-generator.js +306 -0
- package/out/cli/components/vue/vue-pinned-datatable-component-generator.js.map +1 -0
- package/out/cli/components/vue/vue-prompt-generator.js +201 -0
- package/out/cli/components/vue/vue-prompt-generator.js.map +1 -0
- package/out/cli/components/vue/vue-prompt-sheet-class-generator.js +252 -0
- package/out/cli/components/vue/vue-prompt-sheet-class-generator.js.map +1 -0
- package/out/cli/components/vue/vue-sheet-application-generator.js +2008 -0
- package/out/cli/components/vue/vue-sheet-application-generator.js.map +1 -0
- package/out/cli/components/vue/vue-sheet-class-generator.js +484 -0
- package/out/cli/components/vue/vue-sheet-class-generator.js.map +1 -0
- package/out/cli/generator.js +659 -0
- package/out/cli/generator.js.map +1 -0
- package/out/cli/main.js +43 -0
- package/out/cli/main.js.map +1 -0
- package/out/datatables.min.css +54 -0
- package/out/datatables.min.js +178 -0
- package/out/extension/github/githubAuthProvider.js +345 -0
- package/out/extension/github/githubAuthProvider.js.map +1 -0
- package/out/extension/github/githubConfig.js +132 -0
- package/out/extension/github/githubConfig.js.map +1 -0
- package/out/extension/github/githubGistActions.js +251 -0
- package/out/extension/github/githubGistActions.js.map +1 -0
- package/out/extension/github/githubGistManager.js +255 -0
- package/out/extension/github/githubGistManager.js.map +1 -0
- package/out/extension/github/githubManager.js +1735 -0
- package/out/extension/github/githubManager.js.map +1 -0
- package/out/extension/github/githubQuickActions.js +659 -0
- package/out/extension/github/githubQuickActions.js.map +1 -0
- package/out/extension/github/githubTreeProvider.js +181 -0
- package/out/extension/github/githubTreeProvider.js.map +1 -0
- package/out/extension/github/system-workflow.yml +48 -0
- package/out/extension/main.cjs +70315 -0
- package/out/extension/main.cjs.map +7 -0
- package/out/extension/main.js +237 -0
- package/out/extension/main.js.map +1 -0
- package/out/extension/package.json +426 -0
- package/out/isdl.png +0 -0
- package/out/language/generated/ast.js +2992 -0
- package/out/language/generated/ast.js.map +1 -0
- package/out/language/generated/grammar.js +13970 -0
- package/out/language/generated/grammar.js.map +1 -0
- package/out/language/generated/module.js +20 -0
- package/out/language/generated/module.js.map +1 -0
- package/out/language/intelligent-system-design-language-formatter.js +85 -0
- package/out/language/intelligent-system-design-language-formatter.js.map +1 -0
- package/out/language/intelligent-system-design-language-module.js +69 -0
- package/out/language/intelligent-system-design-language-module.js.map +1 -0
- package/out/language/intelligent-system-design-language-quickfixes.js +37 -0
- package/out/language/intelligent-system-design-language-quickfixes.js.map +1 -0
- package/out/language/intelligent-system-design-language-validator.js +515 -0
- package/out/language/intelligent-system-design-language-validator.js.map +1 -0
- package/out/language/isdl-hover-provider.js +77 -0
- package/out/language/isdl-hover-provider.js.map +1 -0
- package/out/language/isdl-scope-provider.js +149 -0
- package/out/language/isdl-scope-provider.js.map +1 -0
- package/out/language/main.cjs +47655 -0
- package/out/language/main.cjs.map +7 -0
- package/out/language/main.js +11 -0
- package/out/language/main.js.map +1 -0
- package/out/missing-character.png +0 -0
- package/out/package.json +426 -0
- package/out/paperdoll_default.png +0 -0
- package/out/progressbar.min.js +7 -0
- package/out/styles.scss +722 -0
- package/out/test/formatting/formatter.test.js +46 -0
- package/out/test/formatting/formatter.test.js.map +1 -0
- package/out/vuetify.esm.js +30279 -0
- package/package.json +426 -0
|
@@ -0,0 +1,543 @@
|
|
|
1
|
+
import * as path from 'node:path';
|
|
2
|
+
import * as fs from 'node:fs';
|
|
3
|
+
import { expandToNode, toString } from 'langium/generate';
|
|
4
|
+
export default function generateMeasuredTemplateComponent(destination) {
|
|
5
|
+
const generatedFileDir = path.join(destination, "system", "templates", "vue", "components");
|
|
6
|
+
const generatedFilePath = path.join(generatedFileDir, `measured-template.vue`);
|
|
7
|
+
if (!fs.existsSync(generatedFileDir)) {
|
|
8
|
+
fs.mkdirSync(generatedFileDir, { recursive: true });
|
|
9
|
+
}
|
|
10
|
+
const fileNode = expandToNode `
|
|
11
|
+
<script setup>
|
|
12
|
+
import { ref, computed, inject, watchEffect, onMounted, onUnmounted, nextTick, watch } from "vue";
|
|
13
|
+
|
|
14
|
+
const props = defineProps({
|
|
15
|
+
label: String,
|
|
16
|
+
systemPath: String,
|
|
17
|
+
context: Object,
|
|
18
|
+
visibility: String,
|
|
19
|
+
editMode: Boolean,
|
|
20
|
+
primaryColor: String,
|
|
21
|
+
secondaryColor: String,
|
|
22
|
+
tertiaryColor: String,
|
|
23
|
+
icon: String,
|
|
24
|
+
disabled: Boolean
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
const document = inject("rawDocument");
|
|
28
|
+
|
|
29
|
+
// Vuetify's up/down stepper buttons update the model without firing a
|
|
30
|
+
// native change event, so Foundry's submitOnChange form handler never
|
|
31
|
+
// persists them. When the value changes while focus is NOT on a text
|
|
32
|
+
// input (i.e. a stepper click, not typing), persist directly. Typing
|
|
33
|
+
// still persists via the input's native change on blur/enter.
|
|
34
|
+
// ('document' is the injected Foundry document; DOM access uses window.)
|
|
35
|
+
const persistOnStep = (path, newValue) => {
|
|
36
|
+
if (document && window.document.activeElement?.tagName !== 'INPUT') {
|
|
37
|
+
document.update({ [path]: newValue });
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
const expanded = ref(false);
|
|
42
|
+
const canvasRef = ref(null);
|
|
43
|
+
let pixiApp = null;
|
|
44
|
+
let templateGraphics = null;
|
|
45
|
+
|
|
46
|
+
const expandIcon = computed(() => {
|
|
47
|
+
return expanded.value ? "fa-solid fa-caret-up" : "fa-solid fa-caret-down";
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
const type = computed({
|
|
51
|
+
get: () => foundry.utils.getProperty(props.context, props.systemPath + ".type") || "circle",
|
|
52
|
+
set: (newValue) => foundry.utils.setProperty(props.context, props.systemPath + ".type", newValue)
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
const direction = computed({
|
|
56
|
+
get: () => foundry.utils.getProperty(props.context, props.systemPath + ".direction") || 0,
|
|
57
|
+
set: (newValue) => foundry.utils.setProperty(props.context, props.systemPath + ".direction", newValue)
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
const angle = computed({
|
|
61
|
+
get: () => foundry.utils.getProperty(props.context, props.systemPath + ".angle") || 60,
|
|
62
|
+
set: (newValue) => foundry.utils.setProperty(props.context, props.systemPath + ".angle", newValue)
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
const distance = computed({
|
|
66
|
+
get: () => foundry.utils.getProperty(props.context, props.systemPath + ".distance") || 30,
|
|
67
|
+
set: (newValue) => foundry.utils.setProperty(props.context, props.systemPath + ".distance", newValue)
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
const width = computed({
|
|
71
|
+
get: () => foundry.utils.getProperty(props.context, props.systemPath + ".width") || 5,
|
|
72
|
+
set: (newValue) => foundry.utils.setProperty(props.context, props.systemPath + ".width", newValue)
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
const summary = computed(() => {
|
|
76
|
+
let sum = \`\${direction.value}° \${type.value} (\${distance.value} squares)\`;
|
|
77
|
+
if (type.value === 'cone') sum += \` \${angle.value}° angle\`;
|
|
78
|
+
if (type.value === 'ray') sum += \` \${width.value} squares wide\`;
|
|
79
|
+
return sum;
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
const getLabel = computed(() => {
|
|
83
|
+
const localized = game.i18n.localize(props.label);
|
|
84
|
+
if (props.icon) {
|
|
85
|
+
return \`<i class="fa-solid \${props.icon}"></i> \${localized}\`;
|
|
86
|
+
}
|
|
87
|
+
return localized;
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
// PIXI Drawing Functions
|
|
92
|
+
const initializePixi = async () => {
|
|
93
|
+
if (!canvasRef.value || pixiApp) return;
|
|
94
|
+
|
|
95
|
+
try {
|
|
96
|
+
const { width, height } = getCanvasSize();
|
|
97
|
+
|
|
98
|
+
pixiApp = new PIXI.Application({
|
|
99
|
+
view: canvasRef.value,
|
|
100
|
+
width,
|
|
101
|
+
height,
|
|
102
|
+
backgroundColor: 0xf8f9fa,
|
|
103
|
+
antialias: true,
|
|
104
|
+
resolution: window.devicePixelRatio || 1,
|
|
105
|
+
autoDensity: true
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
// Draw grid background
|
|
109
|
+
drawGrid();
|
|
110
|
+
|
|
111
|
+
// Create template graphics container
|
|
112
|
+
templateGraphics = new PIXI.Graphics();
|
|
113
|
+
pixiApp.stage.addChild(templateGraphics);
|
|
114
|
+
|
|
115
|
+
// Initial draw
|
|
116
|
+
drawTemplate();
|
|
117
|
+
} catch (error) {
|
|
118
|
+
console.warn("PIXI initialization failed:", error);
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
const getCanvasSize = () => {
|
|
123
|
+
const bufferSquares = 2;
|
|
124
|
+
const canvasSize = 150; // Always 150px x 150px
|
|
125
|
+
|
|
126
|
+
// Calculate required grid squares to display
|
|
127
|
+
let maxDimension = distance.value;
|
|
128
|
+
|
|
129
|
+
if (type.value === 'cone') {
|
|
130
|
+
// For cones, consider the width at the end
|
|
131
|
+
const endWidth = Math.tan((angle.value / 2) * Math.PI / 180) * distance.value * 2;
|
|
132
|
+
maxDimension = Math.max(distance.value, endWidth);
|
|
133
|
+
} else if (type.value === 'ray') {
|
|
134
|
+
maxDimension = Math.max(distance.value, width.value);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
// Total grid squares needed (template + buffer on all sides)
|
|
138
|
+
const totalGridSquares = (maxDimension * 2) + (bufferSquares * 2);
|
|
139
|
+
const gridSize = canvasSize / totalGridSquares;
|
|
140
|
+
|
|
141
|
+
return {
|
|
142
|
+
width: canvasSize,
|
|
143
|
+
height: canvasSize,
|
|
144
|
+
gridSize: gridSize,
|
|
145
|
+
totalGridSquares: totalGridSquares
|
|
146
|
+
};
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
const resizeCanvas = () => {
|
|
150
|
+
if (!pixiApp) return;
|
|
151
|
+
|
|
152
|
+
const { width, height } = getCanvasSize();
|
|
153
|
+
pixiApp.renderer.resize(width, height);
|
|
154
|
+
|
|
155
|
+
// Clear and redraw everything
|
|
156
|
+
pixiApp.stage.removeChildren();
|
|
157
|
+
drawGrid();
|
|
158
|
+
templateGraphics = new PIXI.Graphics();
|
|
159
|
+
pixiApp.stage.addChild(templateGraphics);
|
|
160
|
+
drawTemplate();
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
const drawGrid = () => {
|
|
164
|
+
if (!pixiApp) return;
|
|
165
|
+
|
|
166
|
+
const gridGraphics = new PIXI.Graphics();
|
|
167
|
+
const { gridSize } = getCanvasSize();
|
|
168
|
+
const width = pixiApp.screen.width;
|
|
169
|
+
const height = pixiApp.screen.height;
|
|
170
|
+
|
|
171
|
+
// Always offset grid by half a square so canvas center aligns with grid square center
|
|
172
|
+
const offset = gridSize / 2;
|
|
173
|
+
|
|
174
|
+
console.log("Drawing grid with offset:", offset, "gridSize:", gridSize, "distance:", distance.value);
|
|
175
|
+
|
|
176
|
+
gridGraphics.lineStyle(1, 0xe0e0e0, 0.8);
|
|
177
|
+
|
|
178
|
+
// Vertical lines
|
|
179
|
+
for (let x = offset; x <= width; x += gridSize) {
|
|
180
|
+
gridGraphics.moveTo(x, 0);
|
|
181
|
+
gridGraphics.lineTo(x, height);
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
// Horizontal lines
|
|
185
|
+
for (let y = offset; y <= height; y += gridSize) {
|
|
186
|
+
gridGraphics.moveTo(0, y);
|
|
187
|
+
gridGraphics.lineTo(width, y);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
pixiApp.stage.addChild(gridGraphics);
|
|
191
|
+
};
|
|
192
|
+
|
|
193
|
+
const drawTemplate = () => {
|
|
194
|
+
if (!templateGraphics || !pixiApp) return;
|
|
195
|
+
|
|
196
|
+
templateGraphics.clear();
|
|
197
|
+
|
|
198
|
+
const { gridSize } = getCanvasSize();
|
|
199
|
+
const directionRad = toRadians(direction.value);
|
|
200
|
+
|
|
201
|
+
// Always center in grid square (canvas center)
|
|
202
|
+
const centerX = pixiApp.screen.width / 2;
|
|
203
|
+
const centerY = pixiApp.screen.height / 2;
|
|
204
|
+
|
|
205
|
+
// Convert grid units to pixels for Foundry shape functions
|
|
206
|
+
const distancePixels = distance.value * gridSize;
|
|
207
|
+
const widthPixels = width.value * gridSize;
|
|
208
|
+
|
|
209
|
+
// Set template style
|
|
210
|
+
templateGraphics.lineStyle(3, 0xff6b6b, 1);
|
|
211
|
+
templateGraphics.beginFill(0xff6b6b, 0.25);
|
|
212
|
+
|
|
213
|
+
switch (type.value) {
|
|
214
|
+
case 'circle':
|
|
215
|
+
templateGraphics.drawCircle(centerX, centerY, distancePixels);
|
|
216
|
+
break;
|
|
217
|
+
case 'rectangle':
|
|
218
|
+
templateGraphics.drawRect(
|
|
219
|
+
centerX - distancePixels/2,
|
|
220
|
+
centerY - distancePixels/2,
|
|
221
|
+
distancePixels,
|
|
222
|
+
distancePixels
|
|
223
|
+
);
|
|
224
|
+
break;
|
|
225
|
+
case 'cone':
|
|
226
|
+
const coneShape = getConeShape(directionRad, angle.value, distancePixels);
|
|
227
|
+
const conePoints = [];
|
|
228
|
+
for (let i = 0; i < coneShape.points.length; i += 2) {
|
|
229
|
+
conePoints.push(centerX + coneShape.points[i]);
|
|
230
|
+
conePoints.push(centerY + coneShape.points[i + 1]);
|
|
231
|
+
}
|
|
232
|
+
templateGraphics.drawPolygon(conePoints);
|
|
233
|
+
break;
|
|
234
|
+
case 'ray':
|
|
235
|
+
const rayShape = getRayShape(directionRad, distancePixels, widthPixels);
|
|
236
|
+
const rayPoints = [];
|
|
237
|
+
for (let i = 0; i < rayShape.points.length; i += 2) {
|
|
238
|
+
rayPoints.push(centerX + rayShape.points[i]);
|
|
239
|
+
rayPoints.push(centerY + rayShape.points[i + 1]);
|
|
240
|
+
}
|
|
241
|
+
templateGraphics.drawPolygon(rayPoints);
|
|
242
|
+
break;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
templateGraphics.endFill();
|
|
246
|
+
|
|
247
|
+
// Draw origin point
|
|
248
|
+
templateGraphics.lineStyle(0);
|
|
249
|
+
templateGraphics.beginFill(0x333333, 1);
|
|
250
|
+
templateGraphics.drawCircle(centerX, centerY, Math.max(2, gridSize * 0.15));
|
|
251
|
+
templateGraphics.endFill();
|
|
252
|
+
|
|
253
|
+
// Draw direction indicator
|
|
254
|
+
templateGraphics.lineStyle(2, 0x333333, 1);
|
|
255
|
+
templateGraphics.moveTo(centerX, centerY);
|
|
256
|
+
templateGraphics.lineTo(
|
|
257
|
+
centerX + Math.cos(directionRad) * (gridSize * 0.8),
|
|
258
|
+
centerY + Math.sin(directionRad) * (gridSize * 0.8)
|
|
259
|
+
);
|
|
260
|
+
};
|
|
261
|
+
|
|
262
|
+
// Helper function to simulate Ray.fromAngle
|
|
263
|
+
const createRay = (x, y, angle, distance) => {
|
|
264
|
+
return {
|
|
265
|
+
A: { x, y },
|
|
266
|
+
B: {
|
|
267
|
+
x: x + Math.cos(angle) * distance,
|
|
268
|
+
y: y + Math.sin(angle) * distance
|
|
269
|
+
},
|
|
270
|
+
dx: Math.cos(angle) * distance,
|
|
271
|
+
dy: Math.sin(angle) * distance
|
|
272
|
+
};
|
|
273
|
+
};
|
|
274
|
+
|
|
275
|
+
// Helper function to convert degrees to radians
|
|
276
|
+
const toRadians = (degrees) => degrees * (Math.PI / 180);
|
|
277
|
+
|
|
278
|
+
/**
|
|
279
|
+
* Get a Conical area of effect given a direction, angle, and distance
|
|
280
|
+
* @param {number} direction
|
|
281
|
+
* @param {number} angle
|
|
282
|
+
* @param {number} distance
|
|
283
|
+
* @returns {PIXI.Polygon}
|
|
284
|
+
*/
|
|
285
|
+
const getConeShape = (direction, angle, distance) => {
|
|
286
|
+
angle = angle || 90;
|
|
287
|
+
const coneType = game.settings.get("core", "coneTemplateType"); // Default to round cones
|
|
288
|
+
|
|
289
|
+
// For round cones - approximate the shape with a ray every 3 degrees
|
|
290
|
+
let angles;
|
|
291
|
+
if (coneType === "round") {
|
|
292
|
+
const da = Math.min(angle, 3);
|
|
293
|
+
const numRays = Math.floor(angle / da);
|
|
294
|
+
angles = Array.from({length: numRays + 1}, (_, i) => (angle / -2) + (i * da));
|
|
295
|
+
if (angles[angles.length - 1] !== angle / 2) {
|
|
296
|
+
angles.push(angle / 2);
|
|
297
|
+
}
|
|
298
|
+
} else {
|
|
299
|
+
// For flat cones, direct point-to-point
|
|
300
|
+
angles = [(angle / -2), (angle / 2)];
|
|
301
|
+
distance /= Math.cos(toRadians(angle / 2));
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
// Get the cone shape as a polygon
|
|
305
|
+
const rays = angles.map(a => createRay(0, 0, direction + toRadians(a), distance + 1));
|
|
306
|
+
const points = rays.reduce((arr, r) => {
|
|
307
|
+
return arr.concat([r.B.x, r.B.y]);
|
|
308
|
+
}, [0, 0]).concat([0, 0]);
|
|
309
|
+
return new PIXI.Polygon(points);
|
|
310
|
+
};
|
|
311
|
+
|
|
312
|
+
/**
|
|
313
|
+
* Get a rotated Rectangular area of effect given a width, height, and direction
|
|
314
|
+
* @param {number} direction
|
|
315
|
+
* @param {number} distance
|
|
316
|
+
* @param {number} width
|
|
317
|
+
* @returns {PIXI.Polygon}
|
|
318
|
+
*/
|
|
319
|
+
const getRayShape = (direction, distance, width) => {
|
|
320
|
+
const up = createRay(0, 0, direction - Math.PI/2, (width / 2) + 1);
|
|
321
|
+
const down = createRay(0, 0, direction + Math.PI/2, (width / 2) + 1);
|
|
322
|
+
const l1 = createRay(up.B.x, up.B.y, direction, distance + 1);
|
|
323
|
+
const l2 = createRay(down.B.x, down.B.y, direction, distance + 1);
|
|
324
|
+
|
|
325
|
+
// Create Polygon shape
|
|
326
|
+
const points = [down.B.x, down.B.y, up.B.x, up.B.y, l1.B.x, l1.B.y, l2.B.x, l2.B.y];
|
|
327
|
+
return new PIXI.Polygon(points);
|
|
328
|
+
};
|
|
329
|
+
|
|
330
|
+
const destroyPixi = () => {
|
|
331
|
+
if (pixiApp) {
|
|
332
|
+
pixiApp.destroy(true, true);
|
|
333
|
+
pixiApp = null;
|
|
334
|
+
templateGraphics = null;
|
|
335
|
+
}
|
|
336
|
+
};
|
|
337
|
+
|
|
338
|
+
// Watch for changes and redraw/resize
|
|
339
|
+
watchEffect(() => {
|
|
340
|
+
if (expanded.value && pixiApp) {
|
|
341
|
+
// Use nextTick to ensure all reactive values are updated
|
|
342
|
+
nextTick(() => {
|
|
343
|
+
resizeCanvas();
|
|
344
|
+
});
|
|
345
|
+
}
|
|
346
|
+
});
|
|
347
|
+
|
|
348
|
+
// Separate watcher for individual property changes
|
|
349
|
+
watchEffect(() => {
|
|
350
|
+
// Watch these specific values to trigger updates
|
|
351
|
+
const currentType = type.value;
|
|
352
|
+
const currentDirection = direction.value;
|
|
353
|
+
const currentDistance = distance.value;
|
|
354
|
+
const currentAngle = angle.value;
|
|
355
|
+
const currentWidth = width.value;
|
|
356
|
+
|
|
357
|
+
if (expanded.value && pixiApp && templateGraphics) {
|
|
358
|
+
nextTick(() => {
|
|
359
|
+
drawTemplate();
|
|
360
|
+
});
|
|
361
|
+
}
|
|
362
|
+
});
|
|
363
|
+
|
|
364
|
+
watch(distance, () => {
|
|
365
|
+
if (expanded.value && pixiApp) {
|
|
366
|
+
nextTick(() => {
|
|
367
|
+
resizeCanvas();
|
|
368
|
+
});
|
|
369
|
+
}
|
|
370
|
+
});
|
|
371
|
+
|
|
372
|
+
// Watch for expansion changes
|
|
373
|
+
watchEffect(async () => {
|
|
374
|
+
if (expanded.value) {
|
|
375
|
+
await nextTick();
|
|
376
|
+
await nextTick(); // Double nextTick to ensure DOM and reactive values are ready
|
|
377
|
+
initializePixi();
|
|
378
|
+
}
|
|
379
|
+
});
|
|
380
|
+
|
|
381
|
+
onMounted(() => {
|
|
382
|
+
if (expanded.value) {
|
|
383
|
+
initializePixi();
|
|
384
|
+
}
|
|
385
|
+
});
|
|
386
|
+
|
|
387
|
+
onUnmounted(() => {
|
|
388
|
+
destroyPixi();
|
|
389
|
+
});
|
|
390
|
+
|
|
391
|
+
const onPlace = () => {
|
|
392
|
+
console.log("Placing template at current cursor position");
|
|
393
|
+
game.system.measuredTemplatePreviewClass.place({
|
|
394
|
+
type: type.value,
|
|
395
|
+
distance: distance.value,
|
|
396
|
+
direction: direction.value,
|
|
397
|
+
angle: angle.value,
|
|
398
|
+
width: width.value
|
|
399
|
+
}, document.sheet);
|
|
400
|
+
};
|
|
401
|
+
|
|
402
|
+
</script>
|
|
403
|
+
|
|
404
|
+
<template>
|
|
405
|
+
<v-input class="isdl-tracker isdl-measured-template">
|
|
406
|
+
<template #default>
|
|
407
|
+
<v-field
|
|
408
|
+
class="v-field--active"
|
|
409
|
+
density="compact"
|
|
410
|
+
variant="outlined"
|
|
411
|
+
>
|
|
412
|
+
<template #label>
|
|
413
|
+
<span v-html="getLabel" />
|
|
414
|
+
</template>
|
|
415
|
+
<template #append-inner>
|
|
416
|
+
<v-icon
|
|
417
|
+
icon="fa-solid fa-border-outer"
|
|
418
|
+
class="map-icon"
|
|
419
|
+
@click.stop="onPlace"
|
|
420
|
+
data-tooltip="Place"
|
|
421
|
+
:color="primaryColor" />
|
|
422
|
+
<v-icon
|
|
423
|
+
:icon="expandIcon"
|
|
424
|
+
@click.stop="expanded = !expanded"
|
|
425
|
+
class="v-select__menu-icon"
|
|
426
|
+
/>
|
|
427
|
+
</template>
|
|
428
|
+
<div class="tracker-content flexcol">
|
|
429
|
+
<div class="d-flex tracker-inner-content">
|
|
430
|
+
<span v-html="summary" />
|
|
431
|
+
</div>
|
|
432
|
+
<v-expand-transition>
|
|
433
|
+
<div v-show="expanded" class="template-expanded-content" style="margin-top: 1rem;">
|
|
434
|
+
<div class="template-controls">
|
|
435
|
+
<div class="d-flex flex-row">
|
|
436
|
+
<v-select
|
|
437
|
+
:model-value="type"
|
|
438
|
+
@update:model-value="(v) => { type = v; if (document) document.update({ [systemPath + '.type']: v }); }"
|
|
439
|
+
:name="systemPath + '.type'"
|
|
440
|
+
:items="[
|
|
441
|
+
{ title: 'Circle', value: 'circle' },
|
|
442
|
+
{ title: 'Cone', value: 'cone' },
|
|
443
|
+
{ title: 'Rectangle', value: 'rectangle' },
|
|
444
|
+
{ title: 'Ray', value: 'ray' }
|
|
445
|
+
]"
|
|
446
|
+
label="Type"
|
|
447
|
+
density="compact"
|
|
448
|
+
variant="outlined"
|
|
449
|
+
class="control-field slim-number"
|
|
450
|
+
:hide-details="true"
|
|
451
|
+
:tile="true"
|
|
452
|
+
:disabled="disabled"
|
|
453
|
+
/>
|
|
454
|
+
<v-number-input
|
|
455
|
+
:model-value="direction"
|
|
456
|
+
@update:model-value="(v) => { direction = v; persistOnStep(systemPath + '.direction', v); }"
|
|
457
|
+
:name="systemPath + '.direction'"
|
|
458
|
+
label="Direction (°)"
|
|
459
|
+
controlVariant="stacked"
|
|
460
|
+
density="compact"
|
|
461
|
+
variant="outlined"
|
|
462
|
+
class="control-field slim-number"
|
|
463
|
+
:hide-details="true"
|
|
464
|
+
:tile="true"
|
|
465
|
+
:min="0"
|
|
466
|
+
:max="360"
|
|
467
|
+
:step="0.5"
|
|
468
|
+
:precision="1"
|
|
469
|
+
:disabled="disabled"
|
|
470
|
+
/>
|
|
471
|
+
</div>
|
|
472
|
+
<div class="d-flex flex-row" style="margin-top: 1rem;">
|
|
473
|
+
<v-number-input
|
|
474
|
+
:model-value="distance"
|
|
475
|
+
@update:model-value="(v) => { distance = v; persistOnStep(systemPath + '.distance', v); }"
|
|
476
|
+
:name="systemPath + '.distance'"
|
|
477
|
+
label="Distance (grid units)"
|
|
478
|
+
controlVariant="stacked"
|
|
479
|
+
density="compact"
|
|
480
|
+
variant="outlined"
|
|
481
|
+
class="control-field"
|
|
482
|
+
:hide-details="true"
|
|
483
|
+
:tile="true"
|
|
484
|
+
:min="0"
|
|
485
|
+
:precision="1"
|
|
486
|
+
:step="0.5"
|
|
487
|
+
:disabled="disabled"
|
|
488
|
+
/>
|
|
489
|
+
<v-number-input
|
|
490
|
+
v-if="type === 'cone'"
|
|
491
|
+
:model-value="angle"
|
|
492
|
+
@update:model-value="(v) => { angle = v; persistOnStep(systemPath + '.angle', v); }"
|
|
493
|
+
:name="systemPath + '.angle'"
|
|
494
|
+
label="Angle (°)"
|
|
495
|
+
controlVariant="stacked"
|
|
496
|
+
density="compact"
|
|
497
|
+
variant="outlined"
|
|
498
|
+
class="control-field slim-number"
|
|
499
|
+
:hide-details="true"
|
|
500
|
+
:tile="true"
|
|
501
|
+
:min="0"
|
|
502
|
+
:max="360"
|
|
503
|
+
:step="0.5"
|
|
504
|
+
:precision="1"
|
|
505
|
+
:disabled="disabled"
|
|
506
|
+
/>
|
|
507
|
+
<v-number-input
|
|
508
|
+
v-if="type === 'ray'"
|
|
509
|
+
:model-value="width"
|
|
510
|
+
@update:model-value="(v) => { width = v; persistOnStep(systemPath + '.width', v); }"
|
|
511
|
+
:name="systemPath + '.width'"
|
|
512
|
+
label="Width (grid units)"
|
|
513
|
+
controlVariant="stacked"
|
|
514
|
+
density="compact"
|
|
515
|
+
variant="outlined"
|
|
516
|
+
class="control-field slim-number"
|
|
517
|
+
:hide-details="true"
|
|
518
|
+
:tile="true"
|
|
519
|
+
:min="0"
|
|
520
|
+
:step="0.5"
|
|
521
|
+
:precision="1"
|
|
522
|
+
:disabled="disabled"
|
|
523
|
+
/>
|
|
524
|
+
</div>
|
|
525
|
+
</div>
|
|
526
|
+
<div class="template-preview" style="display: flex; margin-top: 0.5rem;">
|
|
527
|
+
<canvas
|
|
528
|
+
ref="canvasRef"
|
|
529
|
+
class="template-canvas"
|
|
530
|
+
style="margin-left: auto; margin-right: auto;"
|
|
531
|
+
></canvas>
|
|
532
|
+
</div>
|
|
533
|
+
</div>
|
|
534
|
+
</v-expand-transition>
|
|
535
|
+
</div>
|
|
536
|
+
</v-field>
|
|
537
|
+
</template>
|
|
538
|
+
</v-input>
|
|
539
|
+
</template>
|
|
540
|
+
`;
|
|
541
|
+
fs.writeFileSync(generatedFilePath, toString(fileNode));
|
|
542
|
+
}
|
|
543
|
+
//# sourceMappingURL=vue-measured-template.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vue-measured-template.js","sourceRoot":"","sources":["../../../../../src/cli/components/vue/base-components/vue-measured-template.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE1D,MAAM,CAAC,OAAO,UAAU,iCAAiC,CAAC,WAAmB;IACzE,MAAM,gBAAgB,GAAG,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,QAAQ,EAAE,WAAW,EAAE,KAAK,EAAE,YAAY,CAAC,CAAC;IAC5F,MAAM,iBAAiB,GAAG,IAAI,CAAC,IAAI,CAAC,gBAAgB,EAAE,uBAAuB,CAAC,CAAC;IAE/E,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,gBAAgB,CAAC,EAAE;QAClC,EAAE,CAAC,SAAS,CAAC,gBAAgB,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;KACvD;IAED,MAAM,QAAQ,GAAG,YAAY,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAkhB5B,CAAC;IACF,EAAE,CAAC,aAAa,CAAC,iBAAiB,EAAE,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC;AAC5D,CAAC"}
|