-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathFileManager.js
133 lines (90 loc) · 2.74 KB
/
FileManager.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
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
126
127
128
129
130
131
132
133
FileManager = {
baseUri: Settings.dataFolderUri,
loadFileAsync: function( path, callback ) {
var xmlhttp = new XMLHttpRequest();
xmlhttp.open( 'GET', FileManager.baseUri + path, true );
xmlhttp.responseType = 'arraybuffer';
xmlhttp.onreadystatechange = function() {
if( this.readyState == 4 ) {
callback( this.response );
}
};
xmlhttp.send(null);
},
Types: {
},
spritePath: 'sprite',
classPath: 'Àΰ£Á·',
bodyPath: '¸öÅë',
headPath: '¸Ó¸®Åë',
headTopPath: '¾Ç¼¼»ç¸®',
genderMale: '³²',
genderFemale: '¿©',
getGenderName: function( sex ) {
return ( sex == 1 )
? FileManager.genderMale
: FileManager.genderFemale;
},
// job res name
getClassResName: function( class_id, sex ) {
var resName = ClassResNameTable[ class_id ];
return resName + '_' + FileManager.getGenderName( sex );
},
// job body res path
getClassBodyResPath: function( class_id, sex ) {
return FileManager.spritePath + '/'
+ FileManager.classPath + '/'
+ FileManager.bodyPath + '/'
+ FileManager.getGenderName( sex ) + '/'
+ FileManager.getClassResName( class_id, sex );
},
// hair res name
getHeadResName: function( head_id, sex ) {
return HeadIdTable[sex][head_id].toString() + '_' + FileManager.getGenderName( sex );
},
// hair res path
getHeadResPath: function( head_id, sex ) {
return FileManager.spritePath + '/'
+ FileManager.classPath + '/'
+ FileManager.headPath + '/'
+ FileManager.getGenderName( sex ) + '/'
+ FileManager.getHeadResName( head_id, sex );
},
getAccessoryResName: function( access_id, sex ) {
return FileManager.getGenderName( sex ) + AccessoryNameTable[ access_id ]
},
// view ID res path
getAccessoryResPath: function( access_id, sex ) {
return FileManager.spritePath + '/'
+ FileManager.headTopPath + '/'
+ FileManager.getGenderName( sex ) + '/'
+ FileManager.getAccessoryResName( access_id, sex );
},
__cache: new Map(),
getCache: function( path ) {
if( FileManager.__cache.has( path ) ) {
return FileManager.__cache.get( path );
} else {
return null;
}
},
setCache: function( key, data ) {
FileManager.__cache.set( key, data );
},
loadSpriteActAsync: function( uri_base, callback ) {
//var uri_base = path + name;
var cacheData = FileManager.getCache( uri_base );
if( cacheData !== null )
callback( cacheData );
FileManager.loadFileAsync( uri_base + '.spr', function( sprbuf ) {
FileManager.loadFileAsync( uri_base + '.act', function( actbuf ) {
var obj = {
sprite: new SprParser( sprbuf ),
actor: new ActParser( actbuf )
};
FileManager.setCache( uri_base, obj );
callback( obj );
});
});
}
};