Skip to content

Commit

Permalink
Update all Nodes to use new configuration info API
Browse files Browse the repository at this point in the history
Uses the CONFIG_ macros and specifies the property where appropriate.
  • Loading branch information
RedMser committed Oct 7, 2024
1 parent cd855d9 commit 31acd7a
Show file tree
Hide file tree
Showing 138 changed files with 868 additions and 554 deletions.
14 changes: 9 additions & 5 deletions modules/multiplayer/multiplayer_spawner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,18 @@ void MultiplayerSpawner::_get_property_list(List<PropertyInfo> *p_list) const {
}
#endif

PackedStringArray MultiplayerSpawner::get_configuration_warnings() const {
PackedStringArray warnings = Node::get_configuration_warnings();
#ifdef TOOLS_ENABLED
Vector<ConfigurationInfo> MultiplayerSpawner::get_configuration_info() const {
Vector<ConfigurationInfo> infos = Node::get_configuration_info();

if (spawn_path.is_empty() || !has_node(spawn_path)) {
warnings.push_back(RTR("A valid NodePath must be set in the \"Spawn Path\" property in order for MultiplayerSpawner to be able to spawn Nodes."));
CONFIG_WARNING_P(
RTR("A valid NodePath must be set in order for MultiplayerSpawner to be able to spawn Nodes."),
"spawn_path");
}
return warnings;
return infos;
}
#endif

void MultiplayerSpawner::add_spawnable_scene(const String &p_path) {
SpawnableScene sc;
Expand Down Expand Up @@ -250,7 +254,7 @@ NodePath MultiplayerSpawner::get_spawn_path() const {
void MultiplayerSpawner::set_spawn_path(const NodePath &p_path) {
spawn_path = p_path;
_update_spawn_node();
update_configuration_warnings();
update_configuration_info();
}

void MultiplayerSpawner::_track(Node *p_node, const Variant &p_argument, int p_scene_id) {
Expand Down
4 changes: 3 additions & 1 deletion modules/multiplayer/multiplayer_spawner.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,9 @@ class MultiplayerSpawner : public Node {
void _get_property_list(List<PropertyInfo> *p_list) const;
#endif
public:
PackedStringArray get_configuration_warnings() const override;
#ifdef TOOLS_ENABLED
Vector<ConfigurationInfo> get_configuration_info() const override;
#endif

Node *get_spawn_node() const {
return spawn_node.is_valid() ? Object::cast_to<Node>(ObjectDB::get_instance(spawn_node)) : nullptr;
Expand Down
14 changes: 9 additions & 5 deletions modules/multiplayer/multiplayer_synchronizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,15 +143,19 @@ bool MultiplayerSynchronizer::update_inbound_sync_time(uint16_t p_network_time)
return true;
}

PackedStringArray MultiplayerSynchronizer::get_configuration_warnings() const {
PackedStringArray warnings = Node::get_configuration_warnings();
#ifdef TOOLS_ENABLED
Vector<ConfigurationInfo> MultiplayerSynchronizer::get_configuration_info() const {
Vector<ConfigurationInfo> infos = Node::get_configuration_info();

if (root_path.is_empty() || !has_node(root_path)) {
warnings.push_back(RTR("A valid NodePath must be set in the \"Root Path\" property in order for MultiplayerSynchronizer to be able to synchronize properties."));
CONFIG_WARNING_P(
RTR("A valid NodePath must be set in order for MultiplayerSynchronizer to be able to synchronize properties."),
"root_path");
}

return warnings;
return infos;
}
#endif

Error MultiplayerSynchronizer::get_state(const List<NodePath> &p_properties, Object *p_obj, Vector<Variant> &r_variant, Vector<const Variant *> &r_variant_ptrs) {
ERR_FAIL_NULL_V(p_obj, ERR_INVALID_PARAMETER);
Expand Down Expand Up @@ -354,7 +358,7 @@ void MultiplayerSynchronizer::set_root_path(const NodePath &p_path) {
_stop();
root_path = p_path;
_start();
update_configuration_warnings();
update_configuration_info();
}

NodePath MultiplayerSynchronizer::get_root_path() const {
Expand Down
4 changes: 3 additions & 1 deletion modules/multiplayer/multiplayer_synchronizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,9 @@ class MultiplayerSynchronizer : public Node {
bool update_outbound_sync_time(uint64_t p_usec);
bool update_inbound_sync_time(uint16_t p_network_time);

PackedStringArray get_configuration_warnings() const override;
#ifdef TOOLS_ENABLED
Vector<ConfigurationInfo> get_configuration_info() const override;
#endif

void set_replication_interval(double p_interval);
double get_replication_interval() const;
Expand Down
22 changes: 12 additions & 10 deletions modules/openxr/scene/openxr_composition_layer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ void OpenXRCompositionLayer::set_enable_hole_punch(bool p_enable) {
_remove_fallback_node();
}

update_configuration_warnings();
update_configuration_info();
}

bool OpenXRCompositionLayer::get_enable_hole_punch() const {
Expand All @@ -307,7 +307,7 @@ bool OpenXRCompositionLayer::get_enable_hole_punch() const {

void OpenXRCompositionLayer::set_sort_order(int p_order) {
openxr_layer_provider->set_sort_order(p_order);
update_configuration_warnings();
update_configuration_info();
}

int OpenXRCompositionLayer::get_sort_order() const {
Expand Down Expand Up @@ -412,10 +412,10 @@ void OpenXRCompositionLayer::_notification(int p_what) {
_clear_composition_layer_provider();
}
}
update_configuration_warnings();
update_configuration_info();
} break;
case NOTIFICATION_LOCAL_TRANSFORM_CHANGED: {
update_configuration_warnings();
update_configuration_info();
} break;
case NOTIFICATION_ENTER_TREE: {
if (layer_viewport && is_viewport_in_use(layer_viewport)) {
Expand Down Expand Up @@ -479,23 +479,25 @@ void OpenXRCompositionLayer::_validate_property(PropertyInfo &p_property) const
}
}

PackedStringArray OpenXRCompositionLayer::get_configuration_warnings() const {
PackedStringArray warnings = Node3D::get_configuration_warnings();
#ifdef TOOLS_ENABLED
Vector<ConfigurationInfo> OpenXRCompositionLayer::get_configuration_info() const {
Vector<ConfigurationInfo> infos = Node3D::get_configuration_info();

if (is_visible() && is_inside_tree()) {
XROrigin3D *origin = Object::cast_to<XROrigin3D>(get_parent());
if (origin == nullptr) {
warnings.push_back(RTR("OpenXR composition layers must have an XROrigin3D node as their parent."));
CONFIG_WARNING(RTR("OpenXR composition layers must have an XROrigin3D node as their parent."));
}
}

if (!get_transform().basis.is_orthonormal()) {
warnings.push_back(RTR("OpenXR composition layers must have orthonormalized transforms (ie. no scale or shearing)."));
CONFIG_WARNING(RTR("OpenXR composition layers must have orthonormalized transforms (ie. no scale or shearing)."));
}

if (enable_hole_punch && get_sort_order() >= 0) {
warnings.push_back(RTR("Hole punching won't work as expected unless the sort order is less than zero."));
CONFIG_WARNING(RTR("Hole punching won't work as expected unless the sort order is less than zero."));
}

return warnings;
return infos;
}
#endif
4 changes: 3 additions & 1 deletion modules/openxr/scene/openxr_composition_layer.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,9 @@ class OpenXRCompositionLayer : public Node3D {
Ref<JavaObject> get_android_surface();
bool is_natively_supported() const;

virtual PackedStringArray get_configuration_warnings() const override;
#ifdef TOOLS_ENABLED
virtual Vector<ConfigurationInfo> get_configuration_info() const override;
#endif

virtual Vector2 intersects_ray(const Vector3 &p_origin, const Vector3 &p_direction) const;

Expand Down
10 changes: 6 additions & 4 deletions modules/openxr/scene/openxr_visibility_mask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,18 +64,20 @@ void OpenXRVisibilityMask::_on_openxr_session_stopping() {
set_base(RID());
}

PackedStringArray OpenXRVisibilityMask::get_configuration_warnings() const {
PackedStringArray warnings = VisualInstance3D::get_configuration_warnings();
#ifdef TOOLS_ENABLED
Vector<ConfigurationInfo> OpenXRVisibilityMask::get_configuration_info() const {
Vector<ConfigurationInfo> infos = VisualInstance3D::get_configuration_info();

if (is_visible() && is_inside_tree()) {
XRCamera3D *camera = Object::cast_to<XRCamera3D>(get_parent());
if (camera == nullptr) {
warnings.push_back(RTR("OpenXR visibility mask must have an XRCamera3D node as their parent."));
CONFIG_WARNING(RTR("OpenXR visibility mask must have an XRCamera3D node as their parent."));
}
}

return warnings;
return infos;
}
#endif

AABB OpenXRVisibilityMask::get_aabb() const {
AABB ret;
Expand Down
4 changes: 3 additions & 1 deletion modules/openxr/scene/openxr_visibility_mask.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ class OpenXRVisibilityMask : public VisualInstance3D {
void _on_openxr_session_stopping();

public:
virtual PackedStringArray get_configuration_warnings() const override;
#ifdef TOOLS_ENABLED
virtual Vector<ConfigurationInfo> get_configuration_info() const override;
#endif

virtual AABB get_aabb() const override;

Expand Down
14 changes: 9 additions & 5 deletions scene/2d/animated_sprite_2d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ void AnimatedSprite2D::set_sprite_frames(const Ref<SpriteFrames> &p_frames) {

notify_property_list_changed();
queue_redraw();
update_configuration_warnings();
update_configuration_info();
emit_signal("sprite_frames_changed");
}

Expand Down Expand Up @@ -571,13 +571,17 @@ StringName AnimatedSprite2D::get_animation() const {
return animation;
}

PackedStringArray AnimatedSprite2D::get_configuration_warnings() const {
PackedStringArray warnings = Node2D::get_configuration_warnings();
#ifdef TOOLS_ENABLED
Vector<ConfigurationInfo> AnimatedSprite2D::get_configuration_info() const {
Vector<ConfigurationInfo> infos = Node2D::get_configuration_info();
if (frames.is_null()) {
warnings.push_back(RTR("A SpriteFrames resource must be created or set in the \"Sprite Frames\" property in order for AnimatedSprite2D to display frames."));
CONFIG_WARNING_P(
RTR("A SpriteFrames resource must be created or set in order for AnimatedSprite2D to display frames."),
"sprite_frames");
}
return warnings;
return infos;
}
#endif

#ifdef TOOLS_ENABLED
void AnimatedSprite2D::get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options) const {
Expand Down
4 changes: 3 additions & 1 deletion scene/2d/animated_sprite_2d.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,9 @@ class AnimatedSprite2D : public Node2D {
void set_flip_v(bool p_flip);
bool is_flipped_v() const;

PackedStringArray get_configuration_warnings() const override;
#ifdef TOOLS_ENABLED
Vector<ConfigurationInfo> get_configuration_info() const override;
#endif

#ifdef TOOLS_ENABLED
virtual void get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options) const override;
Expand Down
12 changes: 7 additions & 5 deletions scene/2d/canvas_modulate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ void CanvasModulate::_on_in_canvas_visibility_changed(bool p_new_visibility) {
}
}

update_configuration_warnings();
update_configuration_info();
}

void CanvasModulate::_notification(int p_what) {
Expand Down Expand Up @@ -113,20 +113,22 @@ Color CanvasModulate::get_color() const {
return color;
}

PackedStringArray CanvasModulate::get_configuration_warnings() const {
PackedStringArray warnings = Node2D::get_configuration_warnings();
#ifdef TOOLS_ENABLED
Vector<ConfigurationInfo> CanvasModulate::get_configuration_info() const {
Vector<ConfigurationInfo> infos = Node2D::get_configuration_info();

if (is_in_canvas && is_visible_in_tree()) {
List<Node *> nodes;
get_tree()->get_nodes_in_group("_canvas_modulate_" + itos(get_canvas().get_id()), &nodes);

if (nodes.size() > 1) {
warnings.push_back(RTR("Only one visible CanvasModulate is allowed per canvas.\nWhen there are more than one, only one of them will be active. Which one is undefined."));
CONFIG_WARNING(RTR("Only one visible CanvasModulate is allowed per canvas.\nWhen there are more than one, only one of them will be active. Which one is undefined."));
}
}

return warnings;
return infos;
}
#endif

CanvasModulate::CanvasModulate() {
}
Expand Down
4 changes: 3 additions & 1 deletion scene/2d/canvas_modulate.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@ class CanvasModulate : public Node2D {
void set_color(const Color &p_color);
Color get_color() const;

PackedStringArray get_configuration_warnings() const override;
#ifdef TOOLS_ENABLED
Vector<ConfigurationInfo> get_configuration_info() const override;
#endif

CanvasModulate();
~CanvasModulate();
Expand Down
14 changes: 8 additions & 6 deletions scene/2d/cpu_particles_2d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -245,20 +245,22 @@ bool CPUParticles2D::get_fractional_delta() const {
return fractional_delta;
}

PackedStringArray CPUParticles2D::get_configuration_warnings() const {
PackedStringArray warnings = Node2D::get_configuration_warnings();
#ifdef TOOLS_ENABLED
Vector<ConfigurationInfo> CPUParticles2D::get_configuration_info() const {
Vector<ConfigurationInfo> infos = Node2D::get_configuration_info();

CanvasItemMaterial *mat = Object::cast_to<CanvasItemMaterial>(get_material().ptr());

if (get_material().is_null() || (mat && !mat->get_particles_animation())) {
if (get_param_max(PARAM_ANIM_SPEED) != 0.0 || get_param_max(PARAM_ANIM_OFFSET) != 0.0 ||
get_param_curve(PARAM_ANIM_SPEED).is_valid() || get_param_curve(PARAM_ANIM_OFFSET).is_valid()) {
warnings.push_back(RTR("CPUParticles2D animation requires the usage of a CanvasItemMaterial with \"Particles Animation\" enabled."));
CONFIG_WARNING(RTR("CPUParticles2D animation requires the usage of a CanvasItemMaterial with \"Particles Animation\" enabled."));
}
}

return warnings;
return infos;
}
#endif

void CPUParticles2D::restart() {
time = 0;
Expand Down Expand Up @@ -317,7 +319,7 @@ void CPUParticles2D::set_param_max(Parameter p_param, real_t p_value) {
set_param_min(p_param, p_value);
}

update_configuration_warnings();
update_configuration_info();
}

real_t CPUParticles2D::get_param_max(Parameter p_param) const {
Expand Down Expand Up @@ -379,7 +381,7 @@ void CPUParticles2D::set_param_curve(Parameter p_param, const Ref<Curve> &p_curv
}
}

update_configuration_warnings();
update_configuration_info();
}

Ref<Curve> CPUParticles2D::get_param_curve(Parameter p_param) const {
Expand Down
4 changes: 3 additions & 1 deletion scene/2d/cpu_particles_2d.h
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,9 @@ class CPUParticles2D : public Node2D {
void set_gravity(const Vector2 &p_gravity);
Vector2 get_gravity() const;

PackedStringArray get_configuration_warnings() const override;
#ifdef TOOLS_ENABLED
Vector<ConfigurationInfo> get_configuration_info() const override;
#endif

void restart();

Expand Down
Loading

0 comments on commit 31acd7a

Please sign in to comment.