sprite.h

00001 /***************************************************************************
00002  *   Copyright (C) 2007 by Mike Polan                                      *
00003  *   kanadakid@gmail.com                                                   *
00004  *                                                                         *
00005  *   This program is free software; you can redistribute it and/or modify  *
00006  *   it under the terms of the GNU General Public License as published by  *
00007  *   the Free Software Foundation; either version 2 of the License, or     *
00008  *   (at your option) any later version.                                   *
00009  *                                                                         *
00010  *   This program is distributed in the hope that it will be useful,       *
00011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00013  *   GNU General Public License for more details.                          *
00014  *                                                                         *
00015  *   You should have received a copy of the GNU General Public License     *
00016  *   along with this program; if not, write to the                         *
00017  *   Free Software Foundation, Inc.,                                       *
00018  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
00019  ***************************************************************************/
00020 // sprite.h: the Sprite class
00021 
00022 #ifndef SPRITE_H
00023 #define SPRITE_H
00024 
00025 #include <gdkmm/pixbuf.h>
00026 #include <glibmm/ustring.h>
00027 #include <map>
00028 
00033 struct _Frame {
00035         int time;
00036         
00038         Glib::ustring sfx;
00039         
00041         Glib::RefPtr<Gdk::Pixbuf> pixbuf;
00042 };
00043 typedef struct _Frame Frame;
00044 
00049 struct _Animation {
00051         Glib::ustring id;
00052         
00054         bool loop;
00055         
00057         std::vector<Frame> frames;
00058 };
00059 typedef struct _Animation Animation;
00060 
00061 typedef std::map<Glib::ustring, Animation> AnimationMap;
00062 typedef std::map<Glib::ustring, Animation>::iterator AnimationMapIter;
00063 
00071 class Sprite {
00072         public:
00074                 Sprite() { }
00075                 
00080                 bool create_from_gifs(const Glib::ustring &path);
00081                 
00085                 void add_animation(const Animation &anim) { m_Animations[anim.id]=anim; }
00086                 
00091                 void add_animation_from_gif(const Glib::ustring &id, const Glib::ustring &path);
00092                 
00097                 Animation& get_animation(const Glib::ustring &id) { return m_Animations[id]; }
00098                 
00102                 AnimationMap get_animations() const { return m_Animations; }
00103                 
00107                 int num_animations() const { return m_Animations.size(); }
00108                 
00112                 void remove_animation(const Glib::ustring &id) { m_Animations.erase(id); }
00113                 
00119                 void add_frame(const Glib::ustring &id, int time, const Glib::RefPtr<Gdk::Pixbuf> &pixbuf);
00120                 
00125                 void remove_frame(const Glib::ustring &id, int index);
00126                 
00128                 void clear() { m_Animations.clear(); }
00129                 
00130         private:
00132                 AnimationMap m_Animations;
00133 };
00134 
00135 #endif

Generated on Fri Feb 22 22:34:17 2008 for Phoenix Wright Case Editor API by  doxygen 1.5.3