22 #ifndef ALCACHOFA_OBJECTS_H 23 #define ALCACHOFA_OBJECTS_H 25 #include "alcachofa/shape.h" 26 #include "alcachofa/graphics.h" 28 #include "common/serializer.h" 38 static constexpr
const char *kClassName =
"CObjetoBase";
44 inline Room *&room() {
return _room; }
45 inline Room *room()
const {
return _room; }
46 inline bool isEnabled()
const {
return _isEnabled; }
48 virtual void toggle(
bool isEnabled);
50 virtual void drawDebug();
51 virtual void update();
52 virtual void loadResources();
53 virtual void freeResources();
56 virtual Shape *shape();
57 virtual const char *typeName()
const;
61 bool _isEnabled =
true;
62 Room *_room =
nullptr;
67 static constexpr
const char *kClassName =
"CObjetoPunto";
72 const char *typeName()
const override;
78 enum class GraphicObjectType : byte
87 static constexpr
const char *kClassName =
"CObjetoGrafico";
92 void drawDebug()
override;
93 void loadResources()
override;
94 void freeResources()
override;
97 const char *typeName()
const override;
105 GraphicObjectType _type;
106 int32 _posterizeAlpha;
111 static constexpr
const char *kClassName =
"CObjetoGraficoMuare";
114 void draw()
override;
115 const char *typeName()
const override;
118 static constexpr
const float kShiftSpeed = 1 / 256.0f;
120 Math::Vector2d _texShift;
128 inline int8 order()
const {
return _order; }
129 inline bool isNewlySelected()
const {
return _isNewlySelected; }
130 inline bool wasSelected()
const {
return _wasSelected; }
132 void update()
override;
134 Shape *shape()
override;
135 virtual CursorType cursorType()
const;
136 virtual void onHoverStart();
137 virtual void onHoverEnd();
138 virtual void onHoverUpdate();
139 virtual void onClick();
140 const char *typeName()
const override;
144 void updateSelection();
150 CursorType _cursorType;
151 bool _isNewlySelected =
false,
152 _wasSelected =
false;
158 const char *typeName()
const override;
163 static constexpr
const char *kClassName =
"CBotonMenu";
167 inline int32 actionId()
const {
return _actionId; }
168 inline bool &isInteractable() {
return _isInteractable; }
170 void draw()
override;
171 void update()
override;
172 void loadResources()
override;
173 void freeResources()
override;
174 void onHoverUpdate()
override;
175 void onClick()
override;
176 virtual void trigger();
177 const char *typeName()
const override;
181 _isInteractable =
true,
183 _triggerNextFrame =
false;
198 static constexpr
const char *kClassName =
"CBotonMenuInternet";
201 const char *typeName()
const override;
206 static constexpr
const char *kClassName =
"CBotonMenuOpciones";
209 void update()
override;
210 void trigger()
override;
211 const char *typeName()
const override;
216 static constexpr
const char *kClassName =
"CBotonMenuPrincipal";
219 void update()
override;
220 void trigger()
override;
221 const char *typeName()
const override;
226 static constexpr
const char *kClassName =
"CPushButton";
229 const char *typeName()
const override;
239 static constexpr
const char *kClassName =
"CEditBox";
242 const char *typeName()
const override;
255 static constexpr
const char *kClassName =
"CCheckBox";
259 inline bool &isChecked() {
return _isChecked; }
260 inline int32 actionId()
const {
return _actionId; }
262 void draw()
override;
263 void update()
override;
264 void loadResources()
override;
265 void freeResources()
override;
266 void onHoverUpdate()
override;
267 void onClick()
override;
268 virtual void trigger();
269 const char *typeName()
const override;
281 uint32 _clickTime = 0;
286 static constexpr
const char *kClassName =
"CSlideButton";
290 inline float &value() {
return _value; }
292 void draw()
override;
293 void update()
override;
294 void loadResources()
override;
295 void freeResources()
override;
296 const char *typeName()
const override;
299 bool isMouseOver()
const;
312 static constexpr
const char *kClassName =
"CCheckBoxAutoAjustarRuido";
315 const char *typeName()
const override;
320 static constexpr
const char *kClassName =
"CVentanaIRC";
323 const char *typeName()
const override;
331 static constexpr
const char *kClassName =
"CMessageBox";
335 const char *typeName()
const override;
348 static constexpr
const char *kClassName =
"CVuMeter";
351 const char *typeName()
const override;
356 static constexpr
const char *kClassName =
"CObjetoInventario";
361 void draw()
override;
362 const char *typeName()
const override;
371 inline Direction interactionDirection()
const {
return _interactionDirection; }
372 inline Common::Point interactionPoint()
const {
return _interactionPoint; }
374 virtual void trigger(
const char *action) = 0;
380 Direction _interactionDirection = Direction::Right;
385 static constexpr
const char *kClassName =
"CObjetoTipico";
389 void drawDebug()
override;
390 void onClick()
override;
391 void trigger(
const char *action)
override;
392 void toggle(
bool isEnabled)
override;
393 const char *typeName()
const override;
401 static constexpr
const char *kClassName =
"CPuerta";
404 inline const Common::String &targetRoom()
const {
return _targetRoom; }
405 inline const Common::String &targetObject()
const {
return _targetObject; }
406 inline Direction characterDirection()
const {
return _characterDirection; }
408 CursorType cursorType()
const override;
409 void onClick()
override;
410 void trigger(
const char *action)
override;
411 const char *typeName()
const override;
415 Direction _characterDirection;
416 uint32 _lastClickTime = 0;
421 static constexpr
const char *kClassName =
"CPersonaje";
425 void update()
override;
426 void draw()
override;
427 void drawDebug()
override;
428 void loadResources()
override;
429 void freeResources()
override;
432 void onClick()
override;
433 void trigger(
const char *action)
override;
434 const char *typeName()
const override;
440 Task *lerpLodBias(
Process &process,
float targetLodBias, int32 durationMs);
441 inline float &lodBias() {
return _lodBias; }
442 inline bool &isSpeaking() {
return _isSpeaking; }
445 friend struct SayTextTask;
446 friend struct AnimateCharacterTask;
448 void updateTalkingAnimation();
450 Graphic _graphicNormal, _graphicTalking;
452 bool _isTalking =
false;
453 bool _isSpeaking =
true;
454 int _curDialogId = -1;
455 float _lodBias = 0.0f;
457 *_curAnimateObject =
nullptr,
458 *_curTalkingObject =
nullptr;
463 static constexpr
const char *kClassName =
"CPersonajeAnda";
467 inline bool isWalking()
const {
return _isWalking; }
468 inline Common::Point position()
const {
return _currentPos; }
469 inline float stepSizeFactor()
const {
return _stepSizeFactor; }
471 void update()
override;
472 void draw()
override;
473 void drawDebug()
override;
474 void loadResources()
override;
475 void freeResources()
override;
479 Direction endDirection = Direction::Invalid,
481 const char *activateAction =
nullptr);
482 void stopWalking(Direction direction = Direction::Invalid);
484 const char *typeName()
const override;
489 virtual void onArrived();
490 void updateWalking();
491 void updateWalkingAnimation();
494 Animation *animation = animations[(int)_direction].
get();
495 if (animation ==
nullptr)
496 animation = animations[0].
get();
497 assert(animation !=
nullptr);
500 inline Animation *walkingAnimation() {
return currentAnimationOf(_walkingAnimations); }
501 inline Animation *talkingAnimation() {
return currentAnimationOf(_talkingAnimations); }
504 _walkingAnimations[kDirectionCount],
505 _talkingAnimations[kDirectionCount];
508 _lastWalkAnimFrame = -1,
511 float _stepSizeFactor = 0.0f;
515 bool _isWalking =
false;
517 _direction = Direction::Right,
518 _endWalkingDirection = Direction::Invalid;
523 int32 _dialogId = -1;
524 int32 _yPosition = 0;
525 int32 _returnValue = 0;
530 static constexpr
const char *kClassName =
"CPersonajePrincipal";
534 inline MainCharacterKind kind()
const {
return _kind; }
535 inline ObjectBase *¤tlyUsing() {
return _currentlyUsingObject; }
536 inline ObjectBase *currentlyUsing()
const {
return _currentlyUsingObject; }
537 inline Color &color() {
return _color; }
538 inline uint8 &alphaPremultiplier() {
return _alphaPremultiplier; }
542 void update()
override;
543 void draw()
override;
545 const char *typeName()
const override;
548 Direction endDirection = Direction::Invalid,
550 const char *activateAction =
nullptr)
override;
553 void clearInventory();
557 void addDialogLine(int32 dialogId);
558 void setLastDialogReturnValue(int32 returnValue);
560 void resetUsingObjectAndDialogMenu();
563 void onArrived()
override;
567 friend struct DialogMenuTask;
574 MainCharacterKind _kind;
577 const char *_activateAction =
nullptr;
578 Color _color = kWhite;
579 uint8 _alphaPremultiplier = 255;
585 const char *typeName()
const override;
590 static constexpr
const char *kClassName =
"CSueloColor";
594 void update()
override;
595 void drawDebug()
override;
596 Shape *shape()
override;
597 const char *typeName()
const override;
605 #endif // ALCACHOFA_OBJECTS_H Definition: objects.h:461
Definition: objects.h:354
Definition: alcachofa.h:45
Definition: scheduler.h:84
Definition: scheduler.h:164
Definition: objects.h:123
Definition: graphics.h:257
Definition: objects.h:253
Definition: objects.h:109
Definition: objects.h:346
Definition: objects.h:329
Definition: graphics.h:184
Definition: objects.h:582
Definition: objects.h:214
Definition: serializer.h:79
Graphics::Surface * scale(const Graphics::Surface &srcImage, int xSize, int ySize)
Definition: objects.h:310
Definition: objects.h:419
Definition: objects.h:588
Definition: objects.h:366
Definition: objects.h:318
Definition: objects.h:528
Definition: objects.h:155
Definition: objects.h:399
Definition: objects.h:383
This fake semaphore does not work in multi-threaded scenarios It is used as a safer option for a simp...
Definition: common.h:84
PointerType get() const
Definition: ptr.h:636
Definition: objects.h:237