2023-07-21 09:50:06 +00:00
|
|
|
/**
|
|
|
|
* bb_variant.cpp
|
|
|
|
* =============================================================================
|
2024-03-04 20:36:16 +00:00
|
|
|
* Copyright 2021-2024 Serhii Snitsaruk
|
2023-07-21 09:50:06 +00:00
|
|
|
*
|
|
|
|
* Use of this source code is governed by an MIT-style
|
|
|
|
* license that can be found in the LICENSE file or at
|
|
|
|
* https://opensource.org/licenses/MIT.
|
|
|
|
* =============================================================================
|
|
|
|
*/
|
2022-10-25 20:01:00 +00:00
|
|
|
|
|
|
|
#include "bb_variant.h"
|
|
|
|
|
|
|
|
void BBVariant::set_type(Variant::Type p_type) {
|
2023-08-07 12:29:58 +00:00
|
|
|
if (type != p_type) {
|
|
|
|
type = p_type;
|
|
|
|
if (get_saved_value().get_type() != p_type) {
|
|
|
|
_assign_default_value();
|
|
|
|
}
|
|
|
|
emit_changed();
|
|
|
|
notify_property_list_changed();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Variant::Type BBVariant::get_type() const {
|
|
|
|
return type;
|
2022-10-25 20:01:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void BBVariant::_bind_methods() {
|
2024-03-04 20:36:16 +00:00
|
|
|
ClassDB::bind_method(D_METHOD("set_type", "type"), &BBVariant::set_type);
|
2022-10-25 20:01:00 +00:00
|
|
|
|
|
|
|
String vtypes;
|
|
|
|
for (int i = 0; i < Variant::VARIANT_MAX; i++) {
|
|
|
|
if (i > 0) {
|
|
|
|
vtypes += ",";
|
|
|
|
}
|
|
|
|
vtypes += Variant::get_type_name(Variant::Type(i));
|
|
|
|
}
|
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::INT, "type", PROPERTY_HINT_ENUM, vtypes), "set_type", "get_type");
|
|
|
|
}
|
|
|
|
|
2024-01-16 09:46:42 +00:00
|
|
|
BBVariant::BBVariant(const Variant &p_value) {
|
|
|
|
set_type(p_value.get_type());
|
|
|
|
set_saved_value(p_value);
|
|
|
|
}
|
|
|
|
|
2022-10-25 20:01:00 +00:00
|
|
|
BBVariant::BBVariant() {
|
|
|
|
}
|