Etterna 0.74.4
Loading...
Searching...
No Matches
ActorFrame.h
1#ifndef ACTORFRAME_H
2#define ACTORFRAME_H
3
4#include "Actor.h"
5
7class ActorFrame : public Actor
8{
9 public:
10 ActorFrame();
11 ActorFrame(const ActorFrame& cpy);
12 ~ActorFrame() override;
13
15 void InitState() override;
16 void LoadFromNode(const XNode* pNode) override;
17 [[nodiscard]] auto Copy() const -> ActorFrame* override;
18
22 virtual void AddChild(Actor* pActor);
26 virtual void RemoveChild(Actor* pActor);
27 void TransferChildren(ActorFrame* pTo);
28 auto GetChild(const std::string& sName) -> Actor*;
29
30 [[nodiscard]] auto GetChildren() const -> std::vector<Actor*>
31 {
32 return m_SubActors;
33 }
34
35 [[nodiscard]] auto GetNumChildren() const -> int
36 {
37 return static_cast<int>(m_SubActors.size());
38 }
39
41 void RemoveAllChildren();
46 void MoveToTail(Actor* pActor);
51 void MoveToHead(Actor* pActor);
52 void SortByDrawOrder();
53 void SetDrawByZPosition(bool b);
54
55 void SetDrawFunction(const LuaReference& DrawFunction)
56 {
57 m_DrawFunction = DrawFunction;
58 }
59
60 void SetUpdateFunction(const LuaReference& UpdateFunction)
61 {
62 m_UpdateFunction = UpdateFunction;
63 }
64
65 [[nodiscard]] auto GetDrawFunction() const -> LuaReference
66 {
67 return m_DrawFunction;
68 }
69
70 [[nodiscard]] virtual auto AutoLoadChildren() const -> bool
71 {
72 return false;
73 } // derived classes override to automatically LoadChildrenFromNode
74 void DeleteChildrenWhenDone(bool bDelete = true)
75 {
76 m_bDeleteChildren = bDelete;
77 }
78
79 void DeleteAllChildren();
80
81 // Commands
82 void PushSelf(lua_State* L) override;
83 void PushChildrenTable(lua_State* L);
84 void PushChildTable(lua_State* L, const std::string& sName);
85 void PlayCommandOnChildren(const std::string& sCommandName,
86 const LuaReference* pParamTable = nullptr);
87 void PlayCommandOnLeaves(const std::string& sCommandName,
88 const LuaReference* pParamTable = nullptr);
89
90 void RunCommandsRecursively(
91 const LuaReference& cmds,
92 const LuaReference* pParamTable = nullptr) override;
93 virtual void RunCommandsOnChildren(
94 const LuaReference& cmds,
95 const LuaReference* pParamTable = nullptr); /* but not on self */
96 void RunCommandsOnChildren(const apActorCommands& cmds,
97 const LuaReference* pParamTable = nullptr)
98 {
99 this->RunCommandsOnChildren(*cmds, pParamTable);
100 } // convenience
101 void RunCommandsOnLeaves(
102 const LuaReference& cmds,
103 const LuaReference* pParamTable = nullptr) override;
104 /* but not on self */
105 [[nodiscard]] auto IsFirstUpdate() const -> bool;
106 void UpdateInternal(float fDeltaTime) override;
107 void BeginDraw() override;
108 void DrawPrimitives() override;
109 void EndDraw() override;
110
111 // propagated commands
112 void SetZTestMode(ZTestMode mode) override;
113 void SetZWrite(bool b) override;
114 void FinishTweening() override;
115 void HurryTweening(float factor) override;
116
117 void SetUpdateFunctionInterval(float ms)
118 {
119 if (ms > 0.0F) {
120 m_fUpdateFInterval = ms;
121 }
122 }
123
124 void SetUpdateRate(float rate) override
125 {
126 if (rate > 0.0F) {
127 m_fUpdateRate = rate;
128 }
129 }
130
131 auto GetUpdateRate() -> float override { return m_fUpdateRate; }
132 void SetFOV(float fFOV) { m_fFOV = fFOV; }
133
134 void SetVanishPoint(float fX, float fY)
135 {
136 m_fVanishX = fX;
137 m_fVanishY = fY;
138 }
139
140 void SetCustomLighting(bool bCustomLighting)
141 {
142 m_bOverrideLighting = bCustomLighting;
143 }
144
145 void SetAmbientLightColor(const RageColor& c) { m_ambientColor = c; }
146 void SetDiffuseLightColor(const RageColor& c) { m_diffuseColor = c; }
147 void SetSpecularLightColor(const RageColor& c) { m_specularColor = c; }
148 void SetLightDirection(const RageVector3& vec) { m_lightDirection = vec; }
149
150 virtual void SetPropagateCommands(bool b);
151
154 [[nodiscard]] auto GetTweenTimeLeft() const -> float override;
155
156 void HandleMessage(const Message& msg) override;
157 void RunCommands(const LuaReference& cmds,
158 const LuaReference* pParamTable = nullptr) override;
159
160 void RunCommands(const apActorCommands& cmds,
161 const LuaReference* pParamTable = nullptr) override
162 {
163 this->RunCommands(*cmds, pParamTable);
164 } // convenience
165
166 protected:
167 void LoadChildrenFromNode(const XNode* pNode);
168
170 std::vector<Actor*> m_SubActors;
171 bool m_bPropagateCommands;
172 bool m_bDeleteChildren;
173 bool m_bDrawByZPosition;
174 LuaReference m_UpdateFunction;
175 LuaReference m_DrawFunction;
176
177 float m_fUpdateFInterval{ 0.016F };
178 float secsSinceLuaUpdateFWasRun{ 0.0F };
179 // state effects
180 float m_fUpdateRate;
181 float m_fFOV; // -1 = no change
182 float m_fVanishX;
183 float m_fVanishY;
189 bool m_bLighting;
190 bool m_bFirstUpdate;
191 // lighting variables
192 RageColor m_ambientColor;
193 RageColor m_diffuseColor;
194 RageColor m_specularColor;
195 RageVector3 m_lightDirection;
196};
197
200{
201 public:
202 ActorFrameAutoDeleteChildren() { DeleteChildrenWhenDone(true); }
203 [[nodiscard]] auto AutoLoadChildren() const -> bool override
204 {
205 return true;
206 }
207 [[nodiscard]] auto Copy() const -> ActorFrameAutoDeleteChildren* override;
208};
209
210#endif
an ActorFrame that handles deleting children Actors automatically.
Definition ActorFrame.h:200
A container for other Actors.
Definition ActorFrame.h:8
void MoveToTail(Actor *pActor)
Move a particular actor to the tail.
Definition ActorFrame.cpp:200
void BeginDraw() override
Start the drawing and push the transform on the world matrix stack.
Definition ActorFrame.cpp:222
void EndDraw() override
Pop the transform from the world matrix stack.
Definition ActorFrame.cpp:299
std::vector< Actor * > m_SubActors
The children Actors used by the ActorFrame.
Definition ActorFrame.h:170
void InitState() override
Set up the initial state.
Definition ActorFrame.cpp:84
auto GetTweenTimeLeft() const -> float override
Amount of time until all tweens (and all children's tweens) have stopped:
Definition ActorFrame.cpp:562
void RemoveAllChildren()
Remove all of the children from the frame.
Definition ActorFrame.cpp:194
void MoveToHead(Actor *pActor)
Move a particular actor to the head.
Definition ActorFrame.cpp:211
virtual void AddChild(Actor *pActor)
Add a new child to the ActorFrame.
Definition ActorFrame.cpp:146
void DrawPrimitives() override
Draw the primitives of the Actor.
Definition ActorFrame.cpp:243
virtual void RemoveChild(Actor *pActor)
Remove the specified child from the ActorFrame.
Definition ActorFrame.cpp:165
bool m_bOverrideLighting
A flad to see if an override for the lighting is needed.
Definition ActorFrame.h:188
Base class for all objects that appear on the screen.
Definition Actor.h:77
A self-cleaning Lua reference.
Definition LuaReference.h:10
Definition XmlFile.h:95
Definition MessageManager.h:96
Definition RageTypes.h:332
Definition RageTypes.h:172