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
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
|
/* 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.
*
* $URL$
* $Id$
*/
#ifndef TEENAGENT_SCENE_H
#define TEENAGENT_SCENE_H
#include "teenagent/surface.h"
#include "teenagent/actor.h"
#include "common/system.h"
#include "common/list.h"
#include "teenagent/objects.h"
namespace TeenAgent {
class TeenAgentEngine;
class Dialog;
struct SceneEvent {
enum Type {
kNone, //0
kMessage,
kWalk,
kPlayAnimation,
kPlayActorAnimation, //4
kPauseAnimation,
kClearAnimations,
kLoadScene,
kSetOn, //8
kSetLan,
kPlayMusic,
kPlaySound,
kEnableObject, //12
kHideActor,
kWaitForAnimation,
kWaitLanAnimationFrame,
kCreditsMessage,
kQuit //16
} type;
Common::String message;
byte color;
uint16 animation;
byte orientation;
Common::Point dst;
byte scene; //fixme: put some of these to the union?
byte ons;
byte lan;
byte music;
byte sound;
byte object;
SceneEvent(Type type_) :
type(type_), message(), color(0xd1), animation(0), orientation(0), dst(),
scene(0), ons(0), lan(0), music(0), sound(0), object(0) {}
void clear() {
type = kNone;
message.clear();
color = 0xd1;
orientation = 0;
animation = 0;
dst.x = dst.y = 0;
scene = 0;
ons = 0;
lan = 0;
music = 0;
sound = 0;
object = 0;
}
inline bool empty() const {
return type == kNone;
}
void dump() const {
debug(0, "event[%d]: \"%s\"[%02x], animation: %u, dst: (%d, %d) [%u], scene: %u, ons: %u, lan: %u, object: %u, music: %u, sound: %u",
(int)type, message.c_str(), color, animation, dst.x, dst.y, orientation, scene, ons, lan, object, music, sound
);
}
};
class Scene {
public:
bool intro;
Scene();
void init(TeenAgentEngine *engine, OSystem *system);
void init(int id, const Common::Point &pos);
bool render(OSystem *system);
int getId() const { return _id; }
void warp(const Common::Point &point, byte orientation = 0);
void moveTo(const Common::Point &point, byte orientation = 0, bool validate = 0);
Common::Point getPosition() const { return position; }
void displayMessage(const Common::String &str, byte color = 0xd1);
void setOrientation(uint8 o) { orientation = o; }
void push(const SceneEvent &event);
bool processEvent(const Common::Event &event);
void clear();
byte *getOns(int id);
byte *getLans(int id);
bool eventRunning() const { return !current_event.empty(); }
Walkbox *getWalkbox(byte id) { return &walkboxes[_id - 1][id]; }
Object *getObject(int id, int scene_id = 0);
Object *findObject(const Common::Point &point);
void loadObjectData();
private:
void loadOns();
void loadLans();
void playAnimation(byte idx, uint id, bool loop, bool paused);
void playActorAnimation(uint id, bool loop);
byte palette[768];
void setPalette(OSystem *system, const byte *palette, unsigned mul = 1);
static Common::Point messagePosition(const Common::String &str, Common::Point position);
static uint messageDuration(const Common::String &str);
bool processEventQueue();
inline bool nextEvent() {
current_event.clear();
return processEventQueue();
}
void clearMessage();
TeenAgentEngine *_engine;
OSystem *_system;
int _id;
Graphics::Surface background;
Surface on;
Surface *ons;
uint32 ons_count;
Animation actor_animation, animation[4], custom_animation[4];
Common::Rect actor_animation_position, animation_position[4];
Actor teenagent, teenagent_idle;
Common::Point position, destination;
uint8 orientation;
Common::Array<Common::Array<Object> > objects;
Common::Array<Common::Array<Walkbox> > walkboxes;
Common::String message;
Common::Point message_pos;
byte message_color;
uint message_timer;
typedef Common::List<SceneEvent> EventList;
EventList events;
SceneEvent current_event;
bool hide_actor;
struct Sound {
byte id, delay;
Sound(byte i, byte d): id(i), delay(d) {}
};
typedef Common::List<Sound> Sounds;
Sounds sounds;
};
} // End of namespace TeenAgent
#endif
|