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
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (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, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20  *
21  */
22 #ifndef SLUDGE_PEOPLE_H
23 #define SLUDGE_PEOPLE_H
24 
25 #include "common/list.h"
26 
27 namespace Sludge {
28 
29 struct FrozenStuffStruct;
30 struct LoadedSpriteBank;
31 struct ScreenRegion;
32 struct VariableStack;
33 
34 class SludgeEngine;
35 
36 struct AnimFrame {
37 	int frameNum, howMany;
38 	int noise;
39 };
40 
41 #define EXTRA_FRONT         1
42 #define EXTRA_FIXEDSIZE     2
43 #define EXTRA_NOSCALE       2   // Alternative name
44 #define EXTRA_NOZB          4
45 #define EXTRA_FIXTOSCREEN   8
46 #define EXTRA_NOLITE        16
47 #define EXTRA_NOREMOVE      32
48 #define EXTRA_RECTANGULAR   64
49 
50 struct PersonaAnimation {
51 	LoadedSpriteBank *theSprites;
52 	AnimFrame *frames;
53 	int numFrames;
54 
55 	PersonaAnimation();
56 	PersonaAnimation(int num, VariableStack *&stacky);
57 	PersonaAnimation(PersonaAnimation *orig);
58 	~PersonaAnimation();
59 
60 	// Setter & getter
61 	int getTotalTime();
62 
63 	// Save & load
64 	bool save(Common::WriteStream *stream);
65 	bool load(Common::SeekableReadStream *stream);
66 };
67 
68 struct Persona {
69 	PersonaAnimation **animation;
70 	int numDirections;
71 
72 	// Save & load
73 	bool save(Common::WriteStream *stream);
74 	bool load(Common::SeekableReadStream *stream);
75 };
76 
77 struct OnScreenPerson {
78 	float x, y;
79 	int height, floaty, walkSpeed;
80 	float scale;
81 	int walkToX, walkToY, thisStepX, thisStepY, inPoly, walkToPoly;
82 	bool walking, spinning;
83 	struct LoadedFunction *continueAfterWalking;
84 	PersonaAnimation *myAnim;
85 	PersonaAnimation *lastUsedAnim;
86 	Persona *myPersona;
87 	int frameNum, frameTick, angle, wantAngle, angleOffset;
88 	bool show;
89 	int direction, directionWhenDoneWalking;
90 	struct ObjectType *thisType;
91 	int extra, spinSpeed;
92 	byte r, g, b, colourmix, transparency;
93 
94 	void makeTalker();
95 	void makeSilent();
96 	void setFrames(int a);
97 };
98 
99 typedef Common::List<OnScreenPerson *> OnScreenPersonList;
100 
101 class PeopleManager {
102 public:
103 	PeopleManager(SludgeEngine *vm);
104 	~PeopleManager();
105 
106 	// Initialisation and creation
107 	bool init();
108 	bool addPerson(int x, int y, int objNum, Persona *p);
109 
110 	// Draw to screen and to backdrop
111 	void drawPeople();
112 	void freezePeople(int, int);
113 
114 	// Removalisationisms
115 	void kill();
116 	void killMostPeople();
117 	void removeOneCharacter(int i);
118 
119 	// Things which affect or use all characters
120 	OnScreenPerson *findPerson(int v);
121 	void setScale(int16 h, int16 d);
122 
123 	// Things which affect one character
124 	void setShown(bool h, int ob);
125 	void setDrawMode(int h, int ob);
126 	void setPersonTransparency(int ob, byte x);
127 	void setPersonColourise(int ob, byte r, byte g, byte b, byte colourmix);
128 
129 	// Moving 'em
130 	void movePerson(int x, int y, int objNum);
131 	bool makeWalkingPerson(int x, int y, int objNum, struct LoadedFunction *func, int di);
132 	bool forceWalkingPerson(int x, int y, int objNum, struct LoadedFunction *func, int di);
133 	void jumpPerson(int x, int y, int objNum);
134 	void walkAllPeople();
135 	bool turnPersonToFace(int thisNum, int direc);
136 	bool stopPerson(int o);
137 	bool floatCharacter(int f, int objNum);
138 	bool setCharacterWalkSpeed(int f, int objNum);
139 
140 	// Animating 'em
141 	void animatePerson(int obj, PersonaAnimation *);
142 	void animatePerson(int obj, Persona *per);
143 	bool setPersonExtra(int f, int newSetting);
144 
145 	// Loading and saving
146 	bool savePeople(Common::WriteStream *stream);
147 	bool loadPeople(Common::SeekableReadStream *stream);
148 
149 	// Freeze
150 	void freeze(FrozenStuffStruct *frozenStuff);
151 	void resotre(FrozenStuffStruct *frozenStuff);
152 
153 private:
154 	ScreenRegion *_personRegion;
155 	OnScreenPersonList *_allPeople;
156 	int16 _scaleHorizon;
157 	int16 _scaleDivide;
158 
159 	SludgeEngine *_vm;
160 
161 	void shufflePeople();
162 
163 	// OnScreenPerson manipulation
164 	void turnMeAngle(OnScreenPerson *thisPerson, int direc);
165 	void spinStep(OnScreenPerson *thisPerson);
166 	void rethinkAngle(OnScreenPerson *thisPerson);
167 	void moveAndScale(OnScreenPerson &me, float x, float y);
168 	void setMyDrawMode(OnScreenPerson *moveMe, int h);
169 	bool walkMe(OnScreenPerson *thisPerson, bool move = true);
170 };
171 
172 } // End of namespace Sludge
173 
174 #endif
175