-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathactor.h
167 lines (138 loc) · 4.6 KB
/
actor.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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
/* 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 KOM_ACTOR_H
#define KOM_ACTOR_H
#include "common/array.h"
#include "common/scummsys.h"
namespace Kom {
struct Scope {
Scope() : aliasData(0), minFrame(0), maxFrame(0), startFrame(-1) {}
int16 minFrame;
int16 maxFrame;
int16 startFrame;
const int16* aliasData;
};
class KomEngine;
class Actor {
friend class ActorManager;
public:
~Actor();
void defineScope(uint8 scopeId, int16 minFrame, int16 maxFrame, int16 startFrame);
/**
* Allows a hard-coded frame sequence. It is only used for the exit/inventory cursor
* animations which repeat the edge frames several times and play the frames
* forward and then in reverse
*/
void defineScopeAlias(uint8 scopeId, const int16 *aliasData, uint8 length);
void setScope(uint8 scopeId, uint16 animDuration);
void switchScope(uint8 scopeId, uint16 animDuration);
void setAnim(int16 minFrame, int16 maxFrame, uint16 animDuration);
void animate();
void display();
void enable(int state) { _isActive = state; }
void setPos(int xPos, int yPos) { _xPos = xPos; _yPos = yPos; }
void setRatio(uint16 xRatio, uint16 yRatio) { _xRatio = xRatio; _yRatio = yRatio; }
void setMaskDepth(int maskDepth, int depth) { _maskDepth = maskDepth; _depth = depth; }
void setEffect(uint8 effect) { _effect = effect; }
void setFrame(int16 frame) { _currentFrame = frame; }
int getXPos() { return _xPos; }
int getYPos() { return _yPos; }
int16 getFramesNum() { return _framesNum; }
bool inPos(int32 x, int32 y) {
return x >= _displayLeft && x <= _displayRight &&
y >= _displayTop && y <= _displayBottom; }
protected:
Actor(KomEngine *vm, const char *filename, bool isMouse = false);
int16 _framesNum;
byte _isPlayerControlled;
int16 _currentFrame;
int16 _minFrame;
int16 _maxFrame;
uint16 _animDurationTimer;
uint16 _animDuration;
bool _reverseAnim;
int _xPos;
int _yPos;
uint16 _xRatio;
uint16 _yRatio;
int _maskDepth;
int _depth;
bool _isAnimating;
bool _pausedAnim;
int _targetX;
int _targetY;
uint8 _scope;
uint8 _effect;
int _isActive;
int32 _displayLeft;
int32 _displayRight;
int32 _displayTop;
int32 _displayBottom;
Scope _scopes[8];
private:
byte *_framesData;
int _framesDataSize;
KomEngine *_vm;
bool _isMouse;
static const int16 _exitCursorAnimation[];
static const int16 _inventoryCursorAnimation[];
};
class ActorManager {
public:
ActorManager(KomEngine *vm);
~ActorManager();
int load(const char *filename);
void loadExtras();
Actor *get(int idx) { return _actors[idx]; }
Actor *getMouse() { return _mouseActor; }
Actor *getDonut() { return _donutActor; }
Actor *getObjects() { return _objectsActor; }
Actor *getCharIcon() { return _charIconActor; }
Actor *getCoinage() { return _coinageActor; }
Actor *getFightBarL() { return _fightBarLActor; }
Actor *getFightBarR() { return _fightBarRActor; }
Actor *getCloudActor() { return get(_cloudActorId); }
Actor *getCloudEffectActor() { return get(_cloudEffectActorId); }
Actor *getCloudWordActor() { return get(_cloudWordActorId); }
Actor *getNPCCloudActor(int i) { return get(_cloudNPC[i]); }
Actor *getMagicDarkLord(int i) { return get(_magicDarkLord[i]); }
void unload(int idx) { if (idx >= 0) { delete _actors[idx]; _actors[idx] = 0; } }
void unloadAll() { for (uint i = 0; i < _actors.size(); i++) unload(i); }
void displayAll();
void pauseAnimAll(bool pause);
private:
KomEngine *_vm;
Common::Array<Actor *> _actors;
Actor *_mouseActor;
Actor *_donutActor;
Actor *_objectsActor;
Actor *_charIconActor;
Actor *_coinageActor;
Actor *_fightBarLActor;
Actor *_fightBarRActor;
int _cloudActorId;
int _cloudEffectActorId;
int _cloudWordActorId;
int _cloudNPC[4];
int _magicDarkLord[10];
Actor *getFarthestActor();
};
} // End of namespace Kom
#endif