11import { getLayersMap } from "../LayersFlattener" ;
22import { TemplateValue } from "../TemplateValue" ;
3+ import { getAreaObject } from "../AreaObject" ;
34
4- export async function initPropertiesTemplates ( ) : Promise < void > {
5- const layers = await getLayersMap ( ) ;
6-
7- for ( const [ layerName , layer ] of layers . entries ( ) ) {
8- const properties = layer . properties ?? [ ] ;
5+ export async function initPropertiesTemplatesArea ( ) : Promise < void > {
6+ const areas = await getAreaObject ( ) ;
7+ for ( const area of areas ) {
8+ const properties = area . properties ?? [ ] ;
99 for ( const property of properties ) {
1010 if (
1111 property . type === "int" ||
@@ -20,15 +20,54 @@ export async function initPropertiesTemplates(): Promise<void> {
2020 continue ;
2121 }
2222 const newValue = template . getValue ( ) ;
23- setProperty ( layerName , property . name , newValue ) ;
23+ await setPropertyArea ( area . name , property . name , newValue ) ;
2424
25- template . onChange ( ( newValue ) => {
26- setProperty ( layerName , property . name , newValue ) ;
25+ template . onChange ( async ( newValue ) => {
26+ await setPropertyArea ( area . name , property . name , newValue ) ;
2727 } ) ;
2828 }
2929 }
3030}
3131
32+ export async function initPropertiesTemplates ( ) : Promise < void > {
33+ const layers = await getLayersMap ( ) ;
34+
35+ for ( const [ layerName , layer ] of layers . entries ( ) ) {
36+ if ( layer . type !== "objectgroup" ) {
37+ const properties = layer . properties ?? [ ] ;
38+ for ( const property of properties ) {
39+ if (
40+ property . type === "int" ||
41+ property . type === "bool" ||
42+ property . type === "object" ||
43+ typeof property . value !== "string"
44+ ) {
45+ continue ;
46+ }
47+ const template = new TemplateValue ( property . value , WA . state ) ;
48+ if ( template . isPureString ( ) ) {
49+ continue ;
50+ }
51+ const newValue = template . getValue ( ) ;
52+ setProperty ( layerName , property . name , newValue ) ;
53+
54+ template . onChange ( ( newValue ) => {
55+ setProperty ( layerName , property . name , newValue ) ;
56+ } ) ;
57+ }
58+ }
59+ }
60+ }
61+
62+ async function setPropertyArea (
63+ areaName : string ,
64+ propertyName : string ,
65+ value : string ,
66+ ) : Promise < void > {
67+ console . log ( areaName ) ;
68+ const area = await WA . room . area . get ( areaName ) ;
69+ area . setProperty ( propertyName , value ) ;
70+ }
3271/**
3372 * Sets the property value on the map.
3473 * Furthermore, if the property name is "visible", modify the visibility of the layer.
0 commit comments