3#include "sound_bakery/core/core_include.h"
9 class named_parameter_value;
16 template <
typename parameter_type>
19 REGISTER_REFLECTION(
parameter, database_object)
21 static_assert(std::is_arithmetic<parameter_type>::value);
52 : sbk::core::database_object(), m_property(min, min, max), m_defaultValue(min)
59 [[nodiscard]] parameter_type
get()
const {
return m_property.get(); }
60 [[nodiscard]] parameter_type get_default()
const {
return m_defaultValue; }
67 void set(parameter_type value) { m_property.set(value); }
68 void set_default(parameter_type value) { m_defaultValue = value; }
75 return m_property.get_delegate();
89 parameter_type m_defaultValue;
139 : m_values(),
parameter((std::numeric_limits<sbk_id>::min)(), (std::numeric_limits<sbk_id>::max)())
154 if (
const std::shared_ptr<named_parameter_value> parameterValue = create_database_object<named_parameter_value>())
156 parameterValue->set_database_name(name);
157 parameterValue->parentParameter =
this;
159 result = parameterValue;
161 m_values.emplace(parameterValue);
173 std::unordered_set<sbk::core::database_ptr<named_parameter_value>>
get_values()
175 if (m_values.empty())
177 set_selected_value(add_new_value(
"None"));
191 if (m_values.contains(value))
215 std::unordered_set<sbk::core::database_ptr<named_parameter_value>> m_values;
228 std::unordered_set<global_float_parameter> floatParameters;
229 std::unordered_set<global_int_parameter> intParameters;
237 std::unordered_map<global_float_parameter, float_parameter::parameter_property> floatParameters;
238 std::unordered_map<global_int_parameter, named_parameter::parameter_property> intParameters;
Base object type for any object that can exist in the editor/database. Holds an ID and name.
Definition database_object.h:12
Definition database_ptr.h:23
sbk_id id() const noexcept
Get ID of the referenced object.
Definition database_ptr.h:84
bool lookup() const
Find the live object referenced by the ID and store it.
Definition database_ptr.h:153
Definition parameter.h:94
Definition parameter.h:99
Represents a discrete value for a named_parameter.
Definition parameter.h:113
Holds discrete named integer values.
Definition parameter.h:128
named_parameter()
Creates a named_parameter with min and max values.
Definition parameter.h:138
sbk::core::database_ptr< named_parameter_value > get_selected_value() const
Get the selected value as a DatabasePtr.
Definition parameter.h:207
std::unordered_set< sbk::core::database_ptr< named_parameter_value > > get_values()
Gets all named values in this parameter.
Definition parameter.h:173
sbk::core::database_ptr< named_parameter_value > add_new_value(const std::string_view name)
Adds a new value to the parameter.
Definition parameter.h:148
void set_selected_value(sbk::core::database_ptr< named_parameter_value > value)
Sets the parameter value with a DatabasePtr, ensuring the value exists in this parameter.
Definition parameter.h:189
Defines a database object with a changeable property.
Definition parameter.h:18
local_parameter create_local_parameter_from_this() const
Copies this parameter to a runtime version, suitable for handling unique variations per game object e...
Definition parameter.h:83
parameter_property::property_changed_delegate & get_delegate()
Get the parameter delegate that fires when changing the value.
Definition parameter.h:73
parameter(parameter_type min, parameter_type max)
Creates a parameter with min and max values set.
Definition parameter.h:51
void set(parameter_type value)
Set the value of the parameter.
Definition parameter.h:67
std::pair< sbk_id, parameter_property > local_parameter
Defines the type used for passing local versions/variations of this parameter.
Definition parameter.h:34
std::pair< sbk_id, parameter_type > local_parameter_value_pair
Defines an ID to a parameter and a value for that parameter.
Definition parameter.h:42
parameter_type get() const
Get the current value of the parameter.
Definition parameter.h:59
Holds a list of parameters.
Definition parameter.h:227
Holds a list of parameters and their local value.
Definition parameter.h:236