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