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 Aug 31, 2024
1 parent 0b5fe09 commit 4d3dcce
Show file tree
Hide file tree
Showing 134 changed files with 772 additions and 454 deletions.
12 changes: 8 additions & 4 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
Array MultiplayerSpawner::get_configuration_info() const {
Array warnings = 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;
}
#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
Array 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
12 changes: 8 additions & 4 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
Array MultiplayerSynchronizer::get_configuration_info() const {
Array warnings = 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;
}
#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
Array get_configuration_info() const override;
#endif

void set_replication_interval(double p_interval);
double get_replication_interval() const;
Expand Down
20 changes: 11 additions & 9 deletions modules/openxr/scene/openxr_composition_layer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,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 @@ -230,7 +230,7 @@ bool OpenXRCompositionLayer::get_enable_hole_punch() const {
void OpenXRCompositionLayer::set_sort_order(int p_order) {
if (openxr_layer_provider) {
openxr_layer_provider->set_sort_order(p_order);
update_configuration_warnings();
update_configuration_info();
}
}

Expand Down Expand Up @@ -345,10 +345,10 @@ void OpenXRCompositionLayer::_notification(int p_what) {
openxr_layer_provider->set_viewport(RID(), Size2i());
}
}
update_configuration_warnings();
update_configuration_info();
} break;
case NOTIFICATION_LOCAL_TRANSFORM_CHANGED: {
update_configuration_warnings();
update_configuration_info();
} break;
case NOTIFICATION_ENTER_TREE: {
if (composition_layer_extension) {
Expand Down Expand Up @@ -408,23 +408,25 @@ bool OpenXRCompositionLayer::_set(const StringName &p_property, const Variant &p
return true;
}

PackedStringArray OpenXRCompositionLayer::get_configuration_warnings() const {
PackedStringArray warnings = Node3D::get_configuration_warnings();
#ifdef TOOLS_ENABLED
Array OpenXRCompositionLayer::get_configuration_info() const {
Array warnings = 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;
}
#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 @@ -97,7 +97,9 @@ class OpenXRCompositionLayer : public Node3D {

bool is_natively_supported() const;

virtual PackedStringArray get_configuration_warnings() const override;
#ifdef TOOLS_ENABLED
virtual Array get_configuration_info() const override;
#endif

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

Expand Down
12 changes: 8 additions & 4 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
Array AnimatedSprite2D::get_configuration_info() const {
Array warnings = 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."),
"frames");
}
return warnings;
}
#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
Array 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
10 changes: 6 additions & 4 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 = Node::get_configuration_warnings();
#ifdef TOOLS_ENABLED
Array CanvasModulate::get_configuration_info() const {
Array warnings = Node::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;
}
#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
Array get_configuration_info() const override;
#endif

CanvasModulate();
~CanvasModulate();
Expand Down
12 changes: 7 additions & 5 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
Array CPUParticles2D::get_configuration_info() const {
Array warnings = 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;
}
#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
Array get_configuration_info() const override;
#endif

void restart();

Expand Down
20 changes: 11 additions & 9 deletions scene/2d/gpu_particles_2d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,14 +156,14 @@ void GPUParticles2D::set_process_material(const Ref<Material> &p_material) {
}
RS::get_singleton()->particles_set_process_material(particles, material_rid);

update_configuration_warnings();
update_configuration_info();
}

void GPUParticles2D::set_trail_enabled(bool p_enabled) {
trail_enabled = p_enabled;
RS::get_singleton()->particles_set_trails(particles, trail_enabled, trail_lifetime);
queue_redraw();
update_configuration_warnings();
update_configuration_info();

RS::get_singleton()->particles_set_transform_align(particles, p_enabled ? RS::PARTICLES_TRANSFORM_ALIGN_Y_TO_VELOCITY : RS::PARTICLES_TRANSFORM_ALIGN_DISABLED);
}
Expand Down Expand Up @@ -326,11 +326,12 @@ float GPUParticles2D::get_interp_to_end() const {
return interp_to_end_factor;
}

PackedStringArray GPUParticles2D::get_configuration_warnings() const {
PackedStringArray warnings = Node2D::get_configuration_warnings();
#ifdef TOOLS_ENABLED
Array GPUParticles2D::get_configuration_info() const {
Array warnings = Node2D::get_configuration_info();

if (process_material.is_null()) {
warnings.push_back(RTR("A material to process the particles is not assigned, so no behavior is imprinted."));
CONFIG_WARNING(RTR("A material to process the particles is not assigned, so no behavior is imprinted."));
} else {
CanvasItemMaterial *mat = Object::cast_to<CanvasItemMaterial>(get_material().ptr());

Expand All @@ -339,21 +340,22 @@ PackedStringArray GPUParticles2D::get_configuration_warnings() const {
if (process &&
(process->get_param_max(ParticleProcessMaterial::PARAM_ANIM_SPEED) != 0.0 || process->get_param_max(ParticleProcessMaterial::PARAM_ANIM_OFFSET) != 0.0 ||
process->get_param_texture(ParticleProcessMaterial::PARAM_ANIM_SPEED).is_valid() || process->get_param_texture(ParticleProcessMaterial::PARAM_ANIM_OFFSET).is_valid())) {
warnings.push_back(RTR("Particles2D animation requires the usage of a CanvasItemMaterial with \"Particles Animation\" enabled."));
CONFIG_WARNING(RTR("Particles2D animation requires the usage of a CanvasItemMaterial with \"Particles Animation\" enabled."));
}
}
}

if (trail_enabled && OS::get_singleton()->get_current_rendering_method() == "gl_compatibility") {
warnings.push_back(RTR("Particle trails are only available when using the Forward+ or Mobile rendering backends."));
CONFIG_WARNING(RTR("Particle trails are only available when using the Forward+ or Mobile rendering backends."));
}

if (sub_emitter != NodePath() && OS::get_singleton()->get_current_rendering_method() == "gl_compatibility") {
warnings.push_back(RTR("Particle sub-emitters are not available when using the GL Compatibility rendering backend."));
CONFIG_WARNING(RTR("Particle sub-emitters are not available when using the GL Compatibility rendering backend."));
}

return warnings;
}
#endif

Rect2 GPUParticles2D::capture_rect() const {
AABB aabb = RS::get_singleton()->particles_get_current_aabb(particles);
Expand Down Expand Up @@ -424,7 +426,7 @@ void GPUParticles2D::set_sub_emitter(const NodePath &p_path) {
if (is_inside_tree() && sub_emitter != NodePath()) {
_attach_sub_emitter();
}
update_configuration_warnings();
update_configuration_info();
}

NodePath GPUParticles2D::get_sub_emitter() const {
Expand Down
4 changes: 3 additions & 1 deletion scene/2d/gpu_particles_2d.h
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,9 @@ class GPUParticles2D : public Node2D {
void set_amount_ratio(float p_ratio);
float get_amount_ratio() const;

PackedStringArray get_configuration_warnings() const override;
#ifdef TOOLS_ENABLED
Array get_configuration_info() const override;
#endif

void set_sub_emitter(const NodePath &p_path);
NodePath get_sub_emitter() const;
Expand Down
Loading

0 comments on commit 4d3dcce

Please sign in to comment.