mirror of
https://github.com/Xaymar/obs-StreamFX
synced 2024-11-10 22:05:06 +00:00
gfx-effect-source: Allow overriding value and visibility of parameters
This commit is contained in:
parent
ff4a556f3f
commit
335847945d
2 changed files with 26 additions and 1 deletions
|
@ -726,9 +726,12 @@ void gfx::effect_source::effect_source::load_file(std::string file)
|
|||
break;
|
||||
}
|
||||
}
|
||||
if (_cb_valid)
|
||||
skip = skip || _cb_valid(prm);
|
||||
if (skip)
|
||||
continue;
|
||||
|
||||
|
||||
_params.emplace(identity, parameter::create(_effect, prm));
|
||||
}
|
||||
}
|
||||
|
@ -861,6 +864,10 @@ void gfx::effect_source::effect_source::render()
|
|||
}
|
||||
}
|
||||
|
||||
if (_cb_override) {
|
||||
_cb_override(_effect);
|
||||
}
|
||||
|
||||
gs_blend_state_push();
|
||||
gs_matrix_push();
|
||||
|
||||
|
@ -881,3 +888,11 @@ void gfx::effect_source::effect_source::render()
|
|||
gs_matrix_pop();
|
||||
gs_blend_state_pop();
|
||||
}
|
||||
|
||||
void gfx::effect_source::effect_source::set_valid_property_cb(valid_property_cb_t cb) {
|
||||
_cb_valid = cb;
|
||||
}
|
||||
|
||||
void gfx::effect_source::effect_source::set_override_cb(param_override_cb_t cb) {
|
||||
_cb_override = cb;
|
||||
}
|
||||
|
|
|
@ -226,7 +226,9 @@ namespace gfx {
|
|||
virtual void assign() override;
|
||||
};
|
||||
|
||||
typedef std::pair<gs::effect_parameter::type, std::string> param_ident_t;
|
||||
typedef std::pair<gs::effect_parameter::type, std::string> param_ident_t;
|
||||
typedef std::function<bool(std::shared_ptr<gs::effect_parameter> param)> valid_property_cb_t;
|
||||
typedef std::function<void(std::shared_ptr<gs::effect> effect)> param_override_cb_t;
|
||||
|
||||
class effect_source {
|
||||
std::string _file;
|
||||
|
@ -248,6 +250,9 @@ namespace gfx {
|
|||
std::uniform_real_distribution<float_t> _random_dist{0.f, 1.f};
|
||||
std::default_random_engine _random_generator;
|
||||
|
||||
valid_property_cb_t _cb_valid;
|
||||
param_override_cb_t _cb_override;
|
||||
|
||||
bool modified2(obs_properties_t* props, obs_property_t* property, obs_data_t* settings);
|
||||
|
||||
void load_file(std::string file);
|
||||
|
@ -263,6 +268,11 @@ namespace gfx {
|
|||
void tick(float_t time);
|
||||
|
||||
void render();
|
||||
|
||||
public:
|
||||
void set_valid_property_cb(valid_property_cb_t cb);
|
||||
|
||||
void set_override_cb(param_override_cb_t cb);
|
||||
};
|
||||
} // namespace effect_source
|
||||
} // namespace gfx
|
||||
|
|
Loading…
Reference in a new issue