Mercurial > projects > myrrdin
annotate import/myrrdin/imagecache.d @ 5:f4b89014ad39
added moving figure stuff + animated sprites. not usable atm.
author | fred@reichbier.de |
---|---|
date | Sat, 19 Jul 2008 14:33:08 +0200 |
parents | src/imagecache.d@a2d653eb9e99 |
children | 510541745cd1 |
rev | line source |
---|---|
5
f4b89014ad39
added moving figure stuff + animated sprites. not usable atm.
fred@reichbier.de
parents:
0
diff
changeset
|
1 /* |
f4b89014ad39
added moving figure stuff + animated sprites. not usable atm.
fred@reichbier.de
parents:
0
diff
changeset
|
2 This file is part of myrrdin. |
f4b89014ad39
added moving figure stuff + animated sprites. not usable atm.
fred@reichbier.de
parents:
0
diff
changeset
|
3 |
f4b89014ad39
added moving figure stuff + animated sprites. not usable atm.
fred@reichbier.de
parents:
0
diff
changeset
|
4 myrrdin is free software: you can redistribute it and/or modify |
f4b89014ad39
added moving figure stuff + animated sprites. not usable atm.
fred@reichbier.de
parents:
0
diff
changeset
|
5 it under the terms of the GNU Lesser General Public License as |
f4b89014ad39
added moving figure stuff + animated sprites. not usable atm.
fred@reichbier.de
parents:
0
diff
changeset
|
6 published by the Free Software Foundation, either version 3 of |
f4b89014ad39
added moving figure stuff + animated sprites. not usable atm.
fred@reichbier.de
parents:
0
diff
changeset
|
7 the License, or (at your option) any later version. |
f4b89014ad39
added moving figure stuff + animated sprites. not usable atm.
fred@reichbier.de
parents:
0
diff
changeset
|
8 |
f4b89014ad39
added moving figure stuff + animated sprites. not usable atm.
fred@reichbier.de
parents:
0
diff
changeset
|
9 myrrdin is distributed in the hope that it will be useful, |
f4b89014ad39
added moving figure stuff + animated sprites. not usable atm.
fred@reichbier.de
parents:
0
diff
changeset
|
10 but WITHOUT ANY WARRANTY; without even the implied warranty of |
f4b89014ad39
added moving figure stuff + animated sprites. not usable atm.
fred@reichbier.de
parents:
0
diff
changeset
|
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
f4b89014ad39
added moving figure stuff + animated sprites. not usable atm.
fred@reichbier.de
parents:
0
diff
changeset
|
12 GNU Lesser General Public License for more details. |
f4b89014ad39
added moving figure stuff + animated sprites. not usable atm.
fred@reichbier.de
parents:
0
diff
changeset
|
13 |
f4b89014ad39
added moving figure stuff + animated sprites. not usable atm.
fred@reichbier.de
parents:
0
diff
changeset
|
14 You should have received a copy of the GNU Lesser General Public |
f4b89014ad39
added moving figure stuff + animated sprites. not usable atm.
fred@reichbier.de
parents:
0
diff
changeset
|
15 License along with myrrdin. If not, see <http://www.gnu.org/licenses/>. |
f4b89014ad39
added moving figure stuff + animated sprites. not usable atm.
fred@reichbier.de
parents:
0
diff
changeset
|
16 */ |
f4b89014ad39
added moving figure stuff + animated sprites. not usable atm.
fred@reichbier.de
parents:
0
diff
changeset
|
17 |
0 | 18 module imagecache; |
19 | |
20 import dsfml.window.all; | |
21 import dsfml.system.all; | |
22 import dsfml.graphics.all; | |
23 | |
24 import tango.io.vfs.FileFolder; | |
25 | |
26 class Cache { | |
27 private FileFolder filefolder; | |
28 private Image[char[]] images; | |
29 | |
30 this(char[] folder) { | |
31 this.filefolder = new FileFolder(folder, false); | |
32 } | |
33 | |
34 void load(char[] real_filename, char[] seen_filename) { | |
35 this.images[seen_filename] = new Image(); | |
36 this.images[seen_filename].loadFromFile(real_filename); | |
37 } | |
38 | |
39 Image get_image(char[] filename) { | |
40 if (!(filename in this.images)) { | |
41 this.load(this.filefolder.file(filename).toString(), filename); | |
42 } | |
43 return this.images[filename]; | |
44 } | |
45 } |