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