mirror of
https://github.com/Xaymar/obs-StreamFX
synced 2024-11-11 06:15:05 +00:00
gfx/shader/texture: Add default file annotation
This commit is contained in:
parent
c3b1dc2ec2
commit
7994d03166
2 changed files with 23 additions and 5 deletions
|
@ -24,6 +24,7 @@
|
||||||
#include "gfx/gfx-debug.hpp"
|
#include "gfx/gfx-debug.hpp"
|
||||||
#include "obs/gs/gs-helper.hpp"
|
#include "obs/gs/gs-helper.hpp"
|
||||||
#include "obs/obs-source-tracker.hpp"
|
#include "obs/obs-source-tracker.hpp"
|
||||||
|
#include "util/util-platform.hpp"
|
||||||
|
|
||||||
// TODO:
|
// TODO:
|
||||||
// - FFT Audio Conversion
|
// - FFT Audio Conversion
|
||||||
|
@ -47,6 +48,7 @@
|
||||||
#define ST_I18N_SOURCE ST_I18N ".Source"
|
#define ST_I18N_SOURCE ST_I18N ".Source"
|
||||||
|
|
||||||
static constexpr std::string_view _annotation_field_type = "field_type";
|
static constexpr std::string_view _annotation_field_type = "field_type";
|
||||||
|
static constexpr std::string_view _annotation_default = "default";
|
||||||
static constexpr std::string_view _annotation_enum_entry = "enum_%zu";
|
static constexpr std::string_view _annotation_enum_entry = "enum_%zu";
|
||||||
static constexpr std::string_view _annotation_enum_entry_name = "enum_%zu_name";
|
static constexpr std::string_view _annotation_enum_entry_name = "enum_%zu_name";
|
||||||
|
|
||||||
|
@ -93,6 +95,9 @@ streamfx::gfx::shader::texture_parameter::texture_parameter(streamfx::gfx::shade
|
||||||
if (auto anno = get_parameter().get_annotation(_annotation_field_type); anno) {
|
if (auto anno = get_parameter().get_annotation(_annotation_field_type); anno) {
|
||||||
_field_type = get_texture_field_type_from_string(anno.get_default_string());
|
_field_type = get_texture_field_type_from_string(anno.get_default_string());
|
||||||
}
|
}
|
||||||
|
if (auto anno = get_parameter().get_annotation(_annotation_default); anno) {
|
||||||
|
_default = std::filesystem::path(anno.get_default_string());
|
||||||
|
}
|
||||||
|
|
||||||
if (field_type() == texture_field_type::Enum) {
|
if (field_type() == texture_field_type::Enum) {
|
||||||
for (std::size_t idx = 0; idx < std::numeric_limits<std::size_t>::max(); idx++) {
|
for (std::size_t idx = 0; idx < std::numeric_limits<std::size_t>::max(); idx++) {
|
||||||
|
@ -129,13 +134,25 @@ streamfx::gfx::shader::texture_parameter::texture_parameter(streamfx::gfx::shade
|
||||||
|
|
||||||
if (_values.size() == 0) {
|
if (_values.size() == 0) {
|
||||||
_field_type = texture_field_type::Input;
|
_field_type = texture_field_type::Input;
|
||||||
|
} else {
|
||||||
|
_keys[1] = get_key();
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
streamfx::gfx::shader::texture_parameter::~texture_parameter() {}
|
streamfx::gfx::shader::texture_parameter::~texture_parameter() {}
|
||||||
|
|
||||||
|
void streamfx::gfx::shader::texture_parameter::defaults(obs_data_t* settings)
|
||||||
|
{
|
||||||
|
if (field_type() == texture_field_type::Input) {
|
||||||
|
obs_data_set_default_int(settings, _keys[0].c_str(), static_cast<long long>(texture_type::File));
|
||||||
|
obs_data_set_default_string(settings, _keys[1].c_str(), _default.generic_u8string().c_str());
|
||||||
|
obs_data_set_default_string(settings, _keys[2].c_str(), "");
|
||||||
|
} else {
|
||||||
|
obs_data_set_default_string(settings, _keys[1].c_str(), _default.generic_u8string().c_str());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool streamfx::gfx::shader::texture_parameter::modified_type(void* priv, obs_properties_t* props, obs_property_t*,
|
bool streamfx::gfx::shader::texture_parameter::modified_type(void* priv, obs_properties_t* props, obs_property_t*,
|
||||||
obs_data_t* settings)
|
obs_data_t* settings)
|
||||||
{
|
{
|
||||||
|
|
|
@ -39,9 +39,10 @@ namespace streamfx::gfx {
|
||||||
std::list<texture_enum_data> _values;
|
std::list<texture_enum_data> _values;
|
||||||
|
|
||||||
// Data
|
// Data
|
||||||
texture_type _type;
|
texture_type _type;
|
||||||
bool _active;
|
bool _active;
|
||||||
bool _visible;
|
bool _visible;
|
||||||
|
std::filesystem::path _default;
|
||||||
|
|
||||||
// Data: File
|
// Data: File
|
||||||
std::filesystem::path _file_path;
|
std::filesystem::path _file_path;
|
||||||
|
@ -60,7 +61,7 @@ namespace streamfx::gfx {
|
||||||
std::string prefix);
|
std::string prefix);
|
||||||
virtual ~texture_parameter();
|
virtual ~texture_parameter();
|
||||||
|
|
||||||
void defaults(obs_data_t* settings) override{};
|
void defaults(obs_data_t* settings) override;
|
||||||
|
|
||||||
static bool modified_type(void*, obs_properties_t*, obs_property_t*, obs_data_t*);
|
static bool modified_type(void*, obs_properties_t*, obs_property_t*, obs_data_t*);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue