fixed property on scripts

This commit is contained in:
Mikulas Florek 2020-05-23 22:39:08 +02:00
parent 0b5ebe2445
commit 896630f941
4 changed files with 5 additions and 19 deletions

View file

@ -1,3 +1,4 @@
enabled = true
function postprocess(env, transparent_phase, hdr_buffer, gbuffer0, gbuffer1, gbuffer_depth, shadowmap)
if not enabled then return hdr_buffer end
if transparent_phase ~= "pre" then return hdr_buffer end

View file

@ -102,13 +102,6 @@ struct GridUIVisitor final : Reflection::IPropertyVisitor
return attrs;
}
template <typename T>
bool skipProperty(const Reflection::Property<T>& prop)
{
return equalStrings(prop.name, "Enabled");
}
template <typename T>
void dynamicProperty(const ComponentUID& cmp, const Reflection::IDynamicProperties& prop, u32 prop_index) {
struct : Reflection::Property<T> {
@ -179,7 +172,6 @@ struct GridUIVisitor final : Reflection::IPropertyVisitor
void visit(const Reflection::Property<float>& prop) override
{
if (skipProperty(prop)) return;
Attributes attrs = getAttributes(prop);
ComponentUID cmp = getComponent();
float f = prop.get(cmp, m_index);
@ -198,7 +190,6 @@ struct GridUIVisitor final : Reflection::IPropertyVisitor
void visit(const Reflection::Property<int>& prop) override
{
if (skipProperty(prop)) return;
ComponentUID cmp = getComponent();
int value = prop.get(cmp, m_index);
auto* enum_attr = (Reflection::EnumAttribute*)Reflection::getAttribute(prop, Reflection::IAttribute::ENUM);
@ -242,7 +233,6 @@ struct GridUIVisitor final : Reflection::IPropertyVisitor
void visit(const Reflection::Property<u32>& prop) override
{
if (skipProperty(prop)) return;
ComponentUID cmp = getComponent();
u32 value = prop.get(cmp, m_index);
@ -359,7 +349,6 @@ struct GridUIVisitor final : Reflection::IPropertyVisitor
void visit(const Reflection::Property<Vec2>& prop) override
{
if (skipProperty(prop)) return;
ComponentUID cmp = getComponent();
Vec2 value = prop.get(cmp, m_index);
Attributes attrs = getAttributes(prop);
@ -378,7 +367,6 @@ struct GridUIVisitor final : Reflection::IPropertyVisitor
void visit(const Reflection::Property<Vec3>& prop) override
{
if (skipProperty(prop)) return;
Attributes attrs = getAttributes(prop);
ComponentUID cmp = getComponent();
Vec3 value = prop.get(cmp, m_index);
@ -407,7 +395,6 @@ struct GridUIVisitor final : Reflection::IPropertyVisitor
void visit(const Reflection::Property<IVec3>& prop) override
{
if (skipProperty(prop)) return;
ComponentUID cmp = getComponent();
IVec3 value = prop.get(cmp, m_index);
@ -422,7 +409,6 @@ struct GridUIVisitor final : Reflection::IPropertyVisitor
void visit(const Reflection::Property<Vec4>& prop) override
{
if (skipProperty(prop)) return;
Attributes attrs = getAttributes(prop);
ComponentUID cmp = getComponent();
Vec4 value = prop.get(cmp, m_index);
@ -449,7 +435,7 @@ struct GridUIVisitor final : Reflection::IPropertyVisitor
void visit(const Reflection::Property<bool>& prop) override
{
if (skipProperty(prop)) return;
if (equalIStrings(prop.name, "enabled") && m_index == -1 && m_entities.size() == 1) return;
ComponentUID cmp = getComponent();
bool value = prop.get(cmp, m_index);
@ -465,7 +451,6 @@ struct GridUIVisitor final : Reflection::IPropertyVisitor
void visit(const Reflection::Property<Path>& prop) override
{
if (skipProperty(prop)) return;
ComponentUID cmp = getComponent();
const Path p = prop.get(cmp, m_index);
char tmp[MAX_PATH_LENGTH];
@ -495,7 +480,6 @@ struct GridUIVisitor final : Reflection::IPropertyVisitor
void visit(const Reflection::Property<const char*>& prop) override
{
if (skipProperty(prop)) return;
ComponentUID cmp = getComponent();
const Attributes attrs = getAttributes(prop);

View file

@ -1936,7 +1936,7 @@ namespace Lumix
}
bool isScriptEnabled(EntityRef entity, int scr_index) const override
bool isScriptEnabled(EntityRef entity, int scr_index) override
{
return m_scripts[entity]->m_scripts[scr_index].m_flags.isSet(ScriptInstance::ENABLED);
}
@ -2176,6 +2176,7 @@ namespace Lumix
static auto lua_scene = scene("lua_script",
component("lua_script",
array("scripts", &LuaScriptScene::getScriptCount, &LuaScriptScene::addScript, &LuaScriptScene::removeScript,
property("Enabled", &LuaScriptScene::isScriptEnabled, &LuaScriptScene::enableScript),
property("Path", LUMIX_PROP(LuaScriptScene, ScriptPath), ResourceAttribute("Lua script (*.lua)", LuaScript::TYPE)),
LuaProperties()
)

View file

@ -69,7 +69,7 @@ struct LuaScriptScene : IScene
virtual int addScript(EntityRef entity, int scr_index) = 0;
virtual void removeScript(EntityRef entity, int scr_index) = 0;
virtual void enableScript(EntityRef entity, int scr_index, bool enable) = 0;
virtual bool isScriptEnabled(EntityRef entity, int scr_index) const = 0;
virtual bool isScriptEnabled(EntityRef entity, int scr_index) = 0;
virtual void moveScript(EntityRef entity, int scr_index, bool up) = 0;
virtual void serializeScript(EntityRef entity, int scr_index, OutputMemoryStream& blob) = 0;
virtual void deserializeScript(EntityRef entity, int scr_index, InputMemoryStream& blob) = 0;