Mercurial > projects > myrrdin
diff 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 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/import/myrrdin/imagecache.d Sat Jul 19 14:33:08 2008 +0200 @@ -0,0 +1,45 @@ +/* + This file is part of myrrdin. + + myrrdin is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation, either version 3 of + the License, or (at your option) any later version. + + myrrdin is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with myrrdin. If not, see <http://www.gnu.org/licenses/>. +*/ + +module imagecache; + +import dsfml.window.all; +import dsfml.system.all; +import dsfml.graphics.all; + +import tango.io.vfs.FileFolder; + +class Cache { + private FileFolder filefolder; + private Image[char[]] images; + + this(char[] folder) { + this.filefolder = new FileFolder(folder, false); + } + + void load(char[] real_filename, char[] seen_filename) { + this.images[seen_filename] = new Image(); + this.images[seen_filename].loadFromFile(real_filename); + } + + Image get_image(char[] filename) { + if (!(filename in this.images)) { + this.load(this.filefolder.file(filename).toString(), filename); + } + return this.images[filename]; + } +}