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;
239 static constexpr
const char *kClassName =
"CBotonMenuPrincipal";
242 void update()
override;
243 void trigger()
override;
244 const char *typeName()
const override;
249 static constexpr
const char *kClassName =
"CPushButton";
252 const char *typeName()
const override;
262 static constexpr
const char *kClassName =
"CEditBox";
265 const char *typeName()
const override;
272 int32 i3 = 0, i4 = 0, i5 = 0,
288 static constexpr
const char *kClassName =
"CCheckBox";
292 inline bool &isChecked() {
return _isChecked; }
293 inline int32 actionId()
const {
return _actionId; }
295 void draw()
override;
296 void update()
override;
297 void loadResources()
override;
298 void freeResources()
override;
299 void onHoverUpdate()
override;
300 void onClick()
override;
301 virtual void trigger();
302 const char *typeName()
const override;
314 uint32 _clickTime = 0;
319 static constexpr
const char *kClassName =
"CSlideButton";
322 inline float &value() {
return _value; }
324 void draw()
override;
325 void update()
override;
326 void loadResources()
override;
327 void freeResources()
override;
328 const char *typeName()
const override;
331 bool isMouseOver()
const;
354 static constexpr
const char *kClassName =
"CCheckBoxAutoAjustarRuido";
357 const char *typeName()
const override;
362 static constexpr
const char *kClassName =
"CVentanaIRC";
365 const char *typeName()
const override;
373 static constexpr
const char *kClassName =
"CMessageBox";
377 const char *typeName()
const override;
390 static constexpr
const char *kClassName =
"CVuMeter";
393 const char *typeName()
const override;
398 static constexpr
const char *kClassName =
"CObjetoInventario";
403 void draw()
override;
404 const char *typeName()
const override;
413 inline Direction interactionDirection()
const {
return _interactionDirection; }
414 inline Common::Point interactionPoint()
const {
return _interactionPoint; }
416 virtual void trigger(
const char *action) = 0;
424 Direction _interactionDirection = Direction::Right;
429 static constexpr
const char *kClassName =
"CObjetoTipico";
433 void drawDebug()
override;
434 void onClick()
override;
435 void trigger(
const char *action)
override;
436 void toggle(
bool isEnabled)
override;
437 const char *typeName()
const override;
445 static constexpr
const char *kClassName =
"CPuerta";
448 inline const Common::String &targetRoom()
const {
return _targetRoom; }
449 inline const Common::String &targetObject()
const {
return _targetObject; }
450 inline Direction characterDirection()
const {
return _characterDirection; }
452 CursorType cursorType()
const override;
453 void onClick()
override;
454 void trigger(
const char *action)
override;
455 const char *typeName()
const override;
459 Direction _characterDirection;
460 uint32 _lastClickTime = 0;
465 static constexpr
const char *kClassName =
"CPersonaje";
469 void update()
override;
470 void draw()
override;
471 void drawDebug()
override;
472 void loadResources()
override;
473 void freeResources()
override;
476 void onClick()
override;
477 void trigger(
const char *action)
override;
478 const char *typeName()
const override;
484 Task *lerpLodBias(
Process &process,
float targetLodBias, int32 durationMs);
485 inline float &lodBias() {
return _lodBias; }
486 inline bool &isSpeaking() {
return _isSpeaking; }
489 friend struct SayTextTask;
490 friend struct AnimateCharacterTask;
492 void updateTalkingAnimation();
494 Graphic _graphicNormal, _graphicTalking;
496 bool _isTalking =
false;
497 bool _isSpeaking =
true;
498 int _curDialogId = -1;
499 float _lodBias = 0.0f;
501 *_curAnimateObject =
nullptr,
502 *_curTalkingObject =
nullptr;
507 static constexpr
const char *kClassName =
"CPersonajeAnda";
511 inline bool isWalking()
const {
return _isWalking; }
512 inline Common::Point position()
const {
return _currentPos; }
513 inline float stepSizeFactor()
const {
return _stepSizeFactor; }
515 void update()
override;
516 void draw()
override;
517 void drawDebug()
override;
518 void loadResources()
override;
519 void freeResources()
override;
523 Direction endDirection = Direction::Invalid,
525 const char *activateAction =
nullptr);
526 void stopWalking(Direction direction = Direction::Invalid);
528 const char *typeName()
const override;
533 virtual void onArrived();
534 void updateWalking();
535 void updateWalkingAnimation();
538 Animation *animation = animations[(int)_direction].
get();
539 if (animation ==
nullptr)
540 animation = animations[0].
get();
541 assert(animation !=
nullptr);
544 inline Animation *walkingAnimation() {
return currentAnimationOf(_walkingAnimations); }
545 inline Animation *talkingAnimation() {
return currentAnimationOf(_talkingAnimations); }
548 _walkingAnimations[kDirectionCount],
549 _talkingAnimations[kDirectionCount];
552 _lastWalkAnimFrame = -1,
555 float _stepSizeFactor = 0.0f;
559 bool _isWalking =
false;
561 _direction = Direction::Right,
562 _endWalkingDirection = Direction::Invalid;
567 int32 _dialogId = -1;
568 int32 _yPosition = 0;
569 int32 _returnValue = 0;
574 static constexpr
const char *kClassName =
"CPersonajePrincipal";
578 inline MainCharacterKind kind()
const {
return _kind; }
579 inline ObjectBase *¤tlyUsing() {
return _currentlyUsingObject; }
580 inline ObjectBase *currentlyUsing()
const {
return _currentlyUsingObject; }
581 inline Color &color() {
return _color; }
582 inline uint8 &alphaPremultiplier() {
return _alphaPremultiplier; }
586 void update()
override;
587 void draw()
override;
589 const char *typeName()
const override;
592 Direction endDirection = Direction::Invalid,
594 const char *activateAction =
nullptr)
override;
597 void clearInventory();
601 void addDialogLine(int32 dialogId);
602 void setLastDialogReturnValue(int32 returnValue);
604 void resetUsingObjectAndDialogMenu();
607 void onArrived()
override;
611 friend struct DialogMenuTask;
618 MainCharacterKind _kind;
621 const char *_activateAction =
nullptr;
622 Color _color = kWhite;
623 uint8 _alphaPremultiplier = 255;
629 const char *typeName()
const override;
634 static constexpr
const char *kClassName =
"CSueloColor";
638 void update()
override;
639 void drawDebug()
override;
640 Shape *shape()
override;
641 const char *typeName()
const override;
649 #endif // ALCACHOFA_OBJECTS_H Definition: objects.h:505
Definition: objects.h:396
Definition: alcachofa.h:45
Definition: scheduler.h:84
Definition: scheduler.h:164
Definition: objects.h:124
Definition: graphics.h:297
Definition: objects.h:286
Definition: objects.h:110
Definition: objects.h:388
Definition: objects.h:371
Definition: graphics.h:220
Definition: objects.h:626
Definition: objects.h:237
Definition: serializer.h:79
Graphics::Surface * scale(const Graphics::Surface &srcImage, int xSize, int ySize)
Definition: objects.h:352
Definition: objects.h:463
Definition: objects.h:281
Definition: objects.h:632
Definition: objects.h:276
Definition: objects.h:408
Definition: objects.h:360
Definition: objects.h:572
Definition: objects.h:156
Definition: objects.h:443
Definition: objects.h:427
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:260