22 #ifndef ALCACHOFA_OBJECTS_H 23 #define ALCACHOFA_OBJECTS_H 25 #include "alcachofa/shape.h" 26 #include "alcachofa/graphics.h" 27 #include "alcachofa/menu.h" 29 #include "common/serializer.h" 39 static constexpr
const char *kClassName =
"CObjetoBase";
45 inline Room *&room() {
return _room; }
46 inline Room *room()
const {
return _room; }
47 inline bool isEnabled()
const {
return _isEnabled; }
49 virtual void toggle(
bool isEnabled);
51 virtual void drawDebug();
52 virtual void update();
53 virtual void loadResources();
54 virtual void freeResources();
57 virtual Shape *shape();
58 virtual const char *typeName()
const;
62 bool _isEnabled =
true;
63 Room *_room =
nullptr;
68 static constexpr
const char *kClassName =
"CObjetoPunto";
73 const char *typeName()
const override;
79 enum class GraphicObjectType : byte
88 static constexpr
const char *kClassName =
"CObjetoGrafico";
93 void drawDebug()
override;
94 void loadResources()
override;
95 void freeResources()
override;
98 const char *typeName()
const override;
106 GraphicObjectType _type = GraphicObjectType::Normal;
107 int32 _posterizeAlpha = 100;
112 static constexpr
const char *kClassName =
"CObjetoGraficoMuare";
115 void draw()
override;
116 const char *typeName()
const override;
119 static constexpr
const float kShiftSpeed = 1 / 256.0f;
121 Math::Vector2d _texShift;
129 inline int8 order()
const {
return _order; }
130 inline bool isNewlySelected()
const {
return _isNewlySelected; }
131 inline bool wasSelected()
const {
return _wasSelected; }
133 void update()
override;
135 Shape *shape()
override;
136 virtual CursorType cursorType()
const;
137 virtual void onHoverStart();
138 virtual void onHoverEnd();
139 virtual void onHoverUpdate();
140 virtual void onClick();
141 const char *typeName()
const override;
145 void updateSelection();
151 CursorType _cursorType = CursorType::Point;
152 bool _isNewlySelected =
false,
153 _wasSelected =
false;
158 static constexpr
const char *kClassName =
"CObjetoFisico";
160 const char *typeName()
const override;
165 static constexpr
const char *kClassName =
"CBoton";
168 void loadResources()
override;
169 void draw()
override;
170 void update()
override;
171 void onHoverUpdate()
override;
172 void onClick()
override;
173 const char *typeName()
const override;
178 MainMenuAction _action = {};
181 bool _isHovered =
false;
186 static constexpr
const char *kClassName =
"CBotonMenu";
190 inline int32 actionId()
const {
return _actionId; }
191 inline bool &isInteractable() {
return _isInteractable; }
193 void draw()
override;
194 void update()
override;
195 void loadResources()
override;
196 void freeResources()
override;
197 void onHoverUpdate()
override;
198 void onClick()
override;
199 virtual void trigger();
200 const char *typeName()
const override;
204 _isInteractable =
true,
206 _triggerNextFrame =
false;
221 static constexpr
const char *kClassName =
"CBotonMenuInternet";
224 const char *typeName()
const override;
229 static constexpr
const char *kClassName =
"CBotonMenuOpciones";
232 void update()
override;
233 void trigger()
override;
234 const char *typeName()
const override;
241 void update()
override;
242 void trigger()
override;
247 static constexpr
const char *kClassName =
"CBotonMenuPrincipal";
250 void update()
override;
251 void trigger()
override;
252 const char *typeName()
const override;
254 virtual MainMenuAction action()
const;
262 MainMenuAction action()
const override;
268 static constexpr
const char *kClassName =
"CPushButton";
271 inline bool &isChecked() {
return _isChecked; }
273 void draw()
override;
274 void update()
override;
275 void loadResources()
override;
276 void freeResources()
override;
277 void onHoverUpdate()
override;
278 void onClick()
override;
279 virtual void trigger();
280 const char *typeName()
const override;
283 bool _isChecked =
false;
284 Graphic _graphicHovered, _graphicChecked;
285 int32 _actionId = -1;
286 uint32 _clickTime = 0;
291 static constexpr
const char *kClassName =
"CEditBox";
294 const char *typeName()
const override;
301 int32 i3 = 0, i4 = 0, i5 = 0,
317 static constexpr
const char *kClassName =
"CCheckBox";
321 inline bool &isChecked() {
return _isChecked; }
322 inline int32 actionId()
const {
return _actionId; }
324 void draw()
override;
325 void update()
override;
326 void loadResources()
override;
327 void freeResources()
override;
328 void onHoverUpdate()
override;
329 void onClick()
override;
330 virtual void trigger();
331 const char *typeName()
const override;
343 uint32 _clickTime = 0;
348 static constexpr
const char *kClassName =
"CSlideButton";
351 inline float &value() {
return _value; }
353 void draw()
override;
354 void update()
override;
355 void loadResources()
override;
356 void freeResources()
override;
357 const char *typeName()
const override;
360 bool isMouseOver()
const;
383 static constexpr
const char *kClassName =
"CCheckBoxAutoAjustarRuido";
386 const char *typeName()
const override;
391 static constexpr
const char *kClassName =
"CVentanaIRC";
394 const char *typeName()
const override;
402 static constexpr
const char *kClassName =
"CMessageBox";
406 const char *typeName()
const override;
419 static constexpr
const char *kClassName =
"CVuMeter";
422 const char *typeName()
const override;
427 static constexpr
const char *kClassName =
"CObjetoInventario";
432 void draw()
override;
433 const char *typeName()
const override;
442 inline Direction interactionDirection()
const {
return _interactionDirection; }
443 inline Common::Point interactionPoint()
const {
return _interactionPoint; }
445 virtual void trigger(
const char *action) = 0;
453 Direction _interactionDirection = Direction::Right;
458 static constexpr
const char *kClassName =
"CObjetoTipico";
462 void drawDebug()
override;
463 void onClick()
override;
464 void trigger(
const char *action)
override;
465 void toggle(
bool isEnabled)
override;
466 const char *typeName()
const override;
474 static constexpr
const char *kClassName =
"CPuerta";
477 inline const Common::String &targetRoom()
const {
return _targetRoom; }
478 inline const Common::String &targetObject()
const {
return _targetObject; }
479 inline Direction characterDirection()
const {
return _characterDirection; }
481 CursorType cursorType()
const override;
482 void onClick()
override;
483 void trigger(
const char *action)
override;
484 const char *typeName()
const override;
488 Direction _characterDirection;
489 uint32 _lastClickTime = 0;
494 static constexpr
const char *kClassName =
"CPersonaje";
498 void update()
override;
499 void draw()
override;
500 void drawDebug()
override;
501 void loadResources()
override;
502 void freeResources()
override;
505 void onClick()
override;
506 void trigger(
const char *action)
override;
507 const char *typeName()
const override;
513 Task *lerpLodBias(
Process &process,
float targetLodBias, int32 durationMs);
514 inline float &lodBias() {
return _lodBias; }
515 inline bool &isSpeaking() {
return _isSpeaking; }
518 friend struct SayTextTask;
519 friend struct AnimateCharacterTask;
521 void updateTalkingAnimation();
523 Graphic _graphicNormal, _graphicTalking;
525 bool _isTalking =
false;
526 bool _isSpeaking =
true;
527 int _curDialogId = -1;
528 float _lodBias = 0.0f;
530 *_curAnimateObject =
nullptr,
531 *_curTalkingObject =
nullptr;
536 static constexpr
const char *kClassName =
"CPersonajeAnda";
540 inline bool isWalking()
const {
return _isWalking; }
541 inline Common::Point position()
const {
return _currentPos; }
542 inline float stepSizeFactor()
const {
return _stepSizeFactor; }
544 void update()
override;
545 void draw()
override;
546 void drawDebug()
override;
547 void loadResources()
override;
548 void freeResources()
override;
552 Direction endDirection = Direction::Invalid,
554 const char *activateAction =
nullptr);
555 void stopWalking(Direction direction = Direction::Invalid);
557 const char *typeName()
const override;
562 virtual void onArrived();
563 void updateWalking();
564 void updateWalkingAnimation();
567 Animation *animation = animations[(int)_direction].
get();
568 if (animation ==
nullptr)
569 animation = animations[0].
get();
570 assert(animation !=
nullptr);
573 inline Animation *walkingAnimation() {
return currentAnimationOf(_walkingAnimations); }
574 inline Animation *talkingAnimation() {
return currentAnimationOf(_talkingAnimations); }
577 _walkingAnimations[kDirectionCount],
578 _talkingAnimations[kDirectionCount];
581 _lastWalkAnimFrame = -1,
584 float _stepSizeFactor = 0.0f;
588 bool _isWalking =
false;
590 _direction = Direction::Right,
591 _endWalkingDirection = Direction::Invalid;
596 int32 _dialogId = -1;
597 int32 _yPosition = 0;
598 int32 _returnValue = 0;
603 static constexpr
const char *kClassName =
"CPersonajePrincipal";
607 inline MainCharacterKind kind()
const {
return _kind; }
608 inline ObjectBase *¤tlyUsing() {
return _currentlyUsingObject; }
609 inline ObjectBase *currentlyUsing()
const {
return _currentlyUsingObject; }
610 inline Color &color() {
return _color; }
611 inline uint8 &alphaPremultiplier() {
return _alphaPremultiplier; }
615 void update()
override;
616 void draw()
override;
618 const char *typeName()
const override;
621 Direction endDirection = Direction::Invalid,
623 const char *activateAction =
nullptr)
override;
626 void clearInventory();
630 void addDialogLine(int32 dialogId);
631 void setLastDialogReturnValue(int32 returnValue);
633 void resetUsingObjectAndDialogMenu();
636 void onArrived()
override;
640 friend struct DialogMenuTask;
647 MainCharacterKind _kind;
650 const char *_activateAction =
nullptr;
651 Color _color = kWhite;
652 uint8 _alphaPremultiplier = 255;
658 const char *typeName()
const override;
663 static constexpr
const char *kClassName =
"CSueloColor";
667 void update()
override;
668 void drawDebug()
override;
669 Shape *shape()
override;
670 const char *typeName()
const override;
678 #endif // ALCACHOFA_OBJECTS_H Definition: objects.h:534
Definition: objects.h:425
Definition: alcachofa.h:45
Definition: scheduler.h:84
Definition: scheduler.h:164
Definition: objects.h:257
Definition: objects.h:124
Definition: graphics.h:297
Definition: objects.h:315
Definition: objects.h:110
Definition: objects.h:417
Definition: objects.h:400
Definition: graphics.h:220
Definition: objects.h:655
Definition: objects.h:245
Definition: serializer.h:80
Definition: objects.h:381
Definition: objects.h:492
Definition: objects.h:310
Definition: objects.h:661
Definition: objects.h:305
Definition: objects.h:437
Definition: objects.h:389
Definition: objects.h:601
Definition: objects.h:156
Definition: objects.h:472
Definition: objects.h:456
This fake semaphore does not work in multi-threaded scenarios It is used as a safer option for a simp...
Definition: common.h:93
PointerType get() const
Definition: ptr.h:636
Definition: objects.h:289