ScummVM API documentation
sprite.h
1
/* ScummVM - Graphic Adventure Engine
2
*
3
* ScummVM is the legal property of its developers, whose names
4
* are too numerous to list here. Please refer to the COPYRIGHT
5
* file distributed with this source distribution.
6
*
7
* This program is free software: you can redistribute it and/or modify
8
* it under the terms of the GNU General Public License as published by
9
* the Free Software Foundation, either version 3 of the License, or
10
* (at your option) any later version.
11
*
12
* This program is distributed in the hope that it will be useful,
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
* GNU General Public License for more details.
16
*
17
* You should have received a copy of the GNU General Public License
18
* along with this program. If not, see <http://www.gnu.org/licenses/>.
19
*
20
*/
21
22
#ifndef TWINE_PARSER_SPRITE_H
23
#define TWINE_PARSER_SPRITE_H
24
25
#include "common/array.h"
26
#include "common/memstream.h"
27
#include "common/stream.h"
28
#include "graphics/managed_surface.h"
29
#include "twine/parser/parser.h"
30
#include "twine/shared.h"
31
32
namespace
TwinE
{
33
34
struct
SpriteDim
{
35
int16 x = 0;
36
int16 y = 0;
37
int16 w = 0;
38
int16 h = 0;
39
};
40
41
class
SpriteBoundingBoxData
:
public
Parser
{
42
private
:
43
Common::Array<BoundingBox>
_boundingBoxes;
44
Common::Array<SpriteDim>
_dimensions;
45
46
public
:
47
bool
loadFromStream(
Common::SeekableReadStream
&stream,
bool
lba1)
override
;
48
49
const
BoundingBox
*bbox(
int
index)
const
;
// PtrZvAnim3DS, PtrZvExtra, PtrZvExtraRaw
50
const
SpriteDim
*dim(
int
index)
const
;
51
};
52
53
inline
const
BoundingBox
*SpriteBoundingBoxData::bbox(
int
index)
const
{
54
if
(index < 0) {
55
return
nullptr
;
56
}
57
return
&_boundingBoxes[index];
58
}
59
60
inline
const
SpriteDim
*SpriteBoundingBoxData::dim(
int
index)
const
{
61
if
(index < 0) {
62
return
nullptr
;
63
}
64
return
&_dimensions[index];
65
}
66
67
class
SpriteData
:
public
Parser
{
68
protected
:
69
Graphics::ManagedSurface
_surfaces[2];
70
int
_offsetX[2] {0};
71
int
_offsetY[2] {0};
72
int
_sprites = 0;
73
bool
_bricks =
false
;
74
75
bool
loadSprite(
Common::SeekableReadStream
&stream, uint32 offset);
76
void
reset()
override
;
77
public
:
78
bool
loadFromStream(
Common::SeekableReadStream
&stream,
bool
lba1)
override
;
79
80
inline
const
Graphics::ManagedSurface
&surface(
int
index = 0)
const
{
81
if
(index < 0 || index >= _sprites) {
82
error
(
"Sprite surface index out of range: %i (max: %i)"
, index, _sprites);
83
}
84
return
_surfaces[index];
85
}
86
87
inline
int
sprites()
const
{
88
return
_sprites;
89
}
90
91
inline
int
offsetX(
int
index = 0)
const
{
92
if
(index < 0 || index >= _sprites) {
93
error
(
"Sprite offset index out of range: %i (max: %i)"
, index, _sprites);
94
}
95
return
_offsetX[index];
96
}
97
98
inline
int
offsetY(
int
index = 0)
const
{
99
if
(index < 0 || index >= _sprites) {
100
error
(
"Sprite offset index out of range: %i (max: %i)"
, index, _sprites);
101
}
102
return
_offsetY[index];
103
}
104
};
105
106
class
BrickData
:
public
SpriteData
{
107
public
:
108
BrickData
() {
109
_bricks =
true
;
110
}
111
};
112
113
}
// End of namespace TwinE
114
115
#endif
Graphics::ManagedSurface
Definition:
managed_surface.h:51
TwinE::SpriteBoundingBoxData
Definition:
sprite.h:41
Common::Array
Definition:
array.h:52
Common::SeekableReadStream
Definition:
stream.h:745
TwinE::SpriteDim
Definition:
sprite.h:34
TwinE::SpriteData
Definition:
sprite.h:67
TwinE
Definition:
achievements_tables.h:27
error
void NORETURN_PRE error(MSVC_PRINTF const char *s,...) GCC_PRINTF(1
TwinE::Parser
Definition:
parser.h:32
TwinE::BoundingBox
Axis aligned bounding box.
Definition:
shared.h:186
TwinE::BrickData
Definition:
sprite.h:106
engines
twine
parser
sprite.h
Generated on Fri Aug 30 2024 09:04:00 for ScummVM API documentation by
1.8.13