Skip to content

Commit 9cf90f3

Browse files
committed
readd ActorProxy
lets us do cool stuff, not really that bad of a thing to have tbh ... if theres weird exploits with this ill figure it out sooner or later
1 parent 7b9b7af commit 9cf90f3

File tree

3 files changed

+98
-0
lines changed

3 files changed

+98
-0
lines changed

src/Etterna/Actor/Base/ActorProxy.cpp

+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
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

src/Etterna/Actor/Base/ActorProxy.h

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
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

src/Etterna/Actor/CMakeLists.txt

+2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ list(APPEND ACTOR_BASE_SRC
33
"Base/ActorFrame.cpp"
44
"Base/ActorFrameTexture.cpp"
55
"Base/ActorMultiVertex.cpp"
6+
"Base/ActorProxy.cpp"
67
"Base/ActorScroller.cpp"
78
"Base/ActorSound.cpp"
89
"Base/ActorUtil.cpp"
@@ -20,6 +21,7 @@ list(APPEND ACTOR_BASE_HPP
2021
"Base/ActorFrame.h"
2122
"Base/ActorFrameTexture.h"
2223
"Base/ActorMultiVertex.h"
24+
"Base/ActorProxy.h"
2325
"Base/ActorScroller.h"
2426
"Base/ActorSound.h"
2527
"Base/ActorUtil.h"

0 commit comments

Comments
 (0)