ScummVM API documentation
base_object.h
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 modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (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, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 /*
23  * This file is based on WME Lite.
24  * http://dead-code.org/redir.php?target=wmelite
25  * Copyright (c) 2011 Jan Nedoma
26  */
27 
28 #ifndef WINTERMUTE_BASE_OBJECT_H
29 #define WINTERMUTE_BASE_OBJECT_H
30 
31 
32 #include "engines/wintermute/base/base_script_holder.h"
33 #include "engines/wintermute/base/gfx/xmath.h"
34 #include "engines/wintermute/persistent.h"
35 #include "common/events.h"
36 #include "graphics/transform_struct.h"
37 
38 namespace Wintermute {
39 
40 class BaseSprite;
41 class BaseSound;
42 class BaseSurface;
43 class BaseScriptHolder;
44 class ScValue;
45 class ScStack;
46 class ScScript;
47 class XModel;
48 
49 class BaseObject : public BaseScriptHolder {
50 protected:
51  bool _autoSoundPanning;
52  uint32 _sFXStart;
53  bool setSFXTime(uint32 time);
54  bool setSFXVolume(int volume);
55  bool resumeSFX();
56  bool pauseSFX();
57  bool stopSFX(bool deleteSound = true);
58  bool playSFX(const char *filename, bool looping = false, bool playNow = true, const char *eventName = nullptr, uint32 loopStart = 0);
59  BaseSound *_sFX;
60  TSFXType _sFXType;
61  float _sFXParam1;
62  float _sFXParam2;
63  float _sFXParam3;
64  float _sFXParam4;
65  float _relativeRotate;
66  bool _rotateValid;
67  float _rotate;
68  void setSoundEvent(const char *eventName);
69  bool _rotatable;
70  float _scaleX;
71  float _scaleY;
72  float _relativeScale;
73  bool _editorSelected;
74  bool _editorAlwaysRegister;
75  bool _ready;
76  Rect32 _rect;
77  bool _rectSet;
78  int32 _iD;
79  char *_soundEvent;
80 public:
81  Graphics::TSpriteBlendMode _blendMode;
82 #ifdef ENABLE_WME3D
83  virtual bool renderModel();
84 #endif
85  virtual bool afterMove();
86  float _scale;
87  uint32 _alphaColor;
88  virtual bool isReady();
89  virtual bool getExtendedFlag(const char *flagName);
90  virtual bool resetSoundPan();
91  virtual bool updateSounds();
92  bool updateOneSound(BaseSound *sound);
93  int32 _sFXVolume;
94 
95  virtual bool handleMouseWheel(int32 delta);
96  virtual bool handleMouse(TMouseEvent event, TMouseButton button);
97  virtual bool handleKeypress(Common::Event *event, bool printable = false);
98  virtual int32 getHeight();
99  bool setCursor(const char *filename);
100  bool setActiveCursor(const char *filename);
101  bool cleanup();
102  const char *getCaption(int caseVal = 1);
103  void setCaption(const char *caption, int caseVal = 1);
104 
105  bool _editorOnly;
106  bool _is3D;
107 
108  DECLARE_PERSISTENT(BaseObject, BaseScriptHolder)
109  virtual bool showCursor();
110  BaseSprite *_cursor;
111  bool _sharedCursors;
112  BaseSprite *_activeCursor;
113  bool saveAsText(BaseDynamicBuffer *buffer, int indent) override;
114  bool listen(BaseScriptHolder *param1, uint32 param2) override;
115 
116  bool _movable;
117  bool _zoomable;
118  bool _shadowable;
119  int32 _posY;
120  int32 _posX;
121  bool _registrable;
122  char *_caption[7];
123  bool _saveState;
124 
125  BaseObject(BaseGame *inGame);
126  ~BaseObject() override;
127  // base
128  virtual bool update() {
129  return STATUS_FAILED;
130  };
131  virtual bool display() {
132  return STATUS_FAILED;
133  };
134  virtual bool invalidateDeviceObjects() {
135  return STATUS_OK;
136  };
137  virtual bool restoreDeviceObjects() {
138  return STATUS_OK;
139  };
140  bool _nonIntMouseEvents;
141 
142 #ifdef ENABLE_WME3D
143  float _angle;
144  XModel *_xmodel;
145  XModel *_shadowModel;
146  DXMatrix _worldMatrix;
147  DXVector3 _posVector;
148  bool getMatrix(DXMatrix *modelMatrix, DXVector3 *posVect = nullptr);
149  uint32 _shadowColor;
150  BaseSurface *_shadowImage;
151  float _shadowSize;
152  float _scale3D;
153  DXVector3 _shadowLightPos;
154  bool _drawBackfaces;
155  TShadowType _shadowType;
156 
157  virtual uint32 getAnimTransitionTime(char *from, char *to) {
158  return 0;
159  };
160 #endif
161 
162 public:
163  // scripting interface
164  ScValue *scGetProperty(const Common::String &name) override;
165  bool scSetProperty(const char *name, ScValue *value) override;
166  bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name) override;
167  const char *scToString() override;
168 };
169 
170 } // End of namespace Wintermute
171 
172 #endif
Definition: script.h:44
Definition: base_game.h:76
Definition: script_value.h:42
Definition: str.h:59
Definition: xmath.h:50
Definition: base_dynamic_buffer.h:35
Definition: xmodel.h:54
Definition: rect32.h:60
Definition: events.h:199
Definition: script_stack.h:41
Definition: base_surface.h:38
Definition: base_script_holder.h:37
Definition: base_sound.h:39
Definition: xmath.h:116
Definition: base_sprite.h:40
Definition: base_object.h:49
Definition: achievements_tables.h:27