-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathgenerateMemberVariableLayout.js
More file actions
76 lines (70 loc) · 2.22 KB
/
Copy pathgenerateMemberVariableLayout.js
File metadata and controls
76 lines (70 loc) · 2.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/* eslint-disable */
import https from 'https';
import fs from 'fs';
import path from 'path';
import ini from 'ini';
import { fileURLToPath } from 'url';
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const url = 'https://raw.githubusercontent.com/UE4SS-RE/RE-UE4SS/main/assets/MemberVarLayoutTemplates/MemberVariableLayout_5_01_Template.ini';
const outputPath = path.join(__dirname, 'src', 'assets', 'MemberVariableLayout_5_01_Template.ini');
if (fs.existsSync(outputPath)) {
console.log('File already exists. Skipping download.');
} else {
https.get(url, (response) => {
if (response.statusCode === 200) {
const file = fs.createWriteStream(outputPath);
response.pipe(file);
file.on('finish', () => {
file.close();
console.log('Download completed.');
generateMemberVariableLayout();
});
} else {
console.log(`Failed to download file: ${response.statusCode}`);
}
}).on('error', (err) => {
console.error(`Error: ${err.message}`);
});
}
const generateMemberVariableLayout = () => {
fs.readFile(outputPath, 'utf-8', (err, data) => {
if (err) {
console.error(`Error reading file: ${err.message}`);
return;
}
const config = ini.parse(data);
const uEnumSection = {
CppForm: '0x58',
CppType: '0x30',
EnumDisplayNameFn: '0x60',
EnumFlags_Internal: '0x5C',
EnumPackage: '0x68',
Names: '0x48'
};
let needsUpdate = false;
if (!config.UEnum) {
config.UEnum = uEnumSection;
needsUpdate = true;
} else {
for (const key in uEnumSection) {
if (config.UEnum[key] !== uEnumSection[key]) {
config.UEnum[key] = uEnumSection[key];
needsUpdate = true;
}
}
}
if (needsUpdate) {
const newOutputPath = path.join(__dirname, 'src', 'assets', 'MemberVariableLayout.ini');
fs.writeFile(newOutputPath, ini.stringify(config), (err) => {
if (err) {
console.error(`Error writing file: ${err.message}`);
} else {
console.log('File updated and saved as MemberVariableLayout.ini');
}
});
} else {
console.log('No updates needed.');
}
});
};