forked from phaserjs/phaser
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLinkFile.js
More file actions
139 lines (121 loc) · 3.26 KB
/
Copy pathLinkFile.js
File metadata and controls
139 lines (121 loc) · 3.26 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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2018 Photon Storm Ltd.
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
var Class = require('../utils/Class');
/**
* @classdesc
* [description]
*
* @class LinkFile
* @memberOf Phaser.Loader
* @constructor
* @since 3.7.0
*
* @param {Phaser.Loader.LoaderPlugin} loader - The Loader that is going to load this File.
* @param {string} type - The file type string for sorting within the Loader.
* @param {string} key - The key of the file within the loader.
* @param {Phaser.Loader.File[]} files - An array of Files that make-up this LinkFile.
*/
var LinkFile = new Class({
initialize:
function LinkFile (loader, type, key, files)
{
/**
* A reference to the Loader that is going to load this file.
*
* @name Phaser.Loader.LinkFile#loader
* @type {Phaser.Loader.LoaderPlugin}
* @since 3.7.0
*/
this.loader = loader;
/**
* The file type string for sorting within the Loader.
*
* @name Phaser.Loader.LinkFile#type
* @type {string}
* @since 3.7.0
*/
this.type = type;
/**
* Unique cache key (unique within its file type)
*
* @name Phaser.Loader.LinkFile#key
* @type {string}
* @since 3.7.0
*/
this.key = key;
/**
* Array of files that make up this LinkFile.
*
* @name Phaser.Loader.LinkFile#files
* @type {Phaser.Loader.File[]}
* @since 3.7.0
*/
this.files = files;
/**
* The completion status of this LinkFile.
*
* @name Phaser.Loader.LinkFile#complete
* @type {boolean}
* @since 3.7.0
*/
this.complete = false;
/**
* The number of files to load.
*
* @name Phaser.Loader.LinkFile#pending
* @type {integer}
* @since 3.7.0
*/
this.pending = files.length;
/**
* The number of files that failed to load.
*
* @name Phaser.Loader.LinkFile#failed
* @type {integer}
* @default 0
* @since 3.7.0
*/
this.failed = 0;
// Link the files
for (var i = 0; i < files.length; i++)
{
files[i].linkFile = this;
}
},
/**
* Called by each File when it finishes loading.
*
* @method Phaser.Loader.LinkFile#onFileComplete
* @since 3.7.0
*
* @param {Phaser.Loader.File} file - The File that has completed processing.
*/
onFileComplete: function (file)
{
var index = this.files.indexOf(file);
if (index !== -1)
{
this.pending--;
}
},
/**
* Called by each File that fails to load.
*
* @method Phaser.Loader.LinkFile#onFileFailed
* @since 3.7.0
*
* @param {Phaser.Loader.File} file - The File that has failed to load.
*/
onFileFailed: function (file)
{
var index = this.files.indexOf(file);
if (index !== -1)
{
this.failed++;
}
}
});
module.exports = LinkFile;