#include "cl_anim.h"
void ANIM::init()
{
//#ifdef HARD_DEBUG
// cout << "Anim init" << endl;
//#endif
data.clear();
}
void ANIM::done()
{
// deque::const_iterator i;
// for(i=data.begin(); i!=data.end(); i++) {
// destroy_bitmap(i);
// }
}
int ANIM::split_image(BITMAP *bmp, map ani, int sx, int sy)
{
map::const_iterator i;
int x1, x2, y1, y2;
for(i=ani.begin(); i!=ani.end(); i++) {
get_int(i->second, &x1, &y1, &x2, &y2);
// cout<first<<":"<first] = bitmap_sector(bmp, x1, y1, x2, y2, sx, sy);
}
return 0;
}
deque ANIM::getanimrow(string name)
{
deque dummy_deque;
if(data[name].size()) {
return data[name];
} else {
error("Wrong name of animation queue (%s)", name.c_str());
return dummy_deque;
}
}
//copies content of deque into input param :)
void ANIM::getanimrow(deque &row, string name)
{
deque::const_iterator i;
if(data[name].size()) {
for(i=data[name].begin(); i!=data[name].end(); i++) {
row.push_back(i[0]);
}
} else {
error("Wrong name of animation queue (%s)", name.c_str());
}
}
//returns count of animacion with key name
int ANIM::getcount(string &name)
{
return data[name].size();
}
//Returns BITMAP in animation on possition i
BITMAP *ANIM::get(string name, int i)
{
int x = data[name].size();
if((x) && (x >= i) ) {
return data[name][i];
} else {
error("Animation not found (%s)", name.c_str());
return NO_IMG;
}
}
//Return the 1st BITMAP of animmation
BITMAP *ANIM::get(string name)
{
return get(name, 0);
}
void ANIM::open(string fname, string anifile, int sizex, int sizey)
{
tsizex = sizex;
tsizey = sizey;
tbmp = NULL;
tdat = load_datafile_object(fname.c_str(), anifile.c_str());
if(!tdat) {
error("Unable to open image file %s %s",fname.c_str(),anifile.c_str());
tbmp = NULL;
} else {
tbmp = (BITMAP *)tdat->dat;
}
}
void ANIM::load(string name, int x1, int y1, int x2, int y2)
{
if(!tbmp) { cout << "Unitialized anim handler" << endl; }
data[name] = bitmap_sector(tbmp, x1, y1, x2, y2, tsizex, tsizey);
}
void ANIM::close()
{
unload_datafile_object(tdat);
}
Generated by: georgik on armada on Sat Jul 24 07:07:15 2004, using kdoc 2.0a54. |