-
Notifications
You must be signed in to change notification settings - Fork 36
/
AlphaAnimType.h
121 lines (108 loc) · 3.1 KB
/
AlphaAnimType.h
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
////////////////////////////////////////////////////////////////////////////////
//
// Copyright 2016 RWS Inc, All Rights Reserved
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of version 2 of the GNU General Public License as published by
// the Free Software Foundation
//
// This program 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 General Public License for more details.
//
// You should have received a copy of the GNU General Public License along
// with this program; if not, write to the Free Software Foundation, Inc.,
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
//
// AlphaAnimType.h
// Project: Postal
//
////////////////////////////////////////////////////////////////////////////////
#ifndef ALPHAANIMTYPE_H
#define ALPHAANIMTYPE_H
// Simple wrapper class for each frame of alpha animation
class CAlphaAnim
{
public:
short m_sNumAlphas; // Number of alpha images (could be 0!)
short m_sX; // Offset from hotspot to upper-left corner of image
short m_sY; // Offset from hotspot to upper-left corner of image
RImage m_imColor; // "Normal" 8-bit color image
RImage* m_pimAlphaArray; // Array of alpha image's (could be empty!)
public:
CAlphaAnim()
{
m_pimAlphaArray = 0;
Reset();
};
~CAlphaAnim()
{
Reset();
};
CAlphaAnim& operator=(const CAlphaAnim& rhs)
{
Reset();
m_sNumAlphas = rhs.m_sNumAlphas;
m_sX = rhs.m_sX;
m_sY = rhs.m_sY;
m_imColor = rhs.m_imColor;
Alloc(m_sNumAlphas);
rspObjCpy(m_pimAlphaArray, rhs.m_pimAlphaArray, m_sNumAlphas);
return *this;
}
bool operator==(const CAlphaAnim& rhs) const
{
// Comparing two of these objects is a major undertaking. Instead,
// we'll always say that they are different. This is not a great
// solution. In fact, it sucks. But what the hell...
return false;
}
void Reset(void)
{
Free();
m_sNumAlphas = 0;
m_sX = 0;
m_sY = 0;
}
void Alloc(short sNumAlphas)
{
Free();
if (sNumAlphas > 0)
{
m_pimAlphaArray = new RImage[sNumAlphas];
ASSERT(m_pimAlphaArray != 0);
}
m_sNumAlphas = sNumAlphas;
}
void Free(void)
{
delete []m_pimAlphaArray;
m_pimAlphaArray = 0;
}
short Load(RFile* pFile)
{
pFile->Read(&m_sNumAlphas);
pFile->Read(&m_sX);
pFile->Read(&m_sY);
m_imColor.Load(pFile);
Alloc(m_sNumAlphas);
for (short s = 0; s < m_sNumAlphas; s++)
m_pimAlphaArray[s].Load(pFile);
return pFile->Error();
}
short Save(RFile* pFile)
{
pFile->Write(m_sNumAlphas);
pFile->Write(m_sX);
pFile->Write(m_sY);
m_imColor.Save(pFile);
for (short s = 0; s < m_sNumAlphas; s++)
m_pimAlphaArray[s].Save(pFile);
return pFile->Error();
}
};
#endif //ALPHAANIMTYPE_H
////////////////////////////////////////////////////////////////////////////////
// EOF
////////////////////////////////////////////////////////////////////////////////