File tree 3 files changed +98
-0
lines changed
3 files changed +98
-0
lines changed Original file line number Diff line number Diff line change
1
+ #include " Etterna/Globals/global.h"
2
+ #include " ActorProxy.h"
3
+ #include " Etterna/Actor/Base/ActorUtil.h"
4
+
5
+ REGISTER_ACTOR_CLASS (ActorProxy);
6
+
7
+ ActorProxy::ActorProxy ()
8
+ {
9
+ m_pActorTarget = nullptr ;
10
+ }
11
+
12
+ bool
13
+ ActorProxy::EarlyAbortDraw () const
14
+ {
15
+ return m_pActorTarget == nullptr || Actor::EarlyAbortDraw ();
16
+ }
17
+
18
+ void
19
+ ActorProxy::DrawPrimitives ()
20
+ {
21
+ if (m_pActorTarget != nullptr ) {
22
+ bool bVisible = m_pActorTarget->GetVisible ();
23
+ m_pActorTarget->SetVisible (true );
24
+ m_pActorTarget->Draw ();
25
+ m_pActorTarget->SetVisible (bVisible);
26
+ }
27
+ }
28
+
29
+ void
30
+ ActorProxy::LoadFromNode (const XNode* pNode)
31
+ {
32
+ Actor::LoadFromNode (pNode);
33
+ }
34
+
35
+ // lua start
36
+ #include " Etterna/Models/Lua/LuaBinding.h"
37
+
38
+ /* * @brief Allow Lua to have access to the ActorProxy. */
39
+ class LunaActorProxy : public Luna <ActorProxy>
40
+ {
41
+ public:
42
+ static int SetTarget (T* p, lua_State* L)
43
+ {
44
+ Actor* pTarget = Luna<Actor>::check (L, 1 );
45
+ p->SetTarget (pTarget);
46
+ COMMON_RETURN_SELF;
47
+ }
48
+
49
+ static int GetTarget (T* p, lua_State* L)
50
+ {
51
+ Actor* pTarget = p->GetTarget ();
52
+ if (pTarget != nullptr )
53
+ pTarget->PushSelf (L);
54
+ else
55
+ lua_pushnil (L);
56
+ return 1 ;
57
+ }
58
+
59
+ LunaActorProxy ()
60
+ {
61
+ ADD_METHOD (SetTarget);
62
+ ADD_METHOD (GetTarget);
63
+ }
64
+ };
65
+
66
+ LUA_REGISTER_DERIVED_CLASS (ActorProxy, Actor)
67
+ // lua end
Original file line number Diff line number Diff line change
1
+ #ifndef ACTOR_PROXY_H
2
+ #define ACTOR_PROXY_H
3
+
4
+ #include " Actor.h"
5
+
6
+ struct lua_State ;
7
+ /* * @brief Renders another actor. */
8
+ class ActorProxy : public Actor
9
+ {
10
+ public:
11
+ ActorProxy ();
12
+
13
+ virtual bool EarlyAbortDraw () const ;
14
+ virtual void DrawPrimitives ();
15
+
16
+ void LoadFromNode (const XNode* pNode);
17
+ virtual ActorProxy* Copy () const ;
18
+
19
+ Actor* GetTarget () { return m_pActorTarget; }
20
+ void SetTarget (Actor* pTarget) { m_pActorTarget = pTarget; }
21
+
22
+ // Lua
23
+ virtual void PushSelf (lua_State* L);
24
+
25
+ private:
26
+ Actor* m_pActorTarget;
27
+ };
28
+
29
+ #endif
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ list(APPEND ACTOR_BASE_SRC
3
3
"Base/ActorFrame.cpp"
4
4
"Base/ActorFrameTexture.cpp"
5
5
"Base/ActorMultiVertex.cpp"
6
+ "Base/ActorProxy.cpp"
6
7
"Base/ActorScroller.cpp"
7
8
"Base/ActorSound.cpp"
8
9
"Base/ActorUtil.cpp"
@@ -20,6 +21,7 @@ list(APPEND ACTOR_BASE_HPP
20
21
"Base/ActorFrame.h"
21
22
"Base/ActorFrameTexture.h"
22
23
"Base/ActorMultiVertex.h"
24
+ "Base/ActorProxy.h"
23
25
"Base/ActorScroller.h"
24
26
"Base/ActorSound.h"
25
27
"Base/ActorUtil.h"
You can’t perform that action at this time.
0 commit comments