aboutsummaryrefslogtreecommitdiff
path: root/engines/illusions/resources/actorresource.h
blob: 2ccb9efd580cd108abbd685ccc5cce56693c9bbf (plain)
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
122
123
124
125
126
127
128
129
130
131
132
133
134
/* ScummVM - Graphic Adventure Engine
 *
 * ScummVM is the legal property of its developers, whose names
 * are too numerous to list here. Please refer to the COPYRIGHT
 * file distributed with this source distribution.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.

 * 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.
 *
 */

#ifndef ILLUSIONS_ACTORRESOURCE_H
#define ILLUSIONS_ACTORRESOURCE_H

#include "illusions/graphics.h"
#include "illusions/resourcesystem.h"
#include "graphics/surface.h"

namespace Illusions {

class IllusionsEngine;

class ActorResourceLoader : public BaseResourceLoader {
public:
	ActorResourceLoader(IllusionsEngine *vm) : _vm(vm) {}
	virtual ~ActorResourceLoader() {}
	virtual void load(Resource *resource);
	virtual void buildFilename(Resource *resource);
	virtual bool isFlag(int flag);
protected:
	IllusionsEngine *_vm;
};

struct Frame {
	uint16 _flags;
	byte *_pointsConfig;
	SurfInfo _surfInfo;
	byte *_compressedPixels;
	void load(byte *dataStart, Common::SeekableReadStream &stream);
};

struct Sequence {
	uint32 _sequenceId;
	uint32 _unk4;
	byte *_sequenceCode;
	void load(byte *dataStart, Common::SeekableReadStream &stream);
};

struct ActorType {
	uint32 _actorTypeId;
	SurfInfo _surfInfo;
	byte *_pointsConfig;
	NamedPoints _namedPoints;
	RGB _color;
	byte _scale;
	byte _priority;
	int16 _value1E;
	uint16 _pathWalkPointsIndex;
	uint16 _scaleLayerIndex;
	uint16 _pathWalkRectIndex;
	uint16 _priorityLayerIndex;
	uint16 _regionLayerIndex;
	uint16 _flags;
	void load(byte *dataStart, Common::SeekableReadStream &stream);
};

class FramesList : public Common::Array<Frame> {
};

class ActorResource {
public:
	ActorResource();
	~ActorResource();
	void load(Resource *resource);
	bool containsSequence(Sequence *sequence);
	bool findNamedPoint(uint32 namedPointId, Common::Point &pt);
public:
	uint32 _totalSize;
	Common::Array<ActorType> _actorTypes;
	Common::Array<Sequence> _sequences;
	FramesList _frames;
	NamedPoints _namedPoints;
};

class ActorInstance : public ResourceInstance {
public:
	ActorInstance(IllusionsEngine *vm);              
	virtual void load(Resource *resource);
	virtual void unload();
	virtual void pause();
	virtual void unpause();
public:
	IllusionsEngine *_vm;
	uint32 _tag;
	int _pauseCtr;
	ActorResource *_actorResource;
protected:
	void initActorTypes();
	void registerResources();	
	void unregisterResources();	
};

class ActorInstanceList {
public:
	ActorInstanceList(IllusionsEngine *vm);
	~ActorInstanceList();
	ActorInstance *createActorInstance(Resource *resource);
	void removeActorInstance(ActorInstance *actorInstance);
	void pauseByTag(uint32 tag);
	void unpauseByTag(uint32 tag);
	FramesList *findSequenceFrames(Sequence *sequence);
	ActorInstance *findActorByResource(ActorResource *actorResource);
	bool findNamedPoint(uint32 namedPointId, Common::Point &pt);
protected:
	typedef Common::List<ActorInstance*> Items;
	typedef Items::iterator ItemsIterator;
	IllusionsEngine *_vm;
	Items _items;
};

} // End of namespace Illusions

#endif // ILLUSIONS_ACTORRESOURCE_H