25 #include "common/scummsys.h" 26 #include "common/endian.h" 27 #include "common/error.h" 28 #include "common/list.h" 29 #include "common/rect.h" 30 #include "graphics/surface.h" 31 #include "tsage/events.h" 32 #include "tsage/graphics.h" 33 #include "tsage/resources.h" 34 #include "tsage/saveload.h" 42 class SceneObjectList;
63 InvObject(
int visage,
int strip,
int frame);
66 bool inInventory()
const;
71 s.syncAsUint16LE(_sceneNumber);
83 int getObjectScene(
int objectNum);
103 void clear() { _ctr = 0; }
104 void setCtr(
int v) { _ctr = v; }
106 if (_ctr > 0) --_ctr;
109 int incCtr() {
return ++_ctr; }
110 int getCtr()
const {
return _ctr; }
112 void synchronize(
Serializer &s)
override { s.syncAsSint16LE(_ctr); }
122 void synchronize(
Serializer &s)
override { SYNC_POINTER(_action); }
125 virtual void remove() {}
126 virtual void signal() {}
127 virtual void process(
Event &event) {}
128 virtual void dispatch();
129 virtual void setAction(
Action *action) { setAction(action, NULL); }
131 virtual void destroy() {}
147 void remove()
override;
148 void process(
Event &event)
override;
149 void dispatch()
override;
154 va_start(va, endHandler);
155 attached(newOwner, endHandler, va);
158 int getActionIndex()
const {
return _actionIndex; }
159 void setActionIndex(
int index) { _actionIndex = index; }
160 void setDelay(
int numFrames);
168 #define ADD_PLAYER_MOVER(X, Y) { Common::Point pt(X, Y); PlayerMover *mover = new PlayerMover(); \ 169 g_globals->_player.addMover(mover, &pt, this); } 170 #define ADD_PLAYER_MOVER_NULL(OBJ, X, Y) { Common::Point pt(X, Y); PlayerMover *mover = new PlayerMover(); \ 171 OBJ.addMover(mover, &pt, NULL); } 172 #define ADD_PLAYER_MOVER_THIS(OBJ, X, Y) { Common::Point pt(X, Y); PlayerMover *mover = new PlayerMover(); \ 173 OBJ.addMover(mover, &pt, this); } 175 #define ADD_MOVER(OBJ, X, Y) { Common::Point pt(X, Y); NpcMover *mover = new NpcMover(); \ 176 OBJ.addMover(mover, &pt, this); } 177 #define ADD_MOVER_NULL(OBJ, X, Y) { Common::Point pt(X, Y); NpcMover *mover = new NpcMover(); \ 178 OBJ.addMover(mover, &pt, NULL); } 191 ObjectMover() { _action = NULL; _sceneObject = NULL; _minorDiff = 0; _majorDiff = 0; _changeCtr = 0;}
196 void remove()
override;
197 void dispatch()
override;
198 virtual void startMove(
SceneObject *sceneObj, va_list va) {}
200 virtual bool dontMove()
const;
201 virtual void endMove();
215 void dispatch()
override;
216 void startMove(
SceneObject *sceneObj, va_list va)
override;
217 void endMove()
override;
223 void dispatch()
override;
224 void startMove(
SceneObject *sceneObj, va_list va)
override;
225 void endMove()
override;
231 void startMove(
SceneObject *sceneObj, va_list va)
override;
234 #define MAX_ROUTE_SIZE 20 235 #define ROUTE_END_VAL -20000 248 int regionIndexOf(
int xp,
int yp) {
return regionIndexOf(
Common::Point(xp, yp)); }
252 int calculateRestOfRoute(
int *routeList,
int srcRegion,
int destRegion,
bool &foundRoute);
265 void startMove(
SceneObject *sceneObj, va_list va)
override;
266 void endMove()
override;
278 void dispatch()
override;
279 void startMove(
SceneObject *sceneObj, va_list va)
override;
280 void endMove()
override;
295 SYNC_POINTER(_scenePalette);
296 SYNC_POINTER(_action);
298 virtual void signal() = 0;
299 virtual void remove() = 0;
304 byte _palette[256 * 3];
310 virtual void setPalette(
ScenePalette *palette,
int step);
311 Common::String getClassName()
override {
return "PaletteModifierCached"; }
329 Common::String getClassName()
override {
return "PaletteRotation"; }
331 void signal()
override;
332 void remove()
override;
334 void setStep(
int step) { _step = step; }
335 void set(
ScenePalette *palette,
int start,
int end,
int rotationMode,
int duration,
Action *action);
337 void setDelay(
int amount);
342 byte _palette[256 * 3];
346 void signal()
override;
347 void remove()
override;
348 void setPalette(
ScenePalette *palette,
int step)
override;
353 enum FadeMode {FADEMODE_NONE = 0, FADEMODE_GRADUAL = 1, FADEMODE_IMMEDIATE = 2};
357 byte _palette[256 * 3];
372 bool loadPalette(
int paletteNum);
373 void loadPalette(
const byte *pSrc,
int start,
int count);
376 void setPalette(
int index,
int count);
377 void getEntry(
int index, uint *r, uint *g, uint *b);
378 void setEntry(
int index, uint r, uint g, uint b);
379 uint8 indexOf(uint r, uint g, uint b,
int threshold = 0xffff,
int start = 0,
int count = 256);
380 void getPalette(
int start = 0,
int count = 256);
381 void signalListeners();
382 void clearListeners();
383 void fade(
const byte *adjustData,
bool fullAdjust,
int percent);
384 PaletteRotation *addRotation(
int start,
int end,
int rotationMode,
int duration = 0,
Action *action = NULL);
385 PaletteFader *addFader(
const byte *arrBufferRGB,
int palSize,
int step,
Action *action);
387 static void changeBackground(
const Rect &bounds, FadeMode fadeMode);
394 const int SET_WIDTH = 0;
397 const int SET_FONT = 3;
398 const int SET_BG_COLOR = 4;
399 const int SET_FG_COLOR = 5;
400 const int SET_KEEP_ONSCREEN = 6;
401 const int SET_EXT_BGCOLOR = 7;
402 const int SET_EXT_FGCOLOR = 8;
403 const int SET_POS_MODE = 9;
404 const int SET_TEXT_MODE = 10;
405 const int LIST_END = -999;
419 void remove()
override;
420 void destroy()
override {}
421 virtual bool startAction(CursorType action,
Event &event);
422 virtual void doAction(
int action);
425 void setBounds(
const Rect &newBounds) { _bounds = newBounds; }
426 void setBounds(
const int ys,
const int xe,
const int ye,
const int xs) { _bounds =
Rect(
MIN(xs, xe),
MIN(ys, ye),
MAX(xs, xe),
MAX(ys, ye)); }
427 static void display(
int resNum,
int lineNum, ...);
428 static void display2(
int resNum,
int lineNum);
438 SceneItem::synchronize(s);
439 s.syncAsSint16LE(_state);
445 int _resNum, _lookLineNum, _useLineNum, _talkLineNum;
449 bool startAction(CursorType action,
Event &event)
override;
451 void doAction(
int action)
override;
453 void setDetails(
int ys,
int xs,
int ye,
int xe,
const int resnum,
const int lookLineNum,
const int useLineNum);
454 void setDetails(
const Rect &bounds,
int resNum,
int lookLineNum,
int talkLineNum,
int useLineNum,
int mode,
SceneItem *item);
455 void setDetails(
int sceneRegionId,
int resNum,
int lookLineNum,
int talkLineNum,
int useLineNum,
int mode = 0);
456 void setDetails(
int resNum,
int lookLineNum,
int talkLineNum,
int useLineNum,
int mode,
SceneItem *item);
457 void setDetails(
int resNum,
int lookLineNum,
int talkLineNum,
int useLineNum);
460 enum AnimateMode {ANIM_MODE_NONE = 0, ANIM_MODE_1 = 1, ANIM_MODE_2 = 2, ANIM_MODE_3 = 3,
461 ANIM_MODE_4 = 4, ANIM_MODE_5 = 5, ANIM_MODE_6 = 6, ANIM_MODE_7 = 7, ANIM_MODE_8 = 8,
467 enum Effect { EFFECT_NONE = 0, EFFECT_SHADED = 1, EFFECT_SMOKE = 3,
468 EFFECT_SHADOW_MAP = 5, EFFECT_SHADED2 = 6 };
488 void setVisage(
int resNum,
int rlbNum = 9999);
490 int getFrameCount()
const;
507 Common::String getClassName()
override {
return "SceneObjectWrapper"; }
508 void remove()
override;
509 void dispatch()
override;
512 enum ObjectFlags {OBJFLAG_FIXED_PRIORITY = 1, OBJFLAG_NO_UPDATES = 2, OBJFLAG_ZOOMED = 4,
513 OBJFLAG_SUPPRESS_DISPATCH = 8, OBJFLAG_HIDE = 0x100, OBJFLAG_HIDING = 0x200, OBJFLAG_REMOVE = 0x400,
514 OBJFLAG_CLONED = 0x800, OBJFLAG_CHECK_REGION = 0x1000, OBJFLAG_PANE_0 = 0x4000, OBJFLAG_PANE_1 = 0x8000,
515 OBJFLAG_PANES = OBJFLAG_PANE_0 | OBJFLAG_PANE_1,
516 OBJFLAG_FLIP_CENTROID_X = 0x10000, OBJFLAG_FLIP_CENTROID_Y = 0x20000
527 uint32 _updateStartFrame;
528 uint32 _walkStartFrame;
539 AnimateMode _animateMode;
551 uint32 _regionBitList;
555 int _shade, _oldShade;
566 void setStrip(
int frameNum);
567 void setStrip2(
int frameNum);
568 void setZoom(
int percent);
570 void changeZoom(
int percent);
571 void setFrame(
int frameNum);
572 void setFrame2(
int frameNum);
573 void setPriority(
int priority);
574 void fixPriority(
int priority);
575 void setVisage(
int visage);
578 void getHorizBounds();
579 int getRegionIndex();
581 void animate(
int animMode, ...);
588 bool isNoMover()
const {
return !_mover || (_regionIndex > 0); }
593 void remove()
override;
594 void process(
Event &event)
override {
event.handled =
true; }
595 void dispatch()
override;
597 virtual void removeObject();
599 virtual void reposition();
601 virtual void proc19() {}
602 virtual void updateScreen();
605 virtual void changeAngle(
int angle);
610 void setup(
int visage,
int stripFrameNum,
int frameNum,
int posX,
int posY,
int priority);
611 void setup(
int visage,
int stripFrameNum,
int frameNum);
616 Common::String getClassName()
override {
return "BackgroundSceneObject"; }
618 void draw()
override;
621 void setup2(
int visage,
int stripFrameNum,
int frameNum,
int posX,
int posY,
int priority,
int effect);
622 static void copySceneToBackground();
642 GfxSurface getFrame()
override {
return _textSurface; }
643 void updateScreen()
override;
646 #define MAX_CHARACTERS 4 647 enum R2RCharacter { R2_NONE = 0, R2_QUINN = 1, R2_SEEKER = 2, R2_MIRANDA = 3 };
656 R2RCharacter _characterIndex;
657 int _characterScene[MAX_CHARACTERS];
658 int _oldCharacterScene[MAX_CHARACTERS];
660 int _characterStrip[MAX_CHARACTERS];
661 int _characterFrame[MAX_CHARACTERS];
668 void process(
Event &event)
override;
670 void disableControl();
671 void enableControl();
672 void disableControl(CursorType cursorId, CursorType objectId = CURSOR_NONE);
673 void enableControl(CursorType cursorId, CursorType objectId = CURSOR_NONE);
682 void load(
int size,
const byte *srcP) {
683 for (
int i = 0; i < size; ++i, srcP += 4)
686 void load2(
int size, ...) {
691 int xs = va_arg(va,
int);
692 int xe = va_arg(va,
int);
710 Region() { _regionSize = 0; _regionId = 0; }
711 Region(
int resNum,
int rlbNum, ResourceType ctlType = RES_CONTROL);
712 Region(
int regionId,
const byte *regionData);
714 void load(
const byte *regionData);
718 void setRect(
const Rect &r);
719 void setRect(
int xs,
int ys,
int xe,
int ye);
724 void uniteRect(
const Rect &rect);
731 void load(
int sceneNum);
746 Common::String getClassName()
override {
return "SceneObjectList"; }
751 static void deactivate();
754 void recurse(EventHandlerFn Fn) {
756 _listAltered =
false;
765 int size()
const {
return _objList.
size(); }
766 bool contains(
SceneObject *sceneObj) {
return TsAGE::contains(_objList, sceneObj); }
770 _objList.
remove(sceneObj);
773 void clear() { _objList.
clear(); }
779 Region _defaultPriorityRegion;
781 void load(
int resNum);
808 #define PROCESS_LIST_SIZE 100 813 void loadProcessList(byte *dataP,
int dataSize,
int &dataIndex,
int ®ionHeight);
814 int process1(
int idx, byte *dataP,
int dataSize);
815 void process2(
int dataIndex,
int x1,
int y1,
int x2,
int y2);
816 void process3(
int yp,
int dataCount,
int &idx1,
int &idx2);
817 void process4(
int yp,
int idx1,
int idx2,
int &count);
818 void process5(
int idx1,
int idx2);
819 void loadRecords(
int yp,
int size,
int processIndex);
826 void loadRegion(byte *dataP,
int size);
834 void load(byte *data);
855 void load(
int sceneNum);
858 assert((idx >= 1) && (idx <= (
int)_regionList.
size()));
859 return _regionList[idx - 1];
861 void disableRegion(
int regionId);
862 void enableRegion(
int regionId);
869 double _float1, _float2, _float3, _float4;
871 FloatSet() { _float1 = _float2 = _float3 = _float4 = 0; }
872 void add(
double v1,
double v2,
double v3);
873 void proc1(
double v);
892 void dispatch()
override {}
901 uint32 _prevFrameNumber;
903 virtual void playerAction(
Event &event) {}
904 virtual void processEnd(
Event &event) {}
905 virtual void postLoad(
int priorSceneBeforeLoad,
int currentSceneBeforeLoad) {}
908 void registerHandler();
909 uint32 getFrameDifference();
913 void process(
Event &event)
override;
914 void dispatch()
override;
Definition: graphics.h:57
Definition: saveload.h:98
Definition: saveload.h:84
In find(In first, In last, const T &v)
Definition: algorithm.h:225
size_type size() const
Definition: list.h:198
void push_front(const T &element)
Definition: list.h:135
Out copy(In first, In last, Out dst)
Definition: algorithm.h:52
void replace(It begin, It end, const Dat &original, const Dat &replaced)
Definition: algorithm.h:448
void push_back(const T &element)
Definition: array.h:180
iterator end()
Definition: list.h:240
iterator begin()
Definition: list.h:227
Definition: graphics.h:79
Definition: saveload.h:115
Definition: blueforce_dialogs.h:30
void clear()
Definition: list.h:206
size_type size() const
Definition: array.h:315
void remove(const T &val)
Definition: list.h:125
Definition: saveload.h:63
T MIN(T a, T b)
Definition: util.h:59
Definition: graphics.h:65
Definition: list_intern.h:51
T MAX(T a, T b)
Definition: util.h:62
Definition: graphics.h:40
void push_back(const T &element)
Definition: list.h:140