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 public:
51  char *_accessCaption;
52  //virtual char *GetAccessCaption();
53 
54  Graphics::TSpriteBlendMode _blendMode;
55 #ifdef ENABLE_WME3D
56  virtual bool renderModel();
57 #endif
58  virtual bool afterMove();
59  float _relativeRotate;
60  bool _rotateValid;
61  float _rotate;
62  void setSoundEvent(const char *eventName);
63  bool _rotatable;
64  uint32 _alphaColor;
65  float _scale;
66  float _scaleX;
67  float _scaleY;
68  float _relativeScale;
69  virtual bool isReady();
70  virtual bool getExtendedFlag(const char *flagName);
71  virtual bool resetSoundPan();
72  virtual bool updateSounds();
73  bool updateOneSound(BaseSound *sound);
74  bool _autoSoundPanning;
75  uint32 _sFXStart;
76  int32 _sFXVolume;
77  bool setSFXTime(uint32 time);
78  bool setSFXVolume(int volume);
79  bool resumeSFX();
80  bool pauseSFX();
81  bool stopSFX(bool deleteSound = true);
82  bool playSFX(const char *filename, bool looping = false, bool playNow = true, const char *eventName = nullptr, uint32 loopStart = 0);
83  BaseSound *_sFX;
84 
85  TSFXType _sFXType;
86  float _sFXParam1;
87  float _sFXParam2;
88  float _sFXParam3;
89  float _sFXParam4;
90 
91  virtual bool handleMouseWheel(int32 delta);
92  virtual bool handleMouse(TMouseEvent event, TMouseButton button);
93  virtual bool handleKeypress(Common::Event *event, bool printable = false);
94  virtual int32 getHeight();
95  bool setCursor(const char *filename);
96  bool setActiveCursor(const char *filename);
97  bool cleanup();
98  const char *getCaption(int caseVal = 1);
99  void setCaption(const char *caption, int caseVal = 1);
100  bool _editorSelected;
101  bool _editorAlwaysRegister;
102  bool _editorOnly;
103  bool _is3D;
104 
105  DECLARE_PERSISTENT(BaseObject, BaseScriptHolder)
106  virtual bool showCursor();
107  BaseSprite *_cursor;
108  bool _sharedCursors;
109  BaseSprite *_activeCursor;
110  bool saveAsText(BaseDynamicBuffer *buffer, int indent) override;
111  bool listen(BaseScriptHolder *param1, uint32 param2) override;
112  bool _ready;
113  bool _registrable;
114  bool _zoomable;
115  bool _shadowable;
116  Common::Rect32 _rect;
117  bool _rectSet;
118  int32 _iD;
119  bool _movable;
120  BaseObject(BaseGame *inGame);
121  ~BaseObject() override;
122  char *_caption[7];
123  char *_soundEvent;
124  int32 _posY;
125  int32 _posX;
126  bool _saveState;
127 
128  // base
129  virtual bool update() {
130  return STATUS_FAILED;
131  };
132  virtual bool display() {
133  return STATUS_FAILED;
134  };
135  virtual bool invalidateDeviceObjects() {
136  return STATUS_OK;
137  };
138  virtual bool restoreDeviceObjects() {
139  return STATUS_OK;
140  };
141  bool _nonIntMouseEvents;
142 
143 #ifdef ENABLE_WME3D
144  float _angle;
145  XModel *_xmodel;
146  XModel *_shadowModel;
147  DXMatrix _worldMatrix;
148  DXVector3 _posVector;
149  bool getMatrix(DXMatrix *modelMatrix, DXVector3 *posVect = nullptr);
150  uint32 _shadowColor;
151  BaseSurface *_shadowImage;
152  float _shadowSize;
153  float _scale3D;
154  DXVector3 _shadowLightPos;
155  bool _drawBackfaces;
156  TShadowType _shadowType;
157 
158  virtual uint32 getAnimTransitionTime(char *from, char *to) {
159  return 0;
160  };
161 #endif
162 
163 public:
164  // scripting interface
165  ScValue *scGetProperty(const Common::String &name) override;
166  bool scSetProperty(const char *name, ScValue *value) override;
167  bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name) override;
168  const char *scToString() override;
169 };
170 
171 } // End of namespace Wintermute
172 
173 #endif
Definition: script.h:44
Definition: base_game.h:75
Definition: rect.h:526
Definition: script_value.h:42
Definition: str.h:59
Definition: xmath.h:50
Definition: base_dynamic_buffer.h:35
Definition: xmodel.h:53
Definition: events.h:210
Definition: script_stack.h:41
Definition: base_surface.h:37
Definition: base_script_holder.h:37
Definition: base_sound.h:39
Definition: xmath.h:117
Definition: base_sprite.h:40
Definition: base_object.h:49
Definition: achievements_tables.h:27