forked from openfl/lime
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathAsset.hx
More file actions
125 lines (110 loc) · 2.51 KB
/
Asset.hx
File metadata and controls
125 lines (110 loc) · 2.51 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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
package lime.tools;
import hxp.*;
import lime.tools.AssetType;
import sys.FileSystem;
@:access(lime.tools.AssetHelper)
class Asset
{
public var data:Dynamic;
public var embed:Null<Bool>;
public var encoding:AssetEncoding;
public var flatName:String;
public var format:String;
public var glyphs:String;
public var id:String;
public var library:String;
// public var path:String;
// public var rename:String;
public var resourceName:String;
public var sourcePath:String;
public var targetPath:String;
public var deliveryPackName:String;
public var type:AssetType;
public function new(path:String = "", rename:String = "", type:AssetType = null, embed:Null<Bool> = null, setDefaults:Bool = true)
{
if (!setDefaults) return;
this.embed = embed;
sourcePath = Path.standardize(path);
if (rename == "")
{
targetPath = path;
}
else
{
targetPath = rename;
}
id = targetPath;
resourceName = targetPath;
flatName = StringTools.getFlatName(targetPath);
format = Path.extension(path).toLowerCase();
glyphs = "32-255";
deliveryPackName = '';
if (type == null)
{
var extension = Path.extension(path);
if (extension != null) extension = extension.toLowerCase();
if (AssetHelper.knownExtensions.exists(extension))
{
this.type = AssetHelper.knownExtensions.get(extension);
}
else
{
switch (extension)
{
case "bundle":
this.type = AssetType.MANIFEST;
case "ogg", "m4a":
if (FileSystem.exists(path))
{
var stat = FileSystem.stat(path);
// if (stat.size > 1024 * 128) {
if (stat.size > 1024 * 1024)
{
this.type = AssetType.MUSIC;
}
else
{
this.type = AssetType.SOUND;
}
}
else
{
this.type = AssetType.SOUND;
}
default:
if (path != "" && System.isText(path))
{
this.type = AssetType.TEXT;
}
else
{
this.type = AssetType.BINARY;
}
}
}
}
else
{
this.type = type;
}
}
public function clone():Asset
{
var asset = new Asset("", "", null, null, false);
asset.data = data;
asset.embed = embed;
asset.encoding = encoding;
asset.flatName = flatName;
asset.format = format;
asset.glyphs = glyphs;
asset.id = id;
asset.library = library;
asset.resourceName = resourceName;
asset.sourcePath = sourcePath;
asset.targetPath = targetPath;
asset.deliveryPackName = deliveryPackName;
asset.type = type;
// ObjectTools.copyFields (this, asset);
return asset;
}
}