From f87d42f4caf1589668fb2add6e89dd5b564ba001 Mon Sep 17 00:00:00 2001 From: Hugo Locurcio Date: Wed, 30 Dec 2020 15:31:00 +0100 Subject: [PATCH] Use zero-indexing for physics and render layer names The first layer is now Layer 0 instead of Layer 1, and the last layer is now Layer 19 instead of Layer 20. This helps reference physics and render layers from scripts since layers start from 0 there. --- doc/classes/ProjectSettings.xml | 176 ++++++++++++++++---------------- editor/editor_properties.cpp | 6 +- scene/register_scene_types.cpp | 8 +- 3 files changed, 95 insertions(+), 95 deletions(-) diff --git a/doc/classes/ProjectSettings.xml b/doc/classes/ProjectSettings.xml index e856d1ea9ca..b0fec00463d 100644 --- a/doc/classes/ProjectSettings.xml +++ b/doc/classes/ProjectSettings.xml @@ -619,245 +619,245 @@ Default delay for touch events. This only affects iOS devices. + + Optional name for the 2D physics layer 0. If left empty, the layer will display as "Layer 0". + - Optional name for the 2D physics layer 1. + Optional name for the 2D physics layer 1. If left empty, the layer will display as "Layer 1". - Optional name for the 2D physics layer 10. + Optional name for the 2D physics layer 10. If left empty, the layer will display as "Layer 10". - Optional name for the 2D physics layer 11. + Optional name for the 2D physics layer 11. If left empty, the layer will display as "Layer 11". - Optional name for the 2D physics layer 12. + Optional name for the 2D physics layer 12. If left empty, the layer will display as "Layer 12". - Optional name for the 2D physics layer 13. + Optional name for the 2D physics layer 13. If left empty, the layer will display as "Layer 13". - Optional name for the 2D physics layer 14. + Optional name for the 2D physics layer 14. If left empty, the layer will display as "Layer 14". - Optional name for the 2D physics layer 15. + Optional name for the 2D physics layer 15. If left empty, the layer will display as "Layer 15". - Optional name for the 2D physics layer 16. + Optional name for the 2D physics layer 16. If left empty, the layer will display as "Layer 16". - Optional name for the 2D physics layer 17. + Optional name for the 2D physics layer 17. If left empty, the layer will display as "Layer 17". - Optional name for the 2D physics layer 18. + Optional name for the 2D physics layer 18. If left empty, the layer will display as "Layer 18". - Optional name for the 2D physics layer 19. + Optional name for the 2D physics layer 19. If left empty, the layer will display as "Layer 19". - Optional name for the 2D physics layer 2. - - - Optional name for the 2D physics layer 20. + Optional name for the 2D physics layer 2. If left empty, the layer will display as "Layer 2". - Optional name for the 2D physics layer 3. + Optional name for the 2D physics layer 3. If left empty, the layer will display as "Layer 3". - Optional name for the 2D physics layer 4. + Optional name for the 2D physics layer 4. If left empty, the layer will display as "Layer 4". - Optional name for the 2D physics layer 5. + Optional name for the 2D physics layer 5. If left empty, the layer will display as "Layer 5". - Optional name for the 2D physics layer 6. + Optional name for the 2D physics layer 6. If left empty, the layer will display as "Layer 6". - Optional name for the 2D physics layer 7. + Optional name for the 2D physics layer 7. If left empty, the layer will display as "Layer 7". - Optional name for the 2D physics layer 8. + Optional name for the 2D physics layer 8. If left empty, the layer will display as "Layer 8". - Optional name for the 2D physics layer 9. + Optional name for the 2D physics layer 9. If left empty, the layer will display as "Layer 9". + + + Optional name for the 2D render layer 0. If left empty, the layer will display as "Layer 0". - Optional name for the 2D render layer 1. + Optional name for the 2D render layer 1. If left empty, the layer will display as "Layer 1". - Optional name for the 2D render layer 10. + Optional name for the 2D render layer 10. If left empty, the layer will display as "Layer 10". - Optional name for the 2D render layer 11. + Optional name for the 2D render layer 11. If left empty, the layer will display as "Layer 11". - Optional name for the 2D render layer 12. + Optional name for the 2D render layer 12. If left empty, the layer will display as "Layer 12". - Optional name for the 2D render layer 13. + Optional name for the 2D render layer 13. If left empty, the layer will display as "Layer 13". - Optional name for the 2D render layer 14. + Optional name for the 2D render layer 14. If left empty, the layer will display as "Layer 14". - Optional name for the 2D render layer 15. + Optional name for the 2D render layer 15. If left empty, the layer will display as "Layer 15". - Optional name for the 2D render layer 16. + Optional name for the 2D render layer 16. If left empty, the layer will display as "Layer 16". - Optional name for the 2D render layer 17. + Optional name for the 2D render layer 17. If left empty, the layer will display as "Layer 17". - Optional name for the 2D render layer 18. + Optional name for the 2D render layer 18. If left empty, the layer will display as "Layer 18". - Optional name for the 2D render layer 19. + Optional name for the 2D render layer 19. If left empty, the layer will display as "Layer 19". - Optional name for the 2D render layer 2. - - - Optional name for the 2D render layer 20. + Optional name for the 2D render layer 2. If left empty, the layer will display as "Layer 2". - Optional name for the 2D render layer 3. + Optional name for the 2D render layer 3. If left empty, the layer will display as "Layer 3". - Optional name for the 2D render layer 4. + Optional name for the 2D render layer 4. If left empty, the layer will display as "Layer 4". - Optional name for the 2D render layer 5. + Optional name for the 2D render layer 5. If left empty, the layer will display as "Layer 5". - Optional name for the 2D render layer 6. + Optional name for the 2D render layer 6. If left empty, the layer will display as "Layer 6". - Optional name for the 2D render layer 7. + Optional name for the 2D render layer 7. If left empty, the layer will display as "Layer 7". - Optional name for the 2D render layer 8. + Optional name for the 2D render layer 8. If left empty, the layer will display as "Layer 8". - Optional name for the 2D render layer 9. + Optional name for the 2D render layer 9. If left empty, the layer will display as "Layer 9". + + + Optional name for the 3D physics layer 0. If left empty, the layer will display as "Layer 0". - Optional name for the 3D physics layer 1. + Optional name for the 3D physics layer 1. If left empty, the layer will display as "Layer 1". - Optional name for the 3D physics layer 10. + Optional name for the 3D physics layer 10. If left empty, the layer will display as "Layer 10". - Optional name for the 3D physics layer 11. + Optional name for the 3D physics layer 11. If left empty, the layer will display as "Layer 11". - Optional name for the 3D physics layer 12. + Optional name for the 3D physics layer 12. If left empty, the layer will display as "Layer 12". - Optional name for the 3D physics layer 13. + Optional name for the 3D physics layer 13. If left empty, the layer will display as "Layer 13". - Optional name for the 3D physics layer 14. + Optional name for the 3D physics layer 14. If left empty, the layer will display as "Layer 14". - Optional name for the 3D physics layer 15. + Optional name for the 3D physics layer 15. If left empty, the layer will display as "Layer 15". - Optional name for the 3D physics layer 16. + Optional name for the 3D physics layer 16. If left empty, the layer will display as "Layer 16". - Optional name for the 3D physics layer 17. + Optional name for the 3D physics layer 17. If left empty, the layer will display as "Layer 17". - Optional name for the 3D physics layer 18. + Optional name for the 3D physics layer 18. If left empty, the layer will display as "Layer 18". - Optional name for the 3D physics layer 19. + Optional name for the 3D physics layer 19. If left empty, the layer will display as "Layer 19". - Optional name for the 3D physics layer 2. - - - Optional name for the 3D physics layer 20. + Optional name for the 3D physics layer 2. If left empty, the layer will display as "Layer 2". - Optional name for the 3D physics layer 3. + Optional name for the 3D physics layer 3. If left empty, the layer will display as "Layer 3". - Optional name for the 3D physics layer 4. + Optional name for the 3D physics layer 4. If left empty, the layer will display as "Layer 4". - Optional name for the 3D physics layer 5. + Optional name for the 3D physics layer 5. If left empty, the layer will display as "Layer 5". - Optional name for the 3D physics layer 6. + Optional name for the 3D physics layer 6. If left empty, the layer will display as "Layer 6". - Optional name for the 3D physics layer 7. + Optional name for the 3D physics layer 7. If left empty, the layer will display as "Layer 7". - Optional name for the 3D physics layer 8. + Optional name for the 3D physics layer 8. If left empty, the layer will display as "Layer 8". - Optional name for the 3D physics layer 9. + Optional name for the 3D physics layer 9. If left empty, the layer will display as "Layer 9". + + + Optional name for the 2D render layer 0. If left empty, the layer will display as "Layer 0". - Optional name for the 3D render layer 1. + Optional name for the 3D render layer 1. If left empty, the layer will display as "Layer 1". - Optional name for the 3D render layer 10. + Optional name for the 3D render layer 10. If left empty, the layer will display as "Layer 10". - Optional name for the 3D render layer 11. + Optional name for the 3D render layer 11. If left empty, the layer will display as "Layer 11". - Optional name for the 3D render layer 12. + Optional name for the 3D render layer 12. If left empty, the layer will display as "Layer 12". - Optional name for the 3D render layer 13. + Optional name for the 3D render layer 13. If left empty, the layer will display as "Layer 13". - Optional name for the 3D render layer 14 + Optional name for the 3D render layer 14. If left empty, the layer will display as "Layer 14" - Optional name for the 3D render layer 15. + Optional name for the 3D render layer 15. If left empty, the layer will display as "Layer 15". - Optional name for the 3D render layer 16. + Optional name for the 3D render layer 16. If left empty, the layer will display as "Layer 16". - Optional name for the 3D render layer 17. + Optional name for the 3D render layer 17. If left empty, the layer will display as "Layer 17". - Optional name for the 3D render layer 18. + Optional name for the 3D render layer 18. If left empty, the layer will display as "Layer 18". - Optional name for the 3D render layer 19. + Optional name for the 3D render layer 19. If left empty, the layer will display as "Layer 19". - Optional name for the 3D render layer 2. - - - Optional name for the 3D render layer 20. + Optional name for the 3D render layer 2. If left empty, the layer will display as "Layer 2". - Optional name for the 3D render layer 3. + Optional name for the 3D render layer 3. If left empty, the layer will display as "Layer 3". - Optional name for the 3D render layer 4. + Optional name for the 3D render layer 4. If left empty, the layer will display as "Layer 4". - Optional name for the 3D render layer 5. + Optional name for the 3D render layer 5. If left empty, the layer will display as "Layer 5". - Optional name for the 3D render layer 6. + Optional name for the 3D render layer 6. If left empty, the layer will display as "Layer 6". - Optional name for the 3D render layer 7. + Optional name for the 3D render layer 7. If left empty, the layer will display as "Layer 7". - Optional name for the 3D render layer 8. + Optional name for the 3D render layer 8. If left empty, the layer will display as "Layer 8". - Optional name for the 3D render layer 9. + Optional name for the 3D render layer 9. If left empty, the layer will display as "Layer 9". The locale to fall back to if a translation isn't available in a given language. If left empty, [code]en[/code] (English) will be used. diff --git a/editor/editor_properties.cpp b/editor/editor_properties.cpp index 9c27b50a9ab..8ba9fb6e3c1 100644 --- a/editor/editor_properties.cpp +++ b/editor/editor_properties.cpp @@ -725,12 +725,12 @@ void EditorPropertyLayers::setup(LayerType p_layer_type) { for (int i = 0; i < 20; i++) { String name; - if (ProjectSettings::get_singleton()->has_setting(basename + "/layer_" + itos(i + 1))) { - name = ProjectSettings::get_singleton()->get(basename + "/layer_" + itos(i + 1)); + if (ProjectSettings::get_singleton()->has_setting(basename + vformat("/layer_%d", i))) { + name = ProjectSettings::get_singleton()->get(basename + vformat("/layer_%d", i)); } if (name == "") { - name = TTR("Layer") + " " + itos(i + 1); + name = vformat(TTR("Layer %d"), i); } names.push_back(name); diff --git a/scene/register_scene_types.cpp b/scene/register_scene_types.cpp index 30077aa6429..bedbab6d4f8 100644 --- a/scene/register_scene_types.cpp +++ b/scene/register_scene_types.cpp @@ -936,10 +936,10 @@ void register_scene_types() { OS::get_singleton()->yield(); //may take time to init for (int i = 0; i < 20; i++) { - GLOBAL_DEF("layer_names/2d_render/layer_" + itos(i + 1), ""); - GLOBAL_DEF("layer_names/2d_physics/layer_" + itos(i + 1), ""); - GLOBAL_DEF("layer_names/3d_render/layer_" + itos(i + 1), ""); - GLOBAL_DEF("layer_names/3d_physics/layer_" + itos(i + 1), ""); + GLOBAL_DEF(vformat("layer_names/2d_render/layer_%d", i), ""); + GLOBAL_DEF(vformat("layer_names/2d_physics/layer_%d", i), ""); + GLOBAL_DEF(vformat("layer_names/3d_render/layer_%d", i), ""); + GLOBAL_DEF(vformat("layer_names/3d_physics/layer_%d", i), ""); } bool default_theme_hidpi = GLOBAL_DEF("gui/theme/use_hidpi", false);