@@ -14,25 +14,33 @@ export default function MaterialOverrides() {
14
14
return ;
15
15
}
16
16
17
+ let pathWarning = false ;
18
+
17
19
const text = await file . text ( ) ;
18
20
try {
19
21
const jsonData = JSON . parse ( text ) ;
20
-
22
+
21
23
if ( jsonData . MATI . startsWith ( "[" ) && jsonData . MATI . endsWith ( ".pc_mi" ) ) {
22
24
jsonData . MATT = jsonData . MATI . replace ( ".pc_mi" , ".pc_entitytype" ) ;
23
25
jsonData . MATB = jsonData . MATI . replace ( ".pc_mi" , ".pc_entityblueprint" ) ;
26
+ } else {
27
+ pathWarning = true ;
24
28
}
25
-
29
+
26
30
const modified = appendOverrides ( jsonData ) ;
27
31
const materialName = jsonData . Material . Instance [ 0 ] . Name . replace ( "mi" , "material" ) ;
28
- const blob = new Blob ( [ JSON . stringify ( modified , null , 2 ) ] , { type : "application/json" } ) ;
32
+ const blob = new Blob ( [ JSON . stringify ( modified , null , 2 ) ] , { type : "application/json" } ) ;
29
33
30
34
const a = document . createElement ( "a" ) ;
31
35
a . href = URL . createObjectURL ( blob ) ;
32
36
a . download = `${ materialName } .json` ;
33
37
a . click ( ) ;
34
38
35
- setMessage ( `Generated ${ materialName } .json` ) ;
39
+ let message = `Generated ${ materialName } .json` ;
40
+ if ( pathWarning ) {
41
+ message += "\nMATT and MATB could not be set due to MATI not being a path. Please set these manually." ;
42
+ }
43
+ setMessage ( message ) ;
36
44
} catch ( err ) {
37
45
setMessage ( "Failed to process file: " + err . message ) ;
38
46
console . error ( err ) ;
@@ -64,7 +72,13 @@ export default function MaterialOverrides() {
64
72
>
65
73
< h2 > Drop your material.json file here</ h2 >
66
74
< p > and overrides will be automatically added into it.</ p >
67
- { message && < p > < strong > { message } </ strong > </ p > }
75
+ { message && (
76
+ < div >
77
+ { message . split ( "\n" ) . map ( ( line , index ) => (
78
+ < p key = { index } > < strong > { line } </ strong > </ p >
79
+ ) ) }
80
+ </ div >
81
+ ) }
68
82
</ div >
69
83
< p style = { { textAlign : "center" , marginTop : "2rem" } } >
70
84
Adapted from code originally created by{ " " }
0 commit comments