forked from Kode/khamake
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathKhaExporter.js
95 lines (76 loc) · 2.07 KB
/
KhaExporter.js
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
"use strict";
const path = require('path');
const Exporter = require('./Exporter.js');
const Files = require('./Files.js');
const Converter = require('./Converter.js');
class KhaExporter extends Exporter {
constructor(khaDirectory) {
super();
this.width = 640;
this.height = 480;
this.sources = [];
this.addSourceDirectory('Sources');
this.addSourceDirectory(path.join(khaDirectory.toString(), 'Sources'));
}
getCurrentDirectoryName(directory) {
return directory.getFileName();
}
copyFile(from, to) {
Files.copy(from, to, true);
}
copyDirectory(from, to) {
this.createDirectory(to);
var files = Files.newDirectoryStream(from);
for (let f in files) {
let file = Paths.get(from, files[f]);
if (Files.isDirectory(file)) this.copyDirectory(file, to.resolve(file));
else this.copyFile(file, to.resolve(file));
}
}
createDirectory(dir) {
if (!Files.exists(dir)) Files.createDirectories(dir);
}
setWidthAndHeight(width, height) {
this.width = width;
this.height = height;
}
setName(name) {
this.name = name;
this.safename = name.replaceAll(' ', '-');
}
addShader(shader) {
}
addSourceDirectory(path) {
this.sources.push(path);
}
removeSourceDirectory(path) {
for (let i in this.sources) {
if (this.sources[i] === path) {
this.sources.splice(i, 1);
return;
}
}
}
copyImage(platform, from, to, asset, callback) {
callback();
}
copyMusic(platform, from, to, encoders, callback) {
callback();
}
copySound(platform, from, to, encoders, callback) {
callback();
}
copyVideo(platform, from, to, encoders, callback) {
callback();
}
copyBlob(platform, from, to, callback) {
callback();
}
copyFont(platform, from, to, asset, encoders, callback) {
Files.createDirectories(this.directory.resolve(this.sysdir()).resolve(to).parent());
Converter.convert(from, this.directory.resolve(this.sysdir()).resolve(to), encoders.kravur, (success) => {
callback([to]);
}, {size: asset.size});
}
}
module.exports = KhaExporter;