aboutsummaryrefslogtreecommitdiff
path: root/include/smanim.hpp
blob: c2039612ef4f813f147700617428e43be63879d9 (plain) (blame)
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
// -*- C++ -*-
/*
 * Simple MultimEdia LiTerator(SMELT)
 * by Chris Xiong 2015
 * Animation header
 *
 * WARNING: This library is in development and interfaces would be very
 * unstable.
 *
 */
#ifndef SMANIM_H
#define SMANIM_H
#include "smelt.hpp"
#include "smentity.hpp"
#include "smdatapack.hpp"
#include <map>
#include <string>

class smTexInfo
{
public:
	smTexRect rect;
	char *name,*path;
	SMTEX tex;
};
class smAnmInfo
{
public:
	smTexInfo frames[256];
	int framedur[256],mode,fc;
	char* name;
};
class smAnmFile
{
private:
	static SMELT *sm;
	smDtpFileR anm;
	void parseMeta(const char* meta,DWORD size);
	std::map<std::string,smTexInfo> tm;
	std::map<std::string,smAnmInfo> am;
	std::map<std::string,SMTEX> xm;
public:
	bool loadAnmFromMemory(const char* ptr,DWORD size);
	void close();
	smTexInfo* getTextureInfo(const char* name);
	smAnmInfo* getAnimationInfo(const char* name);
};
class smAnimation2D:public smEntity2D
{
private:
	smAnmInfo ai;
	smAnimation2D();
	int cf,mf,r;
public:
	smAnimation2D(smAnmInfo a);
	void updateAnim(int f=1);
	void resetAnim();
};
class smAnimation3D:public smEntity3D
{
private:
	smAnmInfo ai;
	smAnimation3D();
	int cf,mf,r;
public:
	smAnimation3D(smAnmInfo a);
	void updateAnim(int f=1);
	void resetAnim();
};
#endif