Etterna 0.74.4
Loading...
Searching...
No Matches
Actor.h
1#ifndef ACTOR_H
2#define ACTOR_H
3
4#include "Etterna/Models/Misc/EnumHelper.h"
5#include "Etterna/Models/Lua/LuaReference.h"
6#include "RageUtil/Misc/RageTypes.h"
7#include "Etterna/Singletons/MessageManager.h"
8#include "Tween.h"
9
10#include <map>
11
12class XNode;
13struct lua_State;
14class LuaClass;
15
16using apActorCommands = std::shared_ptr<LuaReference>;
17
19#define DRAW_ORDER_BEFORE_EVERYTHING (-200)
21#define DRAW_ORDER_UNDERLAY (-100)
23#define DRAW_ORDER_DECORATIONS 0
27#define DRAW_ORDER_OVERLAY (+100)
29#define DRAW_ORDER_TRANSITIONS (+200)
31#define DRAW_ORDER_AFTER_EVERYTHING (+300)
32
34enum HorizAlign
35{
36 HorizAlign_Left,
37 HorizAlign_Center,
38 HorizAlign_Right,
39 NUM_HorizAlign,
40 HorizAlign_Invalid
41};
42LuaDeclareType(HorizAlign);
43
45enum VertAlign
46{
47 VertAlign_Top,
48 VertAlign_Middle,
49 VertAlign_Bottom,
50 NUM_VertAlign,
51 VertAlign_Invalid
52};
53LuaDeclareType(VertAlign);
54
56#define align_left 0.0f
58#define align_center 0.5f
60#define align_right 1.0f
62#define align_top 0.0f
64#define align_middle 0.5f
66#define align_bottom 1.0f
67
68// This is the number of colors in Actor::diffuse. Actor has multiple
69// diffuse colors so that each edge can be a different color, and the actor
70// is drawn with a gradient between them.
71// I doubt I actually found all the places that touch diffuse and rely on the
72// number of diffuse colors, so change this at your own risk. -Kyz
73#define NUM_DIFFUSE_COLORS 4
74
77{
78 public:
80 Actor();
84 Actor(const Actor& cpy);
85 ~Actor() override;
86 Actor& operator=(const Actor& x);
87 [[nodiscard]] virtual auto Copy() const -> Actor*;
88 virtual void InitState();
89 virtual void LoadFromNode(const XNode* pNode);
90
91 static void SetBGMTime(float fTime,
92 float fBeat,
93 float fTimeNoOffset,
94 float fBeatNoOffset);
95 static void SetPlayerBGMBeat(float fBeat, float fBeatNoOffset);
96
103 {
104 no_effect,
105 diffuse_blink,
106 diffuse_shift,
107 diffuse_ramp,
108 glow_blink,
109 glow_shift,
110 glow_ramp,
111 rainbow,
112 wag,
113 bounce,
114 bob,
115 pulse,
116 spin,
117 vibrate
118 };
119
122 {
123 CLOCK_TIMER,
124 CLOCK_TIMER_GLOBAL,
125 CLOCK_BGM_TIME,
126 CLOCK_BGM_BEAT,
127 CLOCK_BGM_TIME_NO_OFFSET,
128 CLOCK_BGM_BEAT_NO_OFFSET,
129 CLOCK_BGM_BEAT_PLAYER1,
130 CLOCK_BGM_BEAT_PLAYER2,
131 CLOCK_LIGHT_1 = 1000,
132 CLOCK_LIGHT_LAST = 1100,
133 NUM_CLOCKS
134 };
135
140 {
141 void Init();
142 static void MakeWeightedAverage(TweenState& average_out,
143 const TweenState& ts1,
144 const TweenState& ts2,
145 float fPercentBetween);
146 auto operator==(const TweenState& other) const -> bool;
147 auto operator!=(const TweenState& other) const -> bool
148 {
149 return !operator==(other);
150 }
151
152 // start and end position for tweening
153 RageVector3 pos;
154 RageVector3 rotation;
155 RageVector4 quat;
156 RageVector3 scale;
157 float fSkewX{}, fSkewY{};
172 RageColor diffuse[NUM_DIFFUSE_COLORS];
176 float aux{};
177 };
178
179 // PartiallyOpaque broken out of Draw for reuse and clarity.
180 [[nodiscard]] auto PartiallyOpaque() const -> bool;
181 auto IsOver(float mx, float my) -> bool;
182
183 auto GetFakeParentOrParent() -> Actor*; // fake parent > parent -mina
184 auto GetTrueX() -> float; // recursive with parent (for mouseovers) -mina
185 auto GetTrueY() -> float; // same
186 auto GetTrueZ() -> float;
187 auto GetTrueRotationX() -> float;
188 auto GetTrueRotationY() -> float;
189 auto GetTrueRotationZ() -> float; // same
190 auto GetTrueZoom() -> float; // same
191 auto GetTrueZoomX() -> float;
192 auto GetTrueZoomY() -> float;
193 auto GetTrueZoomZ() -> float;
194 auto IsVisible() -> bool; // same but for gating updates on things that may
195 // not explicitly set visible = false -mina
196
206 void Draw();
213 [[nodiscard]] virtual auto EarlyAbortDraw() const -> bool { return false; }
215 virtual void PreDraw();
217 virtual void PostDraw();
220 virtual void BeginDraw();
226 virtual void SetGlobalRenderStates();
231 virtual void SetTextureRenderStates();
236 virtual void DrawPrimitives(){};
238 virtual void EndDraw();
239
240 // TODO(Sam): make Update non virtual and change all classes to override
241 // UpdateInternal instead.
242 virtual void Update(
243 float fDeltaTime); // this can short circuit UpdateInternal
244 virtual void UpdateInternal(float fDeltaTime); // override this
245 void UpdateTweening(float fDeltaTime);
246 void CalcPercentThroughTween();
247 // These next functions should all be overridden by a derived class that has
248 // its own tweening states to handle.
249 virtual void SetCurrentTweenStart() {}
250 virtual void EraseHeadTween() {}
251 virtual void UpdatePercentThroughTween(float PercentThroughTween) {}
252
253 [[nodiscard]] auto get_tween_uses_effect_delta() const -> bool
254 {
255 return m_tween_uses_effect_delta;
256 }
257 void set_tween_uses_effect_delta(bool t) { m_tween_uses_effect_delta = t; }
258
262 [[nodiscard]] auto GetName() const -> const std::string& { return m_sName; }
266 virtual void SetName(const std::string& sName) { m_sName = sName; }
270 void SetParent(Actor* pParent);
274 [[nodiscard]] auto GetParent() const -> Actor* { return m_pParent; }
278 [[nodiscard]] auto GetLineage() const -> std::string;
279
280 void SetFakeParent(Actor* mailman) { m_FakeParent = mailman; }
281 [[nodiscard]] auto GetFakeParent() const -> Actor* { return m_FakeParent; }
282
283 void AddWrapperState();
284 void RemoveWrapperState(size_t i);
285 auto GetWrapperState(size_t i) -> Actor*;
286 [[nodiscard]] auto GetNumWrapperStates() const -> size_t
287 {
288 return m_WrapperStates.size();
289 }
290
294 [[nodiscard]] auto GetX() const -> float { return m_current.pos.x; };
298 [[nodiscard]] auto GetY() const -> float { return m_current.pos.y; };
302 [[nodiscard]] auto GetZ() const -> float { return m_current.pos.z; };
303 [[nodiscard]] auto GetDestX() const -> float
304 {
305 return DestTweenState().pos.x;
306 };
307 [[nodiscard]] auto GetDestY() const -> float
308 {
309 return DestTweenState().pos.y;
310 };
311 [[nodiscard]] auto GetDestZ() const -> float
312 {
313 return DestTweenState().pos.z;
314 };
315 void SetX(float x) { DestTweenState().pos.x = x; };
316 void SetY(float y) { DestTweenState().pos.y = y; };
317 void SetZ(float z) { DestTweenState().pos.z = z; };
318 void SetXY(float x, float y)
319 {
320 DestTweenState().pos.x = x;
321 DestTweenState().pos.y = y;
322 };
326 void AddX(float x) { SetX(GetDestX() + x); }
330 void AddY(float y) { SetY(GetDestY() + y); }
334 void AddZ(float z) { SetZ(GetDestZ() + z); }
335
336 // height and width vary depending on zoom
337 [[nodiscard]] auto GetUnzoomedWidth() const -> float { return m_size.x; }
338 [[nodiscard]] auto GetUnzoomedHeight() const -> float { return m_size.y; }
339
340 [[nodiscard]] auto GetZoomedWidth() const -> float
341 {
342 return m_size.x * m_baseScale.x * DestTweenState().scale.x;
343 }
344
345 [[nodiscard]] auto GetZoomedHeight() const -> float
346 {
347 return m_size.y * m_baseScale.y * DestTweenState().scale.y;
348 }
349 void SetWidth(float width) { m_size.x = width; }
350 void SetHeight(float height) { m_size.y = height; }
351
352 // Base values
353 [[nodiscard]] auto GetBaseZoomX() const -> float { return m_baseScale.x; }
354 void SetBaseZoomX(float zoom) { m_baseScale.x = zoom; }
355 [[nodiscard]] auto GetBaseZoomY() const -> float { return m_baseScale.y; }
356 void SetBaseZoomY(float zoom) { m_baseScale.y = zoom; }
357 [[nodiscard]] auto GetBaseZoomZ() const -> float { return m_baseScale.z; }
358 void SetBaseZoomZ(float zoom) { m_baseScale.z = zoom; }
359 void SetBaseZoom(float zoom)
360 {
361 m_baseScale = RageVector3(zoom, zoom, zoom);
362 }
363 void SetBaseRotationX(float rot) { m_baseRotation.x = rot; }
364 void SetBaseRotationY(float rot) { m_baseRotation.y = rot; }
365 void SetBaseRotationZ(float rot) { m_baseRotation.z = rot; }
366 void SetBaseRotation(const RageVector3& rot) { m_baseRotation = rot; }
367 virtual void SetBaseAlpha(float fAlpha) { m_fBaseAlpha = fAlpha; }
368 void SetInternalDiffuse(const RageColor& c) { m_internalDiffuse = c; }
369 void SetInternalGlow(const RageColor& c) { m_internalGlow = c; }
370
377 [[nodiscard]] auto GetZoom() const -> float
378 {
379 return DestTweenState().scale.x;
380 }
384 [[nodiscard]] auto GetZoomX() const -> float
385 {
386 return DestTweenState().scale.x;
387 }
391 [[nodiscard]] auto GetZoomY() const -> float
392 {
393 return DestTweenState().scale.y;
394 }
398 [[nodiscard]] auto GetZoomZ() const -> float
399 {
400 return DestTweenState().scale.z;
401 }
405 void SetZoom(float zoom)
406 {
407 DestTweenState().scale.x = zoom;
408 DestTweenState().scale.y = zoom;
409 DestTweenState().scale.z = zoom;
410 }
414 void SetZoomX(float zoom) { DestTweenState().scale.x = zoom; }
418 void SetZoomY(float zoom) { DestTweenState().scale.y = zoom; }
422 void SetZoomZ(float zoom) { DestTweenState().scale.z = zoom; }
423 void ZoomTo(float fX, float fY)
424 {
425 ZoomToWidth(fX);
426 ZoomToHeight(fY);
427 }
428 void ZoomToWidth(float zoom) { SetZoomX(zoom / GetUnzoomedWidth()); }
429 void ZoomToHeight(float zoom) { SetZoomY(zoom / GetUnzoomedHeight()); }
430
431 [[nodiscard]] auto GetRotationX() const -> float
432 {
433 return DestTweenState().rotation.x;
434 }
435 [[nodiscard]] auto GetRotationY() const -> float
436 {
437 return DestTweenState().rotation.y;
438 }
439 [[nodiscard]] auto GetRotationZ() const -> float
440 {
441 return DestTweenState().rotation.z;
442 }
443 void SetRotationX(float rot) { DestTweenState().rotation.x = rot; }
444 void SetRotationY(float rot) { DestTweenState().rotation.y = rot; }
445 void SetRotationZ(float rot) { DestTweenState().rotation.z = rot; }
446 // added in StepNXA, now available in sm-ssc:
447 void AddRotationX(float rot) { DestTweenState().rotation.x += rot; };
448 void AddRotationY(float rot) { DestTweenState().rotation.y += rot; };
449 void AddRotationZ(float rot) { DestTweenState().rotation.z += rot; };
450 // and these were normally in SM:
451 void AddRotationH(float rot);
452 void AddRotationP(float rot);
453 void AddRotationR(float rot);
454
455 void SetSkewX(float fAmount) { DestTweenState().fSkewX = fAmount; }
456
457 [[nodiscard]] auto GetSkewX(float /* fAmount */) const -> float
458 {
459 return DestTweenState().fSkewX;
460 }
461 void SetSkewY(float fAmount) { DestTweenState().fSkewY = fAmount; }
462
463 [[nodiscard]] auto GetSkewY(float /* fAmount */) const -> float
464 {
465 return DestTweenState().fSkewY;
466 }
467
468 [[nodiscard]] auto GetCropLeft() const -> float
469 {
470 return DestTweenState().crop.left;
471 }
472 [[nodiscard]] auto GetCropTop() const -> float
473 {
474 return DestTweenState().crop.top;
475 }
476 [[nodiscard]] auto GetCropRight() const -> float
477 {
478 return DestTweenState().crop.right;
479 }
480 [[nodiscard]] auto GetCropBottom() const -> float
481 {
482 return DestTweenState().crop.bottom;
483 }
484 void SetCropLeft(float percent) { DestTweenState().crop.left = percent; }
485 void SetCropTop(float percent) { DestTweenState().crop.top = percent; }
486 void SetCropRight(float percent) { DestTweenState().crop.right = percent; }
487 void SetCropBottom(float percent)
488 {
489 DestTweenState().crop.bottom = percent;
490 }
491
492 void SetFadeLeft(float percent) { DestTweenState().fade.left = percent; }
493 void SetFadeTop(float percent) { DestTweenState().fade.top = percent; }
494 void SetFadeRight(float percent) { DestTweenState().fade.right = percent; }
495 void SetFadeBottom(float percent)
496 {
497 DestTweenState().fade.bottom = percent;
498 }
499
500 void SetGlobalDiffuseColor(const RageColor& c);
501
502 virtual void SetDiffuse(const RageColor& c)
503 {
504 for (auto& i : DestTweenState().diffuse) {
505 i = c;
506 }
507 };
508 virtual void SetDiffuseAlpha(float f)
509 {
510 for (auto i = 0; i < NUM_DIFFUSE_COLORS; ++i) {
511 auto c = GetDiffuses(i);
512 c.a = f;
513 SetDiffuses(i, c);
514 }
515 }
516
517 [[nodiscard]] auto GetCurrentDiffuseAlpha() const -> float
518 {
519 return m_current.diffuse[0].a;
520 }
521 void SetDiffuseColor(const RageColor& c);
522 void SetDiffuses(int i, const RageColor& c)
523 {
524 DestTweenState().diffuse[i] = c;
525 };
526 void SetDiffuseUpperLeft(const RageColor& c)
527 {
528 DestTweenState().diffuse[0] = c;
529 };
530 void SetDiffuseUpperRight(const RageColor& c)
531 {
532 DestTweenState().diffuse[1] = c;
533 };
534 void SetDiffuseLowerLeft(const RageColor& c)
535 {
536 DestTweenState().diffuse[2] = c;
537 };
538 void SetDiffuseLowerRight(const RageColor& c)
539 {
540 DestTweenState().diffuse[3] = c;
541 };
542 void SetDiffuseTopEdge(const RageColor& c)
543 {
544 DestTweenState().diffuse[0] = DestTweenState().diffuse[1] = c;
545 };
546 void SetDiffuseRightEdge(const RageColor& c)
547 {
548 DestTweenState().diffuse[1] = DestTweenState().diffuse[3] = c;
549 };
550 void SetDiffuseBottomEdge(const RageColor& c)
551 {
552 DestTweenState().diffuse[2] = DestTweenState().diffuse[3] = c;
553 };
554 void SetDiffuseLeftEdge(const RageColor& c)
555 {
556 DestTweenState().diffuse[0] = DestTweenState().diffuse[2] = c;
557 };
558 [[nodiscard]] auto GetDiffuse() const -> RageColor
559 {
560 return DestTweenState().diffuse[0];
561 };
562 [[nodiscard]] auto GetDiffuses(int i) const -> RageColor
563 {
564 return DestTweenState().diffuse[i];
565 };
566 [[nodiscard]] auto GetDiffuseAlpha() const -> float
567 {
568 return DestTweenState().diffuse[0].a;
569 };
570 void SetGlow(const RageColor& c) { DestTweenState().glow = c; };
571 [[nodiscard]] auto GetGlow() const -> RageColor
572 {
573 return DestTweenState().glow;
574 };
575
576 void SetAux(float f) { DestTweenState().aux = f; }
577 [[nodiscard]] auto GetAux() const -> float { return m_current.aux; }
578
579 virtual void BeginTweening(float time, ITween* pInterp);
580 virtual void BeginTweening(float time, TweenType tt = TWEEN_LINEAR);
581 virtual void StopTweening();
582 void Sleep(float time);
583 void QueueCommand(const std::string& sCommandName);
584 void QueueMessage(const std::string& sMessageName);
585 virtual void FinishTweening();
586 virtual void HurryTweening(float factor);
587 // Let ActorFrame and BGAnimation override
588 [[nodiscard]] virtual auto GetTweenTimeLeft() const
589 -> float; // Amount of time until all tweens have stopped
590 auto DestTweenState()
591 -> TweenState& // where Actor will end when its tween finish
592 {
593 if (m_Tweens.empty()) { // not tweening
594 return m_current;
595 }
596 {
597 return m_Tweens.back()->state;
598 }
599 }
600
601 [[nodiscard]] auto DestTweenState() const -> const TweenState&
602 {
603 return const_cast<Actor*>(this)->DestTweenState();
604 }
605
608 {
609 fit_inside,
611 cover
612 };
613
614 void ScaleToCover(const RectF& rect) { ScaleTo(rect, cover); }
615 void ScaleToFitInside(const RectF& rect) { ScaleTo(rect, fit_inside); };
616 void ScaleTo(const RectF& rect, StretchType st);
617
618 void StretchTo(const RectF& rect);
619
620 // Alignment settings. These need to be virtual for BitmapText
621 virtual void SetHorizAlign(float f) { m_fHorizAlign = f; }
622 virtual void SetVertAlign(float f) { m_fVertAlign = f; }
623 void SetHorizAlign(HorizAlign ha)
624 {
625 SetHorizAlign((ha == HorizAlign_Left)
626 ? 0.0F
627 : (ha == HorizAlign_Center) ? 0.5F : +1.0F);
628 }
629 void SetVertAlign(VertAlign va)
630 {
631 SetVertAlign((va == VertAlign_Top)
632 ? 0.0F
633 : (va == VertAlign_Middle) ? 0.5F : +1.0F);
634 }
635 virtual auto GetHorizAlign() -> float { return m_fHorizAlign; }
636 virtual auto GetVertAlign() -> float { return m_fVertAlign; }
637
638 // effects
639#if defined(SSC_FUTURES)
640 void StopEffects();
641 Effect GetEffect(int i) const { return m_Effects[i]; }
642#else
643 void StopEffect() { m_Effect = no_effect; }
644 [[nodiscard]] auto GetEffect() const -> Effect { return m_Effect; }
645#endif
646 [[nodiscard]] auto GetSecsIntoEffect() const -> float
647 {
648 return m_fSecsIntoEffect;
649 }
650 [[nodiscard]] auto GetEffectDelta() const -> float
651 {
652 return m_fEffectDelta;
653 }
654
655 // todo: account for SSC_FUTURES by adding an effect as an arg to each one
656 // -aj
657 void SetEffectColor1(const RageColor& c) { m_effectColor1 = c; }
658 void SetEffectColor2(const RageColor& c) { m_effectColor2 = c; }
659 void RecalcEffectPeriod();
660 void SetEffectPeriod(float fTime);
661 [[nodiscard]] auto GetEffectPeriod() const -> float
662 {
663 return m_effect_period;
664 }
665 auto SetEffectTiming(float ramp_toh,
666 float at_half,
667 float ramp_tof,
668 float at_zero,
669 float at_full,
670 std::string& err) -> bool;
671 auto SetEffectHoldAtFull(float haf, std::string& err) -> bool;
672 void SetEffectOffset(float fTime) { m_fEffectOffset = fTime; }
673 void SetEffectClock(EffectClock c) { m_EffectClock = c; }
674 void SetEffectClockString(const std::string& s); // convenience
675
676 void SetEffectMagnitude(const RageVector3& vec)
677 {
678 m_vEffectMagnitude = vec;
679 }
680
681 [[nodiscard]] auto GetEffectMagnitude() const -> RageVector3
682 {
683 return m_vEffectMagnitude;
684 }
685
686 void ResetEffectTimeIfDifferent(Effect new_effect);
687 void SetEffectDiffuseBlink(float fEffectPeriodSeconds,
688 const RageColor& c1,
689 const RageColor& c2);
690 void SetEffectDiffuseShift(float fEffectPeriodSeconds,
691 const RageColor& c1,
692 const RageColor& c2);
693 void SetEffectDiffuseRamp(float fEffectPeriodSeconds,
694 const RageColor& c1,
695 const RageColor& c2);
696 void SetEffectGlowBlink(float fEffectPeriodSeconds,
697 const RageColor& c1,
698 const RageColor& c2);
699 void SetEffectGlowShift(float fEffectPeriodSeconds,
700 const RageColor& c1,
701 const RageColor& c2);
702 void SetEffectGlowRamp(float fEffectPeriodSeconds,
703 const RageColor& c1,
704 const RageColor& c2);
705 void SetEffectRainbow(float fEffectPeriodSeconds);
706 void SetEffectWag(float fPeriod, const RageVector3& vect);
707 void SetEffectBounce(float fPeriod, const RageVector3& vect);
708 void SetEffectBob(float fPeriod, const RageVector3& vect);
709 void SetEffectPulse(float fPeriod, float fMinZoom, float fMaxZoom);
710 void SetEffectSpin(const RageVector3& vect);
711 void SetEffectVibrate(const RageVector3& vect);
712
713 // other properties
717 [[nodiscard]] auto GetVisible() const -> bool { return m_bVisible; }
718 void SetVisible(bool b) { m_bVisible = b; }
719 void SetShadowLength(float fLength)
720 {
721 m_fShadowLengthX = fLength;
722 m_fShadowLengthY = fLength;
723 }
724 void SetShadowLengthX(float fLengthX) { m_fShadowLengthX = fLengthX; }
725 void SetShadowLengthY(float fLengthY) { m_fShadowLengthY = fLengthY; }
726 void SetShadowColor(const RageColor& c) { m_ShadowColor = c; }
727 // TODO(Sam): Implement hibernate as a tween type?
728 void SetDrawOrder(int iOrder) { m_iDrawOrder = iOrder; }
729 [[nodiscard]] auto GetDrawOrder() const -> int { return m_iDrawOrder; }
730
731 virtual void EnableAnimation(bool b)
732 {
733 m_bIsAnimating = b;
734 } // Sprite needs to overload this
735 void StartAnimating() { this->EnableAnimation(true); }
736 void StopAnimating() { this->EnableAnimation(false); }
737
738 // render states
739 void SetBlendMode(BlendMode mode) { m_BlendMode = mode; }
740 void SetTextureTranslate(float x, float y)
741 {
742 m_texTranslate.x = x;
743 m_texTranslate.y = y;
744 }
745 void SetTextureWrapping(bool b) { m_bTextureWrapping = b; }
746 void SetTextureFiltering(bool b) { m_bTextureFiltering = b; }
747 void SetClearZBuffer(bool b) { m_bClearZBuffer = b; }
748 void SetUseZBuffer(bool b)
749 {
750 SetZTestMode(b ? ZTEST_WRITE_ON_PASS : ZTEST_OFF);
751 SetZWrite(b);
752 }
753 virtual void SetZTestMode(ZTestMode mode) { m_ZTestMode = mode; }
754 virtual void SetZWrite(bool b) { m_bZWrite = b; }
755 void SetZBias(float f) { m_fZBias = f; }
756 virtual void SetCullMode(CullMode mode) { m_CullMode = mode; }
757
758 // Lua
759 virtual void PushSelf(lua_State* L);
760 virtual void PushContext(lua_State* L);
761
762 // Named commands
763 void AddCommand(const std::string& sCmdName,
764 const apActorCommands& apac,
765 bool warn = true);
766 [[nodiscard]] auto HasCommand(const std::string& sCmdName) const -> bool;
767 [[nodiscard]] auto GetCommand(const std::string& sCommandName) const
768 -> const apActorCommands*;
769 void PlayCommand(const std::string& sCommandName)
770 {
771 HandleMessage(Message(sCommandName));
772 } // convenience
773 void PlayCommandNoRecurse(const Message& msg);
774
775 // Commands by reference
776 virtual void RunCommands(const LuaReference& cmds,
777 const LuaReference* pParamTable = nullptr);
778
779 virtual void RunCommands(const apActorCommands& cmds,
780 const LuaReference* pParamTable = nullptr)
781 {
782 this->RunCommands(*cmds, pParamTable);
783 } // convenience
784 virtual void RunCommandsRecursively(
785 const LuaReference& cmds,
786 const LuaReference* pParamTable = nullptr)
787 {
788 RunCommands(cmds, pParamTable);
789 }
790 // If we're a leaf, then execute this command.
791 virtual void RunCommandsOnLeaves(const LuaReference& cmds,
792 const LuaReference* pParamTable = nullptr)
793 {
794 RunCommands(cmds, pParamTable);
795 }
796
797 // Messages
798 void HandleMessage(const Message& msg) override;
799
800 // Animation
801 [[nodiscard]] virtual auto GetNumStates() const -> int { return 1; }
802 virtual void SetState(int /* iNewState */) {}
803 [[nodiscard]] virtual auto GetAnimationLengthSeconds() const -> float
804 {
805 return 0;
806 }
807 virtual void SetSecondsIntoAnimation(float /*unused*/) {}
808 virtual void SetUpdateRate(float /*unused*/) {}
809 virtual auto GetUpdateRate() -> float { return 1.0F; }
810
811 std::unique_ptr<LuaClass> m_pLuaInstance;
812
813 protected:
815 std::string m_sName;
818 // m_FakeParent exists to provide a way to render the actor inside another's
819 // state without making that actor the parent. It's like having multiple
820 // parents. -Kyz
821 Actor* m_FakeParent;
822 // WrapperStates provides a way to wrap the actor inside ActorFrames,
823 // applicable to any actor, not just ones the theme creates.
824 std::vector<Actor*> m_WrapperStates;
825
828 {
829 // counters for tweening
830 TweenInfo();
831 ~TweenInfo();
832 TweenInfo(const TweenInfo& cpy);
833 auto operator=(const TweenInfo& rhs) -> TweenInfo&;
834
835 ITween* m_pTween;
843 std::string m_sCommandName;
844 };
845
846 RageVector3 m_baseRotation;
847 RageVector3 m_baseScale;
848 float m_fBaseAlpha{};
849 RageColor m_internalDiffuse;
850 RageColor m_internalGlow;
851
852 RageVector2 m_size;
853 TweenState m_current;
854 TweenState m_start;
856 {
857 TweenState state;
858 TweenInfo info;
859 };
860 std::vector<TweenStateAndInfo*> m_Tweens;
861
864
865 // Stuff for alignment
874
875 // Stuff for effects
876#if defined(SSC_FUTURES) // be able to stack effects
877 std::vector<Effect> m_Effects;
878#else // compatibility
879 Effect m_Effect;
880#endif
881 float m_fSecsIntoEffect{};
882 float m_fEffectDelta{};
883
884 // units depend on m_EffectClock
885 float m_effect_ramp_to_half{};
886 float m_effect_hold_at_half{};
887 float m_effect_ramp_to_full{};
888 float m_effect_hold_at_full{};
889 float m_effect_hold_at_zero{};
890 float m_fEffectOffset{};
891 // Anything changing ramp_up, hold_at_half, ramp_down, or hold_at_zero must
892 // also update the period so the period is only calculated when changed.
893 // -Kyz
894 float m_effect_period{};
895 EffectClock m_EffectClock;
896 bool m_tween_uses_effect_delta;
897
898 /* This can be used in lieu of the fDeltaTime parameter to Update() to
899 * follow the effect clock. Actor::Update must be called first. */
900 [[nodiscard]] auto GetEffectDeltaTime() const -> float
901 {
902 return m_fEffectDelta;
903 }
904
905 // todo: account for SSC_FUTURES by having these be vectors too -aj
906 RageColor m_effectColor1;
907 RageColor m_effectColor2;
908 RageVector3 m_vEffectMagnitude;
909
910 // other properties
911 bool m_bVisible{};
912 bool m_bIsAnimating{};
913 float m_fShadowLengthX{};
914 float m_fShadowLengthY{};
915 RageColor m_ShadowColor;
920
921 // render states
922 BlendMode m_BlendMode;
923 ZTestMode m_ZTestMode;
924 CullMode m_CullMode;
925 RageVector2 m_texTranslate;
926 bool m_bTextureWrapping{};
927 bool m_bTextureFiltering{};
928 bool m_bClearZBuffer{};
929 bool m_bZWrite{};
934 float m_fZBias{};
935
936 // global state
937 static float g_fCurrentBGMTime, g_fCurrentBGMBeat;
938 static float g_fCurrentBGMTimeNoOffset, g_fCurrentBGMBeatNoOffset;
939 static std::vector<float> g_vfCurrentBGMBeatPlayer;
940 static std::vector<float> g_vfCurrentBGMBeatPlayerNoOffset;
941
942 private:
943 // commands
944 std::map<std::string, apActorCommands> m_mapNameToCommands;
945};
946
947#endif
Base class for all objects that appear on the screen.
Definition Actor.h:77
auto GetX() const -> float
Retrieve the Actor's x position.
Definition Actor.h:294
auto GetZoomX() const -> float
Retrieve the zoom factor for the x coordinate of the Actor.
Definition Actor.h:384
float m_fHorizAlign
The particular horizontal alignment.
Definition Actor.h:869
virtual void SetGlobalRenderStates()
Set the global rendering states of this Actor.
Definition Actor.cpp:813
Actor * m_pParent
the current parent of this Actor if it exists.
Definition Actor.h:817
auto GetName() const -> const std::string &
Retrieve the Actor's name.
Definition Actor.h:262
void AddZ(float z)
Add to the z position of this Actor.
Definition Actor.h:334
Actor()
Set up the Actor with its initial settings.
Definition Actor.cpp:145
auto GetZoom() const -> float
Retrieve the general zoom factor, using the x coordinate of the Actor.
Definition Actor.h:377
void AddX(float x)
Add to the x position of this Actor.
Definition Actor.h:326
virtual void SetTextureRenderStates()
Set the texture rendering states of this Actor.
Definition Actor.cpp:834
auto GetZoomZ() const -> float
Retrieve the zoom factor for the z coordinate of the Actor.
Definition Actor.h:398
void Draw()
Calls multiple functions for drawing the Actors.
Definition Actor.cpp:452
void SetParent(Actor *pParent)
Give this Actor a new parent.
Definition Actor.cpp:1670
EffectClock
Various values an Actor's effect can be tied to.
Definition Actor.h:122
virtual void SetName(const std::string &sName)
Set the Actor's name to a new one.
Definition Actor.h:266
Effect
The list of the different effects.
Definition Actor.h:103
std::string m_sName
the name of the Actor.
Definition Actor.h:815
auto GetVisible() const -> bool
Determine if the Actor is visible at this time.
Definition Actor.h:717
void SetZoom(float zoom)
Set the zoom factor for all dimensions of the Actor.
Definition Actor.h:405
float m_fVertAlign
The particular vertical alignment.
Definition Actor.h:873
TweenState * m_pTempState
Temporary variables that are filled just before drawing.
Definition Actor.h:863
virtual void EndDraw()
Pop the transform from the world matrix stack.
Definition Actor.cpp:841
auto GetParent() const -> Actor *
Retrieve the Actor's parent.
Definition Actor.h:274
virtual void BeginDraw()
Start the drawing and push the transform on the world matrix stack.
Definition Actor.cpp:738
void SetZoomZ(float zoom)
Set the zoom factor for the z dimension of the Actor.
Definition Actor.h:422
virtual void PreDraw()
Calculate values that may be needed for drawing.
Definition Actor.cpp:551
float m_fZBias
The amount of bias.
Definition Actor.h:934
void SetZoomX(float zoom)
Set the zoom factor for the x dimension of the Actor.
Definition Actor.h:414
auto GetZ() const -> float
Retrieve the Actor's z position.
Definition Actor.h:302
void SetZoomY(float zoom)
Set the zoom factor for the y dimension of the Actor.
Definition Actor.h:418
void AddY(float y)
Add to the y position of this Actor.
Definition Actor.h:330
StretchType
How do we handle stretching the Actor?
Definition Actor.h:608
@ fit_inside
Definition Actor.h:609
@ cover
Definition Actor.h:611
virtual auto EarlyAbortDraw() const -> bool
Allow the Actor to be aborted early.
Definition Actor.h:213
int m_iDrawOrder
The draw order priority.
Definition Actor.h:919
virtual void PostDraw()
Reset internal diffuse and glow.
Definition Actor.cpp:544
auto GetLineage() const -> std::string
Retrieve the Actor's lineage.
Definition Actor.cpp:1002
virtual void DrawPrimitives()
Draw the primitives of the Actor.
Definition Actor.h:236
auto GetZoomY() const -> float
Retrieve the zoom factor for the y coordinate of the Actor.
Definition Actor.h:391
auto GetY() const -> float
Retrieve the Actor's y position.
Definition Actor.h:298
The interface for simple interpolation.
Definition Tween.h:29
Definition LuaBinding.h:143
A self-cleaning Lua reference.
Definition LuaReference.h:10
Definition MessageManager.h:177
Definition XmlFile.h:95
Some general information about the Tween.
Definition Actor.h:828
float m_fTimeLeftInTween
How far into the tween are we?
Definition Actor.h:837
float m_fTweenTime
The number of seconds between Start and End positions/zooms.
Definition Actor.h:840
std::string m_sCommandName
The command to execute when this TweenState goes into effect.
Definition Actor.h:843
Definition Actor.h:856
The present state for the Tween.
Definition Actor.h:140
RectF fade
The amount of fading involved.
Definition Actor.h:167
RageColor glow
The glow color for this TweenState.
Definition Actor.h:174
RectF crop
The amount of cropping involved.
Definition Actor.h:162
RageColor diffuse[NUM_DIFFUSE_COLORS]
Four values making up the diffuse in this TweenState.
Definition Actor.h:172
float aux
A magical value that nobody really knows the use for. ;)
Definition Actor.h:176
Definition MessageManager.h:96
Definition RageTypes.h:332
Definition RageTypes.h:101
Definition RageTypes.h:172
Definition RageTypes.h:249